:root {
    /* ---- Palette: dusk-to-dawn, "exhale" theme ---- */
    --mist: #F4F1FB;      /* page bg, top */
    --dawn: #FBEEE7;      /* page bg, bottom */
    --surface: #FFFFFF;
    --surface-soft: #F8F6FD;
    --ink: #241F38;
    --muted: #857FA0;
    --violet: #6E5AE0;
    --violet-dark: #5140B8;
    --coral: #F2905F;     /* signature accent — used sparingly */
    --border: #E7E1F5;
    --bot-bubble: #EFEBFC;
    --danger: #D9534F;
    --danger-bg: #FDECEA;
    --radius: 18px;
    --radius-sm: 6px;

    /* back-compat aliases so admin.css keeps working */
    --bg: var(--mist);
    --primary: var(--violet);
    --primary-dark: var(--violet-dark);
    --text: var(--ink);
    --user-bubble: var(--violet);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Figtree', system-ui, -apple-system, sans-serif;
    color: var(--ink);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--mist) 0%, var(--dawn) 100%);
    background-attachment: fixed;
}

.brand-font { font-family: 'Fraunces', Georgia, serif; }

/* ---------- Breathing glow (signature motif) ---------- */
@keyframes breathe {
    0%, 100% { transform: scale(0.92); opacity: 0.55; }
    50%      { transform: scale(1.12); opacity: 0.9; }
}
.glow-dot {
    position: relative;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--coral) 0%, var(--violet) 75%);
    flex-shrink: 0;
}
.glow-dot::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(242,144,95,0.35) 0%, rgba(110,90,224,0.18) 60%, transparent 75%);
    animation: breathe 4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
    .glow-dot::before { animation: none; opacity: 0.6; }
}

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 600;
    font-style: italic;
    font-size: 22px;
    color: var(--violet-dark);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.01em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.topbar-anon, .topbar-user { color: var(--muted); }

.btn-primary, .btn-ghost, .btn-danger {
    border: none;
    border-radius: 999px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--violet) 0%, var(--violet-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(110,90,224,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(110,90,224,0.45); }

.btn-ghost {
    background: transparent;
    color: var(--violet-dark);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-soft); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #f3cfcd;
}

.small { font-size: 12px; padding: 6px 14px; }

/* ---------- Layout ---------- */
.app-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border);
    padding: 18px;
    overflow-y: auto;
}

.sidebar-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.sidebar-head h2 { font-size: 14px; margin: 0; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.conversation-list {
    list-style: none;
    margin: 0 0 16px 0;
    padding: 0;
}
.conversation-list li {
    padding: 11px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink);
    margin-bottom: 4px;
    transition: background 0.15s ease;
}
.conversation-list li:hover, .conversation-list li.active {
    background: var(--bot-bubble);
}

/* ---------- Chat ---------- */
.chat-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
    padding: 20px 20px 0;
}

.crisis-panel {
    background: var(--danger-bg);
    border: 1px solid #f3cfcd;
    color: #7a2b28;
    padding: 16px 18px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 14px;
}
.crisis-panel ul { margin: 8px 0; padding-left: 20px; }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 4px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-bot { justify-content: flex-start; align-items: flex-start; gap: 10px; }

.msg-bot::before {
    content: '';
    width: 14px;
    height: 14px;
    margin-top: 10px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--coral) 0%, var(--violet) 75%);
    flex-shrink: 0;
}

.bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.msg-bot .bubble {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: 0 2px 10px rgba(36,31,56,0.04);
}

.msg-user .bubble {
    background: linear-gradient(135deg, var(--violet) 0%, var(--violet-dark) 100%);
    color: #fff;
    border-bottom-right-radius: var(--radius-sm);
    box-shadow: 0 4px 14px rgba(110,90,224,0.28);
}

.msg-typing .bubble {
    color: var(--muted);
    font-style: italic;
    background: var(--surface-soft);
    border: 1px dashed var(--border);
}

/* ---------- Input ---------- */
.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 4px 8px;
    border-top: 1px solid var(--border);
}

.chat-input-row textarea {
    flex: 1;
    resize: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 16px;
    font-size: 15px;
    font-family: inherit;
    max-height: 140px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-input-row textarea:focus {
    outline: none;
    border-color: var(--violet);
    box-shadow: 0 0 0 3px rgba(110,90,224,0.12);
}

.chat-input-row button[type="submit"] {
    background: linear-gradient(135deg, var(--violet) 0%, var(--violet-dark) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0 24px;
    height: 46px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(110,90,224,0.3);
    transition: transform 0.15s ease;
}
.chat-input-row button[type="submit"]:hover { transform: translateY(-1px); }
.chat-input-row button[type="submit"]:disabled { opacity: 0.6; cursor: default; transform: none; }

.mic-btn {
    position: relative;
    background: var(--surface) !important;
    color: var(--violet) !important;
    border: 1px solid var(--border) !important;
    border-radius: 50% !important;
    width: 46px;
    height: 46px;
    min-width: 46px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mic-btn::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(110,90,224,0.16) 0%, transparent 70%);
    animation: breathe 4s ease-in-out infinite;
    z-index: -1;
}
@media (prefers-reduced-motion: reduce) { .mic-btn::before { animation: none; } }
.mic-btn:hover { background: var(--surface-soft) !important; }
.mic-btn.recording {
    background: var(--danger) !important;
    color: #fff !important;
    border-color: var(--danger) !important;
    animation: pulse 1.4s infinite;
}
.mic-btn.recording::before { display: none; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(217,83,79,0.4); }
    70% { box-shadow: 0 0 0 10px rgba(217,83,79,0); }
    100% { box-shadow: 0 0 0 0 rgba(217,83,79,0); }
}

.voice-status {
    text-align: center;
    color: var(--danger);
    font-size: 13px;
    margin: -4px 0 8px;
}

.disclaimer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 8px 0 16px;
}

/* ---------- Auth pages ---------- */
.auth-page {
    justify-content: center;
    align-items: center;
    display: flex;
    height: 100vh;
}
.auth-card {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    padding: 36px;
    border-radius: 22px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(110,90,224,0.15);
    border: 1px solid var(--border);
}
.auth-back {
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
}
.auth-card h1 {
    font-family: 'Fraunces', Georgia, serif;
    font-style: italic;
    font-weight: 600;
    color: var(--violet-dark);
    margin: 10px 0 4px;
    font-size: 28px;
}
.auth-sub {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 22px;
    line-height: 1.5;
}
.auth-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label {
    font-size: 13px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
}
.auth-form input {
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--violet);
    box-shadow: 0 0 0 3px rgba(110,90,224,0.12);
}
.auth-form button {
    background: linear-gradient(135deg, var(--violet) 0%, var(--violet-dark) 100%);
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    box-shadow: 0 4px 14px rgba(110,90,224,0.3);
}
.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    margin-top: 20px;
}
.auth-switch a { color: var(--violet-dark); font-weight: 600; text-decoration: none; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .sidebar { position: fixed; z-index: 10; height: 100%; }
    .topbar-user, .topbar-anon { display: none; }
    .bubble { max-width: 88%; }
    .chat-wrap { padding: 14px 14px 0; }
}
