/* Atlas interface. Two themes, one accent, no effects that need explaining. */

:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --sunken: #f3f1ea;
  --hover: #ebe8df;
  --line: #e4e0d4;
  --line-strong: #d3cec0;
  --text: #1f1e1b;
  --muted: #6d6a61;
  --faint: #97938a;
  --accent: #b9583a;
  --accent-hover: #a34b30;
  --accent-soft: #f6e7e0;
  --on-accent: #ffffff;
  --good: #3d7a52;
  --warn: #a8741a;
  --bad: #b3402f;
  --shadow: 0 1px 2px rgba(31, 30, 27, .05), 0 8px 24px rgba(31, 30, 27, .07);
  --radius: 10px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1e1b; --surface: #292825; --sunken: #191816; --hover: #32302c; --line: #37352f;
    --line-strong: #4a4740; --text: #ece8df; --muted: #a8a397; --faint: #7d796f; --accent: #d97a5b;
    --accent-hover: #e48a6c; --accent-soft: #3a2a23; --on-accent: #1f1e1b; --good: #7fbf93; --warn: #d9a94e;
    --bad: #e2816f; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f1e1b; --surface: #292825; --sunken: #191816; --hover: #32302c; --line: #37352f;
  --line-strong: #4a4740; --text: #ece8df; --muted: #a8a397; --faint: #7d796f; --accent: #d97a5b;
  --accent-hover: #e48a6c; --accent-soft: #3a2a23; --on-accent: #1f1e1b; --good: #7fbf93; --warn: #d9a94e;
  --bad: #e2816f; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); height: 100dvh; }
.shell.collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.shell.collapsed .sidebar { transform: translateX(-100%); visibility: hidden; }

.sidebar {
  background: var(--sunken); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  min-height: 0; padding: 12px 10px 10px; transition: transform .18s ease;
  padding-top: max(12px, env(safe-area-inset-top));
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 12px 10px; }
.wordmark { font: 600 21px/1 var(--serif); letter-spacing: -.01em; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn[disabled] { opacity: .35; pointer-events: none; }

.new-chat {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 8px;
  font-weight: 550; color: var(--accent);
}
.new-chat:hover { background: var(--hover); }
.nav { display: grid; gap: 1px; margin: 4px 0 10px; }
.nav button {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--muted); text-align: left;
}
.nav button:hover { background: var(--hover); color: var(--text); }
.nav button.active { background: var(--hover); color: var(--text); font-weight: 550; }

.side-label { font-size: 12px; color: var(--faint); padding: 10px 10px 4px; }
.chat-search { position: relative; margin: 0 2px 4px; }
.chat-search input {
  width: 100%; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 6px 30px; font-size: 13.5px;
}
.chat-search input:focus { outline: 0; border-color: var(--line-strong); background: var(--surface); }
.chat-search .icon { position: absolute; left: 9px; top: 8px; color: var(--faint); }
.chat-list { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.chat-row {
  display: flex; align-items: center; width: 100%; border-radius: 8px; padding: 0 4px 0 10px; color: var(--muted);
}
.chat-row:hover, .chat-row.active { background: var(--hover); color: var(--text); }
.chat-row .title { flex: 1; text-align: left; padding: 7px 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.chat-row .more { opacity: 0; width: 26px; height: 26px; }
.chat-row:hover .more, .chat-row.active .more, .chat-row .more:focus-visible { opacity: 1; }
.chat-row .tag { font-size: 11px; color: var(--faint); margin-right: 4px; }
.side-foot { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; display: flex; align-items: center; gap: 4px; }
.side-foot .status { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.dot.off { background: var(--bad); }
.dot.wait { background: var(--warn); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 14px; flex: none;
  padding-top: env(safe-area-inset-top); box-sizing: content-box;
}
.topbar h1 { font: 600 17px var(--serif); flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.topbar .actions { display: flex; align-items: center; gap: 4px; }
.view { flex: 1; min-height: 0; display: none; flex-direction: column; }
.view.active { display: flex; }
.page { overflow-y: auto; padding: 8px 24px 40px; }
.page > .inner { max-width: 880px; margin: 0 auto; }
.scrim { display: none; }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); font-weight: 500; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { background: var(--hover); color: var(--text); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); }
.input, .field input[type=text], .field input[type=url], .field input[type=password], .field input[type=time],
.field input[type=number], .field input[type=datetime-local], .field textarea, .field select {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 11px;
}
.field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.check small { display: block; color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 36px; height: 21px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 20px; background: var(--line-strong); transition: background .15s; }
.switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(15px); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code, pre { font-family: var(--mono); font-size: 13px; }

/* ----------------------------------------------------------------- chat */

.thread { flex: 1; overflow-y: auto; min-height: 0; padding: 4px 20px 24px; scroll-behavior: smooth; }
.thread-inner { max-width: 740px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

.welcome { margin: auto; text-align: center; padding: 8vh 0 26px; max-width: 740px; width: 100%; }
.welcome h2 { font: 500 clamp(26px, 4.2vw, 36px)/1.2 var(--serif); letter-spacing: -.015em; }
.welcome p { color: var(--muted); margin-top: 8px; }
.ideas { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.ideas button { border: 1px solid var(--line); border-radius: 20px; padding: 6px 13px; font-size: 13.5px; color: var(--muted); background: var(--surface); }
.ideas button:hover { border-color: var(--line-strong); color: var(--text); }

.msg { min-width: 0; }
.msg.user { align-self: flex-end; max-width: min(86%, 600px); }
.msg.user .bubble { background: var(--sunken); border: 1px solid var(--line); border-radius: 16px; padding: 9px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 9px; font-size: 13px; max-width: 220px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 4px; margin: -1px 0 -1px -4px; }
.file-chip button { color: var(--faint); display: grid; }
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .12s; }
.msg.user .msg-actions { justify-content: flex-end; }
.msg:hover .msg-actions, .msg:last-child .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions .icon-btn { width: 28px; height: 28px; }
.msg-actions .meta { font-size: 12px; color: var(--faint); align-self: center; margin-left: 6px; }

.prose { overflow-wrap: anywhere; }
.prose > * + * { margin-top: .75em; }
.prose h1, .prose h2, .prose h3 { font-family: var(--serif); font-weight: 600; line-height: 1.3; margin-top: 1.2em; }
.prose h1 { font-size: 1.35em; } .prose h2 { font-size: 1.2em; } .prose h3 { font-size: 1.07em; }
.prose ul, .prose ol { padding-left: 1.4em; margin-bottom: 0; }
.prose li + li { margin-top: .25em; }
.prose blockquote { border-left: 3px solid var(--line-strong); margin: 0; padding-left: 14px; color: var(--muted); }
.prose code { background: var(--sunken); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: .88em; }
.prose pre { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); margin: 0; overflow: hidden; }
.prose pre code { display: block; padding: 12px 14px; overflow-x: auto; border: 0; background: none; font-size: 13px; line-height: 1.5; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 6px 5px 14px; border-bottom: 1px solid var(--line); font: 12px var(--mono); color: var(--faint); }
.code-head button { font: 12px var(--sans); color: var(--muted); padding: 2px 8px; border-radius: 6px; }
.code-head button:hover { background: var(--hover); color: var(--text); }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; font-size: .94em; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.prose th { background: var(--sunken); font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--line); }
.prose img { max-width: 100%; border-radius: 8px; }
.cursor::after { content: ""; display: inline-block; width: 7px; height: 1.05em; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2) infinite; border-radius: 1px; }
@keyframes blink { 50% { opacity: 0; } }

.steps { display: grid; gap: 2px; margin-bottom: 10px; }
.step { border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.step > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 4px 6px; cursor: pointer; border-radius: 8px; min-width: 0; }
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { background: var(--hover); }
.step .name { color: var(--text); font-weight: 500; flex: none; }
.step .what { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; flex: 1; }
.step .state { flex: none; display: grid; }
.step.fail .state { color: var(--bad); }
.step.ok .state { color: var(--good); }
.step .detail { margin: 2px 0 6px 32px; padding: 8px 10px; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; }
.step .detail img { max-width: 100%; border-radius: 6px; display: block; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { font-size: 13.5px; color: var(--muted); font-style: italic; padding: 2px 6px; }
.thinking { font-size: 13.5px; color: var(--muted); border-left: 2px solid var(--line-strong); padding: 2px 0 2px 12px; margin-bottom: 10px; white-space: pre-wrap; max-height: 180px; overflow: auto; }

.approval { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; margin: 6px 0 10px; box-shadow: var(--shadow); }
.approval b { display: block; margin-bottom: 6px; }
.approval pre { background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
.approval .choices { display: flex; gap: 8px; flex-wrap: wrap; }
.errorline { color: var(--bad); display: flex; gap: 8px; align-items: flex-start; }

.composer-wrap { flex: none; padding: 0 20px max(14px, env(safe-area-inset-bottom)); }
.composer {
  max-width: 740px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px;
  box-shadow: var(--shadow); padding: 10px 10px 8px 14px; transition: border-color .12s;
}
.composer:focus-within { border-color: var(--faint); }
.composer.dragging { border-color: var(--accent); border-style: dashed; }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; background: transparent; resize: none; max-height: 40vh; min-height: 26px; padding: 3px 0; line-height: 1.5; }
.composer textarea::placeholder { color: var(--faint); }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.composer-bar { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.composer-bar .grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.pill:hover { background: var(--hover); color: var(--text); }
.pill.on { color: var(--accent); background: var(--accent-soft); }
.send { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.send:hover { background: var(--accent-hover); }
.send[disabled] { background: var(--line-strong); color: var(--surface); pointer-events: none; }
.send.stop { background: var(--text); color: var(--bg); }
.disclaimer { text-align: center; font-size: 12px; color: var(--faint); margin-top: 7px; }

.menu { position: fixed; z-index: 60; min-width: 210px; max-width: 320px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; }
.menu button, .menu label { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 8px; text-align: left; cursor: pointer; }
.menu button:hover, .menu label:hover { background: var(--hover); }
.menu .sub { display: block; font-size: 12.5px; color: var(--muted); }
.menu .grow { flex: 1; min-width: 0; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu .danger { color: var(--bad); }
.menu .head { font-size: 12px; color: var(--faint); padding: 6px 10px 3px; }
.menu [disabled] { opacity: .45; pointer-events: none; }
.tick { width: 16px; color: var(--accent); display: grid; flex: none; }

/* ---------------------------------------------------------------- files */

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.search { position: relative; flex: 1; min-width: 160px; max-width: 320px; }
.search input { width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px 7px 32px; }
.search input:focus { outline: 0; border-color: var(--accent); }
.search .icon { position: absolute; left: 10px; top: 9px; color: var(--faint); }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; margin-bottom: 10px; color: var(--muted); font-size: 14px; }
.crumbs button { padding: 3px 7px; border-radius: 6px; }
.crumbs button:hover { background: var(--hover); color: var(--text); }
.crumbs button:last-of-type { color: var(--text); font-weight: 550; }
.crumbs .count { margin-left: auto; font-size: 13px; color: var(--faint); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { padding: 6px 9px; color: var(--muted); display: grid; }
.seg button.active { background: var(--hover); color: var(--text); }

.files.list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.files.list .item { display: grid; grid-template-columns: 26px minmax(0, 1fr) 90px 150px 32px; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-top: 1px solid var(--line); cursor: default; }
.files.list .item:first-child { border-top: 0; }
.files.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.files.grid .item { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px; display: grid; gap: 8px; position: relative; cursor: default; }
.files.grid .item .thumb { height: 84px; border-radius: 6px; background: var(--sunken); display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.files.grid .item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.files.grid .item .thumb .icon { width: 30px; height: 30px; stroke-width: 1.3; }
.files.grid .item .size, .files.grid .item .date { display: none; }
.files.grid .item .kind { display: none; }
.files.grid .item .more { position: absolute; top: 6px; right: 6px; background: var(--surface); }
.files.list .item .thumb { display: none; }
.files .item:hover { background: var(--sunken); }
.files .item.selected { background: var(--accent-soft); }
.files .item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.files .item .size, .files .item .date { font-size: 13px; color: var(--muted); white-space: nowrap; }
.files .item .kind { color: var(--muted); display: grid; }
.files .item .kind.folder { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 56px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty .icon { width: 28px; height: 28px; stroke-width: 1.3; color: var(--faint); margin-bottom: 8px; }
.drop-hint { position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--accent-soft) 80%, transparent); display: none; place-items: center; font-weight: 550; color: var(--accent); z-index: 5; pointer-events: none; }
#view-files { position: relative; }
#view-files.dragging .drop-hint { display: grid; }

/* -------------------------------------------------------------- browser */

.browser-bar { display: flex; align-items: center; gap: 4px; padding: 0 12px 8px; flex: none; }
.address { flex: 1; position: relative; min-width: 0; }
.address input { width: 100%; background: var(--sunken); border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px 7px 34px; font-size: 14px; }
.address input:focus { outline: 0; border-color: var(--accent); background: var(--surface); }
.address .icon { position: absolute; left: 12px; top: 9px; color: var(--faint); }
.browser-body { flex: 1; min-height: 0; position: relative; border-top: 1px solid var(--line); background: #fff; }
.browser-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.browser-home { position: absolute; inset: 0; background: var(--bg); overflow-y: auto; padding: 9vh 24px 40px; text-align: center; }
.browser-home h2 { font: 500 28px var(--serif); }
.browser-home p { color: var(--muted); max-width: 460px; margin: 8px auto 22px; }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-width: 560px; margin: 0 auto; }
.shortcuts button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 14px 10px; display: grid; gap: 2px; }
.shortcuts button:hover { border-color: var(--line-strong); }
.shortcuts small { color: var(--faint); font-size: 12px; }
.loadbar { position: absolute; left: 0; top: 0; height: 2px; width: 0; background: var(--accent); z-index: 3; transition: width .25s ease, opacity .3s; opacity: 0; }
.loadbar.on { width: 82%; opacity: 1; transition: width 8s cubic-bezier(.1, .7, .2, 1); }

/* ---------------------------------------------------- cards and sections */

.section { margin-bottom: 30px; }
.section > h2 { font: 600 18px var(--serif); margin-bottom: 4px; }
.section > .lead { color: var(--muted); margin-bottom: 14px; font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 16px 18px; }
.list > * { padding: 13px 16px; border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; }
.line { display: flex; align-items: center; gap: 12px; }
.line .grow { flex: 1; min-width: 0; }
.line .title { font-weight: 550; }
.line .desc { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.stat { padding: 14px 16px; }
.stat .label { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.stat .value { font: 500 27px/1.3 var(--serif); font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--faint); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 4px; border-radius: 4px; background: var(--sunken); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: 0; background: var(--text); border-radius: 4px; transition: width .5s ease; opacity: .7; }
.bar i.hot { background: var(--bad); opacity: 1; }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin-bottom: 14px; }
.banner .grow { flex: 1; min-width: 0; }
.banner .readings { display: flex; gap: 16px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.task .result { margin-top: 8px; font-size: 13.5px; color: var(--muted); background: var(--sunken); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; max-height: 110px; overflow: auto; }
.task.off .title { color: var(--muted); }
.steps-guide { counter-reset: s; padding: 0; margin: 10px 0 14px; list-style: none; display: grid; gap: 8px; font-size: 14px; }
.steps-guide li { counter-increment: s; padding-left: 28px; position: relative; color: var(--muted); }
.steps-guide li::before { content: counter(s); position: absolute; left: 0; top: 1px; width: 19px; height: 19px; border-radius: 50%; border: 1px solid var(--line-strong); font-size: 11.5px; display: grid; place-items: center; color: var(--text); }
.copyable { font: 12.5px var(--mono); background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; word-break: break-all; cursor: copy; color: var(--text); }
.memory-note { display: flex; gap: 10px; align-items: flex-start; }
.memory-note .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.memory-note .src { font-size: 12px; color: var(--faint); }

/* -------------------------------------------------------------- overlays */

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 19, 17, .45); display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--bg); border: 1px solid var(--line-strong); border-radius: 14px; width: min(520px, 100%); max-height: min(88dvh, 780px); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.dialog.wide { width: min(940px, 100%); }
.dialog > header { display: flex; align-items: center; gap: 10px; padding: 14px 12px 10px 20px; }
.dialog > header h3 { font: 600 18px var(--serif); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog > .body { padding: 4px 20px 18px; overflow-y: auto; }
.dialog > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.preview { display: grid; place-items: center; min-height: 240px; }
.preview img, .preview video { max-width: 100%; max-height: 70dvh; border-radius: 8px; }
.preview iframe { width: 100%; height: 70dvh; border: 0; border-radius: 8px; background: #fff; }
.preview pre { width: 100%; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow: auto; max-height: 70dvh; white-space: pre-wrap; overflow-wrap: anywhere; }
.tree button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 6px 8px; border-radius: 8px; }
.tree button:hover { background: var(--hover); }
.tree button.chosen { background: var(--accent-soft); color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 80; max-width: min(92vw, 480px); box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }

/* --------------------------------------------------------------- mobile */

@media (max-width: 820px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-100%); visibility: hidden; box-shadow: var(--shadow); }
  .shell.drawer .sidebar { transform: none; visibility: visible; }
  .shell.drawer .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 19, 17, .4); z-index: 35; }
  .topbar { padding-left: 8px; padding-right: 8px; }
  .thread { padding: 4px 14px 18px; }
  .composer-wrap { padding-left: 10px; padding-right: 10px; }
  .page { padding: 6px 14px 32px; }
  .msg.user { max-width: 92%; }
  .files.list .item { grid-template-columns: 24px minmax(0, 1fr) 70px 32px; }
  .files.list .item .date { display: none; }
  .msg-actions { opacity: 1; }
  .chat-row .more { opacity: 1; }
  .disclaimer { display: none; }
  .pill .label { display: none; }
  body { font-size: 16px; }
  .composer textarea, .input, .field input, .field textarea, .field select, .address input, .search input, .chat-search input { font-size: 16px; }
}

/* ---------------------------------------------------------------- login */

.login-page { display: grid; place-items: center; min-height: 100dvh; overflow: auto; padding: 24px; }
.login { width: min(360px, 100%); }
.login h1 { font: 500 34px var(--serif); letter-spacing: -.02em; margin-bottom: 4px; }
.login > p { color: var(--muted); margin-bottom: 26px; }
.login .error { color: var(--bad); margin: 0 0 14px; font-size: 14px; }
.login .btn { width: 100%; padding: 10px; margin-top: 6px; }
