:root {
    color-scheme: dark;
    --bg: #090b10;
    --surface: #0d1017;
    --sidebar: #101218;
    --raised: #151924;
    --hover: #1a2030;
    --active: #1b2130;
    --border: #293040;
    --border-soft: #202633;
    --text: #f6f7fb;
    --muted: #a0a8ba;
    --quiet: #7c879c;
    --accent: #6172ff;
    --accent-hover: #7180ff;
    --accent-ink: #ffffff;
    --danger: #f0a7a7;
    --input: #0c0f15;
    --code-bg: #07090d;
    --code-text: #d9deea;
    --overlay: rgba(2, 4, 9, .72);
    --shadow: 0 14px 38px rgba(0, 0, 0, .24);
    --sidebar-width: 280px;
    --context-width: 310px;
    --kairo-viewport-height: 100dvh;
    --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    --sage: var(--accent);
    --sage-strong: var(--accent);
    --sage-ink: var(--accent-ink);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #fbfcfe;
    --sidebar: #f7f8fb;
    --raised: #f2f4f9;
    --hover: #eef1f7;
    --active: #e9edfa;
    --border: #dfe4ed;
    --border-soft: #eaedf3;
    --text: #171a22;
    --muted: #606a7c;
    --quiet: #667085;
    --accent: #5065f5;
    --accent-hover: #4157e9;
    --accent-ink: #ffffff;
    --danger: #b54141;
    --input: #ffffff;
    --code-bg: #f3f5f9;
    --code-text: #2b3240;
    --overlay: rgba(24, 30, 44, .3);
    --shadow: 0 14px 36px rgba(33, 43, 67, .12);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; min-height: 100%; }
body {
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font: 14px var(--font);
    -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { color: inherit; font: inherit; outline: none; }
button { cursor: pointer; }
button, a, input, textarea, select { touch-action: manipulation; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.kairo-orbit { position: relative; isolation: isolate; }
.kairo-orbit::after {
    position: absolute;
    z-index: -1;
    inset: -4px -7px;
    border: 1px solid var(--accent);
    border-radius: 50%;
    content: "";
    opacity: .7;
    pointer-events: none;
    transform: rotate(-24deg);
    animation: orbit-in .75s ease-out both;
}

.auth-loading, .auth-shell { position: fixed; z-index: 120; inset: 0; min-height: 100dvh; background: var(--bg); }
.auth-loading { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.auth-shell { display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.auth-card {
    width: min(100%, 410px);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.auth-brand, .onboarding-mark { display: grid; width: 42px; height: 42px; place-items: center; color: var(--text); font-size: 20px; font-weight: 720; letter-spacing: -.05em; }
.auth-heading > span, .onboarding-heading > div:last-child > span { display: block; margin-top: 20px; color: var(--accent); font-size: 10px; font-weight: 720; letter-spacing: .08em; text-transform: uppercase; }
.auth-heading h1 { margin: 7px 0 0; font-size: 27px; font-weight: 620; letter-spacing: -.035em; }
.auth-heading p { margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 26px 0 18px; padding: 4px; border: 1px solid var(--border-soft); border-radius: 9px; background: var(--input); }
.auth-tabs button { min-height: 36px; border: 0; border-radius: 7px; background: transparent; color: var(--quiet); font-size: 12px; }
.auth-tabs button.active { background: var(--raised); color: var(--text); }
.auth-form label { display: block; margin: 14px 0 7px; color: var(--text); font-size: 12px; font-weight: 560; }
.auth-form input, .journey-form > input, .journey-form > textarea, .study-form > input, .study-form > textarea, .onboarding-form > input, .onboarding-form > textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--input);
    color: var(--text);
}
.auth-form input { height: 44px; padding: 0 12px; }
.auth-form input:focus, .journey-form > input:focus, .journey-form > textarea:focus, .study-form > input:focus, .study-form > textarea:focus, .study-form select:focus, .onboarding-form > input:focus, .onboarding-form > textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--quiet); }
.auth-hint { display: block; margin-top: 7px; color: var(--quiet); font-size: 10px; line-height: 1.4; }
.auth-error, .profile-error { margin: 12px 0 0; color: var(--danger); font-size: 11px; line-height: 1.45; }
.auth-submit { width: 100%; min-height: 43px; margin-top: 19px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.auth-submit:hover, .primary-button:hover, .send-button:hover, .new-chat-button:hover { background: var(--accent-hover); }
.auth-footnote { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--border-soft); color: var(--quiet); font-size: 10px; line-height: 1.5; }

.app-shell { display: grid; width: 100%; height: 100dvh; min-height: 0; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); overflow: hidden; background: var(--bg); }
.sidebar { position: relative; z-index: 20; display: flex; min-width: 0; min-height: 0; height: 100%; overflow: hidden; flex-direction: column; padding: 14px 12px 12px; border-right: 1px solid var(--border-soft); background: var(--sidebar); }
.brand-row { display: flex; min-height: 42px; align-items: center; gap: 12px; padding: 0 9px; }
.brand-mark, .welcome-mark { display: grid; place-items: center; color: var(--text); font-weight: 720; letter-spacing: -.05em; }
.brand-mark { width: 30px; height: 30px; font-size: 16px; }
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.icon-button, .composer-icon, .send-button, .dialog-close { display: inline-grid; place-items: center; padding: 0; border: 0; background: transparent; }
.icon-button { width: 32px; height: 32px; border-radius: 8px; color: var(--muted); }
.icon-button:hover { color: var(--text); background: var(--hover); }
.sidebar-close, .sidebar-open { display: none; }
.sidebar-close { margin-left: auto; }
.new-chat-button { display: flex; width: 100%; height: 42px; align-items: center; gap: 10px; margin-top: 18px; padding: 0 13px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-align: left; }
.new-chat-button svg { width: 17px; height: 17px; }
.sidebar-collections { min-height: 0; flex: 1; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; }
.sidebar-section-header { display: flex; align-items: center; justify-content: space-between; margin: 23px 8px 8px; color: var(--quiet); font-size: 11px; font-weight: 650; letter-spacing: .04em; }
.sidebar-section-header .icon-button { width: 28px; height: 28px; }
.sidebar-section-header svg { width: 15px; height: 15px; }
.chat-list, .journey-list, .study-list { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.sidebar-empty-copy { margin: 8px 10px 3px; color: var(--quiet); font-size: 11px; line-height: 1.45; }
.journey-item, .journey-empty-button { position: relative; display: flex; width: 100%; min-height: 42px; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; }
.journey-item:hover, .journey-empty-button:hover { color: var(--text); background: var(--hover); }
.journey-item.active { color: var(--text); background: var(--active); }
.journey-item.active::before { position: absolute; top: 8px; bottom: 8px; left: 0; width: 2px; border-radius: 2px; background: var(--accent); content: ""; }
.journey-item-icon { display: grid; width: 27px; height: 27px; flex: 0 0 auto; place-items: center; border: 1px solid var(--border); border-radius: 7px; color: var(--accent); font-size: 10px; font-weight: 700; }
.chat-item-icon { color: var(--muted); }
.journey-item-copy { min-width: 0; }
.journey-item-copy strong, .journey-item-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.journey-item-copy strong { color: inherit; font-size: 13px; font-weight: 550; }
.journey-item-copy span { margin-top: 2px; color: var(--quiet); font-size: 10px; }
.journey-empty-button { font-size: 12px; }
.journey-empty-button svg { width: 15px; height: 15px; }
.sidebar-footer { position: relative; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.sidebar-footer-button { display: flex; width: 100%; height: 40px; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; }
.sidebar-footer-button:hover { color: var(--text); background: var(--hover); }
.footer-chevron { width: 14px; height: 14px; margin-left: auto; }
.settings-popover { position: absolute; bottom: 50px; left: 0; width: 246px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.account-summary { display: flex; align-items: center; gap: 9px; margin: 0 2px 6px; padding: 5px 5px 11px; border-bottom: 1px solid var(--border-soft); }
.account-avatar { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 740; }
.account-summary > span:last-child { min-width: 0; }
.account-summary strong, .account-summary small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-summary strong { color: var(--text); font-size: 12px; font-weight: 620; }
.account-summary small { margin-top: 2px; color: var(--quiet); font-size: 9px; }
.settings-popover label { display: flex; align-items: center; gap: 9px; padding: 9px 7px; color: var(--muted); }
.settings-popover input { accent-color: var(--accent); }
.settings-popover button, .settings-popover a { display: flex; width: 100%; align-items: center; gap: 9px; margin-top: 4px; padding: 9px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; text-decoration: none; }
.settings-popover button:hover, .settings-popover a:hover { color: var(--text); background: var(--hover); }
.settings-popover button svg, .settings-popover a svg { width: 16px; height: 16px; }
.settings-popover #forget { margin-top: 7px; border-color: var(--border); color: var(--danger); }
.settings-popover .logout-button { border-color: var(--border); }
.theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: block; }

.workspace { display: flex; min-width: 0; min-height: 0; height: 100%; overflow: hidden; flex-direction: column; background: var(--bg); }
.workspace-header { display: flex; min-height: 66px; align-items: center; gap: 12px; padding: 10px 22px; border-bottom: 1px solid var(--border-soft); }
.workspace-title-wrap { min-width: 0; }
.workspace-title-wrap h1 { overflow: hidden; margin: 0; color: var(--text); font-size: 15px; font-weight: 620; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.workspace-title-wrap p { overflow: hidden; margin: 3px 0 0; color: var(--quiet); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.research-button, .context-toggle { display: inline-flex; height: 34px; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; }
.research-button:hover, .context-toggle:hover { color: var(--text); background: var(--hover); }
.research-button svg, .context-toggle svg { width: 15px; height: 15px; }
.research-button.busy svg { animation: spin 1s linear infinite; }
.context-chevron { transition: transform .18s ease; }
.context-toggle[aria-expanded="true"] .context-chevron { transform: rotate(180deg); }
.content-layout { display: grid; min-width: 0; min-height: 0; flex: 1; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.content-layout.has-context { grid-template-columns: minmax(0, 1fr) var(--context-width); }
.conversation-column { display: grid; min-width: 0; min-height: 0; overflow: hidden; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto auto; padding: 0 clamp(18px, 4vw, 48px) 16px; }
.chat { width: min(100%, 860px); min-width: 0; max-width: 100%; margin: 0 auto; padding: 34px 0 18px; overflow-y: auto; overscroll-behavior: contain; }
.welcome-state { display: flex; min-height: 100%; align-items: center; justify-content: center; flex-direction: column; padding: 46px 0 86px; text-align: center; }
.welcome-mark { width: 44px; height: 44px; font-size: 21px; }
.welcome-state h2 { margin: 22px 0 8px; font-size: clamp(26px, 3vw, 32px); font-weight: 610; letter-spacing: -.035em; }
.welcome-state > p { max-width: 480px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.suggestions { display: grid; width: min(100%, 630px); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 28px; }
.suggestions button { min-height: 44px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; text-align: left; }
.suggestions button:hover { color: var(--text); background: var(--raised); }
.message { display: flex; min-width: 0; margin: 0 0 25px; }
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }
.message-body { min-width: 0; max-width: min(88%, 750px); color: var(--text); line-height: 1.62; }
.message.user .message-body { max-width: 78%; padding: 11px 14px; border: 1px solid var(--border-soft); border-radius: 11px; background: var(--raised); }
.message-copy { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.message-copy p { margin: 0 0 12px; white-space: pre-wrap; }
.message-copy p:last-child { margin-bottom: 0; }
.message-heading { margin: 18px 0 7px; color: var(--text); font-weight: 650; letter-spacing: -.01em; }
.message-meta + .message-copy .message-heading:first-child { margin-top: 0; }
.message-list-item { display: grid; min-width: 0; grid-template-columns: 22px minmax(0, 1fr); gap: 2px; margin: 6px 0; }
.message-list-item > span:first-child { color: var(--accent); }
.message-code { width: 100%; max-width: 100%; margin: 12px 0; padding: 13px; overflow-x: auto; border: 1px solid var(--border); border-radius: 9px; background: var(--code-bg); color: var(--code-text); font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; white-space: pre; }
.message-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.answer-badge { display: inline-flex; min-height: 21px; align-items: center; padding: 2px 7px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.answer-badge.web, .answer-badge.webpage, .answer-badge.journey { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent); }
.answer-badge.calculator { border-color: #746838; color: #c7ac4a; }
.message-sources { display: flex; width: 100%; min-width: 0; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--border-soft); }
.message-sources-label { width: 100%; margin-bottom: 2px; color: var(--quiet); font-size: 10px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.message-sources a { display: inline-flex; max-width: 210px; align-items: center; padding: 5px 8px; overflow: hidden; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); font-size: 11px; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.message-sources a:hover { color: var(--text); border-color: var(--accent); }
.response-actions { display: flex; align-items: center; gap: 3px; margin-top: 9px; }
.response-action { display: inline-flex; min-width: 30px; height: 30px; align-items: center; justify-content: center; gap: 6px; padding: 0 7px; border: 0; border-radius: 7px; background: transparent; color: var(--quiet); font-size: 10px; }
.response-action:hover, .response-action.active { color: var(--text); background: var(--hover); }
.response-action.active { color: var(--accent); }
.response-action svg { width: 15px; height: 15px; }
.response-action.busy svg { animation: spin .9s linear infinite; }
.compare-action { margin-left: 2px; }
.typing-row { width: min(100%, 860px); margin: 0 auto 8px; color: var(--quiet); font-size: 11px; }
.typing-row span { display: inline-block; width: 4px; height: 4px; margin-right: 3px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.typing-row span:nth-child(2) { animation-delay: .16s; }
.typing-row span:nth-child(3) { animation-delay: .32s; }
.typing-row em { margin-left: 5px; font-style: normal; }
.composer { display: flex; width: min(100%, 860px); min-width: 0; min-height: 55px; align-items: flex-end; gap: 6px; margin: 0 auto; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--raised); }
.composer:focus-within { border-color: var(--accent); }
.composer-icon { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 8px; color: var(--quiet); }
.composer-icon:hover { color: var(--text); background: var(--hover); }
.composer textarea { min-width: 0; max-height: 160px; flex: 1; resize: none; padding: 9px 5px 7px; overflow-y: auto; border: 0; background: transparent; color: var(--text); line-height: 1.45; }
.mode-control { display: flex; height: 36px; align-items: center; gap: 4px; padding: 0 7px; border-radius: 8px; color: var(--quiet); }
.mode-control:hover { background: var(--hover); }
.mode-control svg { width: 14px; height: 14px; }
.mode-control select { max-width: 72px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.send-button { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 9px; background: var(--accent); color: var(--accent-ink); }
.send-button svg { width: 17px; height: 17px; stroke-width: 2; }
.composer-note { margin: 7px auto 0; color: var(--quiet); font-size: 10px; text-align: center; }

.study-item-icon { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.study-workspace { min-width: 0; min-height: 0; overflow: hidden; }
.study-scroll { width: min(100%, 920px); height: 100%; margin: 0 auto; padding: 38px 34px 72px; overflow-y: auto; overscroll-behavior: contain; }
.study-hero { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 25px; }
.study-kicker, .study-section-label { display: block; color: var(--accent); font-size: 9px; font-weight: 720; letter-spacing: .09em; text-transform: uppercase; }
.study-hero h2 { margin: 7px 0 6px; font-size: clamp(25px, 3vw, 34px); font-weight: 620; letter-spacing: -.04em; }
.study-hero p { max-width: 650px; margin: 0; color: var(--muted); line-height: 1.55; }
.study-mastery { --study-progress: 0deg; position: relative; display: grid; width: 82px; height: 82px; flex: 0 0 auto; place-items: center; align-content: center; border-radius: 50%; background: conic-gradient(var(--accent) var(--study-progress), var(--border-soft) 0); }
.study-mastery::after { position: absolute; inset: 5px; border-radius: inherit; background: var(--bg); content: ""; }
.study-mastery strong, .study-mastery span { position: relative; z-index: 1; }
.study-mastery strong { font-size: 17px; font-weight: 650; letter-spacing: -.03em; }
.study-mastery span { margin-top: 1px; color: var(--quiet); font-size: 8px; letter-spacing: .06em; text-transform: uppercase; }
.study-tabs { display: flex; gap: 4px; margin-bottom: 22px; padding: 4px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface); }
.study-tabs button { min-height: 38px; flex: 1; border: 0; border-radius: 7px; background: transparent; color: var(--quiet); font-size: 12px; font-weight: 560; }
.study-tabs button:hover { color: var(--text); }
.study-tabs button.active { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.study-loading, .study-empty { display: flex; min-height: 410px; align-items: center; justify-content: center; flex-direction: column; text-align: center; }
.study-loading-mark { display: grid; width: 46px; height: 46px; place-items: center; font-size: 20px; font-weight: 720; animation: pulse 1.4s ease-in-out infinite; }
.study-loading h3, .study-empty h3 { margin: 22px 0 7px; font-size: 20px; font-weight: 610; letter-spacing: -.025em; }
.study-loading p, .study-empty p { max-width: 430px; margin: 0; color: var(--muted); line-height: 1.55; }
.study-loading .research-progress { width: min(260px, 70%); margin-top: 22px; }
.study-empty-icon { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid var(--border); border-radius: 13px; color: var(--accent); background: var(--surface); font-size: 19px; }
.study-empty .primary-button { margin-top: 22px; }
.study-panel { animation: study-in .18s ease-out both; }
.study-overview-card, .study-key-card, .study-weak-card, .quiz-card { padding: 24px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface); }
.study-overview { margin-top: 16px; color: var(--text); font-size: 14px; line-height: 1.7; }
.study-overview p { margin: 0 0 14px; }
.study-overview p:last-child { margin-bottom: 0; }
.study-key-card, .study-weak-card { margin-top: 12px; }
.study-key-points { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px 22px; margin-top: 14px; }
.study-key-points > div { display: grid; min-width: 0; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; padding: 13px 0; border-bottom: 1px solid var(--border-soft); }
.study-key-points span { color: var(--accent); font-size: 10px; font-weight: 650; }
.study-key-points p { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.study-weak-topics { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.study-weak-topics span { padding: 7px 10px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); border-radius: 999px; color: var(--muted); font-size: 10px; }
.quiz-card { max-width: 720px; margin: 0 auto; }
.quiz-meta { display: flex; justify-content: space-between; gap: 16px; color: var(--quiet); font-size: 10px; font-weight: 650; letter-spacing: .045em; text-transform: uppercase; }
.quiz-meta span:last-child { color: var(--accent); text-align: right; }
.quiz-card h3 { margin: 24px 0 20px; font-size: clamp(18px, 2.2vw, 23px); font-weight: 590; line-height: 1.4; letter-spacing: -.02em; }
.quiz-options { display: grid; gap: 8px; }
.quiz-option { display: grid; min-height: 52px; grid-template-columns: 31px minmax(0, 1fr); align-items: center; gap: 11px; padding: 9px 13px; border: 1px solid var(--border); border-radius: 9px; background: transparent; color: var(--muted); text-align: left; }
.quiz-option:hover:not(:disabled), .quiz-option.selected { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.quiz-option > span:first-child { display: grid; width: 27px; height: 27px; place-items: center; border: 1px solid var(--border); border-radius: 7px; color: var(--quiet); font-size: 10px; font-weight: 700; }
.quiz-option.selected > span:first-child { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.quiz-option.correct { border-color: #4e9d73; background: color-mix(in srgb, #4e9d73 10%, transparent); color: var(--text); opacity: 1; }
.quiz-option.correct > span:first-child { border-color: #4e9d73; background: #4e9d73; color: white; }
.quiz-option.incorrect { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); opacity: 1; }
.quiz-feedback { margin-top: 15px; padding: 13px 14px; border-left: 2px solid var(--danger); border-radius: 0 8px 8px 0; background: var(--raised); color: var(--muted); font-size: 12px; line-height: 1.55; }
.quiz-feedback.correct { border-left-color: #4e9d73; }
.quiz-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.quiz-actions #quiz-restart { margin-right: auto; }
.flashcard-hint { margin: 0 0 14px; color: var(--quiet); font-size: 11px; text-align: center; }
.flashcard { display: flex; width: min(100%, 680px); min-height: 330px; align-items: center; justify-content: center; flex-direction: column; gap: 16px; margin: 0 auto; padding: 42px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 10px 32px rgba(0, 0, 0, .1); text-align: center; transition: border-color .18s ease, transform .18s ease; }
.flashcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.flashcard.flipped { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.flashcard > span { color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.flashcard > strong { max-width: 560px; font-size: clamp(20px, 3vw, 28px); font-weight: 560; line-height: 1.4; letter-spacing: -.025em; }
.flashcard > small { color: var(--quiet); font-size: 10px; }
.flashcard-controls { display: flex; width: min(100%, 680px); align-items: center; justify-content: space-between; margin: 14px auto 0; color: var(--quiet); font-size: 10px; }
.study-chat-panel { height: clamp(480px, calc(100dvh - 285px), 680px); min-height: 480px; }
.study-chat-shell { display: grid; height: 100%; min-height: 0; overflow: hidden; grid-template-rows: minmax(0, 1fr) auto auto auto; border: 1px solid var(--border-soft); border-radius: 13px; background: var(--surface); }
.study-chat { min-height: 0; padding: 24px 25px 8px; overflow-y: auto; overscroll-behavior: contain; scroll-padding-bottom: 18px; }
.study-chat .message { margin-bottom: 20px; }
.study-chat .message-body { max-width: min(88%, 680px); }
.study-chat .message.user .message-body { max-width: 78%; }
.study-chat-empty { display: flex; min-height: 100%; align-items: center; justify-content: center; flex-direction: column; padding: 34px 20px; text-align: center; }
.study-chat-mark { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: 12px; color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); font-size: 16px; font-weight: 720; }
.study-chat-empty h3 { margin: 17px 0 6px; font-size: 18px; font-weight: 610; letter-spacing: -.02em; }
.study-chat-empty > p { max-width: 450px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.study-chat-suggestions { display: flex; max-width: 620px; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 20px; }
.study-chat-suggestions button { min-height: 36px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--muted); font-size: 10px; }
.study-chat-suggestions button:hover { border-color: var(--accent); color: var(--text); background: var(--hover); }
.study-chat-typing { padding: 4px 25px 8px; color: var(--quiet); font-size: 10px; }
.study-chat-typing span { display: inline-block; width: 4px; height: 4px; margin-right: 3px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.study-chat-typing span:nth-child(2) { animation-delay: .16s; }
.study-chat-typing span:nth-child(3) { animation-delay: .32s; }
.study-chat-typing em { margin-left: 5px; font-style: normal; }
.study-chat-composer { display: flex; min-width: 0; align-items: flex-end; gap: 7px; margin: 0 14px; padding: 7px; border: 1px solid var(--border); border-radius: 11px; background: var(--raised); }
.study-chat-composer:focus-within { border-color: var(--accent); }
.study-chat-composer textarea { min-width: 0; max-height: 130px; flex: 1; resize: none; padding: 9px 7px 7px; overflow-y: auto; border: 0; background: transparent; color: var(--text); line-height: 1.45; }
.study-chat-composer textarea:disabled { opacity: .7; }
.study-chat-note { margin: 8px 14px 11px; color: var(--quiet); font-size: 9px; line-height: 1.35; text-align: center; }
.study-form > p { margin: 8px 38px 24px 0; color: var(--muted); line-height: 1.5; }
.study-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.study-form-grid label { color: var(--text); font-size: 12px; font-weight: 550; }
.study-form-grid select { width: 100%; min-height: 42px; margin-top: 7px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--input); }

@keyframes study-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.journey-context { min-width: 0; padding: 26px 22px; overflow-y: auto; border-left: 1px solid var(--border-soft); background: var(--surface); }
.context-section { margin-bottom: 25px; }
.context-label { display: block; margin-bottom: 9px; color: var(--quiet); font-size: 10px; font-weight: 700; letter-spacing: .065em; text-transform: uppercase; }
.context-value { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.context-value svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; color: var(--accent); }
.research-progress { height: 2px; margin-top: 12px; overflow: hidden; background: var(--border); }
.research-progress span { display: block; width: 45%; height: 100%; background: var(--accent); animation: progress 1.4s infinite ease-in-out; }
.context-sources { padding-top: 2px; border-top: 1px solid var(--border-soft); }
.context-sources > .context-label { margin-top: 20px; }
.context-source-list { display: flex; flex-direction: column; gap: 5px; }
.context-source { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 8px 6px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.context-source:hover { color: var(--text); background: var(--hover); }
.context-source-favicon { display: grid; width: 22px; height: 22px; flex: 0 0 auto; place-items: center; border: 1px solid var(--border); border-radius: 6px; color: var(--accent); font-size: 9px; font-weight: 700; }
.context-source-copy { min-width: 0; }
.context-source-copy strong, .context-source-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-source-copy strong { font-size: 11px; font-weight: 550; }
.context-source-copy span { margin-top: 2px; color: var(--quiet); font-size: 9px; }
.source-empty { margin: 0; color: var(--quiet); font-size: 11px; line-height: 1.5; }

.journey-dialog, .study-dialog, .onboarding-dialog, .pet-customizer-dialog, .answer-compare-dialog { width: min(520px, calc(100vw - 32px)); padding: 0; overflow: visible; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.onboarding-dialog { width: min(600px, calc(100vw - 32px)); }
.pet-customizer-dialog { width: min(730px, calc(100vw - 32px)); max-height: calc(100dvh - 24px); overflow-y: auto; }
.answer-compare-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.journey-dialog::backdrop, .study-dialog::backdrop, .onboarding-dialog::backdrop, .pet-customizer-dialog::backdrop, .answer-compare-dialog::backdrop { background: var(--overlay); }
.journey-form, .study-form, .onboarding-form, .pet-customizer-form { position: relative; padding: 27px; }
.journey-form h2, .study-form h2, .onboarding-form h2, .pet-customizer-form h2 { margin: 0; font-size: 21px; font-weight: 620; letter-spacing: -.025em; }
.journey-form > p { margin: 8px 38px 24px 0; color: var(--muted); line-height: 1.45; }
.dialog-close { position: absolute; top: 18px; right: 18px; width: 32px; height: 32px; border-radius: 8px; color: var(--quiet); }
.dialog-close:hover { color: var(--text); background: var(--hover); }
.journey-form > label, .study-form > label, .onboarding-form > label { display: block; margin: 15px 0 7px; color: var(--text); font-size: 12px; font-weight: 550; }
.journey-form > input, .journey-form > textarea, .study-form > input, .study-form > textarea, .onboarding-form > input, .onboarding-form > textarea { padding: 11px 12px; resize: vertical; line-height: 1.4; }
.privacy-note { display: flex; align-items: flex-start; gap: 10px; margin-top: 20px; padding: 12px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: var(--raised); font-size: 11px; line-height: 1.45; }
.privacy-note svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.secondary-button, .primary-button { min-height: 38px; padding: 0 15px; border-radius: 8px; font-size: 12px; font-weight: 570; }
.secondary-button { border: 1px solid var(--border); background: transparent; color: var(--muted); }
.secondary-button:hover { color: var(--text); background: var(--hover); }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.answer-compare-shell { position: relative; padding: 27px; }
.answer-compare-kicker { display: block; margin-bottom: 6px; color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.answer-compare-shell h2 { margin: 0; padding-right: 42px; font-size: 21px; font-weight: 620; letter-spacing: -.025em; }
.answer-compare-prompt { max-width: 720px; margin: 9px 42px 20px 0; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; line-height: 1.45; }
.answer-compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.answer-choice { display: flex; min-width: 0; min-height: 260px; flex-direction: column; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.answer-choice-label { margin-bottom: 13px; color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.answer-choice-copy { max-height: min(45dvh, 420px); flex: 1; padding-right: 4px; overflow-y: auto; color: var(--text); font-size: 13px; line-height: 1.58; }
.answer-choice-button { width: 100%; margin-top: 17px; flex: 0 0 auto; }
.answer-compare-note { margin: 13px 0 0; color: var(--quiet); font-size: 9px; line-height: 1.45; text-align: center; }
.onboarding-heading { display: flex; align-items: center; gap: 16px; padding-right: 38px; }
.onboarding-heading .onboarding-mark { flex: 0 0 auto; }
.onboarding-heading > div:last-child > span { margin-top: 0; }
.onboarding-heading h2 { margin-top: 4px; }
.onboarding-intro { margin: 18px 38px 22px 0; color: var(--muted); line-height: 1.5; }
.response-style { margin: 18px 0 0; padding: 0; border: 0; }
.response-style legend { margin-bottom: 8px; color: var(--text); font-size: 12px; font-weight: 550; }
.style-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.style-options label { display: flex; min-width: 0; align-items: flex-start; gap: 8px; padding: 11px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); cursor: pointer; }
.style-options label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.style-options input { flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--accent); }
.style-options strong, .style-options small { display: block; }
.style-options strong { color: var(--text); font-size: 11px; font-weight: 620; }
.style-options small { margin-top: 3px; color: var(--quiet); font-size: 9px; line-height: 1.3; }
.profile-privacy { margin: 13px 0 0; color: var(--quiet); font-size: 9px; text-align: right; }
.pet-customizer-kicker { display: block; margin-bottom: 5px; color: var(--accent); font-size: 9px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.pet-customizer-form > p:not(.profile-privacy) { margin: 8px 38px 22px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.pet-preset-section { margin: 0 0 22px; }
.pet-preset-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.pet-preset-heading strong { color: var(--text); font-size: 11px; font-weight: 620; }
.pet-preset-heading span { color: var(--quiet); font-size: 9px; }
.pet-preset-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.pet-preset { display: grid; min-width: 0; place-items: center; gap: 3px; padding: 5px 3px 7px; border: 1px solid var(--border); border-radius: 9px; background: var(--raised); color: var(--quiet); cursor: pointer; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.pet-preset:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); color: var(--text); transform: translateY(-1px); }
.pet-preset.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--raised)); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent); }
.pet-preset canvas { width: 50px; height: 50px; image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }
.pet-preset span { width: 100%; overflow: hidden; font-size: 8px; line-height: 1.2; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.pet-customizer-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 22px; align-items: stretch; }
.pet-preview-card { display: grid; min-height: 220px; place-items: center; align-content: center; gap: 16px; border: 1px solid var(--border); border-radius: 11px; background: var(--raised); }
.pet-preview-card canvas { width: 144px; height: 144px; image-rendering: pixelated; image-rendering: crisp-edges; }
.pet-preview-card span { color: var(--quiet); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.pet-customizer-controls > label { display: block; margin: 0 0 7px; color: var(--text); font-size: 11px; font-weight: 560; }
.pet-customizer-controls > input, .pet-customizer-controls > select { width: 100%; margin-bottom: 13px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--raised); color: var(--text); }
.pet-color-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 14px; }
.pet-color-grid label { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; padding: 7px 8px 7px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 9px; }
.pet-color-grid input[type="color"] { width: 25px; height: 25px; padding: 2px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; }
.pet-customizer-actions { justify-content: space-between; }
.kairo-pet { position: fixed; z-index: 90; right: 18px; bottom: 90px; display: flex; align-items: flex-end; flex-direction: column; gap: 9px; }
.pet-button { position: relative; display: grid; width: 68px; height: 68px; place-items: center; padding: 0; overflow: visible; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); }
.pet-button:hover { border-color: var(--accent); }
.pet-sprite { width: 62px; height: 62px; pointer-events: none; image-rendering: pixelated; image-rendering: crisp-edges; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .2)); transform-origin: 50% 82%; animation: pet-idle 2.8s steps(2, jump-none) infinite; }
.pet-button::before { position: absolute; z-index: 2; top: -10px; left: -4px; width: 5px; height: 5px; border-radius: 1px; background: var(--accent); box-shadow: 10px -7px 0 var(--accent), 22px -9px 0 var(--accent); opacity: 0; content: ""; pointer-events: none; }
.pet-button::after { position: absolute; inset: -5px; border: 1px solid transparent; border-radius: 50%; content: ""; pointer-events: none; }
.pet-state-dot { position: absolute; right: 2px; bottom: 4px; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: #6fb98f; }
.kairo-pet.thinking .pet-button::after, .kairo-pet.researching .pet-button::after { border-top-color: var(--accent); border-right-color: color-mix(in srgb, var(--accent) 35%, transparent); animation: pet-orbit 1.15s linear infinite; }
.kairo-pet.thinking .pet-state-dot, .kairo-pet.researching .pet-state-dot { background: var(--accent); animation: pet-pulse 1s ease-in-out infinite; }
.kairo-pet.thinking .pet-button::before { animation: pet-thoughts 1.2s steps(3, end) infinite; }
.kairo-pet.thinking .pet-sprite { animation: pet-think 1.4s steps(3, end) infinite; }
.kairo-pet.researching .pet-sprite { animation: pet-search 1s steps(3, end) infinite; }
.kairo-pet.happy .pet-sprite { animation: pet-hop .62s steps(4, end), pet-idle 2.8s .62s steps(2, jump-none) infinite; }
.kairo-pet.concerned .pet-sprite { animation: pet-worry 1.1s steps(2, end) 2; filter: saturate(.68) drop-shadow(0 6px 5px rgba(0, 0, 0, .22)); }
.kairo-pet.concerned .pet-state-dot { background: #dca665; }
.pet-panel { width: 278px; padding: 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow); }
.pet-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pet-panel-heading h2 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: -.01em; }
.pet-panel-heading p { margin: 3px 0 0; color: var(--quiet); font-size: 9px; }
.pet-close { display: grid; width: 27px; height: 27px; flex: 0 0 auto; place-items: center; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--quiet); }
.pet-close:hover { color: var(--text); background: var(--hover); }
.pet-close svg { width: 14px; height: 14px; }
.pet-message { min-height: 40px; margin: 14px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.pet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.pet-actions button, .pet-customize, .pet-hide { min-height: 34px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--muted); font-size: 10px; }
.pet-actions button:hover, .pet-customize:hover { border-color: var(--accent); color: var(--text); background: var(--hover); }
.pet-customize { width: 100%; margin-top: 8px; color: var(--text); }
.pet-hide { width: 100%; min-height: 30px; margin-top: 8px; border-color: transparent; color: var(--quiet); }
.pet-hide:hover { color: var(--text); background: var(--hover); }
.pet-nudge { max-width: 230px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px 9px 2px 9px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow); font-size: 10px; line-height: 1.4; }
.toast { position: fixed; z-index: 150; right: 20px; bottom: 20px; max-width: 360px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: 12px; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.mobile-scrim { position: fixed; z-index: 15; inset: 0; background: var(--overlay); }

@keyframes orbit-in { from { opacity: 0; transform: rotate(-6deg) scale(.8); } to { opacity: .7; transform: rotate(-24deg) scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 70%, 100% { opacity: .3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
@keyframes progress { 0% { transform: translateX(-110%); } 100% { transform: translateX(240%); } }
@keyframes pet-idle { 0%, 100% { transform: translateY(1px) scaleY(1); } 50% { transform: translateY(-2px) scaleY(.98); } }
@keyframes pet-orbit { to { transform: rotate(360deg); } }
@keyframes pet-pulse { 50% { opacity: .45; transform: scale(.8); } }
@keyframes pet-thoughts { 0% { opacity: 0; transform: translateY(4px); } 35%, 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-5px); } }
@keyframes pet-think { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-2px) rotate(-3deg); } }
@keyframes pet-search { 0%, 100% { transform: translateX(-2px) rotate(-2deg); } 50% { transform: translateX(3px) rotate(2deg); } }
@keyframes pet-hop { 0%, 100% { transform: translateY(0) scale(1); } 35% { transform: translateY(-10px) scale(1.04); } 65% { transform: translateY(1px) scale(.96, 1.04); } }
@keyframes pet-worry { 0%, 100% { transform: rotate(0); } 50% { transform: translateY(2px) rotate(4deg); } }

@media (max-width: 1000px) {
    .content-layout.has-context { position: relative; grid-template-columns: minmax(0, 1fr); }
    .journey-context { position: absolute; z-index: 10; top: 0; right: 0; bottom: 0; width: min(var(--context-width), calc(100vw - var(--sidebar-width))); box-shadow: var(--shadow); }
}

@media (min-width: 761px) {
    .app-shell:has(.content-layout.has-context) .kairo-pet { right: calc(var(--context-width) + 18px); }
}

@media (max-width: 760px) {
    html, body { width: 100%; height: var(--kairo-viewport-height); min-height: 0; overscroll-behavior: none; }
    body { position: fixed; inset: 0; overflow: hidden; font-size: 15px; }
    button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
    .auth-shell { align-items: start; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); }
    .auth-card { margin-top: 3vh; padding: 25px 20px; }
    input, textarea, select { font-size: 16px; }
    .app-shell { height: var(--kairo-viewport-height); min-height: 0; grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 90vw); padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
    body.sidebar-visible .sidebar { transform: translateX(0); }
    .sidebar-open, .sidebar-close { display: inline-grid; }
    .icon-button { width: 44px; height: 44px; }
    .new-chat-button, .journey-item, .journey-empty-button, .sidebar-footer-button { min-height: 48px; }
    .settings-popover { width: calc(100% - 4px); max-height: min(70dvh, 560px); overflow-y: auto; }
    .settings-popover label, .settings-popover button, .settings-popover a { min-height: 44px; }
    .workspace-header { min-height: 56px; padding: max(7px, env(safe-area-inset-top)) 10px 7px; }
    .research-button span, .context-toggle span { display: none; }
    .research-button, .context-toggle { width: 44px; height: 44px; justify-content: center; padding: 0; }
    .context-chevron { display: none; }
    .conversation-column { padding: 0 10px max(10px, env(safe-area-inset-bottom)); }
    .chat { padding: 18px 0 12px; scroll-padding-bottom: 90px; }
    .welcome-state { min-height: auto; justify-content: flex-start; padding: 36px 4px 44px; }
    .welcome-state h2 { margin-top: 18px; font-size: 27px; }
    .welcome-state > p { font-size: 14px; }
    .suggestions { grid-template-columns: minmax(0, 1fr); }
    .suggestions button { min-height: 48px; font-size: 14px; }
    .message { margin-bottom: 18px; }
    .message-body, .message.user .message-body { max-width: 92%; }
    .message-body { font-size: 15px; line-height: 1.55; }
    .message.user .message-body { padding: 10px 12px; }
    .typing-row { margin-bottom: 6px; font-size: 12px; }
    .composer { min-height: 58px; gap: 4px; padding: 6px; border-radius: 14px; }
    .composer-icon, .send-button { width: 44px; height: 44px; }
    .composer textarea { min-height: 44px; padding: 10px 4px 8px; line-height: 1.35; }
    .mode-control { height: 44px; padding: 0 4px; }
    .mode-control svg { display: none; }
    .mode-control select { max-width: 70px; }
    .composer-note { margin-top: 5px; padding: 0 8px; font-size: 9px; line-height: 1.35; }
    .journey-context { width: min(var(--context-width), 88vw); }
    .journey-dialog, .study-dialog, .onboarding-dialog, .pet-customizer-dialog, .answer-compare-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; }
    .journey-form, .study-form, .onboarding-form, .pet-customizer-form { padding: 23px 20px; }
    .dialog-close { top: 10px; right: 10px; width: 44px; height: 44px; }
    .journey-form > input, .study-form > input, .study-form-grid select, .onboarding-form > input, .pet-customizer-controls > input, .pet-customizer-controls > select { min-height: 44px; }
    .answer-compare-shell { padding: 23px 16px; }
    .answer-compare-grid { grid-template-columns: minmax(0, 1fr); }
    .answer-choice { min-height: 0; }
    .answer-choice-copy { max-height: 36dvh; font-size: 14px; }
    .response-action { min-width: 44px; height: 44px; }
    .response-action span { display: none; }
    .style-options { grid-template-columns: minmax(0, 1fr); }
    .onboarding-actions { align-items: stretch; flex-direction: column-reverse; }
    .onboarding-actions button { width: 100%; }
    .dialog-actions .primary-button, .dialog-actions .secondary-button { min-height: 44px; }
    .profile-privacy { text-align: center; }
    .kairo-pet { right: 10px; bottom: calc(100px + env(safe-area-inset-bottom)); }
    .app-shell:has(.content-layout.has-context) .kairo-pet { display: none; }
    body.sidebar-visible .kairo-pet { visibility: hidden; pointer-events: none; }
    .pet-button { width: 58px; height: 58px; }
    .pet-sprite { width: 50px; height: 50px; }
    .pet-panel { width: min(278px, calc(100vw - 20px)); }
    .pet-close { width: 44px; height: 44px; }
    .pet-actions button, .pet-customize, .pet-hide { min-height: 44px; }
    .pet-nudge { max-width: min(210px, calc(100vw - 30px)); font-size: 11px; }
    .pet-customizer-layout { grid-template-columns: minmax(0, 1fr); }
    .pet-preset-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
    .pet-preset-grid { grid-template-rows: repeat(2, 78px); grid-template-columns: none; grid-auto-columns: 76px; grid-auto-flow: column; gap: 7px; padding: 0 0 6px; overflow-x: auto; overscroll-behavior-inline: contain; scroll-snap-type: inline proximity; }
    .pet-preset { scroll-snap-align: start; }
    .pet-preset canvas { width: 48px; height: 48px; }
    .pet-color-grid label { min-height: 44px; }
    .pet-preview-card { min-height: 150px; }
    .pet-preview-card canvas { width: 112px; height: 112px; }
    .study-scroll { padding: 24px 12px max(42px, env(safe-area-inset-bottom)); }
    .study-hero { align-items: flex-start; gap: 14px; }
    .study-hero h2 { font-size: 25px; }
    .study-mastery { width: 68px; height: 68px; }
    .study-tabs button { min-height: 44px; }
    .study-loading, .study-empty { min-height: 360px; padding: 20px; }
    .study-overview-card, .study-key-card, .study-weak-card, .quiz-card { padding: 18px 15px; }
    .study-key-points { grid-template-columns: minmax(0, 1fr); }
    .quiz-option { min-height: 56px; padding: 9px 10px; font-size: 14px; }
    .quiz-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .quiz-actions #quiz-restart { grid-column: 1 / -1; order: 2; }
    .quiz-actions button { min-height: 44px; }
    .flashcard { min-height: 300px; padding: 30px 20px; }
    .flashcard-controls .secondary-button { min-height: 44px; }
    .study-chat-panel { height: min(590px, calc(100dvh - 230px)); min-height: 470px; }
    .study-chat { padding: 18px 12px 6px; }
    .study-chat .message-body, .study-chat .message.user .message-body { max-width: 92%; }
    .study-chat-empty { padding: 28px 8px; }
    .study-chat-suggestions { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr); }
    .study-chat-suggestions button { min-height: 44px; text-align: left; }
    .study-chat-typing { padding: 4px 13px 7px; font-size: 11px; }
    .study-chat-composer { margin: 0 8px; }
    .study-chat-composer textarea { min-height: 44px; padding: 10px 6px 8px; font-size: 16px; }
    .study-chat-composer .send-button { width: 44px; height: 44px; }
    .study-chat-note { margin: 7px 10px max(9px, env(safe-area-inset-bottom)); }
    .study-form-grid { grid-template-columns: minmax(0, 1fr); }
    .toast { right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); max-width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


.study-cockpit { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin: 24px 0; }
.study-mission, .study-focus, .study-map, .study-coach { border: 1px solid var(--border); border-radius: 20px; padding: 24px; background: var(--surface); }
.study-mission { background: linear-gradient(125deg, rgba(97,114,255,.16), transparent); }
.study-mission h3 { margin: 12px 0; font-size: 24px; letter-spacing: -.6px; }
.study-cockpit p { color: var(--muted); line-height: 1.65; }
.study-focus strong { display: block; font-size: 44px; font-variant-numeric: tabular-nums; margin-top: 12px; }
.study-map, .study-coach { grid-column: 1 / -1; }
#concept-map { display: flex; flex-wrap: wrap; gap: 14px; padding: 16px 0 4px; }
.concept-star { padding: 16px 22px; border: 1px solid var(--border); border-radius: 32px; color: var(--text); background: rgba(97,114,255,.1); cursor: pointer; font: inherit; }
.concept-star:hover { border-color: #8897ff; }
.concept-star.needs-review { border-color: #dfb16b; }
.study-coach { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#study-evidence { color: var(--muted); font-size: 12px; margin-left: auto; }
@media (max-width: 650px) { .study-cockpit { grid-template-columns: 1fr; } .study-mission, .study-focus, .study-map, .study-coach { padding: 18px; } #study-evidence { margin-left: 0; } }
.mastery-note { color: var(--muted); font-size: 12px; line-height: 1.65; max-width: 900px; }
.adaptive-summary { padding: 24px; border: 1px solid var(--border); border-radius: 20px; background: linear-gradient(110deg, rgba(97,114,255,.13), transparent); margin-bottom: 18px; }
.adaptive-summary h3 { margin: 10px 0; font-size: 24px; }
.adaptive-summary p { color: var(--muted); line-height: 1.65; }
.lesson-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.full-lesson-section { padding: 20px 0; border-bottom: 1px solid var(--border); line-height: 1.8; }
.full-lesson-section h3 { font-size:22px; line-height:1.3; }
.full-lesson-section li { margin: 8px 0; }
.lesson-example { padding:18px; border-left:3px solid #8897ff; border-radius:8px; background:rgba(97,114,255,.08); }
.lesson-example p { white-space:pre-wrap; }
#lesson-generation-status { color:var(--muted); line-height:1.6; }
.study-mastery > span { font-size:9px; text-align:center; }
.creation-dialog { width:min(1100px,95vw); max-height:90dvh; padding:28px; }
.creation-dialog, .voice-dialog { color:var(--text); background:var(--surface); border:1px solid var(--border); border-radius:22px; }
.creation-heading { display:flex; justify-content:space-between; gap:18px; align-items:center; }
.creation-heading h2 { margin:8px 0 18px; font-size:25px; }
#creation-form > label { display:block; margin:12px 0 8px; }
#creation-prompt, #voice-transcript { width:100%; resize:vertical; border:1px solid var(--border); border-radius:12px; padding:14px; background:var(--bg); color:var(--text); font:inherit; line-height:1.5; }
.creation-options, .creation-downloads, .voice-actions { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin:14px 0; }
.creation-options select, #voice-language { padding:9px; border-radius:8px; background:var(--bg); color:var(--text); border:1px solid var(--border); }
#creation-status, .creation-footnote, #voice-status { font-size:13px; color:var(--muted); line-height:1.6; }
.creation-layout { display:grid; grid-template-columns:235px minmax(0,1fr); gap:25px; border-top:1px solid var(--border); margin-top:22px; padding-top:18px; }
.creation-item { display:block; width:100%; text-align:left; padding:14px; margin-bottom:9px; color:var(--text); background:var(--bg); border:1px solid var(--border); border-radius:12px; cursor:pointer; }
.creation-item small { display:block; margin-top:7px; color:var(--muted); }
.creation-section { border-top:1px solid var(--border); padding:16px 0; line-height:1.7; }
.creation-body, #voice-answer { white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.75; }
.creation-downloads a { text-decoration:none; display:inline-block; }
.creation-section li { margin:8px 0; }
.slide-preview { background:#101a32; color:#dfe7fa; padding:26px; border-radius:15px; margin-top:15px; }
.slide-preview h3 { color:#fff; font-size:24px; }
.slide-preview summary { cursor:pointer; color:#96afff; }
.voice-dialog { width:min(620px,95vw); max-height:90dvh; padding:28px; }
.voice-dialog > p { color:var(--muted); line-height:1.7; }
.voice-auto { display:block; margin:18px 0; line-height:1.6; }
#voice-answer { border-top:1px solid var(--border); margin-top:20px; padding-top:18px; }
.message-studio-actions { display:flex; gap:12px; padding-top:9px; }
.message-studio-actions button { border:0; background:transparent; color:var(--muted); font:inherit; font-size:12px; cursor:pointer; }
@media(max-width:700px) { .creation-layout { grid-template-columns:1fr; } .creation-library { max-height:190px; overflow:auto; } .creation-dialog,.voice-dialog { padding:18px; } .workspace-header .header-actions { gap:5px; } #open-creation,#open-voice,#stop-audio { font-size:11px; padding:7px; } .creation-heading h2 { font-size:21px; } }
