:root {
    --forest: #174f44;
    --forest-dark: #103d35;
    --forest-soft: #e6f0ec;
    --ink: #17201e;
    --muted: #6d7774;
    --line: #e3e5df;
    --paper: #fafaf7;
    --cream: #f3f2ea;
    --white: #ffffff;
    --coral: #e98366;
    --gold: #f0b761;
    --shadow: 0 18px 55px rgba(25, 43, 38, .09);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body { margin: 0; min-height: 100%; }

body {
    color: var(--ink);
    background: var(--paper);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.brand {
    align-items: center;
    color: var(--forest-dark);
    display: inline-flex;
    gap: 10px;
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: var(--forest);
    border-radius: 12px;
    display: inline-flex;
    height: 40px;
    justify-content: center;
    width: 40px;
}

.brand-mark svg { height: 28px; width: 28px; }
.brand-mark path:first-child { fill: none; stroke: #f3b65f; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.5; }
.brand-mark path:last-child { fill: none; stroke: #fff; stroke-linecap: round; stroke-width: 2.2; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1; }
.brand strong { font-family: Georgia, serif; font-size: 20px; font-weight: 600; letter-spacing: -.5px; }
.brand small { color: var(--coral); font-size: 9px; font-weight: 800; letter-spacing: 2.6px; margin-top: 5px; text-transform: uppercase; }

/* Authentication */
.auth-page { display: grid; min-height: 100svh; }

.auth-hero {
    background:
        radial-gradient(circle at 15% 85%, rgba(242, 184, 100, .13), transparent 26%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, .07), transparent 30%),
        var(--forest-dark);
    color: #fff;
    display: none;
    min-height: 100vh;
    overflow: hidden;
    padding: 46px clamp(40px, 5vw, 78px);
    position: relative;
}

.auth-hero .brand { color: #fff; position: relative; z-index: 2; }
.auth-hero .brand-mark { background: rgba(255,255,255,.1); }
.auth-hero .brand small { color: #f4b96c; }
.auth-copy { margin-top: clamp(90px, 16vh, 160px); max-width: 620px; position: relative; z-index: 2; }
.eyebrow, .auth-kicker { color: #e9a963; font-size: 11px; font-weight: 800; letter-spacing: 2.2px; text-transform: uppercase; }
.eyebrow { align-items: center; display: flex; gap: 10px; }
.eyebrow i { background: #e9a963; height: 1px; width: 30px; }
.auth-copy h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(52px, 5.5vw, 82px);
    font-weight: 400;
    letter-spacing: -3px;
    line-height: .99;
    margin: 25px 0 28px;
}
.auth-copy h1 em { color: #efb46c; font-weight: 400; }
.auth-copy > p { color: rgba(255,255,255,.7); font-size: 17px; line-height: 1.75; margin: 0; max-width: 510px; }
.insight-preview { bottom: -200px; height: 520px; position: absolute; right: -50px; width: 520px; }
.preview-orbit { border: 1px solid rgba(255,255,255,.08); border-radius: 50%; position: absolute; }
.preview-orbit--one { inset: 40px; }
.preview-orbit--two { inset: 100px; }
.preview-card {
    backdrop-filter: blur(15px);
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 22px;
    left: 65px;
    padding: 23px 25px;
    position: absolute;
    top: 50px;
    transform: rotate(-3deg);
    width: 330px;
}
.preview-icon { color: #efb46c; font-size: 24px; }
.preview-card p { font-family: Georgia, serif; font-size: 19px; line-height: 1.45; margin: 12px 0 0; }

.auth-panel {
    align-items: center;
    background: #fbfbf8;
    display: flex;
    justify-content: center;
    min-height: 100svh;
    padding: 30px 22px;
}
.auth-box { max-width: 430px; width: 100%; }
.mobile-brand { margin-bottom: 56px; }
.auth-heading h2 { font-family: Georgia, serif; font-size: 38px; font-weight: 400; letter-spacing: -1.4px; margin: 11px 0 9px; }
.auth-heading > p { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 0 30px; }
.auth-form { display: grid; gap: 19px; }
.field label { display: block; font-size: 12px; font-weight: 750; margin-bottom: 8px; }
.input-wrap { position: relative; }
.input-wrap > svg {
    fill: none;
    height: 19px;
    left: 15px;
    pointer-events: none;
    position: absolute;
    stroke: #8b9390;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
    top: 50%;
    transform: translateY(-50%);
    width: 19px;
}
.input-wrap input {
    background: #fff;
    border: 1px solid #dfe2de;
    border-radius: 11px;
    color: var(--ink);
    font-size: 15px;
    height: 52px;
    outline: none;
    padding: 0 45px;
    transition: border .2s, box-shadow .2s;
    width: 100%;
}
.input-wrap input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(23,79,68,.09); }
.input-wrap input::placeholder { color: #adb3b1; }
.password-toggle { background: none; border: 0; cursor: pointer; padding: 10px; position: absolute; right: 5px; top: 6px; }
.password-toggle svg { fill: none; height: 19px; stroke: #929a97; stroke-width: 1.6; width: 19px; }
.form-error { background: #fff0ed; border: 1px solid #f4cec4; border-radius: 10px; color: #a73f28; font-size: 13px; line-height: 1.45; padding: 11px 13px; }
.primary-button {
    align-items: center;
    background: var(--forest);
    border: 0;
    border-radius: 11px;
    box-shadow: 0 9px 24px rgba(23,79,68,.18);
    color: #fff;
    cursor: pointer;
    display: flex;
    font-size: 14px;
    font-weight: 750;
    height: 53px;
    justify-content: center;
    margin-top: 3px;
    transition: background .2s, transform .2s;
    width: 100%;
}
.primary-button:hover { background: var(--forest-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .65; transform: none; }
.primary-button svg { fill: none; height: 19px; margin-left: 8px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 19px; }
.auth-switch { color: var(--muted); font-size: 13px; margin: 23px 0; text-align: center; }
.auth-switch button { background: none; border: 0; color: var(--forest); cursor: pointer; font-weight: 800; padding: 3px; }
.privacy-note { align-items: center; color: #9ba19f; display: flex; font-size: 10px; gap: 7px; justify-content: center; margin: 30px 0 0; }
.privacy-note svg { fill: none; height: 14px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 14px; }

/* App shell */
.app-shell { display: flex; height: 100dvh; overflow: hidden; }
.sidebar {
    background: #f0f0e9;
    border-right: 1px solid #dedfd7;
    display: flex;
    flex: 0 0 292px;
    flex-direction: column;
    height: 100%;
    padding: 25px 17px calc(16px + var(--safe-bottom));
    max-width: 292px;
    min-width: 292px;
    overflow: hidden;
    width: 292px;
    z-index: 40;
}
.sidebar-head { align-items: center; display: flex; justify-content: space-between; padding: 0 7px 24px; }
.icon-button.sidebar-close { display: none; }
.icon-button {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
    height: 38px;
    justify-content: center;
    transition: background .18s;
    width: 38px;
}
.icon-button:hover { background: rgba(23,79,68,.08); }
.icon-button svg { fill: none; height: 20px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 20px; }
.new-chat-button {
    align-items: center;
    background: var(--forest);
    border: 0;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: flex;
    font-size: 13px;
    font-weight: 750;
    gap: 10px;
    height: 45px;
    justify-content: center;
    margin-bottom: 28px;
    transition: background .2s;
    width: 100%;
}
.new-chat-button:hover { background: var(--forest-dark); }
.new-chat-button svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-width: 2; width: 18px; }
.history-label { color: #8b918e; font-size: 9px; font-weight: 800; letter-spacing: 1.6px; margin: 0 9px 12px; text-transform: uppercase; }
.conversation-list { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; }
.conversation-item { align-items: center; border-radius: 9px; color: #4f5956; display: flex; margin: 2px 0; min-width: 0; position: relative; }
.conversation-item.active { background: #fff; box-shadow: 0 3px 12px rgba(31,48,43,.05); color: var(--forest-dark); }
.conversation-open { background: none; border: 0; cursor: pointer; flex: 1; min-width: 0; padding: 11px 34px 11px 11px; text-align: left; }
.conversation-open strong { display: block; font-size: 12px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-open small { color: #9aa19e; display: block; font-size: 10px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-delete { background: none; border: 0; border-radius: 6px; color: #9aa19e; cursor: pointer; opacity: 0; padding: 7px; position: absolute; right: 3px; }
.conversation-item:hover .conversation-delete, .conversation-item.active .conversation-delete { opacity: 1; }
.conversation-delete:hover { background: #fff0ed; color: #b84d35; }
.conversation-delete svg { fill: none; height: 15px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 15px; }
.history-empty { color: #969c99; font-size: 12px; line-height: 1.55; padding: 20px 10px; text-align: center; }
.history-loading { display: flex; gap: 5px; justify-content: center; padding: 24px; }
.history-loading i { animation: pulse 1s infinite alternate; background: #c8ccc8; border-radius: 50%; height: 5px; width: 5px; }
.history-loading i:nth-child(2) { animation-delay: .2s; }
.history-loading i:nth-child(3) { animation-delay: .4s; }
.sidebar-profile { align-items: center; border-top: 1px solid #dbddd6; display: flex; gap: 10px; margin-top: 14px; padding: 17px 5px 0; }
.avatar { align-items: center; background: #d7e6e1; border-radius: 50%; color: var(--forest); display: flex; flex: 0 0 35px; font-family: Georgia, serif; font-size: 16px; font-weight: 700; height: 35px; justify-content: center; }
.profile-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.profile-copy strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy span { color: #979e9b; font-size: 9px; margin-top: 3px; }
.sidebar-profile .icon-button { color: #7f8784; }
.sidebar-backdrop { display: none; }

.chat-area { background: #fbfbf8; display: flex; flex: 1; flex-direction: column; min-width: 0; position: relative; }
.chat-header {
    align-items: center;
    background: rgba(251,251,248,.9);
    border-bottom: 1px solid rgba(225,226,220,.8);
    display: flex;
    flex: 0 0 70px;
    justify-content: center;
    padding: 0 22px;
    position: relative;
    z-index: 10;
}
.menu-button { display: none; left: 14px; position: absolute; }
.mobile-new-chat { display: none; position: absolute; right: 14px; }
.agent-identity { align-items: center; display: flex; gap: 10px; }
.agent-avatar { align-items: center; background: var(--forest); border-radius: 50%; display: inline-flex; height: 38px; justify-content: center; width: 38px; }
.agent-avatar svg { fill: #f2bd73; height: 24px; width: 24px; }
.agent-identity > span:last-child { display: flex; flex-direction: column; }
.agent-identity strong { font-family: Georgia, serif; font-size: 16px; font-weight: 600; }
.agent-identity small { align-items: center; color: #8a928f; display: flex; font-size: 9px; gap: 5px; margin-top: 3px; }
.agent-identity small i { background: #3eb581; border-radius: 50%; height: 6px; width: 6px; }

.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.empty-state { align-items: center; display: flex; flex-direction: column; margin: 0 auto; max-width: 780px; min-height: 100%; padding: clamp(45px, 8vh, 90px) 24px 42px; text-align: center; }
.epiphany-symbol { align-items: center; background: #e4eee9; border: 1px solid #d5e5de; border-radius: 50%; display: flex; height: 64px; justify-content: center; margin-bottom: 22px; position: relative; width: 64px; }
.epiphany-symbol::after { border: 1px solid #e8ece8; border-radius: 50%; content: ""; inset: -9px; position: absolute; }
.epiphany-symbol span { color: var(--forest); font-size: 30px; }
.welcome-kicker { color: #d47659; font-size: 9px; font-weight: 850; letter-spacing: 2px; margin-bottom: 14px; }
.empty-state h1 { font-family: Georgia, serif; font-size: clamp(38px, 4.4vw, 58px); font-weight: 400; letter-spacing: -2px; line-height: 1.02; margin: 0; }
.empty-state h1 em { color: var(--forest); font-weight: 400; }
.empty-state > p { color: #757e7b; font-size: 14px; line-height: 1.65; margin: 20px auto 32px; max-width: 520px; }
.prompt-grid { display: grid; gap: 10px; max-width: 660px; width: 100%; }
.prompt-card {
    align-items: center;
    background: #fff;
    border: 1px solid #e2e4df;
    border-radius: 13px;
    cursor: pointer;
    display: flex;
    min-height: 69px;
    padding: 12px 14px;
    text-align: left;
    transition: border .2s, box-shadow .2s, transform .2s;
}
.prompt-card:hover { border-color: #cbd9d3; box-shadow: 0 8px 25px rgba(29,55,47,.07); transform: translateY(-2px); }
.prompt-card-icon { align-items: center; border-radius: 9px; display: flex; flex: 0 0 40px; height: 40px; justify-content: center; margin-right: 12px; }
.prompt-card-icon.coral { background: #fff0eb; color: #db785b; }
.prompt-card-icon.green { background: #eaf3ee; color: #347c69; }
.prompt-card-icon.blue { background: #edf2f5; color: #577689; }
.prompt-card-icon svg { fill: none; height: 21px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; width: 21px; }
.prompt-card > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.prompt-card strong { font-size: 12px; }
.prompt-card small { color: #959c99; font-size: 9px; margin-top: 4px; }
.card-arrow { fill: none; height: 17px; stroke: #a7adaa; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 17px; }

.message-list { margin: 0 auto; max-width: 850px; padding: 35px 26px 50px; width: 100%; }
.message-row { display: flex; gap: 12px; margin: 0 0 30px; }
.message-row.user { justify-content: flex-end; }
.message-row .message-avatar { align-items: center; background: var(--forest); border-radius: 50%; color: #f2bd73; display: flex; flex: 0 0 32px; font-size: 14px; height: 32px; justify-content: center; margin-top: 2px; width: 32px; }
.message-body { min-width: 0; }
.message-row.assistant .message-body { max-width: min(690px, calc(100% - 44px)); }
.message-row.user .message-body { background: var(--forest); border-radius: 17px 17px 4px 17px; color: #fff; max-width: min(620px, 84%); padding: 12px 16px; }
.message-name { color: var(--forest); display: block; font-family: Georgia, serif; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.message-content { font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.message-content p { margin: 0 0 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong { color: #183f36; }
.user .message-content strong { color: #fff; }
.message-content ul, .message-content ol { margin: 8px 0 13px; padding-left: 21px; }
.message-content li { margin: 5px 0; }
.typing { align-items: center; display: flex; gap: 5px; min-height: 25px; }
.typing i { animation: typing 1.1s infinite ease-in-out; background: #759087; border-radius: 50%; height: 6px; width: 6px; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.composer-wrap { background: linear-gradient(to top, #fbfbf8 78%, rgba(251,251,248,0)); flex: 0 0 auto; padding: 16px 24px calc(13px + var(--safe-bottom)); position: relative; z-index: 10; }
.composer { align-items: flex-end; background: #fff; border: 1px solid #daddd8; border-radius: 14px; box-shadow: 0 8px 30px rgba(26,46,40,.08); display: flex; gap: 10px; margin: 0 auto; max-width: 800px; padding: 10px 10px 10px 17px; }
.composer:focus-within { border-color: #9fb8af; box-shadow: 0 8px 30px rgba(26,46,40,.1), 0 0 0 3px rgba(23,79,68,.06); }
.composer textarea { background: transparent; border: 0; color: var(--ink); line-height: 1.5; max-height: 145px; min-height: 27px; outline: none; padding: 3px 0; resize: none; width: 100%; }
.composer textarea::placeholder { color: #9ea5a2; }
.send-button { align-items: center; background: var(--forest); border: 0; border-radius: 9px; color: #fff; cursor: pointer; display: flex; flex: 0 0 38px; height: 38px; justify-content: center; transition: background .2s, opacity .2s; }
.send-button:hover { background: var(--forest-dark); }
.send-button:disabled { cursor: default; opacity: .28; }
.send-button svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 18px; }
.composer-wrap > p { color: #a1a7a4; font-size: 9px; margin: 8px 0 0; text-align: center; }
.toast { background: #182b26; border-radius: 10px; bottom: calc(25px + var(--safe-bottom)); color: #fff; font-size: 13px; left: 50%; opacity: 0; padding: 11px 16px; pointer-events: none; position: fixed; transform: translate(-50%, 20px); transition: opacity .25s, transform .25s; z-index: 100; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9a402d; }

@keyframes typing { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
@keyframes pulse { from { opacity: .35; } to { opacity: 1; } }

@media (min-width: 760px) {
    .prompt-grid { grid-template-columns: repeat(3, 1fr); }
    .prompt-card { align-items: flex-start; flex-direction: column; min-height: 142px; padding: 16px; position: relative; }
    .prompt-card-icon { margin: 0 0 16px; }
    .prompt-card small { margin-top: 6px; }
    .card-arrow { position: absolute; right: 13px; top: 22px; }
}

@media (min-width: 960px) {
    .auth-page { grid-template-columns: minmax(0, 1.17fr) minmax(430px, .83fr); }
    .auth-hero { display: block; }
    .mobile-brand { display: none; }
    .auth-panel { padding: 50px; }
}

@media (max-width: 760px) {
    .sidebar {
        box-shadow: 15px 0 50px rgba(18,38,32,.18);
        left: 0;
        max-width: 86vw;
        min-width: 0;
        position: fixed;
        top: 0;
        transform: translateX(-105%);
        transition: transform .25s ease;
        width: 310px;
    }
    .sidebar.open { transform: translateX(0); }
    .icon-button.sidebar-close { display: inline-flex; }
    .sidebar-backdrop { background: rgba(15,31,27,.35); border: 0; display: block; inset: 0; opacity: 0; pointer-events: none; position: fixed; transition: opacity .25s; z-index: 30; }
    .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
    .menu-button, .mobile-new-chat { display: inline-flex; }
    .chat-header { flex-basis: 64px; padding: 0 58px; }
    .agent-avatar { height: 34px; width: 34px; }
    .empty-state { justify-content: center; padding: 35px 18px 25px; }
    .epiphany-symbol { height: 56px; margin-bottom: 18px; width: 56px; }
    .empty-state h1 { font-size: 38px; letter-spacing: -1.5px; }
    .empty-state > p { font-size: 13px; margin: 16px auto 23px; }
    .message-list { padding: 25px 15px 35px; }
    .message-row { gap: 9px; margin-bottom: 24px; }
    .message-row .message-avatar { flex-basis: 29px; height: 29px; width: 29px; }
    .message-row.assistant .message-body { max-width: calc(100% - 38px); }
    .message-row.user .message-body { max-width: 88%; }
    .message-content { font-size: 13.5px; }
    .composer-wrap { padding: 10px 11px calc(9px + var(--safe-bottom)); }
    .composer { border-radius: 13px; padding: 8px 8px 8px 13px; }
    .composer-wrap > p { display: none; }
}

@media (max-width: 430px) {
    .auth-panel { align-items: flex-start; padding: 26px 20px; }
    .mobile-brand { margin-bottom: 48px; }
    .auth-heading h2 { font-size: 34px; }
    .prompt-card:nth-child(3) { display: none; }
    .empty-state { justify-content: flex-start; padding-top: 42px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
