/* Diji — two-ink risograph world: Dejoiy pink and blue on paper. */
:root {
  --paper: #f5f1ea;
  --bg: var(--paper);
  --bg-2: #fbe7ef;
  --rail-hover: #f6d6e5;
  --surface: #fffdf9;
  --surface-2: #efe9e0;
  --surface-3: #e5ddd1;
  --line: #e0d7ca;
  --line-2: #cbbfae;
  --ink: #221a1f;
  --ink-2: #54484f;
  --ink-3: #74676e;
  --pink: #e8178a;
  --on-pink: #ffffff;
  --pink-ink: #b80f69;
  --pink-tint: #f9d2e4;
  --blue: #2f6bff;
  --blue-ink: #1d4bd1;
  --blue-tint: #cddbff;
  --accent: var(--blue-ink);
  --accent-ink: var(--blue-ink);
  --accent-soft: #e2e9ff;
  --ok: #157a52;
  --ok-soft: #dcf1e6;
  --err: #c01f4b;
  --err-soft: #fbe2e9;
  --user-bubble: var(--pink-tint);
  --plate: rgb(47 107 255 / 0.5);
  --code-bg: #f0eae0;
  --blend: multiply;
  --grain-opacity: 0.9;
  --shadow-sm: 0 1px 2px rgb(70 30 50 / 0.07);
  --shadow: 0 6px 18px -8px rgb(70 30 50 / 0.2), 0 1px 3px rgb(70 30 50 / 0.06);
  --shadow-lg: 0 22px 50px -18px rgb(70 30 50 / 0.34), 0 4px 12px rgb(70 30 50 / 0.08);
  --scrim: rgb(34 18 28 / 0.38);
  --mochi-body: #f25aa8;
  --mochi-plate: #2f6bff;
  --mochi-face: #241a20;
  --mochi-cheek: #c80e72;
  --magenta: var(--pink);
  --violet: var(--pink);
  --brand: var(--pink);

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", "Schibsted Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-sm: 6px;
  --r: 9px;
  --r-lg: 12px;
  --r-xl: 16px;
  --side-w: 272px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #19141a;
    --bg: var(--paper);
    --bg-2: #241921;
    --rail-hover: #2f212b;
    --surface: #211b21;
    --surface-2: #2a232a;
    --surface-3: #342b33;
    --line: #342b32;
    --line-2: #4b4049;
    --ink: #f4edf0;
    --ink-2: #cbbfc5;
    --ink-3: #a19499;
    --pink: #ff4fa6;
  --on-pink: #241a20;
    --on-pink: #241a20;
    --pink-ink: #ff86c3;
    --pink-tint: #6a2350;
    --blue: #6f96ff;
    --blue-ink: #9cb7ff;
    --blue-tint: #25356b;
    --accent: var(--blue-ink);
    --accent-ink: var(--blue-ink);
    --accent-soft: #1f2a52;
    --ok: #52d39f;
    --ok-soft: #12302a;
    --err: #ff7f9e;
    --err-soft: #3d1527;
    --user-bubble: var(--pink-tint);
    --plate: rgb(111 150 255 / 0.55);
    --code-bg: #151115;
    --blend: screen;
    --grain-opacity: 0.4;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 8px 22px -10px rgb(0 0 0 / 0.65), 0 1px 3px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 26px 60px -20px rgb(0 0 0 / 0.8), 0 4px 14px rgb(0 0 0 / 0.35);
    --scrim: rgb(6 3 6 / 0.6);
    --mochi-body: #ff6cb4;
    --mochi-plate: #5d86ff;
    --mochi-face: #241a20;
    --mochi-cheek: #c80e72;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #19141a;
  --bg: var(--paper);
  --bg-2: #241921;
  --rail-hover: #2f212b;
  --surface: #211b21;
  --surface-2: #2a232a;
  --surface-3: #342b33;
  --line: #342b32;
  --line-2: #4b4049;
  --ink: #f4edf0;
  --ink-2: #cbbfc5;
  --ink-3: #a19499;
  --pink: #ff4fa6;
  --on-pink: #241a20;
  --pink-ink: #ff86c3;
  --pink-tint: #6a2350;
  --blue: #6f96ff;
  --blue-ink: #9cb7ff;
  --blue-tint: #25356b;
  --accent: var(--blue-ink);
  --accent-ink: var(--blue-ink);
  --accent-soft: #1f2a52;
  --ok: #52d39f;
  --ok-soft: #12302a;
  --err: #ff7f9e;
  --err-soft: #3d1527;
  --user-bubble: var(--pink-tint);
  --plate: rgb(111 150 255 / 0.55);
  --code-bg: #151115;
  --blend: screen;
  --grain-opacity: 0.4;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 8px 22px -10px rgb(0 0 0 / 0.65), 0 1px 3px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 26px 60px -20px rgb(0 0 0 / 0.8), 0 4px 14px rgb(0 0 0 / 0.35);
  --scrim: rgb(6 3 6 / 0.6);
  --mochi-body: #ff6cb4;
  --mochi-plate: #5d86ff;
  --mochi-face: #241a20;
  --mochi-cheek: #c80e72;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
::selection { background: var(--blue-tint); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
code, kbd, pre { font-family: var(--mono); }
input, textarea, select { caret-color: var(--pink); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.ic { flex: none; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -40px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); }
.skip:focus { top: 12px; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 0.86em; }
.sm { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.tiny { width: 28px; height: 28px; border-radius: 8px; }
.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 11px; font-weight: 550; font-size: 14px;
  transition: transform 0.15s var(--ease), background 0.15s, box-shadow 0.15s;
  white-space: nowrap; cursor: pointer;
}
.btn-primary { background: var(--ink); color: var(--surface); box-shadow: var(--shadow-sm); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:active, .send:not(:disabled):active, .new-chat:active { transform: translate(1px, 1px); }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-ghost.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 9px; gap: 6px; }
.btn-danger { background: var(--err-soft); color: var(--err); }
.btn-danger:hover { filter: brightness(0.97); }
.link-btn { color: var(--accent-ink); font-size: 13px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------- mascot ---------- */
.diji { display: inline-block; width: var(--s); height: var(--s); line-height: 0; flex: none; }
.diji svg { overflow: visible; }
.diji .d-plate-pink { fill: var(--mochi-body); }
.diji .d-plate-blue { fill: var(--mochi-plate); opacity: 0.55; mix-blend-mode: var(--blend); }
.diji .d-shine { stroke: #fff; opacity: 0.55; }
.diji .d-stem { stroke: var(--mochi-plate); }
.diji .d-leaf { fill: var(--mochi-plate); }
.diji .d-eye, .diji .d-joy path { fill: var(--mochi-face); stroke: var(--mochi-face); }
.diji .d-joy path { fill: none; }
.diji .d-glint { fill: #fff; }
.diji .d-cheek { fill: var(--mochi-cheek); opacity: 0.5; }
.diji .d-smile, .diji .d-flat { stroke: var(--mochi-face); }
.diji .d-joy, .diji .d-flat { display: none; }
.diji.mood-happy .d-open { display: none; }
.diji.mood-happy .d-joy { display: inline; }
.diji.mood-oops .d-smile { display: none; }
.diji.mood-oops .d-flat { display: inline; }
.diji .d-squish, .diji .d-bob, .diji .d-sprout, .diji .d-open { transform-box: fill-box; }
.diji .d-squish { transform-origin: 50% 100%; }
.diji .d-sprout { transform-origin: 30% 100%; animation: d-sway 4.6s ease-in-out infinite; }
.diji .d-open { transform-origin: center; animation: d-blink 5.4s infinite; }
.diji.mood-thinking .d-squish { animation: d-squish 1s var(--ease) infinite; }
.diji.mood-thinking .d-sprout { animation: d-wiggle 0.5s ease-in-out infinite; }
.diji.mood-happy .d-bob { animation: d-hop 0.9s var(--ease) 1; }
.diji.mood-oops .d-bob { animation: d-wobble 0.6s cubic-bezier(0.22, 1, 0.36, 1) 1; transform-origin: 50% 100%; transform-box: fill-box; }
@keyframes d-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
@keyframes d-sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(6deg); } }
@keyframes d-wiggle { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes d-squish { 0%, 100% { transform: scale(1, 1); } 35% { transform: scale(1.09, 0.88); } 65% { transform: scale(0.95, 1.06); } }
@keyframes d-hop { 0% { transform: none; } 30% { transform: translateY(-16%) scale(0.96, 1.05); } 60% { transform: translateY(0) scale(1.08, 0.92); } 100% { transform: none; } }
@keyframes d-wobble { 0% { transform: rotate(-7deg); } 100% { transform: rotate(0); } }

/* ---------- signature: misregistered two-ink overprint ---------- */
/* Selected things are printed twice: the paper card, and the blue plate a few pixels off-register. */
.chat-item.on, .tab[aria-selected="true"], .pop-item[aria-selected="true"], .file-item.on, .snav.on, .prov-item.on, .seg input:checked + span {
  background: var(--surface) !important;
  color: var(--ink) !important;
  box-shadow: inset 0 0 0 1px var(--line-2), 3px 2.5px 0 var(--plate) !important;
}
.bubble { background: var(--pink-tint); color: var(--ink); box-shadow: 3px 2.5px 0 var(--plate); }
.empty-title { text-shadow: 3px 2px 0 color-mix(in srgb, var(--pink) 45%, transparent); }

/* paper grain on the ground only, never on reading surfaces */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .35 0 0 0 0 .42 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
.app { position: relative; z-index: 1; }

/* ---------- layout ---------- */
.app { display: flex; height: 100dvh; width: 100%; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }

/* sidebar */
.sidebar {
  position: relative;
  width: var(--side-w); flex: none;
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 10px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  transition: margin-left 0.32s var(--ease), transform 0.32s var(--ease);
  z-index: 30;
}
body:not(.side-open) .sidebar { margin-left: calc(-1 * var(--side-w)); }
body.side-open #side-open { visibility: hidden; width: 0; margin: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand-word { font: 700 23px/1 var(--display); letter-spacing: -0.04em; color: var(--pink-ink); }
.new-chat {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px;
  border-radius: 12px; font-weight: 550;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
}
.new-chat:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.new-chat kbd { margin-left: auto; font-size: 11px; color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.side-search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px; margin-top: 4px;
  border-radius: 10px; color: var(--ink-3); border: 1px solid transparent;
}
.side-search:focus-within { background: var(--surface); border-color: var(--line-2); }
.side-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font-size: 14px; }
.side-search input::placeholder { color: var(--ink-3); }
.chat-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.side-group { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin: 16px 10px 6px; letter-spacing: 0.01em; }
.side-empty { color: var(--ink-3); font-size: 13.5px; padding: 12px 10px; }
.chat-item { display: flex; align-items: center; border-radius: 9px; position: relative; }
.chat-item:hover { background: var(--rail-hover); }
.chat-link { flex: 1; min-width: 0; text-align: left; padding: 8px 10px; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.on .chat-link { color: var(--ink); font-weight: 600; }
.chat-item .icon-btn { opacity: 0; width: 26px; height: 26px; }
.chat-item:hover .icon-btn, .chat-item:focus-within .icon-btn { opacity: 1; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.side-btn { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 10px; color: var(--ink-2); font-size: 14px; }
.side-btn:hover { background: var(--rail-hover); color: var(--ink); }
.side-count { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.side-row { display: flex; gap: 2px; padding-top: 2px; }
.bell { position: relative; }
.badge {
  position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--magenta); color: var(--on-pink); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 25; animation: fade 0.2s; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 14px;
  flex: none; z-index: 5;
}
.chat-title { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
body.is-empty .chat-title { visibility: hidden; }
.top-actions { display: flex; gap: 6px; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  border-radius: 10px; color: var(--ink-2); border: 1px solid var(--line); background: var(--surface);
  font-size: 13.5px; font-weight: 500; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pill-btn:hover { color: var(--ink); border-color: var(--line-2); }
.pill-btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); border-color: var(--line-2); box-shadow: 3px 2.5px 0 var(--plate); }
.pill-count { font-size: 11.5px; background: var(--pink); color: var(--on-pink); border-radius: 7px; padding: 0 6px; line-height: 18px; font-weight: 650; }

/* thread */
.thread { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-padding-bottom: 24px; }
.thread-inner { max-width: 780px; margin: 0 auto; padding: 12px 24px 40px; display: flex; flex-direction: column; gap: 26px; }
body.is-empty .main { justify-content: center; }
body.is-empty .thread { flex: 0 1 auto; overflow: visible; }
body.is-empty .topbar { position: absolute; inset: 0 0 auto 0; }
.empty { max-width: 780px; margin: 0 auto; padding: 0 24px 22px; text-align: center; animation: rise 0.6s var(--ease); }
.empty-mascot { display: inline-block; margin-bottom: 8px; }
.empty-title { margin: 0 0 10px; font: 700 clamp(30px, 4vw, 44px)/1.08 var(--display); letter-spacing: -0.035em; text-wrap: balance; }
.empty-sub { margin: 0 auto 26px; max-width: 52ch; color: var(--ink-2); font-size: 15.5px; text-wrap: pretty; }
.starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.starter {
  display: flex; flex-direction: column; gap: 2px; padding: 13px 15px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface);
  transition: border-color 0.15s, transform 0.2s var(--ease), box-shadow 0.2s;
}
.starter:hover { border-color: var(--line-2); transform: translateY(-1px); box-shadow: var(--shadow); }
.starter strong { font-weight: 600; font-size: 14.5px; }
.starter span { color: var(--ink-3); font-size: 13.5px; }

/* messages */
.msg { position: relative; animation: rise 0.35s var(--ease); }
.msg.user { align-self: flex-end; max-width: min(85%, 620px); display: flex; flex-direction: column; align-items: flex-end; }
.bubble { background: var(--user-bubble); padding: 11px 16px; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.6; }
.att-row, .attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.att { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); max-width: 220px; }
.att button { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; color: var(--ink-3); }
.att button:hover { background: var(--surface-3); color: var(--ink); }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity 0.15s; min-height: 28px; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg.assistant:last-child .msg-actions { opacity: 1; }
.msg-actions .meta { margin-left: 8px; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.assistant { display: flex; gap: 14px; align-items: flex-start; }
.avatar { flex: none; padding-top: 2px; }
.msg-body { flex: 1; min-width: 0; }
.content { font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md table { margin: 0 0 14px; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--ink-3); }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--display); line-height: 1.25; letter-spacing: -0.02em; margin: 26px 0 10px; font-weight: 650; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md strong { font-weight: 650; }
.md :not(pre) > code { font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.md blockquote { border-left: 1px solid var(--line-2); padding: 2px 0 2px 16px; color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 14.5px; display: block; overflow-x: auto; font-variant-numeric: tabular-nums; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md img { max-width: 100%; border-radius: var(--r); }
.codeblock { margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--code-bg); }
.codeblock-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; font: 12px var(--mono); color: var(--ink-3); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.copy-code { font: 500 12px var(--font); color: var(--ink-2); padding: 3px 8px; border-radius: 6px; }
.copy-code:hover { background: var(--surface-3); color: var(--ink); }
.codeblock pre, .code-body { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; tab-size: 2; }
.thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 15px; height: 32px; }
.thinking span { animation: ink-fade 1.6s ease-in-out infinite; }
@keyframes ink-fade { 50% { opacity: 0.45; } }
.caret { display: inline-block; width: 8px; height: 1.1em; vertical-align: -3px; margin-left: 2px; border-radius: 1px; background: var(--pink); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.callout { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 14px; border-radius: var(--r); font-size: 14.5px; line-height: 1.5; margin: 6px 0 12px; }
.callout.err { background: var(--err-soft); color: var(--err); }
.callout span { flex: 1; min-width: 200px; }
.chip-note { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-3); margin: 4px 0 10px; }

.file-card {
  display: flex; align-items: center; gap: 12px; width: 100%; max-width: 420px; padding: 10px 12px; margin: 4px 0 12px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-align: left;
  box-shadow: var(--shadow-sm); transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s var(--ease);
}
.file-card:hover { border-color: var(--line-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.file-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--pink-tint); color: var(--pink-ink); flex: none; }
.file-card.writing .file-ic { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { filter: saturate(1.4) brightness(1.15); transform: scale(0.94); } }
.file-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.file-meta strong { font: 500 13.5px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta span { font-size: 12.5px; color: var(--ink-3); }
.file-go { color: var(--ink-3); }

.msg.tool { margin: -12px 0 -10px 44px; }
.tool-card {
  display: flex; align-items: center; gap: 10px; width: 100%; max-width: 520px; padding: 8px 10px 8px 12px;
  border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface-2); text-align: left; cursor: pointer;
}
.tool-card:disabled { cursor: default; opacity: 1; }
.tool-card:not(:disabled):hover { border-color: var(--line-2); background: var(--surface); }
.tool-ic { color: var(--accent-ink); }
.tool-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.tool-label { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-url { font: 12px var(--mono); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-err { font-size: 12.5px; color: var(--err); }
.tool-thumb { width: 64px; height: 40px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--line); }
.tool-status { color: var(--ok); }
.msg.tool.failed .tool-status { color: var(--err); }

.jump {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 6;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink-2);
}

/* composer */
.composer { flex: none; padding: 0 24px calc(10px + env(safe-area-inset-bottom)); }
.composer-box {
  max-width: 780px; margin: 0 auto; padding: 12px 12px 10px 16px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-xl);
  box-shadow: var(--shadow); transition: border-color 0.2s, box-shadow 0.2s;
}
.composer-box:focus-within { border-color: var(--ink-3); box-shadow: var(--shadow), 0 0 0 1px var(--ink-3); }
.attachments { margin: 0 0 8px; }
#composer-input {
  display: block; width: 100%; resize: none; border: 0; outline: 0; background: none;
  font-size: 16px; line-height: 1.55; padding: 4px 0 8px; min-height: 32px; max-height: 280px;
}
#composer-input::placeholder { color: var(--ink-3); }
.composer-row { display: flex; align-items: center; gap: 6px; }
.spacer { flex: 1; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 10px;
  font-size: 13px; color: var(--ink-2); border: 1px solid var(--line); transition: all 0.2s;
}
.chip-btn:hover { background: var(--surface-2); color: var(--ink); }
.chip-btn .lbl-short { display: none; }
.chip-btn.lit { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }
.model-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px 0 10px; border-radius: 10px;
  font-size: 13px; color: var(--ink-2); max-width: 46%; min-width: 0;
}
.model-btn:hover { background: var(--surface-2); color: var(--ink); }
.model-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-prov { color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; flex: none;
  background: var(--brand); color: var(--on-pink); box-shadow: none;
  transition: transform 0.2s var(--ease), opacity 0.2s, filter 0.2s;
}
.send:not(:disabled):hover { transform: translateY(-1px) scale(1.04); filter: saturate(1.15); }
.send:disabled { opacity: 0.35; box-shadow: none; }
.send.stop { background: var(--ink); color: var(--bg); box-shadow: none; }
.fineprint { text-align: center; font-size: 12px; color: var(--ink-3); margin: 8px 0 0; }
body.is-empty .fineprint { visibility: hidden; }

/* panel */
.panel {
  width: clamp(400px, 44vw, 820px); flex: none; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line);
  animation: slide-in 0.35s var(--ease);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px; padding: 9px 8px 9px 12px; border-bottom: 1px solid var(--line); flex: none; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 11px; }
.tab { height: 30px; padding: 0 13px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.panel-actions { display: flex; gap: 2px; }
.panel-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.panel-body iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.panel-empty { margin: auto; max-width: 340px; text-align: center; padding: 32px 24px; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.panel-empty .ic { color: var(--ink-3); margin-bottom: 10px; }
.panel-empty p { margin: 0; font-size: 14px; }
.panel-empty strong { color: var(--ink); font-size: 15px; font-weight: 600; }
.panel-empty .btn-primary { margin-top: 16px; }
.code-view { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px 1fr; }
.file-tree { border-right: 1px solid var(--line); overflow-y: auto; padding: 8px; background: var(--surface-2); }
.file-item { display: flex; align-items: center; gap: 7px; width: 100%; padding: 6px 8px; border-radius: 8px; font: 12.5px var(--mono); color: var(--ink-2); text-align: left; }
.file-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item:hover { background: var(--surface-2); color: var(--ink); }
.file-item.on { background: var(--accent-soft); color: var(--accent-ink); }
.code-pane { min-width: 0; display: flex; flex-direction: column; }
.code-pane-head { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.code-pane-head .btn-ghost { margin-left: auto; }
.code-body { flex: 1; overflow: auto; background: var(--code-bg); }

/* cloud browser */
.cb { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cb-bar, .cb-type { display: flex; align-items: center; gap: 4px; padding: 8px; flex: none; }
.cb-bar { border-bottom: 1px solid var(--line); }
.cb-type { border-top: 1px solid var(--line); padding-left: 14px; }
.cb-url, .cb-type input {
  flex: 1; min-width: 0; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  padding: 0 12px; outline: 0; font-size: 13.5px;
}
.cb-url:focus, .cb-type input:focus { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: var(--surface); }
.cb-view { flex: 1; min-height: 0; overflow: auto; background: var(--surface-2); position: relative; display: flex; flex-direction: column; align-items: center; }
.cb-shot { width: 100%; height: auto; display: block; cursor: crosshair; transition: opacity 0.2s, filter 0.2s; }
.cb-view.busy .cb-shot { opacity: 0.6; filter: blur(1px); }
.cb-status { padding: 18px; font-size: 13.5px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; }
.cb-status:empty { display: none; }
.cb-view.busy .cb-status { position: absolute; top: 12px; background: var(--surface); border-radius: 10px; padding: 8px 14px; box-shadow: var(--shadow); }
.err { color: var(--err); }

/* popovers */
.popover {
  position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: pop 0.2s var(--ease);
}
.pop-scroll { overflow-y: auto; padding: 6px; }
.pop-group h3 { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin: 10px 10px 4px; }
.pop-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 9px; text-align: left; font-size: 13.5px; }
.pop-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-item:hover, .pop-item:focus-visible { background: var(--surface-2); outline: none; }
.pop-item[aria-selected="true"] { color: var(--accent-ink); font-weight: 550; }
.muted-item { color: var(--ink-3); }
.notif-pop { width: 340px; }
.ship-form { padding: 16px 16px 14px; }
.ship-form h3 { margin: 0 0 4px; font: 650 17px/1.25 var(--display); letter-spacing: -0.015em; }
.ship-form > .muted { margin: 0 0 14px; font-size: 13.5px; line-height: 1.5; }
.ship-form .field { margin-bottom: 12px; }
.ship-form .switch { margin-bottom: 12px; font-size: 13.5px; }
.ship-form .btn-row { margin-top: 4px; }
.ship-form .test-out { margin-top: 10px; overflow-wrap: anywhere; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 6px; }
.notif-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.notif { display: flex; gap: 10px; padding: 10px; border-radius: 10px; }
.notif + .notif { margin-top: 2px; }
.notif.unread { background: var(--accent-soft); }
.notif-ic { color: var(--ink-3); padding-top: 2px; }
.notif.success .notif-ic { color: var(--ok); }
.notif.error .notif-ic { color: var(--err); }
.notif.agent .notif-ic { color: var(--violet); }
.notif strong { font-size: 13.5px; font-weight: 600; display: block; }
.notif p { margin: 1px 0 2px; font-size: 13px; color: var(--ink-2); }
.notif time { font-size: 11.5px; color: var(--ink-3); }
.notif-empty { text-align: center; padding: 22px; color: var(--ink-3); font-size: 13.5px; }
.notif-empty p { margin: 6px 0 0; }

/* toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 10px 12px 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: toast-in 0.4s var(--ease); font-size: 13.5px; line-height: 1.45;
}
.toast.out { animation: toast-out 0.22s ease-in forwards; }
.toast-ic { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; flex: none; background: var(--surface-2); color: var(--ink-2); }
.toast-success .toast-ic { background: var(--ok-soft); color: var(--ok); }
.toast-error .toast-ic { background: var(--err-soft); color: var(--err); }
.toast-agent .toast-ic { background: var(--brand); color: var(--on-pink); }
.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-top: 2px; }
.toast-body strong { font-weight: 600; }
.toast-body span { color: var(--ink-2); overflow-wrap: anywhere; }
.toast-act { font-weight: 600; color: var(--accent-ink); padding: 3px 8px; border-radius: 7px; align-self: center; white-space: nowrap; }
.toast-act:hover { background: var(--accent-soft); }
.toast-x { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: var(--ink-3); flex: none; }
.toast-x:hover { background: var(--surface-2); color: var(--ink); }

/* modals */
.modal { border: 0; padding: 0; background: none; max-width: none; max-height: none; color: var(--ink); }
.modal::backdrop { background: var(--scrim); backdrop-filter: blur(3px); animation: fade 0.2s; }
.modal[open] .modal-card { animation: pop 0.28s var(--ease); }
.modal-card {
  width: min(880px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 48px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 22px; flex: none; }
.modal-head h2 { margin: 0; font: 700 21px/1.2 var(--display); letter-spacing: -0.025em; }
.settings { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px 1fr; }
.settings-nav { padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); }
.snav { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 10px; color: var(--ink-2); font-size: 14px; text-align: left; }
.snav:hover { background: var(--surface-2); color: var(--ink); }
.snav.on { background: var(--surface-3); color: var(--ink); font-weight: 550; }
.settings-body { overflow-y: auto; padding: 4px 24px 24px; }
.settings-body h3 { margin: 8px 0 4px; font: 650 18px/1.25 var(--display); letter-spacing: -0.015em; }
.settings-body > .muted, .prov-detail > .muted { margin: 0 0 16px; font-size: 14px; max-width: 62ch; }
.prov { display: grid; grid-template-columns: 210px 1fr; gap: 20px; min-height: 100%; }
.prov-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.prov-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border-radius: 9px; font-size: 13.5px; color: var(--ink-2); text-align: left; }
.prov-item:hover { background: var(--surface-2); color: var(--ink); }
.prov-item.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 550; }
.dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--ink-3); flex: none; }
.dot.ok { background: var(--pink); box-shadow: 1.5px 1px 0 var(--plate); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field > span, .field legend { font-size: 13px; font-weight: 550; color: var(--ink-2); display: flex; gap: 8px; align-items: baseline; padding: 0; margin-bottom: 6px; }
.field input:not([type=range]):not([type=radio]), .field select, .import input, .import textarea {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); padding: 0 12px; outline: 0; font-size: 14px; min-width: 0;
}
.field input:focus, .field select:focus, .import input:focus, .import textarea:focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--surface); }
.field input[type=range] { accent-color: var(--violet); width: 100%; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2374676e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input-row { display: flex; gap: 8px; align-items: center; }
.hint-link { font-size: 12.5px; display: inline-flex; gap: 4px; align-items: center; align-self: flex-start; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2); background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin: -4px 0 16px; }
.note code { font-size: 12px; }
.test-out { font-size: 13.5px; margin: 14px 0 0; display: flex; gap: 8px; align-items: center; color: var(--ink-2); min-height: 20px; }
.test-out.ok { color: var(--ok); }
.test-out.err { color: var(--err); }
.radio { display: flex; gap: 10px; align-items: center; font-size: 14px; padding: 4px 0; }
.radio input { accent-color: var(--violet); width: 16px; height: 16px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 11px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.switch { display: flex; align-items: center; gap: 12px; font-size: 14px; margin: 0 0 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { width: 38px; height: 22px; border-radius: 11px; background: var(--line-2); position: relative; flex: none; transition: background 0.2s; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.25s var(--ease); }
.switch input:checked + .track { background: var(--violet); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.mini { margin: 0; }
.switch.mini .track { width: 32px; height: 19px; }
.switch.mini .track::after { width: 13px; height: 13px; }
.switch.mini input:checked + .track::after { transform: translateX(13px); }

.skills { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 22px 18px; }
.skills > .muted { margin: 0 0 14px; font-size: 14px; }
.skills-tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.skills-tools .switch { margin: 0; }
.side-search.grow { flex: 1; min-width: 200px; margin: 0; border-color: var(--line); background: var(--surface-2); }
.skill-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; align-content: start; padding: 2px; }
.skill { padding: 13px 14px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 6px; transition: border-color 0.2s, background 0.2s; }
.skill.on { border-color: var(--line-2); box-shadow: 3px 2.5px 0 var(--plate); }
.skill-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.skill-top strong { font-size: 14px; font-weight: 600; line-height: 1.35; }
.skill p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; flex: 1; }
.skill-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.skill-tags span { font-size: 11.5px; color: var(--ink-3); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.skill-tags .link-btn { margin-left: auto; font-size: 12px; }
.import { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.import summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 550; font-size: 14px; }
.import p { font-size: 13px; margin: 8px 0; }
.import textarea { height: auto; padding: 10px 12px; margin-top: 8px; resize: vertical; font: 12.5px/1.5 var(--mono); }

.drop-hint { position: fixed; inset: 0; z-index: 90; background: var(--scrim); display: grid; place-items: center; animation: fade 0.15s; }
.drop-hint > div { padding: 40px 56px; border-radius: var(--r-xl); border: 2px dashed color-mix(in srgb, var(--violet) 60%, transparent); background: var(--surface); text-align: center; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; }
.drop-hint p { margin: 10px 0 0; font-weight: 550; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--violet) 25%, transparent); border-top-color: var(--violet); animation: spin 0.7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* highlight.js tokens: two inks only (pink, blue) plus the text ink */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-doctag { color: var(--pink-ink); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-type { color: var(--pink); }
.hljs-string, .hljs-attr-value, .hljs-template-tag, .hljs-addition, .hljs-regexp { color: var(--blue-ink); }
.hljs-title, .hljs-section, .hljs-name, .hljs-selector-id, .hljs-selector-class, .hljs-function { color: var(--ink); font-weight: 600; }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--ink-3); font-style: italic; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-property, .hljs-params { color: var(--ink-2); }
.hljs-deletion { color: var(--err); }

/* ---------- responsive ---------- */
/* Tablet and small laptop: sidebar and panel float over the chat. */
@media (max-width: 1179px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; margin-left: 0 !important; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body:not(.side-open) .sidebar { box-shadow: none; visibility: hidden; transition: transform 0.32s var(--ease), visibility 0s 0.32s; }
  body.side-open .sidebar { transform: none; }
  body.side-open #side-open { visibility: visible; width: 36px; }
  .panel { position: fixed; inset: 0 0 0 auto; width: min(680px, 88vw); z-index: 28; box-shadow: var(--shadow-lg); }
  .toasts { top: calc(64px + env(safe-area-inset-top)); bottom: auto; }
  .toast { animation-name: toast-in-top; }
}
@media (min-width: 1180px) and (max-width: 1440px) {
  body.side-open.panel-open .panel { width: clamp(380px, 40vw, 620px); }
}

/* Phones */
@media (max-width: 767px) {
  body { font-size: 15px; }
  .topbar { height: 52px; padding: 0 8px; }
  .pill-btn { width: 38px; padding: 0; justify-content: center; position: relative; }
  .pill-btn .lbl { display: none; }
  .pill-count { position: absolute; top: -5px; right: -5px; }
  .thread-inner { padding: 8px 16px 28px; gap: 22px; }
  .msg.assistant { gap: 10px; }
  .avatar .diji { --s: 26px !important; width: 26px; height: 26px; }
  .avatar svg { width: 26px; height: 26px; }
  .msg.tool { margin-left: 36px; }
  .msg.user { max-width: 90%; }
  .content { font-size: 15.5px; }
  .msg-actions { opacity: 1; }
  .composer { padding: 0 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer-box { padding: 10px 8px 8px 12px; border-radius: 20px; }
  .model-btn { max-width: 52%; }
  .model-prov { display: none; }
  .chip-btn .lbl-full { display: none; }
  .chip-btn .lbl-short { display: inline; }
  .fineprint { display: none; }
  .empty { padding: 0 16px 18px; }
  .empty-mascot .diji { --s: 72px !important; width: 72px; height: 72px; }
  .empty-mascot svg { width: 72px; height: 72px; }
  .starters { grid-template-columns: 1fr; gap: 8px; }
  .starter:nth-child(n + 3) { display: none; }
  .panel { inset: 0; width: 100%; border-left: 0; animation: sheet-up 0.35s var(--ease); }
  .panel-head { padding: 8px 6px 8px 8px; gap: 4px; }
  .panel-head .tab { padding: 0 9px; font-size: 13px; }
  .panel-head .tabs { min-width: 0; flex-shrink: 1; overflow: hidden; }
  #open-tab { display: none; }
  .panel-actions .icon-btn { width: 34px; height: 34px; }
  .panel-actions { gap: 0; }
  .code-view { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .file-tree { display: flex; gap: 4px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .file-item { width: auto; flex: none; }
  .toasts { left: 12px; right: 12px; top: calc(60px + env(safe-area-inset-top)); bottom: auto; width: auto; }
  .toast { animation-name: toast-in-top; }
  .modal-card { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .settings { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 12px 10px; }
  .snav { flex: none; }
  .snav span { white-space: nowrap; }
  .settings-body { padding: 14px 16px 24px; }
  .prov { grid-template-columns: 1fr; gap: 12px; min-height: 0; align-content: start; }
  .prov-list { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .prov-item { white-space: nowrap; border: 1px solid var(--line); }
  .input-row { flex-wrap: wrap; }
  .input-row input { flex: 1 1 200px; }
  .skills { padding: 0 16px 16px; }
  .skill-grid { grid-template-columns: 1fr; }
  .jump { bottom: 120px; }
  #composer-input { font-size: 16px; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes toast-in-top { from { opacity: 0; transform: translateY(-14px) scale(0.97); } }

/* Very small phones */
@media (max-width: 360px) {
  .chip-btn .lbl-short { display: none; }
  .panel-head .tab { padding: 0 6px; font-size: 12.5px; }
  .panel-actions .icon-btn { width: 30px; height: 30px; }
  .model-btn { max-width: 44%; }
}

/* Big screens get a roomier reading column */
@media (min-width: 1700px) {
  .thread-inner, .composer-box, .empty { max-width: 860px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media (hover: none) {
  .chat-item .icon-btn { opacity: 1; }
}
