/* ===========================================================
   max.css — Max's look

   His picks (2026-11-26): Max is its own thing, not Weather
   Protocol's look. Four themes to start (Graphite, Paper, OLED
   black, Midnight, plus Auto = follow the device). Quiet and
   crafted: no gradients-on-everything, no glow, no emoji.
   =========================================================== */

:root, [data-theme="graphite"] {
  --bg: #161718; --bg-2: #1b1c1e; --raised: #222326; --raised-2: #28292c; --hover: #2b2c30;
  --line: #2c2d31; --line-2: #3a3b40; --text: #ebeae6; --dim: #a3a29d; --faint: #6f6e6a;
  --accent: #d9a35b; --accent-ink: #1b1306; --accent-soft: rgba(217, 163, 91, .14);
  --bubble: #26272a; --code: #111213; --danger: #e48473; --ok: #86bb8f; --warn: #d9b25b;
  --dot: 235, 234, 230; --scrim: rgba(0, 0, 0, .55); --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
[data-theme="paper"] {
  --bg: #f5f3ee; --bg-2: #eeebe4; --raised: #ffffff; --raised-2: #faf9f6; --hover: #e7e3da;
  --line: #e1ddd3; --line-2: #cfcabe; --text: #1e1d1a; --dim: #5d5a53; --faint: #8e8a80;
  --accent: #b5542b; --accent-ink: #ffffff; --accent-soft: rgba(181, 84, 43, .10);
  --bubble: #e9e5dc; --code: #efece5; --danger: #b83f2c; --ok: #3d7a48; --warn: #9a6a12;
  --dot: 30, 29, 26; --scrim: rgba(30, 29, 26, .35); --shadow: 0 10px 30px rgba(60, 50, 30, .14);
  color-scheme: light;
}
[data-theme="oled"] {
  --bg: #000000; --bg-2: #080808; --raised: #111111; --raised-2: #161616; --hover: #1b1b1b;
  --line: #1e1e1e; --line-2: #2c2c2c; --text: #ececec; --dim: #9c9c9c; --faint: #636363;
  --accent: #d9a35b; --accent-ink: #1b1306; --accent-soft: rgba(217, 163, 91, .14);
  --bubble: #151515; --code: #0a0a0a; --danger: #e48473; --ok: #86bb8f; --warn: #d9b25b;
  --dot: 236, 236, 236; --scrim: rgba(0, 0, 0, .7); --shadow: 0 10px 30px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
[data-theme="midnight"] {
  --bg: #0e131c; --bg-2: #121925; --raised: #18202d; --raised-2: #1c2533; --hover: #212b3a;
  --line: #222c3b; --line-2: #2f3b4d; --text: #e2e8f0; --dim: #9aa7b8; --faint: #677487;
  --accent: #8db5dc; --accent-ink: #0a1420; --accent-soft: rgba(141, 181, 220, .14);
  --bubble: #1a2331; --code: #0b1018; --danger: #e58a7b; --ok: #8cc198; --warn: #d9b867;
  --dot: 226, 232, 240; --scrim: rgba(4, 8, 14, .6); --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  --r-sm: 6px; --r: 10px; --r-lg: 16px; --r-xl: 20px;
  --side-w: 268px; --read: 740px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased; overflow: hidden; -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-underline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
kbd { font: 11px var(--mono); color: var(--faint); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- reactive background ---------- */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* ---------- boot / sign-in ---------- */
#boot, #auth { position: fixed; inset: 0; display: grid; place-items: center; z-index: 2; padding: 24px; }
#boot .orb { position: static; }
.card {
  width: min(400px, 100%); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 28px; box-shadow: var(--shadow);
}
.card h1 { font-size: 22px; font-weight: 650; margin: 14px 0 4px; letter-spacing: -.01em; }
.card p { color: var(--dim); margin: 0 0 18px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--dim); margin-bottom: 5px; }
.field input {
  width: 100%; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 10px 12px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--raised-2); font-weight: 550;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.wide { width: 100%; }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.linkish { color: var(--accent); font-size: 14px; }
.form-msg { min-height: 20px; font-size: 13px; color: var(--danger); margin: 2px 0 10px; }
.fine { font-size: 12.5px; color: var(--faint); margin-top: 14px; }

/* ---------- layout ---------- */
#app { position: relative; z-index: 1; display: flex; height: 100dvh; }
/* the sidebar floats (his ask): a panel with a gap all round, gently pulled toward the cursor */
#side {
  width: var(--side-w); flex: none; display: flex; flex-direction: column; min-height: 0;
  padding: 10px 0 10px 10px; transition: transform .25s var(--ease);
}
.side-in {
  display: flex; flex-direction: column; min-height: 0; flex: 1; padding: 12px 10px 10px; will-change: transform;
  background: color-mix(in srgb, var(--bg-2) 90%, transparent); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#sideClose { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16.5px; letter-spacing: -.01em; }
.brand-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.icon {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-sm); color: var(--dim);
  transition: background .15s, color .15s;
}
.icon:hover { background: var(--hover); color: var(--text); }
.icon.on { color: var(--accent); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; }
.tabs button { height: 30px; border-radius: 7px; color: var(--dim); font-size: 14px; font-weight: 550; }
.tabs button.on { background: var(--raised-2); color: var(--text); box-shadow: 0 1px 0 var(--line); }
.new {
  display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 10px; border-radius: var(--r);
  color: var(--text); font-weight: 550; margin-bottom: 6px;
}
.new:hover { background: var(--hover); }
.new kbd { margin-left: auto; }
.side-search { position: relative; margin-bottom: 8px; }
.side-search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--faint); }
.side-search input {
  width: 100%; height: 34px; border-radius: var(--r-sm); border: 1px solid transparent; background: var(--bg);
  padding: 0 10px 0 32px; outline: none; font-size: 14px;
}
.side-search input:focus { border-color: var(--line-2); }
#list { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.group { font-size: 12px; color: var(--faint); padding: 12px 10px 4px; font-weight: 550; }
.row {
  position: relative; display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 8px 0 10px;
  border-radius: var(--r-sm); color: var(--dim); text-align: left; font-size: 14px;
}
.row:hover { background: var(--hover); color: var(--text); }
.row.on { background: var(--raised-2); color: var(--text); }
.row .t { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row .x { opacity: 0; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 5px; color: var(--faint); }
.row:hover .x, .row.on .x { opacity: 1; }
.row .x:hover { color: var(--danger); background: var(--bg); }
.row svg.i { width: 15px; height: 15px; color: var(--faint); }
.empty-list { color: var(--faint); font-size: 13.5px; padding: 14px 10px; }
.side-foot { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }
.who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r-sm); text-align: left; }
.who:hover { background: var(--hover); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--raised-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: none; }
.who .n { font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .p { font-size: 12px; color: var(--faint); }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
#top { display: flex; align-items: center; gap: 4px; height: 54px; padding: 0 12px; flex: none; }
#top .grow { flex: 1; }
#sideOpen { display: none; }
.pick {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 15px;
}
.pick:hover { background: var(--hover); }
.pick .sub { color: var(--faint); font-weight: 500; font-size: 13.5px; }
.pick svg.i { width: 15px; height: 15px; color: var(--faint); }
.pick.minor { font-weight: 500; color: var(--dim); font-size: 14px; }

/* ---------- menus / popovers ---------- */
.menu {
  position: fixed; z-index: 50; min-width: 240px; max-width: min(360px, calc(100vw - 24px)); background: var(--raised);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 6px; box-shadow: var(--shadow);
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu .mi {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); text-align: left;
}
.menu .mi:hover, .menu .mi:focus-visible { background: var(--hover); }
.menu .mi .l { flex: 1; min-width: 0; }
.menu .mi .h { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.menu .mi .d { font-size: 13px; color: var(--dim); line-height: 1.4; }
.menu .mi .r { font-size: 12px; color: var(--faint); white-space: nowrap; padding-top: 2px; }
.menu .mi.on .h::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.menu .mi[aria-disabled="true"] { opacity: .5; cursor: default; }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu .lab { font-size: 12px; color: var(--faint); padding: 6px 10px 2px; font-weight: 550; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: var(--r-sm); width: 100%; text-align: left; }
.switch-row:hover { background: var(--hover); }
.switch { width: 34px; height: 20px; border-radius: 20px; background: var(--line-2); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform .2s var(--ease); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(14px); background: var(--accent-ink); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 10px 8px; }
.seg button { height: 28px; padding: 0 10px; border-radius: 14px; border: 1px solid var(--line-2); font-size: 13px; color: var(--dim); }
.seg button.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* ---------- chat ---------- */
#chatView { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
#scroller { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: auto; overscroll-behavior: contain; }
#thread { max-width: var(--read); margin: 0 auto; padding: 18px 24px 40px; }
.msg { margin: 0 0 26px; position: relative; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  background: var(--bubble); border-radius: 18px 18px 6px 18px; padding: 9px 15px; max-width: 82%;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.user .pics { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; }
.msg.user .pics img { width: 120px; height: 120px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); cursor: zoom-in; }
.msg.max { min-height: 22px; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--faint); margin-bottom: 6px; }
.actions { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg.max:hover .actions, .msg.max:focus-within .actions, .msg.max.last .actions { opacity: 1; }
.actions .icon { width: 30px; height: 30px; }
.actions .icon svg.i { width: 16px; height: 16px; }
.warn-line { font-size: 13px; color: var(--warn); margin: 0 0 8px; display: flex; gap: 8px; align-items: flex-start; }

/* markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 22px 0 8px; line-height: 1.3; letter-spacing: -.01em; }
.md h1 { font-size: 21px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--faint); }
.md blockquote { margin: 0 0 12px; padding: 2px 14px; border-left: 3px solid var(--line-2); color: var(--dim); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md code { font: 13.5px var(--mono); background: var(--raised-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.md table { border-collapse: collapse; margin: 0 0 14px; font-size: 14px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line-2); padding: 6px 10px; text-align: left; }
.md th { background: var(--raised-2); font-weight: 600; }
.code { margin: 0 0 14px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--code); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; font: 12px var(--mono); color: var(--faint); border-bottom: 1px solid var(--line); }
.code-head button { display: inline-flex; gap: 6px; align-items: center; font: 12px var(--font); color: var(--dim); padding: 4px 8px; border-radius: 5px; }
.code-head button:hover { background: var(--hover); color: var(--text); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 13.5px/1.55 var(--mono); }
.code pre code { background: none; border: 0; padding: 0; font: inherit; }
.tk-k { color: var(--accent); } .tk-s { color: var(--ok); } .tk-c { color: var(--faint); font-style: italic; } .tk-n { color: var(--warn); }

/* thought process */
.thought { margin: 0 0 12px; }
.thought-head { display: inline-flex; align-items: center; gap: 8px; color: var(--dim); font-size: 14px; padding: 3px 8px 3px 0; border-radius: var(--r-sm); max-width: 100%; }
.thought-head:hover { color: var(--text); }
.thought-head svg.i { width: 15px; height: 15px; transition: transform .2s var(--ease); }
.thought.open .thought-head svg.i { transform: rotate(90deg); }
.thought-live { display: block; font-size: 13px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; margin-top: 2px; }
.thought.done .thought-live { display: none; }
.steps { display: none; margin: 8px 0 4px; padding-left: 16px; border-left: 1px solid var(--line-2); }
.thought.open .steps { display: block; }
.step { position: relative; font-size: 13.5px; color: var(--dim); margin: 0 0 10px; white-space: pre-wrap; line-height: 1.5; }
.step::before { content: ''; position: absolute; left: -20.5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--line-2); }
.step.tool { color: var(--text); display: flex; align-items: center; gap: 8px; }
.step.tool::before { border-color: var(--accent); }
.step.tool.run::before { background: var(--accent); animation: blink 1s infinite; }
.step.tool.fail::before { border-color: var(--danger); }
.step.tool svg.i { width: 15px; height: 15px; color: var(--faint); }
@keyframes blink { 50% { opacity: .35; } }

/* cards inside the chat */
.ask { border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 14px; margin: 4px 0 12px; background: color-mix(in srgb, var(--raised) 88%, transparent); }
.ask .q { font-weight: 600; margin-bottom: 10px; }
.ask .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.ask .opt { padding: 7px 13px; border-radius: 18px; border: 1px solid var(--line-2); background: var(--raised-2); font-size: 14px; text-align: left; }
.ask .opt:hover { border-color: var(--accent); }
.ask .opt.on { border-color: var(--accent); background: var(--accent-soft); }
.ask .other { display: flex; gap: 8px; margin-top: 10px; }
.ask .other input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 7px 10px; outline: none; font-size: 14px; }
.ask .chosen { color: var(--dim); font-size: 14px; }
.suggest { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r); padding: 9px 12px; margin: 4px 0 12px; font-size: 14px; color: var(--dim); }
.suggest b { color: var(--text); font-weight: 600; }
.suggest .grow { flex: 1; min-width: 160px; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.sources a { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; font-size: 12.5px; color: var(--dim); text-decoration: none; border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px; }
.sources a:hover { color: var(--text); border-color: var(--line-2); }
.sources a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter { display: flex; align-items: center; gap: 12px; margin: 8px 0 22px; color: var(--faint); font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.chapter::before, .chapter::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.oops { display: flex; gap: 14px; align-items: flex-start; border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 14px 16px; margin: 4px 0 12px; }
.oops .orb { position: relative; flex: none; margin-top: 4px; }
.oops .ttl { font-weight: 600; margin-bottom: 2px; }
.oops .txt { color: var(--dim); font-size: 14.5px; }
.oops .small { color: var(--faint); font: 11px var(--mono); margin-top: 6px; }
.oops .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* the tiny orb */
.orb {
  --s: 12px; width: var(--s); height: var(--s); border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft); display: block; will-change: transform;
}
.orb.think { animation: orbPulse 1.15s var(--ease) infinite; }
.orb.talk { animation: orbTalk 2.2s ease-in-out infinite; }
.orb.sad { background: var(--faint); box-shadow: 0 0 0 4px rgba(var(--dot), .08); }
@keyframes orbPulse { 0%, 100% { box-shadow: 0 0 0 3px var(--accent-soft); scale: .9; } 50% { box-shadow: 0 0 0 8px transparent; scale: 1.08; } }
@keyframes orbTalk { 0%, 100% { scale: 1; } 50% { scale: 1.12; } }
.orb-slot { height: 22px; display: flex; align-items: center; margin-top: 6px; padding-left: 1px; }

/* empty state */
.hello { min-height: calc(100% - 40px); display: flex; flex-direction: column; justify-content: center; padding: 40px 0 10px; }
.hello h2 { font-size: 27px; font-weight: 600; letter-spacing: -.02em; margin: 14px 0 6px; }
.hello p { color: var(--dim); margin: 0 0 22px; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chip { text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: color-mix(in srgb, var(--raised) 70%, transparent); color: var(--dim); font-size: 14px; transition: border-color .15s, color .15s; }
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip b { display: block; color: var(--text); font-weight: 600; font-size: 14px; margin-bottom: 1px; }

/* chapters jump list */
#chapters { position: absolute; right: 14px; top: 8px; width: 190px; max-height: 60%; overflow-y: auto; font-size: 13px; z-index: 3; }
#chapters .lab { color: var(--faint); font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin: 4px 8px 6px; }
#chapters button { display: block; width: 100%; text-align: left; padding: 4px 8px; border-radius: var(--r-sm); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 2px solid var(--line); border-radius: 0; }
#chapters button:hover { color: var(--text); border-left-color: var(--line-2); }
#chapters button.on { color: var(--text); border-left-color: var(--accent); }
@media (max-width: 1240px) { #chapters { display: none; } #chapters.pop { display: block; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r); padding: 6px; box-shadow: var(--shadow); } }

/* composer */
#composer { flex: none; padding: 0 24px 16px; }
.comp { max-width: var(--read); margin: 0 auto; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-xl); padding: 10px 10px 8px 14px; box-shadow: 0 1px 0 var(--line); transition: border-color .15s; }
.comp:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, var(--line-2)); }
.comp.drag { border-color: var(--accent); border-style: dashed; }
.comp textarea { width: 100%; resize: none; border: 0; outline: none; background: none; max-height: 240px; min-height: 26px; line-height: 1.5; padding: 2px 0; display: block; }
.comp textarea::placeholder { color: var(--faint); }
.comp-row { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.comp-row .grow { flex: 1; }
.comp-row .icon { width: 34px; height: 34px; }
.webchip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 15px; font-size: 13px; color: var(--faint); border: 1px solid transparent; }
.webchip:hover { background: var(--hover); }
.webchip.on { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.webchip svg.i { width: 15px; height: 15px; }
.send { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); transition: opacity .15s, transform .15s; }
.send:disabled { opacity: .35; cursor: default; }
.send:not(:disabled):active { transform: scale(.94); }
.send svg.i { stroke-width: 2.2; }
.attach-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.attach { position: relative; width: 64px; height: 64px; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line-2); }
.attach img { width: 100%; height: 100%; object-fit: cover; }
.attach button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; display: grid; place-items: center; }
.attach button svg.i { width: 12px; height: 12px; }
.comp-note { max-width: var(--read); margin: 7px auto 0; font-size: 12px; color: var(--faint); text-align: center; min-height: 17px; }
.mic-on { color: var(--danger) !important; }

/* ---------- voice ---------- */
#voiceView { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 24px 40px; min-height: 0; text-align: center; }
#face { width: min(300px, 70vw); height: auto; cursor: pointer; touch-action: manipulation; }
#face .eye, #face .mouth { stroke: var(--text); stroke-width: 9; stroke-linecap: round; fill: none; }
#face .mouth { stroke-width: 6; }
#face .halo { fill: none; stroke: var(--accent); stroke-width: 2; opacity: 0; transition: opacity .3s; }
#face.listen .halo { opacity: .5; }
.v-status { font-size: 17px; font-weight: 600; margin-top: 18px; min-height: 26px; }
.v-caption { color: var(--dim); max-width: 560px; margin: 10px auto 0; min-height: 48px; font-size: 15px; }
.v-you { color: var(--faint); font-size: 14px; margin-top: 4px; min-height: 22px; max-width: 560px; }
.v-mic { margin-top: 26px; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--raised-2); border: 1px solid var(--line-2); }
.v-mic:hover { background: var(--hover); }
.v-mic.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.v-mic svg.i { width: 24px; height: 24px; }
.v-note { font-size: 12.5px; color: var(--faint); margin-top: 14px; min-height: 18px; }

/* ---------- modal (settings, picture viewer) ---------- */
#modal { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: min(720px, 100%); max-height: min(720px, calc(100dvh - 32px)); display: flex; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-xl); box-shadow: var(--shadow); overflow: hidden; }
.sheet nav { width: 180px; flex: none; border-right: 1px solid var(--line); padding: 14px 8px; background: var(--bg-2); }
.sheet nav h3 { font-size: 15px; margin: 4px 10px 12px; }
.sheet nav button { display: flex; align-items: center; gap: 9px; width: 100%; height: 34px; padding: 0 10px; border-radius: var(--r-sm); color: var(--dim); font-size: 14px; }
.sheet nav button:hover { background: var(--hover); color: var(--text); }
.sheet nav button.on { background: var(--raised-2); color: var(--text); }
.sheet .pane { flex: 1; min-width: 0; overflow-y: auto; padding: 18px 22px 22px; position: relative; }
.sheet .pane h4 { font-size: 13px; color: var(--faint); font-weight: 600; margin: 18px 0 8px; letter-spacing: .02em; }
.sheet .pane h4:first-of-type { margin-top: 4px; }
.sheet .close { position: absolute; top: 10px; right: 10px; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.theme { border: 1px solid var(--line-2); border-radius: var(--r); padding: 6px; text-align: left; font-size: 13.5px; }
.theme.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme .sw { height: 54px; border-radius: 6px; margin-bottom: 6px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 8px; }
.theme .sw i { display: block; height: 5px; border-radius: 3px; }
.opt-list { display: flex; flex-direction: column; gap: 4px; }
.opt-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); border: 1px solid transparent; text-align: left; width: 100%; }
.opt-item:hover { background: var(--hover); }
.opt-item.on { border-color: var(--accent); background: var(--accent-soft); }
.opt-item .h { font-weight: 600; font-size: 14px; }
.opt-item .d { font-size: 13px; color: var(--dim); }
.meter { margin: 8px 0 12px; }
.meter .row2 { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 4px; }
.meter .row2 span:last-child { color: var(--faint); }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.pane p.help { color: var(--dim); font-size: 13.5px; margin: 0 0 10px; }
.viewer img { max-width: min(92vw, 1200px); max-height: 88dvh; border-radius: var(--r); display: block; }

/* toast */
#toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: min(520px, calc(100vw - 32px)); background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 14px; box-shadow: var(--shadow); font-size: 14px; animation: pop .18s var(--ease); }
.toast .orb { --s: 10px; flex: none; }

/* ---------- phones ---------- */
@media (max-width: 820px) {
  #side { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; transform: translateX(-104%); width: min(86vw, 300px); padding: 10px; }
  #side .side-in { background: var(--bg-2); box-shadow: var(--shadow); }
  #sideClose { display: inline-grid; }
  #app.side-open #side { transform: none; }
  #app.side-open::after { content: ''; position: fixed; inset: 0; background: var(--scrim); z-index: 39; }
  #sideOpen { display: inline-grid; }
  #thread { padding: 10px 16px 30px; }
  #composer { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  .chips { grid-template-columns: 1fr; }
  .new kbd { display: none; }
  .hello h2 { font-size: 23px; }
  .sheet { flex-direction: column; }
  .sheet nav { width: auto; display: flex; overflow-x: auto; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .sheet nav h3 { display: none; }
  .sheet nav button { width: auto; flex: none; }
  .msg.user .bubble { max-width: 90%; }
  .actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}

/* ---------- Weather Protocol card (wears Weather Protocol's Forest look, not Max's theme) ---------- */
.wp-card {
  --wa: #7bd88f; --wbg: #06110a; --wpanel: #0c1a11; --wfg: #d5e8d9; --wdim: rgba(213, 232, 217, .6); --wline: rgba(123, 216, 143, .16);
  background: var(--wbg); color: var(--wfg); border: 1px solid var(--wline); border-radius: var(--r-lg); overflow: hidden;
  font: 13px/1.4 var(--mono); margin: 2px 0 14px; max-width: 560px;
}
.wp-card .wpi { stroke: var(--wa); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.wp-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; border-bottom: 1px solid var(--wline); background: var(--wpanel); }
.wp-brand { display: flex; align-items: center; gap: 8px; color: var(--wa); font-size: 11px; letter-spacing: .14em; font-weight: 700; }
.wp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wa); box-shadow: 0 0 8px rgba(123, 216, 143, .7); }
.wp-open, .wp-foot a { color: var(--wa); text-decoration: none; font-size: 11px; letter-spacing: .08em; }
.wp-open:hover, .wp-foot a:hover { text-decoration: underline; }
.wp-now { display: flex; align-items: center; gap: 16px; padding: 14px 14px 10px; flex-wrap: wrap; }
.wp-big { display: flex; align-items: center; gap: 10px; }
.wp-temp { font-size: 40px; font-weight: 600; letter-spacing: -.03em; color: #effaf1; text-shadow: 0 0 18px rgba(123, 216, 143, .25); }
.wp-unit { color: var(--wdim); font-size: 14px; align-self: flex-start; margin-top: 8px; margin-left: -6px; }
.wp-side { min-width: 0; }
.wp-place { font-weight: 700; color: #effaf1; font-size: 14px; }
.wp-place span { color: var(--wdim); font-weight: 400; }
.wp-cond { color: var(--wa); margin: 1px 0 3px; }
.wp-meta { color: var(--wdim); font-size: 11px; letter-spacing: .04em; }
.wp-hours { display: flex; gap: 2px; overflow-x: auto; padding: 4px 10px 10px; border-bottom: 1px solid var(--wline); scrollbar-width: thin; }
.wp-hour { flex: none; width: 48px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 8px; }
.wp-hour:first-child { background: rgba(123, 216, 143, .08); }
.wp-ht { color: var(--wdim); font-size: 10.5px; }
.wp-hv { color: #effaf1; font-weight: 600; }
.wp-hp { color: #7fc4e8; font-size: 10.5px; }
.wp-days { padding: 6px 14px 8px; }
.wp-day { display: grid; grid-template-columns: 52px 22px 38px 34px 1fr 34px; align-items: center; gap: 6px; padding: 4px 0; }
.wp-dn { color: var(--wfg); font-size: 12px; }
.wp-dp { color: #7fc4e8; font-size: 11px; }
.wp-dl { color: var(--wdim); text-align: right; }
.wp-dh { color: #effaf1; font-weight: 600; }
.wp-bar { position: relative; height: 4px; border-radius: 4px; background: rgba(213, 232, 217, .08); }
.wp-bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: linear-gradient(90deg, #5fb7d6, var(--wa) 60%, #e7c86b); }
.wp-foot { padding: 8px 14px 10px; border-top: 1px solid var(--wline); }
@media (max-width: 520px) { .wp-day { grid-template-columns: 44px 20px 34px 30px 1fr 30px; gap: 5px; } .wp-temp { font-size: 34px; } }
.attach.file { width: auto; max-width: 200px; display: flex; align-items: center; gap: 6px; padding: 0 30px 0 10px; height: 40px; font: 12.5px var(--mono); color: var(--dim); background: var(--raised-2); }
.attach.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach.file svg.i { width: 15px; height: 15px; }
.attach.file button { top: 10px; }
.tabs { grid-template-columns: repeat(3, 1fr); }
body[data-mode="code"] .comp textarea { font-family: var(--mono); font-size: 14px; }
.pick.fixed { cursor: default; }
.pick.fixed:hover { background: none; }
.wp-hours::-webkit-scrollbar { height: 6px; }
.wp-hours::-webkit-scrollbar-thumb { background: rgba(123, 216, 143, .22); border: 0; border-radius: 6px; }
.wp-hours { scrollbar-color: rgba(123, 216, 143, .22) transparent; }
.md code, .code pre, body[data-mode="code"] .comp textarea { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* ---------- "Run Max on this computer" popup (right side) ---------- */
.local-card { position: fixed; right: 18px; bottom: 140px; z-index: 55; width: min(340px, calc(100vw - 32px)); background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 14px 16px; animation: lcIn .35s var(--ease); }
@keyframes lcIn { from { opacity: 0; transform: translateX(24px); } }
.local-card.out { opacity: 0; transform: translateX(24px); transition: .25s var(--ease); }
.local-card.mini .lc-body p { display: none; }
.lc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.lc-head b { flex: 1; font-size: 15px; }
.lc-head .icon { width: 28px; height: 28px; }
.lc-body p { margin: 0 0 8px; font-size: 14px; color: var(--dim); }
.lc-body .lc-fine, .lc-note { font-size: 12.5px; color: var(--faint); }
.lc-note { margin-top: 6px; }
.lc-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- side panel: Docs doc / changed file ---------- */
#panel { width: min(46vw, 640px); flex: none; display: flex; flex-direction: column; min-height: 0; margin: 10px 10px 10px 0; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); animation: lcIn .3s var(--ease); }
.pn-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.pn-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.pn-note { font-size: 12.5px; color: var(--faint); }
.pn-head a.btn { text-decoration: none; color: var(--text); }
.pn-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.pn-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.pn-code { padding: 12px; }
.pn-code .code { margin: 0; }
@media (max-width: 820px) { #panel { position: fixed; inset: 0; width: auto; margin: 0; border-radius: 0; z-index: 45; } }

/* chips / cards in Max's answer */
.doc-chip { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 420px; padding: 10px 12px; margin: 2px 0 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--raised); text-align: left; }
.doc-chip:hover { border-color: var(--accent); }
.doc-chip span:first-of-type { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-sub { font-size: 12px; color: var(--faint); }
.changes { border: 1px solid var(--line-2); border-radius: var(--r); margin: 2px 0 12px; overflow: hidden; }
.ch-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13.5px; font-weight: 600; background: var(--raised); border-bottom: 1px solid var(--line); }
.ch-head svg.i { width: 15px; height: 15px; }
.ch-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; font-size: 13.5px; border-top: 1px solid var(--line); }
.ch-row:first-of-type { border-top: 0; }
.ch-path { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-tag { font-size: 11.5px; color: var(--faint); }
.ch-link { font-size: 12.5px; }

/* Code tab: the folder bar */
.ws-bar { max-width: var(--read); margin: 0 auto 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--dim); }
.ws-chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--line-2); background: var(--raised); color: var(--text); font-family: var(--mono); font-size: 12.5px; }
.ws-chip svg.i { width: 15px; height: 15px; color: var(--accent); }
.lc-hello { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--faint); min-height: 20px; }
.lc-hello svg.i { width: 15px; height: 15px; color: var(--accent); flex: none; }
.lc-hello .icon { width: 26px; height: 26px; margin-left: auto; }
.lc-hello .linkish { font-size: 13px; white-space: nowrap; }
