/* ==========================================================================
   Hush. Petrol base, marigold lamp.
   The orb is the one memorable element: it is the model's live status light.
   ========================================================================== */

:root {
  --font-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-read: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-code: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --ease: cubic-bezier(.22, .9, .24, 1);
  --ease-spring: cubic-bezier(.34, 1.36, .5, 1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --sidebar-w: 300px;
  --col: 720px;

  /* dark (default) */
  --bg: #0B2529;
  --bg-2: #0E2C31;
  --surface: #143940;
  --surface-2: #1A464E;
  --line: rgba(213, 240, 236, .09);
  --line-2: rgba(213, 240, 236, .18);
  --text: #E9F2EF;
  --text-2: #A9C2BF;
  --text-3: #7FA09E;
  --user: #1B4A52;
  --primary: #FFC46B;
  --primary-ink: #2B1B00;
  --glow: #FFC46B;
  --glow-deep: #E8902E;
  --glow-a: rgba(255, 196, 107, .42);
  --focus: rgba(255, 196, 107, .55);
  --danger: #FF9D8E;
  --ok: #86DDB5;
  --code-bg: #0A1F23;
  --mono-l: 78%;
  --shadow: 0 22px 44px -20px rgba(0, 0, 0, .65);
  --backdrop: rgba(3, 14, 16, .62);
}

:root[data-theme="light"] {
  --bg: #F3F7F5;
  --bg-2: #EAF1EE;
  --surface: #FFFFFF;
  --surface-2: #F0F5F3;
  --line: rgba(11, 37, 41, .09);
  --line-2: rgba(11, 37, 41, .18);
  --text: #0C2226;
  --text-2: #3E5C5F;
  --text-3: #587473;
  --user: #DAEAE6;
  --primary: #0E5F69;
  --primary-ink: #FFFFFF;
  --glow: #F5B547;
  --glow-deep: #DE8A1C;
  --glow-a: rgba(238, 164, 52, .40);
  --focus: rgba(14, 95, 105, .45);
  --danger: #B3382A;
  --ok: #1C7D57;
  --code-bg: #E5EEEB;
  --mono-l: 26%;
  --shadow: 0 22px 44px -22px rgba(11, 37, 41, .35);
  --backdrop: rgba(11, 37, 41, .38);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background-color .3s var(--ease);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.sm { width: 16px; height: 16px; }

/* ---------- shell ---------- */
.app {
  position: fixed; inset: 0 0 auto 0;
  height: var(--app-h, 100dvh);
  display: grid; grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}
.main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; position: relative; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: min(86vw, 330px); z-index: 30;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 10px) 0 calc(var(--safe-b) + 8px) var(--safe-l);
  transform: translateX(-104%);
  transition: transform .42s var(--ease);
  will-change: transform;
}
.app[data-sidebar="open"] .sidebar { transform: none; box-shadow: var(--shadow); }
.scrim {
  position: fixed; inset: 0; z-index: 20; background: var(--backdrop);
  opacity: 0; pointer-events: none; transition: opacity .35s var(--ease);
}
.app[data-sidebar="open"] .scrim { opacity: 1; pointer-events: auto; }

@media (min-width: 900px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar { position: relative; inset: auto; width: auto; transform: none; box-shadow: none; will-change: auto; }
  .scrim { display: none; }
  .menu-btn { display: none !important; }
}

.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px 10px 20px; }
.brand { display: flex; align-items: center; gap: 10px; font: 500 22px/1 var(--font-read); letter-spacing: -.01em; }
.chat-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 10px 12px; }
.group-title { margin: 16px 10px 6px; font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.chat-item {
  display: flex; align-items: center; gap: 4px; width: 100%; min-height: 44px; padding: 0 4px 0 12px;
  border-radius: 12px; text-align: left; color: var(--text-2); cursor: pointer;
  transition: background-color .2s, color .2s;
}
.chat-open { flex: 1; min-width: 0; min-height: 44px; text-align: left; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item:hover { background: var(--line); color: var(--text); }
.chat-item[aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.chat-item .del { opacity: 0; display: grid; place-items: center; min-width: 36px; height: 36px; border-radius: 10px; color: var(--text-3); font-size: 13px; font-weight: 500; }
.chat-item:hover .del, .chat-item:focus-within .del, .chat-item .del.confirm { opacity: 1; }
.chat-item .del:hover { color: var(--danger); }
.chat-item .del.confirm { color: var(--danger); padding: 0 8px; }
@media (hover: none) { .chat-item .del { opacity: .7; } }
.empty-list { margin: 24px 14px; color: var(--text-3); font-size: 14px; }

.sb-foot { padding: 8px 10px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.row-btn {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px;
  color: var(--text-2); text-align: left; width: 100%; transition: background-color .2s, color .2s;
}
.row-btn:hover { background: var(--line); color: var(--text); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 10px) 8px calc(var(--safe-l) + 10px);
  border-bottom: 1px solid transparent; background: var(--bg);
  transition: border-color .25s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: var(--text-2);
  transition: background-color .2s, color .2s, transform .2s var(--ease);
}
.icon-btn:hover { background: var(--line); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.model-pill {
  display: flex; align-items: center; gap: 10px; min-height: 44px; max-width: min(100%, 420px); min-width: 0;
  margin: 0 auto; padding: 0 14px 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  transition: border-color .25s, transform .2s var(--ease), background-color .25s;
}
.model-pill:hover { border-color: var(--line-2); }
.model-pill:active { transform: scale(.98); }
.pill-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pill-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-sub { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.pill-sub:empty { display: none; }
@media (min-width: 900px) {
  .topbar { padding-left: 20px; padding-right: 16px; }
  .model-pill { margin: 0 auto 0 0; }
}

/* ---------- the orb ---------- */
.orb { --s: 16px; position: relative; display: inline-block; width: var(--s); height: var(--s); flex: none; }
.orb::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #FFF3D6 0%, var(--glow) 40%, var(--glow-deep) 100%);
  transition: opacity .5s var(--ease), transform .5s var(--ease-spring), filter .5s;
}
.orb .halo {
  position: absolute; inset: -70%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--glow-a) 0%, transparent 62%);
  opacity: 0; transform: scale(.7); transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.orb::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 1.5px solid transparent;
  border-top-color: var(--glow); opacity: 0; transition: opacity .3s;
}
.orb[data-state="idle"]::before { opacity: .42; filter: saturate(.55); transform: scale(.86); }
.orb.big[data-state="idle"] .halo { opacity: .35; transform: scale(1); }
.orb[data-state="ready"]::before { opacity: 1; }
.orb[data-state="ready"] .halo { opacity: .7; transform: scale(1); }
.orb[data-state="loading"]::before { opacity: .65; transform: scale(.9); }
.orb[data-state="loading"]::after { opacity: 1; animation: spin .9s linear infinite; }
.orb[data-state="generating"]::before { animation: breathe 1.2s ease-in-out infinite; }
.orb[data-state="generating"] .halo { opacity: .95; animation: halo 1.2s ease-in-out infinite; }
.orb.big { --s: 84px; }
.orb.big[data-state="ready"]::before { animation: breathe 5s ease-in-out infinite; }
.orb.big[data-state="ready"] .halo { animation: halo 5s ease-in-out infinite; }
.orb.big::after { inset: -10px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { transform: scale(.94); } 50% { transform: scale(1.06); } }
@keyframes halo { 0%, 100% { transform: scale(.9); opacity: .55; } 50% { transform: scale(1.12); opacity: 1; } }

/* ---------- thread ---------- */
.thread { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; -webkit-overflow-scrolling: touch; }
.thread-inner {
  max-width: var(--col); margin: 0 auto; min-height: 100%;
  padding: 12px calc(var(--safe-r) + 20px) 28px calc(var(--safe-l) + 20px);
  display: flex; flex-direction: column; gap: 30px;
}

.hero { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 22px; padding: 4vh 0 2vh; }
.hero h1 { margin: 6px 0 0; font: 300 clamp(36px, 9vw, 54px)/1.04 var(--font-read); letter-spacing: -.025em; max-width: 14em; text-wrap: balance; }
.hero p { margin: 0; max-width: 32em; color: var(--text-2); font: 400 17px/1.55 var(--font-read); text-wrap: pretty; }
.hero .btn { margin-top: 4px; }
.notice { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: 14px; max-width: 34em; }
.suggest { width: 100%; margin-top: 10px; display: grid; }
.suggest button {
  text-align: left; padding: 15px 2px; border-top: 1px solid var(--line); color: var(--text-2);
  font: 400 17px/1.4 var(--font-read); transition: color .2s, padding-left .3s var(--ease);
}
.suggest button:last-child { border-bottom: 1px solid var(--line); }
.suggest button:hover { color: var(--text); padding-left: 8px; }

.msg { contain: layout style; }
.msg.enter { animation: rise .42s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.msg.user {
  align-self: flex-end; max-width: min(88%, 560px); padding: 10px 16px; background: var(--user);
  border-radius: 20px 20px 6px 20px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.5;
}
.msg.assistant { font: 400 17.5px/1.68 var(--font-read); font-optical-sizing: auto; color: var(--text); overflow-wrap: anywhere; }
.msg.assistant.empty .prose { display: none; }
.pending { display: none; align-items: center; gap: 12px; height: 34px; color: var(--text-3); font: 400 14px var(--font-ui); }
.msg.assistant.empty .pending { display: flex; }

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 .85em; }
.prose h2, .prose h3, .prose h4, .prose h5 { margin: 1.3em 0 .5em; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
.prose h2 { font-size: 1.4em; } .prose h3 { font-size: 1.22em; } .prose h4, .prose h5 { font-size: 1.05em; }
.prose ul, .prose ol { margin: 0 0 .9em; padding-left: 1.4em; }
.prose li { margin: .25em 0; padding-left: .2em; }
.prose li::marker { color: var(--text-3); }
.prose li > ul, .prose li > ol { margin: .3em 0 .3em; }
.prose a { color: var(--primary); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose strong { font-weight: 650; }
.prose blockquote { margin: 0 0 .9em; padding: .1em 0 .1em 1em; border-left: 2px solid var(--glow); color: var(--text-2); font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--line-2); margin: 1.4em 0; }
.prose code { font: 450 .8em var(--font-code); padding: .15em .4em; border-radius: 6px; background: var(--code-bg); }
.code { margin: 0 0 1em; border-radius: 14px; background: var(--code-bg); border: 1px solid var(--line); overflow: hidden; font-family: var(--font-ui); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); color: var(--text-3); font-size: 13px; }
.copy-code { height: 30px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-size: 13px; transition: background-color .2s, color .2s; }
.copy-code:hover { background: var(--line); color: var(--text); }
.code pre { margin: 0; padding: 12px 14px 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.code pre code { padding: 0; background: none; font: 400 13.5px/1.6 var(--font-code); white-space: pre; color: var(--text); }
.table-wrap { margin: 0 0 1em; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; font: 400 15px/1.5 var(--font-ui); }
.table-wrap table { border-collapse: collapse; width: 100%; }
.table-wrap th, .table-wrap td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap th { font-weight: 600; background: var(--surface); }

.msg.streaming .prose > p:last-child::after,
.msg.streaming .prose > :is(ul, ol):last-child li:last-child:not(:has(li))::after {
  content: ""; display: inline-block; width: .5ch; height: 1.05em; margin-left: 3px; vertical-align: text-bottom;
  border-radius: 2px; background: var(--glow); animation: blink 1s steps(2, jump-none) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.think { margin: 0 0 14px; font: 400 14.5px/1.6 var(--font-ui); color: var(--text-2); }
.think-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px 0 4px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.think-toggle:hover { color: var(--text); }
.think-toggle .i { transition: transform .3s var(--ease); }
.think.open .think-toggle .i { transform: rotate(90deg); }
.think.live .think-label { background: linear-gradient(90deg, var(--text-3) 30%, var(--text) 50%, var(--text-3) 70%) 0 0 / 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.8s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.think-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .38s var(--ease); }
.think.open .think-body { grid-template-rows: 1fr; }
.think-body > div { overflow: hidden; min-height: 0; }
.think-body .prose { padding: 4px 0 4px 14px; margin-left: 9px; border-left: 2px solid var(--line-2); }
.think-body .prose p { margin-bottom: .6em; }

.msg-foot { display: flex; align-items: center; gap: 2px; margin-top: 6px; margin-left: -8px; font: 400 12.5px var(--font-ui); color: var(--text-3); min-height: 34px; }
.msg-foot .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.msg-foot .icon-btn .i { width: 17px; height: 17px; }
.msg-foot .stat { margin-left: 8px; }
.msg.assistant:not(:last-child) .msg-foot { opacity: 0; transition: opacity .2s; }
.msg.assistant:hover .msg-foot, .msg.assistant:focus-within .msg-foot { opacity: 1; }
@media (hover: none) { .msg.assistant:not(:last-child) .msg-foot { opacity: 1; } }
.msg.streaming .msg-foot { visibility: hidden; }
.err { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); color: var(--text); font: 400 14.5px/1.5 var(--font-ui); }

.jump {
  position: absolute; right: 18px; bottom: calc(112px + var(--safe-b)); z-index: 5; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: rise .3s var(--ease) both;
}

/* ---------- composer ---------- */
.composer-wrap { padding: 8px calc(var(--safe-r) + 14px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 14px); background: var(--bg); }
.composer {
  max-width: var(--col); margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; padding: 7px 7px 7px 20px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 28px; box-shadow: var(--shadow);
  transition: border-color .25s, box-shadow .25s;
}
.composer:focus-within { border-color: var(--focus); box-shadow: 0 0 0 4px var(--glow-a), var(--shadow); }
.composer textarea {
  flex: 1; min-width: 0; max-height: 176px; padding: 9px 0; background: none; border: 0; outline: 0; resize: none;
  font-size: 16px; line-height: 1.5; caret-color: var(--glow);
}
.composer textarea::placeholder { color: var(--text-3); }
.send {
  position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink);
  transition: transform .25s var(--ease-spring), opacity .25s, background-color .25s;
}
.send:active { transform: scale(.9); }
.send:disabled { opacity: .28; transform: scale(.94); cursor: default; }
.send .i { position: absolute; transition: opacity .2s, transform .35s var(--ease-spring); }
.send .stop-ic { opacity: 0; transform: scale(.4) rotate(-40deg); }
.send[data-mode="stop"] .send-ic { opacity: 0; transform: scale(.4) rotate(40deg); }
.send[data-mode="stop"] .stop-ic { opacity: 1; transform: none; }
.send[data-mode="stop"] { animation: ring 1.6s ease-out infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 var(--glow-a); } 100% { box-shadow: 0 0 0 12px transparent; } }
.fineprint { margin: 8px auto 0; max-width: var(--col); text-align: center; color: var(--text-3); font-size: 12.5px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line-2); font-weight: 550; color: var(--text); white-space: nowrap;
  transition: background-color .2s, transform .2s var(--ease), border-color .2s, opacity .2s;
}
.btn:hover { background: var(--line); }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { background: var(--primary); filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 16px; font-size: 14px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* ---------- sheets ---------- */
.sheet {
  padding: 0; border: 0; background: transparent; color: inherit; overflow: visible;
  width: 100%; max-width: 640px; max-height: none; margin: auto auto 0;
}
.sheet::backdrop { background: var(--backdrop); opacity: 0; transition: opacity .35s var(--ease); }
.sheet.open::backdrop { opacity: 1; }
.sheet-card {
  display: flex; flex-direction: column; max-height: min(90dvh, 820px); min-height: 0;
  background: var(--surface); border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: 28px 28px 0 0; box-shadow: var(--shadow);
  padding-bottom: var(--safe-b);
  transform: translateY(102%); transition: transform .5s var(--ease);
}
.sheet.open .sheet-card { transform: none; }
.grab { flex: none; height: 26px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.grab::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); }
.sheet-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0 12px 14px 24px; }
.sheet-head h2 { margin: 0; font: 400 28px/1.15 var(--font-read); letter-spacing: -.015em; }
.sheet-head p { margin: 4px 0 0; color: var(--text-3); font-size: 14px; }
.sheet-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 24px 24px; -webkit-overflow-scrolling: touch; }
@media (min-width: 720px) {
  .sheet { margin: auto; }
  .sheet-card { border-radius: 28px; border-bottom: 1px solid var(--line-2); padding-bottom: 0; transform: translateY(18px) scale(.97); opacity: 0; transition: transform .45s var(--ease), opacity .3s; }
  .sheet.open .sheet-card { opacity: 1; }
  .grab { display: none; }
  .sheet-head { padding-top: 22px; }
}

.device { flex: none; display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; padding: 2px 24px 10px; overflow-x: auto; scrollbar-width: none; }
.device::-webkit-scrollbar { display: none; }
.device-meter { flex: none; padding: 0 24px 12px; }
.device-meter .meter-label { margin-top: 8px; }
.tag { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
.tag.ok { color: var(--ok); } .tag.warn { color: var(--glow); } .tag.bad { color: var(--danger); }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.meter { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--used, 0%); border-radius: 4px; background: var(--glow); transition: width .6s var(--ease); }
.meter-label { font-size: 12.5px; color: var(--text-3); text-wrap: pretty; }

.chips { flex: none; display: flex; gap: 8px; padding: 0 24px 12px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); font-weight: 500; transition: background-color .2s, color .2s, border-color .2s; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: transparent; }

.models { list-style: none; margin: 0; padding: 0; }
.model-group { padding: 18px 0 6px; display: flex; align-items: baseline; gap: 10px; font-family: var(--font-read); font-size: 19px; }
.model-group small { font: 400 13px var(--font-ui); color: var(--text-3); }
.model {
  --h: 190;
  display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 14px; align-items: start; padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.model-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.mono { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; font: 600 16px var(--font-read); background: hsl(var(--h) 45% 50% / .18); color: hsl(var(--h) 60% var(--mono-l)); }
.model[data-family="Gemma"] { --h: 212; } .model[data-family="Qwen"] { --h: 268; } .model[data-family="Granite"] { --h: 200; }
.model[data-family="Llama"] { --h: 28; } .model[data-family="Phi"] { --h: 165; } .model[data-family="SmolLM"] { --h: 48; }
.model[data-family="Mistral"] { --h: 14; } .model[data-family="DeepSeek"] { --h: 230; } .model[data-family="Custom"] { --h: 320; }
.model-name { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.model-desc { color: var(--text-2); font-size: 14px; margin-top: 0; text-wrap: pretty; }
.model-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.model-tags .tag { height: 22px; padding: 0 8px; font-size: 12px; }
.model.is-active .model-name::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--glow); box-shadow: 0 0 10px var(--glow-a); }
.model-act { display: flex; flex: none; align-items: center; gap: 2px; }
.model-act .icon-btn { width: 40px; height: 40px; }
.model-act .ring { margin-right: 6px; }
.model-act .icon-btn.confirm { color: var(--danger); width: auto; padding: 0 12px; font-size: 13px; font-weight: 550; }
.ring { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: var(--line-2); }
.ring .fg { stroke: var(--glow); stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: calc(113.1 * (1 - var(--p, 0))); transition: stroke-dashoffset .3s linear; }
.ring.indeterminate svg { animation: spin 1s linear infinite; }
.ring.indeterminate .fg { --p: .28; }
.ring span { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

.custom { margin-top: 20px; padding: 14px 0 4px; border-top: 1px solid var(--line); }
.custom summary { cursor: pointer; font-weight: 550; min-height: 32px; display: flex; align-items: center; }
.custom p { color: var(--text-2); font-size: 14px; margin: 8px 0 12px; }
.custom code { font: 450 12.5px var(--font-code); background: var(--code-bg); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.custom-form { display: flex; gap: 8px; }
.custom-form input { flex: 1; min-width: 0; height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg); font-size: 16px; outline: 0; }
.custom-form input:focus { border-color: var(--focus); }

/* ---------- settings ---------- */
.form { display: grid; gap: 24px; align-content: start; padding-top: 8px; }
.field { display: grid; gap: 8px; }
.label { font-weight: 550; display: flex; justify-content: space-between; gap: 12px; }
.label output { color: var(--text-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.hint { color: var(--text-3); font-size: 13px; }
.field textarea { width: 100%; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--bg); resize: vertical; min-height: 96px; font-size: 16px; line-height: 1.5; outline: 0; }
.field textarea:focus { border-color: var(--focus); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line-2); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-2); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%; background: var(--primary); border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); border: 0; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.segmented button { min-height: 40px; border-radius: 999px; color: var(--text-2); font-weight: 500; transition: background-color .25s, color .25s; }
.segmented button[aria-checked="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }
.switch-field { grid-template-columns: 1fr auto; align-items: center; gap: 16px; }
.switch-field > div { display: grid; gap: 4px; }
.switch { position: relative; width: 52px; height: 32px; border-radius: 999px; background: var(--line-2); transition: background-color .3s; }
.switch i { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); transition: transform .35s var(--ease-spring); }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"] i { transform: translateX(20px); background: var(--primary-ink); }
:root[data-theme="light"] .switch[aria-checked="true"] i { background: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 132px); z-index: 100; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 460px; padding: 12px 12px 12px 18px; border-radius: 18px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 14.5px; line-height: 1.4;
  animation: toast-in .45s var(--ease-spring) both;
}
.toast.out { animation: toast-out .3s var(--ease) both; }
.toast button { flex: none; height: 34px; padding: 0 12px; border-radius: 10px; font-weight: 600; color: var(--bg); background: color-mix(in srgb, var(--bg) 16%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
