:root {
    --bg:            #000000;
    --surface:       #0a0f1a;
    --lilith-bubble: rgba(10, 18, 35, 0.52);
    --user-bubble:   rgba(12, 28, 62, 0.56);
    --accent:        #3b82f6;
    --accent-dim:    #1e3a8a;
    --text:          #f0f4ff;
    --text-muted:    #6b7a99;
    --border:        #1a2540;
    --topbar-h:      60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    height: 100dvh;
    overflow: hidden;
}

/* ── AUTH ───────────────────────────────────────── */

#auth-screen {
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* Full-bleed splash image */
.auth-splash-bg {
    background-image: url('/static/images/npcs/Lilith/therapist/main_splash.png');
    background-position: center top;
    background-repeat: no-repeat;
    background-size: cover;   /* mobile: fill screen */
    inset: 0;
    position: absolute;
}

/* Wide screens: show the full portrait without cropping */
@media (min-width: 640px) {
    .auth-splash-bg { background-size: auto 100%; }
}

/* Dark overlay — deepens toward bottom where the form sits */
.auth-splash-overlay {
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.35) 0%,
        rgba(0, 0, 0, 0.75) 55%,
        rgba(0, 0, 0, 0.92) 100%
    );
    inset: 0;
    position: absolute;
}

/* Form panel — anchored to bottom, floats over image */
.auth-panel {
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    left: 50%;
    max-width: 360px;
    padding: 32px 24px max(32px, env(safe-area-inset-bottom));
    position: absolute;
    transform: translateX(-50%);
    width: 100%;
    z-index: 1;
}

.auth-title {
    color: #fff;
    font-size: 32px;
    font-weight: 300;
    letter-spacing: 0.2em;
    text-align: center;
    text-transform: uppercase;
}

.auth-tagline {
    color: rgba(255, 255, 255, 0.45);
    font-size: 13px;
    font-style: italic;
    margin-top: -8px;
    text-align: center;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.form-group input {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    outline: none;
    padding: 10px 12px;
    transition: border-color 0.15s;
    width: 100%;
}

.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: rgba(255,255,255,0.25); }

.btn-auth {
    background: var(--accent-dim);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-top: 4px;
    padding: 12px;
    transition: background 0.15s;
    width: 100%;
}

.btn-auth:hover  { background: var(--accent); }
.btn-auth:disabled { cursor: default; opacity: 0.5; }

.auth-error {
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: 8px;
    color: #fca5a5;
    font-size: 13px;
    padding: 10px 12px;
}

.auth-toggle {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    text-align: center;
}

.auth-toggle a { color: var(--accent); text-decoration: none; }

.auth-help {
    color: rgba(255, 255, 255, 0.25);
    font-size: 12px;
    text-align: center;
}

.auth-help a { color: rgba(255, 255, 255, 0.25); }

.auth-version {
    color: rgba(255, 255, 255, 0.2);
    font-size: 11px;
    text-align: right;
}

/* ── APP LAYOUT ─────────────────────────────────── */

#app-screen {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* Full-bleed background — Lilith portrait, swaps on reaction */
#lth-bg {
    background-position: center top;
    background-repeat: no-repeat;
    background-size: cover;
    inset: 0;
    opacity: 1;
    pointer-events: none;
    position: fixed;
    transition: opacity 0.4s ease;
    z-index: 0;
}

#lth-bg::after {
    background: rgba(4, 4, 10, 0.18);
    content: '';
    inset: 0;
    position: absolute;
}

/* Lift all app chrome above the background */
.lth-topbar,
.telehealth-banner,
.lth-messages,
.lth-composer-wrap,
#lth-menu {
    position: relative;
    z-index: 1;
}

/* ── TOPBAR ─────────────────────────────────────── */

.lth-topbar {
    align-items: center;
    background: rgba(13, 13, 20, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-shrink: 0;
    gap: 10px;
    height: var(--topbar-h);
    padding: 8px 12px;
}

.lth-npc-info {
    align-items: center;
    display: flex;
    flex: 1;
    gap: 10px;
    min-width: 0;
}

.lth-avatar-img {
    border: 1px solid var(--accent-dim);
    border-radius: 50%;
    flex-shrink: 0;
    height: 40px;
    object-fit: cover;
    width: 40px;
}

.lth-npc-name { font-size: 15px; font-weight: 600; }

.lth-npc-sub { color: var(--text-muted); font-size: 11px; }

.lth-mode-tabs {
    background: var(--bg);
    border-radius: 8px;
    display: flex;
    flex-shrink: 0;
    gap: 3px;
    padding: 3px;
}

.lth-mode-tab {
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    transition: all 0.15s;
    white-space: nowrap;
}

.lth-mode-tab.active {
    background: var(--accent-dim);
    color: #fff;
}

.lth-topbar-actions { display: flex; gap: 4px; }

.lth-icon-btn {
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
    transition: color 0.15s;
}

.lth-icon-btn:hover { color: var(--text); }

/* ── TELEHEALTH BANNER ──────────────────────────── */

.telehealth-banner {
    background: rgba(107, 33, 168, 0.1);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 16px;
    text-align: center;
}

/* ── MESSAGES ───────────────────────────────────── */

.lth-messages {
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 16px 12px;
}

.lth-bubble-row {
    align-items: flex-end;
    display: flex;
    gap: 8px;
}

.lth-bubble-row.user { flex-direction: row-reverse; }

.lth-bubble {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    max-width: 78%;
    padding: 10px 14px;
    word-break: break-word;
}

.lth-bubble.assistant {
    background: var(--lilith-bubble);
    border-bottom-left-radius: 4px;
    color: var(--text);
}

.lth-bubble.user {
    background: var(--user-bubble);
    border-bottom-right-radius: 4px;
    color: var(--text);
    white-space: pre-wrap;
}

.lth-bubble strong { font-weight: 700; }
.lth-bubble em { color: var(--text-muted); font-style: italic; }

/* Action buttons rendered inside bubbles */
.lth-action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.lth-action-btn {
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid var(--accent-dim);
    border-radius: 16px;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    padding: 6px 14px;
    transition: all 0.15s;
}

.lth-action-btn:hover {
    background: var(--accent-dim);
    color: #fff;
}

/* MSG_BREAK divider */
.lth-msg-break {
    align-items: center;
    color: var(--text-muted);
    display: flex;
    font-size: 11px;
    gap: 8px;
    margin: 4px 0;
}

.lth-msg-break::before,
.lth-msg-break::after {
    border-top: 1px solid var(--border);
    content: '';
    flex: 1;
}

/* Typing indicator */
.lth-typing {
    -webkit-backdrop-filter: blur(12px);
    align-items: center;
    backdrop-filter: blur(12px);
    background: var(--lilith-bubble);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    width: fit-content;
}

.lth-typing span {
    animation: lth-blink 1.2s infinite;
    background: var(--text-muted);
    border-radius: 50%;
    height: 6px;
    width: 6px;
}

.lth-typing span:nth-child(2) { animation-delay: 0.2s; }
.lth-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lth-blink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40%           { opacity: 1;   transform: scale(1); }
}

/* Telehealth session end card */
.lth-session-end {
    background: rgba(107, 33, 168, 0.07);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 13px;
    margin: 8px 0 4px;
    padding: 14px 16px;
    text-align: center;
}

.lth-session-end button {
    background: var(--accent-dim);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    margin-top: 10px;
    padding: 8px 18px;
    transition: background 0.15s;
}

.lth-session-end button:hover { background: var(--accent); }

/* ── COMPOSER ───────────────────────────────────── */

.lth-composer-wrap {
    background: rgba(13, 13, 20, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.lth-composer {
    align-items: flex-end;
    display: flex;
    gap: 8px;
}

.lth-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    flex: 1;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    max-height: 120px;
    outline: none;
    overflow-y: auto;
    padding: 10px 14px;
    resize: none;
    transition: border-color 0.15s;
}

.lth-input:focus { border-color: var(--accent-dim); }
.lth-input::placeholder { color: var(--text-muted); }
.lth-input:disabled { opacity: 0.4; }

.lth-send-btn {
    align-items: center;
    background: var(--accent-dim);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-shrink: 0;
    height: 40px;
    justify-content: center;
    transition: background 0.15s;
    width: 40px;
}

.lth-send-btn:hover:not(:disabled) { background: var(--accent); }
.lth-send-btn:disabled { cursor: default; opacity: 0.4; }

/* ── MENU PANEL ─────────────────────────────────── */

#lth-menu {
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    inset: 0;
    justify-content: flex-end;
    position: fixed;
    z-index: 200;
}

.lth-menu-inner {
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    width: min(300px, 100vw);
}

.lth-menu-header {
    align-items: center;
    display: flex;
    font-size: 16px;
    font-weight: 600;
    justify-content: space-between;
    margin-bottom: 20px;
}

.lth-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
}

.lth-menu-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.lth-menu-label {
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.lth-menu-row {
    align-items: center;
    display: flex;
    font-size: 14px;
    justify-content: space-between;
}

.lth-menu-val { color: var(--text); font-size: 13px; }

.lth-menu-stack {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
}

.lth-edit-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

.lth-edit-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    flex: 1;
    font-size: 14px;
    outline: none;
    padding: 6px 10px;
}

.lth-edit-input:focus { border-color: var(--accent); }

.lth-btn-sm {
    background: var(--accent-dim);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 12px;
    white-space: nowrap;
}

.lth-menu-divider {
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.lth-logout-btn {
    background: none;
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: 8px;
    color: #f87171;
    cursor: pointer;
    font-size: 14px;
    padding: 10px;
    text-align: center;
    transition: all 0.15s;
    width: 100%;
}

.lth-logout-btn:hover { background: rgba(220, 38, 38, 0.1); }
