/* The Ghost AI layout (design canvas, desktop row, chosen by Vith 23 Oct 2026) in Athena's olive colours. */
:root {
  /* Olive palette from the logo (Vith, 24 Oct 2026); layout and sizes from the Ghost AI canvas. */
  --frame: #F3F4EE;
  --panel: #FFFFFF;
  --side-panel: #F9FAF5;
  --ink: #1C2116;
  --ink-2: #33392B;
  --muted: #5C6152;
  --line: #DFE3D5;
  --line-soft: #ECEFE5;
  --field: #D5DBC8;
  --hover: #E9EDE0;
  --selected: #E1E7D3;
  --bubble: #ECEFE3;
  --primary: #2E3D1B;
  --primary-hover: #1F2A12;
  --on-primary: #FFFFFF;
  --logo-bg: #E4EBD6;
  --logo-edge: #CAD5B4;
  --accent: #4A6527;
  --accent-ink: #34481B;
  --highlight: #E0A800;
  --memory-bg: #E4EBD6;
  --memory-ink: #3B5320;
  --ok-bg: #E8F4EC;
  --ok-ink: #1C5A33;
  --warn-bg: #FFF4E5;
  --warn-ink: #7A4100;
  --danger: #B42318;
  --radius-panel: 16px;
  --radius-box: 18px;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(28, 33, 22, 0.06);
  --font: "Inter", "Noto Sans Khmer", system-ui, sans-serif;
  color-scheme: light;
}
/* Dark mode: follows the device unless she picks Light or Dark in Settings (D038). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --frame: #12150D;
    --panel: #1B1F15;
    --side-panel: #20251A;
    --ink: #E6EADC;
    --ink-2: #CDD3C1;
    --muted: #A3AA95;
    --line: #333A2B;
    --line-soft: #2A3023;
    --field: #3D4533;
    --hover: #262C1F;
    --selected: #2D3425;
    --bubble: #2A3022;
    --primary: #A8C474;
    --primary-hover: #BCD58C;
    --on-primary: #12170A;
    --logo-edge: #4A5A33;
    --accent: #AFC97F;
    --accent-ink: #C8DCA0;
    --memory-bg: #2B3820;
    --memory-ink: #D3E3AE;
    --ok-bg: #1F3524;
  --ok-ink: #B5E0C1;
  --warn-bg: #3A2A12;
    --warn-ink: #F3C98B;
    --danger: #F49A90;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --frame: #12150D;
  --panel: #1B1F15;
  --side-panel: #20251A;
  --ink: #E6EADC;
  --ink-2: #CDD3C1;
  --muted: #A3AA95;
  --line: #333A2B;
  --line-soft: #2A3023;
  --field: #3D4533;
  --hover: #262C1F;
  --selected: #2D3425;
  --bubble: #2A3022;
  --primary: #A8C474;
  --primary-hover: #BCD58C;
  --on-primary: #12170A;
  --logo-edge: #4A5A33;
  --accent: #AFC97F;
  --accent-ink: #C8DCA0;
  --memory-bg: #2B3820;
  --memory-ink: #D3E3AE;
  --ok-bg: #1F3524;
  --ok-ink: #B5E0C1;
  --warn-bg: #3A2A12;
  --warn-ink: #F3C98B;
  --danger: #F49A90;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--frame); color: var(--ink); font: 15px/1.6 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
h1, h2, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.error { color: var(--danger); font-size: 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: var(--radius); background: var(--primary); color: var(--on-primary); font-weight: 600; text-decoration: none; cursor: pointer; }
.button:hover { color: var(--on-primary); background: var(--primary-hover); }
.button.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.button.ghost:hover { background: var(--hover); }
.button.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.icon-button { flex-shrink: 0; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); cursor: pointer; }
.icon-button.dark { border: 0; background: var(--primary); color: var(--on-primary); }
.icon-button.dark:hover { background: var(--primary-hover); }

/* Shell: sidebar + white panel */
.shell { display: flex; height: 100vh; height: 100dvh; }
.sidebar { width: 272px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; overflow-y: auto; }
.brand { height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 6px; color: var(--ink); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; text-decoration: none; }
.brand:hover { color: var(--ink); }
.logo { width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px; background: var(--logo-bg); box-shadow: inset 0 0 0 1px var(--logo-edge); display: inline-flex; align-items: center; justify-content: center; }
.logo.big { width: 52px; height: 52px; border-radius: 16px; }
.new-chat { margin: 8px 0 4px; height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: var(--radius);
  background: var(--primary); color: var(--on-primary); font-weight: 600; text-decoration: none; }
.new-chat:hover { color: var(--on-primary); background: var(--primary-hover); }
.side-search { height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: var(--radius); color: var(--muted); }
.side-search:focus-within { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.side-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); outline: none; font-size: 14px; }
.side-search input::placeholder { color: var(--muted); }
.side-link { min-height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; font-size: 14px; }
.side-link:hover { color: var(--ink); background: var(--hover); }
.side-link[aria-current] { background: var(--selected); font-weight: 600; }
.side-link.recent { display: block; min-height: 34px; line-height: 34px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 4px; }
.side-link > span[lang="km"] { white-space: nowrap; flex-shrink: 0; }
.folder-item { position: relative; }
.folder-item .side-link { padding-right: 36px; }
.folder-icon { flex-shrink: 0; }
.more { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; }
.more:hover { background: var(--hover); color: var(--ink); }
.folder-item .more { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); opacity: 0; }
.folder-item:hover .more, .folder-item .more:focus-visible, .folder-item .more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .folder-item .more { opacity: 1; } }
.folder-item:hover .side-sub, .folder-item:focus-within .side-sub { visibility: hidden; }
.title-row { display: flex; align-items: center; gap: 10px; }
.title-mark { display: inline-flex; }
.title-mark .dot { width: 14px; height: 14px; border-radius: 7px; }
.menu-pop { position: fixed; z-index: 10; width: 248px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); display: flex; flex-direction: column; gap: 8px; }
.menu-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatches button { width: 30px; height: 30px; border: 2px solid var(--panel); border-radius: 50%; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.icon-grid button { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; }
.icon-grid button:hover { background: var(--hover); }
.icon-grid button[aria-pressed="true"] { background: var(--selected); box-shadow: inset 0 0 0 1px var(--accent); }
.menu-item { min-height: 36px; display: flex; align-items: center; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; text-decoration: none; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--hover); color: var(--ink); }
.menu-item.danger { color: var(--danger); border-top: 1px solid var(--line-soft); border-radius: 0 0 8px 8px; }
.menu-item.danger:hover { color: var(--danger); }
.side-sub { margin-left: auto; min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot { margin-top: auto; padding-top: 6px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 4px; }
.side-foot .side-link { flex: 1; }
.theme-switch { width: 38px; height: 38px; }
.theme-switch svg { display: none; }
.theme-switch[data-theme="system"] [data-show="system"], .theme-switch[data-theme="light"] [data-show="light"],
.theme-switch[data-theme="dark"] [data-show="dark"] { display: block; }
[lang="km"] { font-family: "Noto Sans Khmer", var(--font); line-height: 1.7; }
.saved { padding: 10px 14px; border-radius: var(--radius); background: var(--memory-bg); color: var(--memory-ink); font-weight: 600; }
.settings { display: flex; flex-direction: column; gap: 22px; }
.settings fieldset { margin: 0; padding: 0 0 20px; border: 0; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 6px; }
.settings legend { margin-bottom: 8px; font-weight: 700; }
.choice { min-height: 40px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.choice input { width: 18px; height: 18px; accent-color: var(--accent); }
.settings > .button { align-self: flex-start; }
.side-title { margin: 14px 0 2px; padding: 0 12px; font-size: 12px; font-weight: 600; color: var(--muted); }
.menu { display: none; }
.panel { flex: 1; min-width: 0; margin: 8px 8px 8px 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel);
  overflow: hidden; display: flex; flex-direction: column; }

/* Chat */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-head { height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 0 16px; border-bottom: 1px solid var(--line-soft); color: var(--muted); min-width: 0; }
.crumb select { height: 34px; max-width: 220px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.crumb select:hover { background: var(--hover); }
.chat-title { min-width: 0; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 28px 24px 0; }
.thread { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; padding-bottom: 24px; }
.hero { display: none; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.hero h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.hero p { font-size: 16px; color: var(--muted); }
.chat.empty .hero { display: flex; }
.chat.empty .scroll { flex: 0 0 auto; margin-top: auto; padding-bottom: 28px; }
.chat.empty .dock { margin-bottom: auto; }
.starts { display: none; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; }
.chat.empty .starts { display: flex; }
.starts button { height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); font-size: 13px; cursor: pointer; }
.starts button:hover { background: var(--hover); }

.msg { display: flex; gap: 14px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 85%; padding: 12px 16px; background: var(--bubble); border-radius: var(--radius-box); white-space: pre-wrap; line-height: 1.5; }
.msg.assistant .body { flex: 1; min-width: 0; line-height: 1.65; }
.avatar { width: 28px; height: 28px; flex-shrink: 0; margin-top: 2px; border-radius: 8px; background: var(--logo-bg); box-shadow: inset 0 0 0 1px var(--logo-edge); display: inline-flex; align-items: center; justify-content: center; }
.body > :first-child { margin-top: 0; }
.body p, .body ul, .body ol { margin: 0 0 12px; }
.body ul, .body ol { padding-left: 22px; }
.body ul { list-style: disc; }
.body h1, .body h2, .body h3 { margin: 18px 0 8px; font-size: 17px; }
.body .katex-display { overflow-x: auto; overflow-y: hidden; margin: 8px 0 12px; padding: 10px 16px; background: var(--side-panel); border: 1px solid var(--line-soft); border-radius: 12px; }
.body table { border-collapse: collapse; margin: 0 0 12px; display: block; overflow-x: auto; }
.body th, .body td { border: 1px solid var(--line); padding: 6px 10px; }
.body code { background: var(--bubble); border-radius: 6px; padding: 1px 5px; font-size: 14px; }
.thinking { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip { min-height: 28px; display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 10px; border-radius: 14px; font-size: 13px; font-weight: 600; line-height: 1.4; }
.chip.memory { background: var(--memory-bg); color: var(--memory-ink); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip a { color: inherit; }
.rule { display: flex; flex-direction: column; gap: 6px; padding: 16px 4px; }
.source-chip { align-self: flex-start; padding: 3px 10px; border: 1px solid var(--field); border-radius: 14px; font-size: 13px; font-weight: 600; text-decoration: none; color: var(--ink); }
.chip-button { min-height: 24px; padding: 0 10px; border: 0; border-radius: 11px; background: var(--panel); color: inherit; font-size: 12px; cursor: pointer; }

.dock { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 24px 14px; }
.composer { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 10px 16px;
  border: 1px solid var(--field); border-radius: var(--radius-box); background: var(--panel); box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { min-height: 28px; max-height: 40vh; padding: 0; border: 0; outline: none; resize: none; font-size: 15px; line-height: 1.5; background: transparent; }
.composer-row { display: flex; align-items: center; gap: 8px; }
.attachment { display: flex; align-items: center; gap: 10px; }
.attachment img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.sent-photo { display: block; max-width: 220px; max-height: 220px; margin-bottom: 8px; border-radius: 12px; }
.msg.user { flex-direction: column; }
#voice[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.segmented { display: flex; flex-shrink: 0; padding: 3px; border-radius: var(--radius); background: var(--bubble); }
.segmented button { height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(28, 33, 22, 0.12); }
.model-pick { margin-left: auto; min-width: 0; }
.model-pick select { max-width: 100%; height: 36px; padding: 0 8px; border: 0; border-radius: var(--radius); background: transparent; font-size: 13px; cursor: pointer; }
.model-pick select:hover { background: var(--hover); }
.note { max-width: 760px; font-size: 12px; color: var(--muted); text-align: center; }

/* Pages: folder, memory, search, file */
.page { flex: 1; overflow-y: auto; padding: 40px 48px; display: flex; flex-direction: column; gap: 24px; }
.page > * { width: 100%; max-width: 820px; }
.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.4; }
.crumb-text { font-size: 13px; color: var(--muted); text-decoration: none; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); padding-bottom: 8px; }
.start-box { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; border: 1px solid var(--field); border-radius: var(--radius-panel); box-shadow: var(--shadow); background: var(--panel); }
.start-box input:not([type=hidden]) { flex: 1; min-width: 0; height: 34px; border: 0; outline: none; font-size: 15px; background: transparent; }
.rows { border-top: 1px solid var(--line-soft); }
.rows > li { border-bottom: 1px solid var(--line-soft); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 4px; color: var(--ink); text-decoration: none; }
.row:hover { color: var(--ink); background: var(--side-panel); }
.row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row-title { font-weight: 600; }
.row-text .muted { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-row { padding: 14px 4px; }

.folder { flex: 1; min-height: 0; display: flex; }
.folder-main { flex: 1; min-width: 0; overflow-y: auto; padding: 40px 48px; display: flex; flex-direction: column; gap: 22px; }
.folder-side { width: 340px; flex-shrink: 0; overflow-y: auto; padding: 40px 24px; border-left: 1px solid var(--line-soft); background: var(--side-panel); display: flex; flex-direction: column; gap: 26px; }
.folder-side section { display: flex; flex-direction: column; gap: 8px; }
.side-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 700; }
.side-action { font-size: 13px; font-weight: 500; text-decoration: none; }
.card-line { padding: 10px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line-soft); font-size: 14px; line-height: 1.45; }
.file-line { display: flex; flex-direction: column; gap: 4px; }
.inline-actions { display: flex; gap: 8px; }
.stack { display: grid; gap: 8px; }
.stack input:not([type=file]), .stack textarea, .memory-row input, .memory-row select { min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); resize: vertical; }
.stack input[type=file] { font-size: 13px; }
.stack .button { justify-self: start; }
.switch { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.memory-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.memory-row input { flex: 1; min-width: 0; }
.add-row { padding-top: 0; }
.tag { flex-shrink: 0; padding: 3px 9px; border-radius: 8px; background: var(--memory-bg); color: var(--memory-ink); font-size: 12px; font-weight: 600; }
.transcript { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 20px; background: var(--side-panel); border: 1px solid var(--line-soft); border-radius: var(--radius-panel); font: 15px/1.7 var(--font); }

/* Mock exams and progress */
.strong { font-weight: 700; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { min-height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); text-decoration: none; font-size: 13px; }
.filter[aria-current] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.callout { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-radius: 14px; background: var(--memory-bg); color: var(--memory-ink); }
.exam-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; }
.exam-row > .muted:last-child:not(.nowrap) { grid-column: 2 / -1; }
@media (max-width: 600px) { .exam-row { grid-template-columns: 1fr; } }
.exam-row form { margin: 0; }
.steps-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--ink-2); }
.exam { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.exam-head { justify-content: space-between; }
.timer { min-height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 18px; background: var(--primary); color: var(--on-primary); font-weight: 700; font-variant-numeric: tabular-nums; }
.exam-progress { display: grid; grid-auto-flow: column; gap: 6px; }
.exam-progress span { height: 6px; border-radius: 3px; background: var(--line); }
.exam-progress span.done { background: var(--accent); }
.question-text { font-size: 19px; line-height: 1.8; }
.exam-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.finish { width: 100%; }
.score { font-size: 28px; font-weight: 700; }
.review-q { border-top: 1px solid var(--line-soft); padding: 14px 4px; }
.review-q summary { cursor: pointer; display: flex; justify-content: space-between; gap: 12px; min-height: 36px; align-items: center; }
.steps { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.step { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--line-soft); border-radius: var(--radius); cursor: pointer; }
.step input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.step-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.step-text .tag { align-self: flex-start; }
.step-text p { margin: 0; }
.step-marks { font-weight: 700; }
.ask-link { display: inline-block; margin: 4px 0 0 44px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; }
.stat-num { font-size: 28px; font-weight: 700; }
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.bar { grid-column: 1 / -1; height: 10px; border-radius: 5px; background: var(--selected); display: flex; }
.bar span { border-radius: 5px; background: var(--accent); }
.home-cards { display: none; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 760px; }
.chat.empty .home-cards { display: grid; }
.home-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none; }
.home-card:hover { background: var(--side-panel); color: var(--ink); }
@media (max-width: 600px) { .stat-grid { grid-template-columns: 1fr; } .home-cards { grid-template-columns: 1fr; } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { width: min(360px, 100%); display: grid; gap: 12px; padding: 32px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel); }
.card h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 22px; }
.card input { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); }

/* Tablet and phone: the sidebar becomes a menu */
@media (max-width: 960px) {
  .menu { display: inline-flex; position: fixed; top: 16px; left: 16px; z-index: 3; width: 40px; height: 40px; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; z-index: 4; background: var(--frame); box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.3); }
  .show-menu .sidebar { display: flex; }
  .panel { margin: 8px; }
  .chat-head { padding-left: 60px; }
  .page .page-head, .folder-main > .page-head { padding-left: 44px; }
  .folder { flex-direction: column; overflow-y: auto; }
  .folder-main, .folder-side { overflow: visible; }
  .folder-side { width: auto; border-left: 0; border-top: 1px solid var(--line-soft); }
}
@media (max-width: 600px) {
  .panel { margin: 0; border-radius: 0; border: 0; }
  .menu { top: 8px; left: 8px; }
  .chat-head { padding: 0 12px 0 56px; }
  .crumb select { max-width: 130px; }
  .scroll { padding: 20px 16px 0; }
  .dock { padding: 10px 12px 12px; }
  .composer-row { flex-wrap: wrap; }
  .model-pick { order: 3; flex-basis: 100%; margin-left: 0; }
  .hero h1 { font-size: 26px; }
  .page, .folder-main, .folder-side { padding: 24px 16px; }
  .memory-row { flex-wrap: wrap; }
  .memory-row input { flex-basis: 100%; }
}
