/* ---- FULL SCREEN APP SHELL ---- */
.app-shell { display: flex; height: 100vh; height: 100dvh; width: 100vw; }

/* Icon navigation rail (left, 64px) */
.app-rail {
    width: 64px; background: var(--bg-header);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    align-items: center; padding: 16px 0;
    flex-shrink: 0;
}
.rail-logo {
    width: 40px; height: 40px; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary-600), var(--primary-400));
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-bottom: 24px;
    box-shadow: 0 4px 16px var(--primary-glow);
}
.rail-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.rail-btn {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 20px; display: flex;
    align-items: center; justify-content: center;
    transition: var(--transition); position: relative;
}
.rail-btn:hover { color: var(--primary-400); background: var(--primary-100); }
.rail-btn.active { color: var(--primary-400); background: var(--primary-100); }
.rail-btn.active::before {
    content: ''; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px;
    background: var(--primary-500); border-radius: 0 3px 3px 0;
}
.rail-btn span { font-size: 20px; }
.rail-footer {
    font-size: 9px; color: var(--text-dim); writing-mode: vertical-lr;
    transform: rotate(180deg); letter-spacing: 0.1em; font-weight: 500;
}

/* Main content area */
.app-content { flex: 1; display: flex; overflow: hidden; }

/* Tool panels (encode, decode, info) */
.tool-panel {
    display: none; flex: 1; overflow-y: auto;
    padding: 40px; max-width: 720px; margin: 0 auto;
    position: relative;
}
.tool-panel.active {
    display: block;
    animation: panelIn 0.25s ease-out;
}

@keyframes panelIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.tool-panel h2 {
    font-size: 22px; font-weight: 700; margin-bottom: 24px;
    letter-spacing: -0.02em;
}

/* Cards */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; margin-bottom: 16px;
}
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; letter-spacing: -0.01em; }

/* Forms */
.field { margin-bottom: 16px; }
.field label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
    letter-spacing: 0.04em; text-transform: uppercase;
}
.input, .select, .textarea {
    width: 100%; padding: 12px 16px;
    font-family: var(--font-display), var(--font-emoji); font-size: 14px;
    background: var(--bg-input); color: var(--text-primary);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    transition: var(--transition);
}
.textarea { min-height: 120px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 24px; font-family: var(--font-display), var(--font-emoji);
    font-size: 14px; font-weight: 600; border: none;
    border-radius: var(--radius-sm); cursor: pointer;
    transition: var(--transition); letter-spacing: 0.02em;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    color: white; box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:hover { box-shadow: 0 6px 20px var(--primary-glow); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary-500); color: var(--primary-400); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* File upload */
.file-drop {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 32px; text-align: center; cursor: pointer;
    transition: var(--transition); background: var(--bg-surface);
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary-500); background: var(--primary-100); }
.file-drop input[type="file"] { display: none; }
.file-drop-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.4; }
.file-drop-text { color: var(--text-muted); font-size: 13px; }
.file-drop-name { color: var(--primary-400); font-weight: 600; margin-top: 8px; }

/* Row grid */
.row { display: grid; gap: 16px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Result area */
.result { padding: 20px; border-radius: var(--radius); margin-top: 16px; display: none; }
.result.show { display: block; }
.result-success { background: var(--primary-100); border: 1px solid var(--primary-glow); }
.result-error { background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.2); }
.result-text {
    font-family: var(--font-mono); font-size: 13px;
    background: var(--bg-body); padding: 16px;
    border-radius: var(--radius-sm); margin-top: 12px;
    white-space: pre-wrap; word-break: break-all;
    max-height: 300px; overflow-y: auto; color: var(--primary-400);
}

/* ============================================================
   CHAT — WHATSAPP-STYLE SPLIT LAYOUT
   ============================================================ */
.chat-layout {
    display: none; flex: 1; height: 100%;
    overflow: hidden; background: var(--bg-surface);
}
.chat-layout.active { display: flex; animation: panelIn 0.25s ease-out; }

/* Auth-based visibility: hide auth-required buttons for guests */
[data-auth="required"] { display: none !important; }
body.app-authenticated [data-auth="required"] { display: flex !important; }