/* DarksDev — the studio's developer console. Dark only, system fonts only, no
   external requests. Palette and button language follow darksgames.app. */

:root {
  color-scheme: dark;
  --bg: #05050c;
  --bg2: #090912;
  --panel: rgba(255, 255, 255, 0.03);
  --panel2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.08);
  --line2: rgba(255, 255, 255, 0.14);
  --text: #eceded;
  --dim: #9497b8;
  --mint: #7df9c6;
  --cyan: #6bd5fa;
  --violet: #c26bfa;
  --amber: #f5b942;
  --red: #fa8f6b;
  --grad: linear-gradient(115deg, var(--mint), var(--cyan) 45%, var(--violet));
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --st: env(safe-area-inset-top, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --col: 860px;
}

* { margin: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); height: 100%; -webkit-text-size-adjust: 100%; }
body {
  height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 480px at 8% -10%, color-mix(in srgb, var(--violet) 13%, transparent), transparent 70%),
    radial-gradient(900px 520px at 100% 110%, color-mix(in srgb, var(--mint) 9%, transparent), transparent 70%);
}
#app { height: var(--app-h, 100dvh); }

::selection { background: var(--mint); color: var(--bg); }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 6px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #23233c; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: #23233c transparent; }

a { color: var(--cyan); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
.dim { color: var(--dim); }
.ic { flex: none; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
.noscript { padding: 2rem; text-align: center; }

/* ================= buttons, inputs, pills ================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.82rem; letter-spacing: 0.08em; text-decoration: none;
  padding: 0.7rem 1.3rem; border-radius: 10px; border: 0; min-height: 42px; white-space: nowrap;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), filter 0.18s, opacity 0.18s;
}
.btn.big { font-size: 0.95rem; padding: 0.95rem 2rem; }
.btn.sm { padding: 0.42rem 0.85rem; font-size: 0.72rem; min-height: 34px; border-radius: 8px; }
.btn.primary {
  color: #04140c; font-weight: 700;
  background: linear-gradient(115deg, var(--mint), var(--cyan));
  box-shadow: 0 6px 22px color-mix(in srgb, var(--mint) 22%, transparent);
}
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 10px 30px color-mix(in srgb, var(--mint) 36%, transparent); }
.btn.ghost {
  color: var(--text); border: 1px solid transparent;
  background: linear-gradient(var(--bg2), var(--bg2)) padding-box, var(--grad) border-box;
}
.btn.ghost:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(120, 120, 200, 0.16); }
.btn.ghost.danger { color: var(--red); background: linear-gradient(var(--bg2), var(--bg2)) padding-box, linear-gradient(color-mix(in srgb, var(--red) 55%, transparent), color-mix(in srgb, var(--red) 55%, transparent)) border-box; }
.btn.ghost.danger.armed { background: color-mix(in srgb, var(--red) 22%, var(--bg2)); }
.btn:disabled { opacity: 0.45; box-shadow: none; }

.linkbtn {
  display: inline-flex; align-items: center; gap: 0.35rem; background: none; border: 0; padding: 4px 6px; border-radius: 6px;
  color: var(--dim); font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-decoration: none;
}
.linkbtn:hover:not(:disabled) { color: var(--text); background: var(--panel2); }
.linkbtn.accent { color: var(--mint); }
.linkbtn:disabled { opacity: 0.5; }

.iconbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  background: none; border: 0; border-radius: 10px; color: var(--dim);
}
.iconbtn:hover:not(:disabled) { color: var(--text); background: var(--panel2); }
.iconbtn:disabled { opacity: 0.4; }

.input, .select {
  width: 100%; min-width: 0; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.6rem 0.75rem; font-size: 0.9rem; color: var(--text); min-height: 42px;
}
.input::placeholder, .composer-text::placeholder { color: color-mix(in srgb, var(--dim) 75%, transparent); }
.input:focus, .select:focus { outline: none; border-color: var(--cyan); }
.input.sm { min-height: 36px; padding: 0.4rem 0.65rem; font-size: 0.82rem; }
.input:disabled, .select:disabled { opacity: 0.55; }
textarea.input { resize: vertical; line-height: 1.5; font-family: var(--mono); font-size: 0.82rem; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 2rem; text-overflow: ellipsis; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239497b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center;
}
.select.sm { min-height: 34px; padding: 0.3rem 1.8rem 0.3rem 0.6rem; font-size: 0.78rem; width: auto; max-width: 190px; border-radius: 8px; }
.select option { background: #10101c; color: var(--text); }

.field { display: grid; gap: 0.35rem; min-width: 0; }
.field > span { display: inline-flex; align-items: center; gap: 0.35rem; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.field small, .switch-row small { color: var(--dim); font-size: 0.78rem; line-height: 1.4; }
.field .req { color: var(--amber); font-style: normal; }
.form-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.form-msg { font-size: 0.82rem; color: var(--dim); }
.form-msg:empty { display: none; }
.form-msg.ok { color: var(--mint); }
.form-msg.err { color: var(--red); }

.pill {
  display: inline-block; font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 0.22rem 0.6rem; border-radius: 99px; white-space: nowrap;
  color: var(--dim); border: 1px solid var(--line2); background: var(--panel);
}
.pill.live { color: var(--mint); border-color: color-mix(in srgb, var(--mint) 45%, transparent); background: color-mix(in srgb, var(--mint) 9%, transparent); }
.pill.warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 50%, transparent); background: color-mix(in srgb, var(--amber) 10%, transparent); }
.pill.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); background: color-mix(in srgb, var(--red) 10%, transparent); }
.pill.violet { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 45%, transparent); background: color-mix(in srgb, var(--violet) 9%, transparent); }
.pill.soft { letter-spacing: 0.1em; text-transform: none; font-size: 0.68rem; }

.chip {
  display: inline-flex; align-items: center; gap: 0.3rem; font-family: var(--mono); font-size: 0.7rem;
  color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 0.12rem 0.5rem;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tag {
  display: inline-block; font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--violet); border: 1px solid color-mix(in srgb, var(--violet) 40%, transparent); border-radius: 5px; padding: 0.05rem 0.35rem;
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; }
.callout { display: flex; gap: 0.7rem; align-items: flex-start; border-radius: 12px; padding: 0.8rem 0.9rem; font-size: 0.86rem; }
.callout.warn { color: var(--text); border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent); background: color-mix(in srgb, var(--amber) 8%, transparent); }
.callout.warn .ic { color: var(--amber); margin-top: 2px; }

.empty { display: grid; justify-items: center; gap: 0.7rem; padding: 2rem 1rem; color: var(--dim); text-align: center; }
.empty.tall { padding: 4rem 1rem; }
.loading { display: flex; align-items: center; gap: 0.6rem; color: var(--dim); font-size: 0.86rem; padding: 0.8rem 0; }

.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); animation: bounce 1.2s infinite var(--ease); }
.dots i:nth-child(2) { animation-delay: 0.15s; background: var(--cyan); }
.dots i:nth-child(3) { animation-delay: 0.3s; background: var(--violet); }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }
.spin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--cyan) 30%, transparent); border-top-color: var(--cyan); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 60% { box-shadow: 0 0 0 6px transparent; } }
@keyframes blink { 50% { opacity: 0; } }

/* Nothing animates while the page is hidden (app.js toggles .paused). */
html.paused *, html.paused *::before, html.paused *::after { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= boot + gates ================= */

.boot, .gate { height: 100%; display: grid; place-items: center; align-content: center; padding: calc(1.2rem + var(--st)) 1.2rem calc(1.2rem + var(--sb)); }
.boot { gap: 0.8rem; }
.boot-mark { animation: breathe 1.6s ease-in-out infinite; }
.boot-text { font-family: var(--mono); letter-spacing: 0.3em; font-size: 0.72rem; color: var(--dim); text-transform: uppercase; }
@keyframes breathe { 50% { opacity: 0.45; transform: scale(0.96); } }
.gate-card {
  width: min(430px, 100%); text-align: center; display: grid; justify-items: center; gap: 0.9rem;
  padding: 2.4rem 1.8rem 2rem; border-radius: 20px; border: 1px solid transparent;
  background: linear-gradient(#0a0a14, #0a0a14) padding-box, linear-gradient(140deg, color-mix(in srgb, var(--mint) 55%, transparent), var(--line) 35%, var(--line) 65%, color-mix(in srgb, var(--violet) 55%, transparent)) border-box;
}
.gate { background: radial-gradient(560px 400px at 50% 50%, color-mix(in srgb, var(--violet) 11%, transparent), transparent 72%); }
.gate-card h1 { font-size: 1.55rem; letter-spacing: -0.01em; }
.gate-card p { color: var(--dim); max-width: 34ch; }
.gate-card .btn { margin-top: 0.5rem; text-decoration: none; }
.gate-foot { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; margin-top: 0.4rem; }
.gate-mark { filter: drop-shadow(0 0 22px color-mix(in srgb, var(--cyan) 45%, transparent)); }

/* the pairing card (app.js pairCard) */
.pair-card { width: min(460px, 100%); }
.gate-card p.pair-lost { color: var(--amber); font-size: 0.86rem; }
.pair-form { width: 100%; display: grid; gap: 0.8rem; text-align: left; margin-top: 0.2rem; }
.pair-form .btn { width: 100%; margin-top: 0.2rem; }
.pair-form .form-msg { text-align: center; max-width: none; }
.gate-card .pair-form .form-msg.err { color: var(--red); }
.pair-code { font-family: var(--mono); letter-spacing: 0.1em; text-transform: uppercase; text-align: center; }
.pair-code::placeholder { letter-spacing: 0.04em; }
.gate-card p.pair-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.1rem 0.7rem; max-width: none; }
.pair-foot .linkbtn { font-size: inherit; letter-spacing: inherit; text-decoration: underline; padding: 2px 4px; }

/* ================= shell ================= */

.shell { height: 100%; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
/* Explicit rows: the banner and the tab bar are often display:none, and
   auto-placement would then drop the views into an `auto` row. */
.topbar { grid-row: 1; }
.banner { grid-row: 2; }
.views { grid-row: 3; }
.tabbar { grid-row: 4; }

.topbar {
  position: relative; z-index: 30; display: flex; align-items: center; gap: 0.9rem;
  padding: calc(0.5rem + var(--st)) calc(1rem + var(--sr)) 0.5rem calc(1rem + var(--sl));
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 82%, transparent);
}
.topbar .menu { display: none; margin-left: -6px; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--text); flex: none; }
.brand-name { font-weight: 750; letter-spacing: -0.01em; font-size: 1.02rem; }
.brand-zoe {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.2em; padding: 0.12rem 0.4rem 0.1rem; border-radius: 5px;
  color: #04140c; background: var(--grad); font-weight: 700;
}
.tabs { display: flex; gap: 0.2rem; margin-left: 0.6rem; }
.tabs a {
  position: relative; display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.45rem 0.8rem; border-radius: 9px;
  color: var(--dim); text-decoration: none; font-size: 0.86rem; min-height: 38px;
}
.tabs a:hover { color: var(--text); background: var(--panel); }
.tabs a.active { color: var(--text); background: var(--panel2); }
.tabs a.active::after { content: ""; position: absolute; left: 0.8rem; right: 0.8rem; bottom: -0.56rem; height: 2px; border-radius: 2px; background: var(--grad); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; min-width: 0; }

.box {
  display: inline-flex; align-items: center; gap: 0.7rem; min-height: 34px; padding: 0.25rem 0.7rem; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line); color: var(--dim);
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.04em; white-space: nowrap;
}
.box:hover { border-color: var(--line2); color: var(--text); }
.box.empty .box-item { display: none; }
.box-item { display: inline-flex; gap: 0.35rem; align-items: baseline; color: var(--text); }
.box-item b { font-weight: 400; color: var(--dim); font-size: 0.6rem; letter-spacing: 0.14em; }
.box-item[data-level="warn"] { color: var(--amber); }
.box-item[data-level="bad"] { color: var(--red); }
.box[data-level="warn"] { border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.box[data-level="bad"] { border-color: color-mix(in srgb, var(--red) 45%, transparent); }

.box-pop {
  position: absolute; top: calc(100% + 6px); right: calc(1rem + var(--sr)); z-index: 40; width: min(360px, calc(100vw - 2rem));
  background: #0c0c18; border: 1px solid var(--line2); border-radius: 14px; padding: 0.9rem 1rem; display: grid; gap: 0.55rem;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6); font-size: 0.82rem;
}
.box-pop-head { display: flex; justify-content: space-between; align-items: baseline; }
.box-row { display: grid; grid-template-columns: 78px minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; }
.box-row > span:first-child { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box-row .num { font-family: var(--mono); font-size: 0.72rem; }
.box-row .num.wide { grid-column: 2 / -1; }
.box-sub { margin: -0.35rem 0 0 calc(78px + 0.6rem); color: var(--dim); font-size: 0.72rem; font-family: var(--mono); }
.meter { display: block; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--mint), var(--cyan)); }
.meter[data-level="warn"] i { background: var(--amber); }
.meter[data-level="bad"] i { background: var(--red); }
.box-services { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.svc { display: inline-flex; align-items: center; gap: 0.35rem; font-family: var(--mono); font-size: 0.68rem; color: var(--dim); }
.svc i { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }
.svc.dead { color: var(--red); }
.svc.dead i { background: var(--red); }

.conn { display: inline-flex; align-items: center; gap: 0.45rem; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.conn.ok .conn-dot { background: var(--mint); color: var(--mint); box-shadow: 0 0 10px color-mix(in srgb, var(--mint) 70%, transparent); }
.conn.warn .conn-dot { background: var(--amber); color: var(--amber); }
.conn.warn { color: var(--amber); }
.conn.down .conn-dot { background: var(--red); color: var(--red); animation: pulse 1.6s infinite; }
.conn.wait .conn-dot { background: var(--cyan); color: var(--cyan); animation: pulse 1.6s infinite; }

.userchip {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none; text-decoration: none;
  font-weight: 700; font-size: 0.82rem; color: var(--text);
  background: linear-gradient(var(--bg2), var(--bg2)) padding-box, var(--grad) border-box; border: 1.5px solid transparent;
}

.banner {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem calc(1rem + var(--sr)) 0.5rem calc(1rem + var(--sl)); font-size: 0.82rem;
  color: var(--amber); background: color-mix(in srgb, var(--amber) 9%, var(--bg)); border-bottom: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
}
.banner.lost { color: var(--red); background: color-mix(in srgb, var(--red) 9%, var(--bg)); border-bottom-color: color-mix(in srgb, var(--red) 30%, transparent); }
.banner span { flex: 1; min-width: 0; }
.banner .linkbtn { color: inherit; border: 1px solid currentColor; padding: 3px 9px; flex: none; }

.views { min-height: 0; position: relative; overflow: hidden; }
.view { height: 100%; overflow-y: auto; overscroll-behavior: contain; }

.tabbar { display: none; }

/* ================= pages (toolbox, activity, settings) ================= */

.toolbox, .activity, .settings { padding: 1.6rem calc(1.4rem + var(--sr)) 3rem calc(1.4rem + var(--sl)); }
.toolbox > *, .activity > *, .settings > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
.page-head p { color: var(--dim); font-size: 0.9rem; margin-top: 0.15rem; }

/* toolbox */
.tb-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.tb-list { display: grid; gap: 0.5rem; }
.tb-card {
  display: flex; gap: 0.75rem; align-items: flex-start; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem 0.85rem;
  transition: border-color 0.15s, background 0.15s, transform 0.15s var(--ease);
}
.tb-card:hover { border-color: var(--line2); transform: translateY(-1px); }
.tb-card.active { background: linear-gradient(#0d0d1a, #0d0d1a) padding-box, var(--grad) border-box; border-color: transparent; }
.tb-ic { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: none; color: var(--cyan); background: color-mix(in srgb, var(--cyan) 10%, transparent); }
.tb-ic.big { width: 44px; height: 44px; border-radius: 12px; }
.tb-card.active .tb-ic { color: #04140c; background: linear-gradient(115deg, var(--mint), var(--cyan)); }
.tb-text { display: grid; gap: 0.1rem; min-width: 0; }
.tb-text strong { font-size: 0.92rem; }
.tb-text span { color: var(--dim); font-size: 0.8rem; line-height: 1.35; }
.tb-runner { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem 1.3rem; display: grid; gap: 1rem; min-width: 0; scroll-margin-top: 1rem; }
.tb-head { display: flex; gap: 0.9rem; align-items: center; }
.tb-head h2 { font-size: 1.15rem; }
.tb-head p { color: var(--dim); font-size: 0.86rem; }
.tb-form { display: grid; gap: 0.9rem; }
.tb-area { min-height: 180px; }
.tb-back { display: none; justify-self: start; }
.tb-result:empty { display: none; }
.tb-result { border-top: 1px solid var(--line); padding-top: 1rem; min-width: 0; }
.tb-result-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.6rem; font-family: var(--mono); font-size: 0.7rem; }
.tb-result-head .btn { margin-left: auto; }

/* ---- Generate image (docs/PROTOCOL.md §9) ---- */
textarea.tb-prompt { min-height: 96px; font-family: var(--sans); font-size: 0.92rem; }
.tb-image-opts { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0.8rem; align-items: start; }
.tb-model-desc { color: var(--dim); font-size: 0.78rem; line-height: 1.4; min-height: 1.2em; }
.tb-image { display: grid; justify-items: start; }
.tb-image-open, .md-img-open { padding: 0; border: 0; background: none; border-radius: 12px; overflow: hidden; line-height: 0; cursor: zoom-in; }
.tb-image-open:disabled, .md-img-open:disabled { cursor: progress; }
.tb-image-pic, .md-img-pic { display: block; max-width: min(100%, 560px); max-height: 60vh; width: auto; height: auto; border-radius: 12px; border: 1px solid var(--line2); background: #0b0b16; }
.tb-image-pic:not([src]), .md-img-pic:not([src]) { width: 240px; height: 180px; background: linear-gradient(135deg, #0d0d1a, #141428); }
.tb-image-actions .btn.ghost.danger.armed { background: color-mix(in srgb, var(--red) 22%, var(--bg2)); }
.tb-recent-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; border-top: 1px solid var(--line); padding-top: 0.9rem; }
.tb-recent-head h3 { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.tb-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 0.6rem; }
.tb-recent-empty { font-size: 0.84rem; }
.tb-thumb { display: grid; gap: 0.3rem; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); text-align: left; transition: border-color 0.15s, transform 0.15s var(--ease); }
.tb-thumb:hover:not(:disabled) { border-color: var(--line2); transform: translateY(-1px); }
.tb-thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #0b0b16; }
.tb-thumb.broken img { opacity: 0.3; }
.tb-thumb-meta { display: flex; justify-content: space-between; gap: 0.4rem; padding: 0 0.45rem 0.4rem; font-size: 0.7rem; min-width: 0; }
.tb-thumb-meta > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* a generated image inside markdown (a Zoe reply, a toolbox result) */
.md-img { margin: 0.65em 0 0; display: grid; justify-items: start; gap: 0.3rem; }
.md-img figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--dim); }
.md-img-alt { overflow-wrap: anywhere; }
.md-img-err { color: var(--red); }
.md-img.broken .md-img-open { display: none; }

/* the large view */
.lightbox { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 1rem; background: rgba(2, 2, 8, 0.86); backdrop-filter: blur(6px); animation: fade 0.15s var(--ease); }
.lightbox-inner { display: grid; gap: 0.7rem; justify-items: center; max-width: min(96vw, 1200px); max-height: calc(100dvh - 2rem); }
.lightbox-inner img { display: block; max-width: 100%; max-height: calc(100dvh - 6.5rem); width: auto; height: auto; border-radius: 12px; border: 1px solid var(--line2); background: #0b0b16; }
.lightbox-bar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; justify-content: center; width: 100%; }
.lightbox-cap { color: var(--dim); font-size: 0.82rem; flex: 1 1 100%; text-align: center; overflow-wrap: anywhere; }
@keyframes fade { from { opacity: 0; } }

/* activity */
.act-list { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; }
.act-row { display: grid; grid-template-columns: 70px 150px 270px minmax(0, 1fr); gap: 0.9rem; align-items: center; padding: 0.6rem 1rem; border-top: 1px solid var(--line); font-size: 0.86rem; }
.act-row:first-child { border-top: 0; }
.act-headrow { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); background: rgba(255, 255, 255, 0.02); }
.act-time { color: var(--dim); font-family: var(--mono); font-size: 0.74rem; }
.act-who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-what { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.act-sid { font-family: var(--mono); font-size: 0.72rem; color: var(--dim); }
.act-detail { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; }
.act-foot { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }

/* settings */
.set-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; align-items: start; }
.set-card { display: grid; gap: 0.9rem; }
.set-head { display: flex; gap: 0.8rem; align-items: flex-start; }
.set-head > div { flex: 1; min-width: 0; }
.set-head h2 { font-size: 1.02rem; }
.set-head p { color: var(--dim); font-size: 0.84rem; }
.set-ic { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none; color: var(--mint); background: color-mix(in srgb, var(--mint) 9%, transparent); }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.set-grid .field:last-child { grid-column: 1 / -1; }
.set-who { font-family: var(--mono); font-size: 0.8rem; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.switch-row > span:first-child { display: grid; gap: 0.1rem; min-width: 0; }
.switch-row strong { font-size: 0.9rem; font-weight: 600; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch input:disabled { cursor: default; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line2); transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--dim); transition: transform 0.2s var(--ease), background 0.2s; }
.switch input:checked + i { background: color-mix(in srgb, var(--mint) 30%, transparent); border-color: color-mix(in srgb, var(--mint) 55%, transparent); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--mint); }
.switch input:focus-visible + i { outline: 2px solid var(--mint); outline-offset: 2px; }
.switch input:disabled + i { opacity: 0.45; }
.about { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.3rem 1rem; font-size: 0.84rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.about dt { color: var(--dim); font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; align-self: center; }
.about dd { overflow-wrap: anywhere; }

/* ================= chat ================= */

.view.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); overflow: hidden; }

.rail { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: rgba(255, 255, 255, 0.012); padding-left: var(--sl); }
.rail-head { display: grid; gap: 0.6rem; padding: 0.9rem 0.8rem 0.6rem; }
.rail-new { width: 100%; }
.rail-searchwrap { position: relative; display: block; color: var(--dim); }
.rail-searchwrap .ic { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
.rail-search { padding-left: 2.1rem; min-height: 38px; font-size: 0.84rem; }
.rail-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 0.5rem calc(0.8rem + var(--sb)); }
.rail-section { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); padding: 0.8rem 0.5rem 0.3rem; }
.rail-empty { color: var(--dim); font-size: 0.84rem; padding: 1rem 0.5rem; }
.rail-more { margin: 0.4rem 0.3rem; }
.sess-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.55rem; border-radius: 10px; text-decoration: none; color: var(--text); border: 1px solid transparent; }
.sess-row:hover { background: var(--panel); }
.sess-row.active { background: var(--panel2); border-color: var(--line); }
.sess-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; border: 1px solid transparent; background: rgba(255, 255, 255, 0.1); }
.st-live .sess-dot { background: var(--cyan); border-color: var(--cyan); }
.st-running .sess-dot { background: var(--mint); border-color: var(--mint); color: var(--mint); animation: pulse 1.6s infinite; }
.st-waiting .sess-dot { background: var(--amber); border-color: var(--amber); color: var(--amber); animation: pulse 1.6s infinite; }
.st-error .sess-dot { background: var(--red); border-color: var(--red); }
.sess-main { display: grid; min-width: 0; flex: 1; }
.sess-name { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-sub { display: flex; gap: 0.5rem; color: var(--dim); font-size: 0.72rem; font-family: var(--mono); white-space: nowrap; overflow: hidden; }
.sess-sub > * { overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.sess-sub > .sess-by { flex-shrink: 3; }
.sess-sub > .sess-time, .sess-sub > .sess-state { flex: none; }
.sess-state { color: var(--mint); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.64rem; align-self: center; }
.st-waiting .sess-state { color: var(--amber); }
.st-error .sess-state { color: var(--red); }
.sess-sub > * + *::before { content: "·"; margin-right: 0.5rem; opacity: 0.6; }
.sess-folder { color: color-mix(in srgb, var(--cyan) 70%, var(--dim)); }
.scrim { display: none; }

.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.sess-head { display: flex; align-items: center; gap: 0.8rem 1rem; flex-wrap: wrap; padding: 0.6rem calc(1.2rem + var(--sr)) 0.6rem 1.2rem; border-bottom: 1px solid var(--line); }
.sess-head-main { display: flex; align-items: center; gap: 0.7rem; min-width: 0; flex: 1 1 260px; }
.sess-title { font-size: 1rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sess-chips { display: flex; gap: 0.4rem; flex: none; max-width: 50%; }
.chip.branch { color: var(--violet); }
.sess-head-ctl { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.recap { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--violet) 4%, transparent); }
.recap summary { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem calc(1.2rem + var(--sr)) 0.45rem 1.2rem; cursor: pointer; list-style: none; color: var(--dim); font-size: 0.82rem; min-height: 36px; }
.recap summary::-webkit-details-marker { display: none; }
.recap summary .ic:first-child { color: var(--violet); }
.recap-label { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--violet); flex: none; }
.recap-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recap-chev { display: inline-grid; transition: transform 0.2s var(--ease); }
.recap[open] .recap-chev { transform: rotate(180deg); }
.recap[open] .recap-preview { visibility: hidden; }
.recap-inner { padding: 0 calc(1.2rem + var(--sr)) 0.8rem 1.2rem; max-width: calc(var(--col) + 2.4rem); font-size: 0.9rem; max-height: 40vh; overflow-y: auto; }
.recap-foot { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.5rem; }
.recap.busy .recap-body { opacity: 0.5; }

.scrollwrap { flex: 1; min-height: 0; position: relative; }
.scroller { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 1.2rem calc(1.2rem + var(--sr)) 1rem 1.2rem; outline: none; }
.transcript-holder, .working { max-width: var(--col); margin: 0 auto; }
.transcript { display: flex; flex-direction: column; gap: 0.55rem; }

.is-new .scroller { display: grid; align-items: center; }
.hero { max-width: 640px; margin: 0 auto; text-align: center; display: grid; justify-items: center; gap: 0.8rem; padding: 1rem 0; }
.hero-mark { filter: drop-shadow(0 0 30px color-mix(in srgb, var(--cyan) 40%, transparent)); }
.hero h1 { font-size: clamp(1.35rem, 3.4vw, 1.9rem); letter-spacing: -0.015em; }
.hero-sub { color: var(--dim); max-width: 52ch; font-size: 0.92rem; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; margin-top: 0.3rem; }

.who { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.9rem; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.transcript > .who:first-child { margin-top: 0; }

.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; margin-top: 0.9rem; }
.transcript > .msg.user:first-child { margin-top: 0; }
.bubble {
  max-width: min(86%, 640px); padding: 0.6rem 0.9rem; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: linear-gradient(135deg, color-mix(in srgb, var(--mint) 13%, #0a0a14), color-mix(in srgb, var(--cyan) 11%, #0a0a14));
  border: 1px solid color-mix(in srgb, var(--mint) 24%, transparent);
}
.msg-meta { font-family: var(--mono); font-size: 0.62rem; color: var(--dim); letter-spacing: 0.06em; }
.msg.zoe { min-width: 0; }
.msg.zoe.streaming .md > :last-child::after { content: "▍"; color: var(--mint); margin-left: 2px; animation: blink 1s steps(1) infinite; }

/* markdown */
.md { overflow-wrap: anywhere; min-width: 0; }
.md > * + * { margin-top: 0.65em; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin-top: 1.1em; font-weight: 700; }
.md h1 { font-size: 1.25rem; } .md h2 { font-size: 1.12rem; } .md h3 { font-size: 1rem; } .md h4, .md h5, .md h6 { font-size: 0.92rem; color: var(--dim); }
.md > :first-child { margin-top: 0; }
.md ul, .md ol { padding-left: 1.4rem; }
.md li + li { margin-top: 0.2em; }
.md li > ul, .md li > ol { margin-top: 0.2em; }
.md li input[type="checkbox"] { margin-right: 0.4em; accent-color: var(--mint); }
.md code { font-family: var(--mono); font-size: 0.84em; background: rgba(255, 255, 255, 0.07); border-radius: 5px; padding: 0.1em 0.35em; }
.md blockquote { border-left: 3px solid color-mix(in srgb, var(--violet) 60%, transparent); padding: 0.1rem 0 0.1rem 0.9rem; color: var(--dim); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md a { color: var(--cyan); }
.md-code { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #08080f; }
.md-code-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.15rem 0.3rem 0.15rem 0.75rem; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.025); font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.1em; color: var(--dim); }
.md-code pre { margin: 0; padding: 0.7rem 0.85rem; overflow-x: auto; max-height: 460px; }
.md-code pre code { background: none; padding: 0; font-size: 0.8rem; line-height: 1.5; white-space: pre; overflow-wrap: normal; }
.md-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
.md th, .md td { padding: 0.4rem 0.7rem; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.md thead th { border-top: 0; background: rgba(255, 255, 255, 0.03); font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }

/* thought + tool cards */
.thought { font-size: 0.8rem; color: var(--dim); }
.thought.flat, .thought summary { display: flex; align-items: center; gap: 0.4rem; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; min-height: 26px; }
.thought summary { cursor: pointer; list-style: none; }
.thought summary::-webkit-details-marker { display: none; }
.thought summary:hover { color: var(--text); }
.thought .ic { color: var(--violet); }
.thought-peek { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; opacity: 0.7; font-family: var(--sans); letter-spacing: 0; font-style: italic; font-size: 0.78rem; }
.thought[open] .thought-peek { display: none; }
.thought-body { white-space: pre-wrap; overflow-wrap: anywhere; border-left: 2px solid color-mix(in srgb, var(--violet) 45%, transparent); padding: 0.2rem 0 0.2rem 0.8rem; margin: 0.2rem 0 0.2rem 0.4rem; font-style: italic; }

.tool { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); min-width: 0; }
.tool summary { display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.6rem; cursor: pointer; list-style: none; min-height: 38px; min-width: 0; }
.tool summary::-webkit-details-marker { display: none; }
.tool summary:hover { background: rgba(255, 255, 255, 0.025); border-radius: 10px; }
.tool-ic { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; flex: none; color: var(--cyan); background: color-mix(in srgb, var(--cyan) 10%, transparent); }
.tool-name { font-family: var(--mono); font-size: 0.74rem; font-weight: 700; flex: none; }
.tool-line { font-family: var(--mono); font-size: 0.74rem; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.tool-status { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; }
.tool-status.ok { color: var(--mint); }
.tool-status.fail { color: var(--red); }
.tool.fail { border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.tool-chev { display: inline-grid; color: var(--dim); transition: transform 0.2s var(--ease); flex: none; }
.tool[open] .tool-chev { transform: rotate(180deg); }
.tool[open] .tool-line { opacity: 0.55; }
.tool-body { padding: 0.2rem 0.7rem 0.7rem; display: grid; gap: 0.4rem; min-width: 0; border-top: 1px solid var(--line); }
.tool-label { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); margin-top: 0.4rem; }
.tool-out { display: grid; gap: 0.4rem; min-width: 0; }
.tool-outhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; }
.tool-actions { display: flex; gap: 0.2rem; margin-left: auto; }
.tool-summary { border: 1px solid color-mix(in srgb, var(--violet) 30%, transparent); background: color-mix(in srgb, var(--violet) 5%, transparent); border-radius: 10px; padding: 0.3rem 0.8rem 0.7rem; font-size: 0.88rem; min-width: 0; }
pre.code {
  font-family: var(--mono); font-size: 0.76rem; line-height: 1.5; background: #08080f; border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 0.75rem; overflow: auto; max-height: 320px; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0;
}
pre.code.out { max-height: 380px; }

/* permission card */
.perm { border-radius: 12px; min-width: 0; }
.perm.open {
  border: 1px solid transparent; padding: 0.8rem 0.9rem; display: grid; gap: 0.6rem;
  background: linear-gradient(color-mix(in srgb, var(--amber) 6%, #0a0a14), color-mix(in srgb, var(--amber) 6%, #0a0a14)) padding-box,
    linear-gradient(120deg, var(--amber), color-mix(in srgb, var(--amber) 25%, transparent)) border-box;
  box-shadow: 0 10px 40px color-mix(in srgb, var(--amber) 8%, transparent);
}
.perm-title { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; min-width: 0; }
.perm.open .perm-title .ic { color: var(--amber); }
.perm-body { display: grid; gap: 0.6rem; min-width: 0; }
.perm-line { max-height: 180px; }
.perm-more summary { cursor: pointer; font-family: var(--mono); font-size: 0.68rem; color: var(--dim); letter-spacing: 0.06em; }
.perm-more pre { margin-top: 0.4rem; }
.perm-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.perm.allowed, .perm.denied { font-size: 0.78rem; color: var(--dim); }
.perm.allowed .perm-title, .perm.denied .perm-title { font-size: 0.78rem; font-family: var(--mono); gap: 0.45rem; min-height: 26px; }
.perm.allowed .perm-title .ic { color: var(--mint); }
.perm.denied .perm-title .ic { color: var(--red); }
.perm-title > span { flex: none; max-width: 100%; }
.perm.open .perm-title > span { flex: 1; min-width: 0; }

.result { display: flex; align-items: center; gap: 0.45rem; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.04em; color: var(--dim); padding-top: 0.5rem; margin-top: 0.3rem; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.result.ok .ic { color: var(--mint); }
.result.fail { color: var(--red); }
.result-bits { color: var(--dim); }
.notice { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.8rem; color: var(--dim); padding: 0.4rem 0.7rem; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); overflow-wrap: anywhere; }
.notice .ic { margin-top: 2px; }
.notice.warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); background: color-mix(in srgb, var(--amber) 6%, transparent); }
.notice.error { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); background: color-mix(in srgb, var(--red) 7%, transparent); }
.notice span { min-width: 0; white-space: pre-wrap; }

.working { display: flex; align-items: center; gap: 0.6rem; color: var(--dim); font-size: 0.84rem; padding: 0.9rem 0 0.2rem; }
.working.waiting { color: var(--amber); }
.working.waiting .dots i { background: var(--amber); animation: none; opacity: 0.8; }

.jump {
  position: absolute; left: 50%; bottom: 0.7rem; transform: translateX(-50%); z-index: 5;
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.9rem; border-radius: 99px; min-height: 36px;
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em; color: var(--text);
  background: #12121f; border: 1px solid var(--line2); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.jump:hover { border-color: var(--mint); }
.drop-hint {
  position: absolute; inset: 0.6rem; z-index: 6; display: grid; place-content: center; justify-items: center; gap: 0.5rem; pointer-events: none;
  border: 2px dashed color-mix(in srgb, var(--mint) 60%, transparent); border-radius: 16px; color: var(--mint);
  background: color-mix(in srgb, var(--bg) 84%, transparent); font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.1em;
}

/* new-chat options + composer */
.newopts, .composer { width: calc(100% - 2.4rem - var(--sr)); max-width: var(--col); margin: 0 auto; }
.newopts { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 0.6rem; }
.composer {
  margin-bottom: 0.9rem; border-radius: 16px; border: 1px solid transparent; padding: 0.4rem 0.45rem 0.35rem;
  background: linear-gradient(#0c0c17, #0c0c17) padding-box, linear-gradient(var(--line2), var(--line2)) border-box;
  transition: box-shadow 0.2s;
}
.composer:focus-within { background: linear-gradient(#0c0c17, #0c0c17) padding-box, var(--grad) border-box; box-shadow: 0 10px 44px color-mix(in srgb, var(--cyan) 9%, transparent); }
.composer.blocked { opacity: 0.75; }
.composer-row { display: flex; align-items: flex-end; gap: 0.3rem; }
.composer-text {
  flex: 1; min-width: 0; background: none; border: 0; outline: none; resize: none; padding: 0.55rem 0.3rem; line-height: 1.45;
  font-size: 0.95rem; max-height: 40vh; overflow-y: hidden;
}
.sendbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 12px;
  color: #04140c; background: linear-gradient(115deg, var(--mint), var(--cyan)); transition: transform 0.15s var(--ease), filter 0.15s, opacity 0.15s;
}
.sendbtn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.sendbtn:disabled { opacity: 0.3; }
.sendbtn.stop { color: #fff; background: color-mix(in srgb, var(--red) 80%, #000); }
.composer.sending .sendbtn { animation: breathe 1s ease-in-out infinite; }
.composer-note { font-size: 0.7rem; color: var(--dim); padding: 0.1rem 0.5rem 0.15rem; min-height: 1.2rem; }
.composer-note:empty { display: none; }
.composer-note.warn { color: var(--amber); }
.thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.35rem 0.35rem 0.2rem; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.7); color: #fff; }
.chip.img { margin-top: 0.1rem; }

/* ================= toasts ================= */

#toasts { position: fixed; z-index: 90; left: 50%; top: calc(4rem + var(--st)); transform: translateX(-50%); display: grid; gap: 0.5rem; justify-items: center; width: min(92vw, 460px); pointer-events: none; }
.toast {
  pointer-events: auto; padding: 0.6rem 1rem; border-radius: 12px; font-size: 0.86rem; background: #13131f; border: 1px solid var(--line2);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55); animation: rise 0.25s var(--ease); max-width: 100%; overflow-wrap: anywhere;
}
.toast.ok { border-color: color-mix(in srgb, var(--mint) 50%, transparent); }
.toast.err { border-color: color-mix(in srgb, var(--red) 55%, transparent); color: #ffd9cc; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes rise { from { opacity: 0; transform: translateY(-8px); } }

/* settings: paired devices and the pairing code */
.dev-list { display: grid; }
.dev-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.dev-main { display: grid; gap: 0.15rem; min-width: 0; }
.dev-name { display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.5rem; min-width: 0; }
.dev-name strong { font-size: 0.9rem; font-weight: 600; overflow-wrap: anywhere; }
.dev-main small { color: var(--dim); font-size: 0.78rem; line-height: 1.4; overflow-wrap: anywhere; }
.dev-row.revoked .dev-name strong { color: var(--dim); text-decoration: line-through; }
.dev-row .btn { flex: none; white-space: normal; max-width: 46%; }
.dev-off { color: var(--dim); font-size: 0.84rem; padding: 0.7rem 0 0; border-top: 1px solid var(--line); }
.dev-card .btn.ghost.armed:not(.danger) { background: color-mix(in srgb, var(--amber) 20%, var(--bg2)); }
.code-box { display: grid; gap: 0.7rem; }
.code-line {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.7rem; padding: 0.8rem 0.9rem; border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--mint) 50%, transparent); background: color-mix(in srgb, var(--mint) 6%, transparent);
}
.code-new { flex: 1 1 auto; min-width: 0; font-family: var(--mono); font-size: 1.02rem; letter-spacing: 0.08em; color: var(--mint); user-select: all; -webkit-user-select: all; overflow-wrap: anywhere; }

/* ================= narrower ================= */

@media (max-width: 1100px) {
  .box-item[data-k="load"] { display: none; }
  .conn-label { display: none; }
  .view.chat { grid-template-columns: 264px minmax(0, 1fr); }
  .act-row { grid-template-columns: 60px 130px 230px minmax(0, 1fr); }
}

@media (max-width: 860px) {
  body { font-size: 15px; }
  /* 16px inputs: iOS zooms the page on anything smaller. */
  .input, .select, .composer-text, .input.sm, .select.sm, textarea.input { font-size: 16px; }

  .topbar { gap: 0.5rem; padding-left: calc(0.7rem + var(--sl)); padding-right: calc(0.8rem + var(--sr)); }
  body[data-view="chat"] .topbar .menu { display: inline-grid; }
  .tabs, .userchip, .brand-zoe { display: none; }
  .topbar-right { gap: 0.6rem; }
  .box { padding: 0.25rem 0.55rem; gap: 0.55rem; }
  .box > .ic { display: none; }

  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 92%, #fff 0%); padding: 0.25rem calc(0.4rem + var(--sr)) calc(0.25rem + var(--sb)) calc(0.4rem + var(--sl));
  }
  .tabbar a { display: grid; justify-items: center; gap: 0.1rem; padding: 0.35rem 0; border-radius: 10px; text-decoration: none; color: var(--dim); font-size: 0.64rem; letter-spacing: 0.04em; min-height: 48px; align-content: center; }
  .tabbar a.active { color: var(--mint); }
  html.kb .tabbar { display: none; }

  .view.chat { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(86vw, 330px); background: #08080f;
    padding-top: var(--st); transform: translateX(-102%); transition: transform 0.26s var(--ease); box-shadow: 30px 0 80px rgba(0, 0, 0, 0.6);
    visibility: hidden;
  }
  body.rail-open .rail { transform: none; visibility: visible; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.55); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  body.rail-open .scrim { opacity: 1; pointer-events: auto; }
  .sess-row { padding: 0.65rem 0.55rem; }

  .sess-head { padding: 0.5rem calc(0.8rem + var(--sr)) 0.5rem calc(0.8rem + var(--sl)); gap: 0.45rem; }
  .sess-head-main { flex-basis: 100%; }
  .sess-head-ctl { width: 100%; flex-wrap: nowrap; }
  .sess-head-ctl .select.sm { flex: 1 1 0; max-width: none; min-width: 0; min-height: 38px; }
  .sess-head-ctl .select.sm:first-child { flex-grow: 1.5; }
  .sess-head-ctl .btn { flex: none; min-height: 38px; }
  /* Phone: the close button is an icon until it is armed. */
  .sess-close:not(.armed) span { display: none; }
  .sess-close:not(.armed) { padding: 0; width: 42px; }
  .sess-chips { flex: 0 1 auto; min-width: 0; max-width: 45%; }
  .sess-chips .branch { display: none; }
  .sess-title { flex: 1 1 auto; }
  .recap summary, .recap-inner { padding-left: calc(0.8rem + var(--sl)); padding-right: calc(0.8rem + var(--sr)); }
  .scroller { padding: 0.9rem calc(0.8rem + var(--sr)) 0.8rem calc(0.8rem + var(--sl)); }
  .bubble { max-width: 92%; }
  .newopts, .composer { width: calc(100% - 1.2rem - var(--sl) - var(--sr)); }
  .newopts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
  .newopts .field > span { font-size: 0.58rem; }
  .composer { margin-bottom: 0.5rem; }
  html.kb .composer { margin-bottom: calc(0.4rem + var(--sb)); }
  .hero { gap: 0.6rem; }
  .hero-mark { width: 64px; height: 64px; }
  .hero-sub { font-size: 0.86rem; }
  .perm-actions .btn { flex: 1 1 auto; }

  .toolbox, .activity, .settings { padding: 1.1rem calc(0.9rem + var(--sr)) 2rem calc(0.9rem + var(--sl)); }
  .page-head h1 { font-size: 1.3rem; }
  .tb-grid { grid-template-columns: minmax(0, 1fr); }
  .toolbox.has-active .tb-list { display: none; }
  .toolbox:not(.has-active) .tb-runner { display: none; }
  .tb-back { display: inline-flex; }
  .tb-runner { padding: 1rem; }
  .tb-image-opts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tb-image-opts .tb-model { grid-column: 1 / -1; }
  .tb-recent { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .tb-image-pic, .md-img-pic { max-width: 100%; max-height: 70vh; }
  .set-cols { grid-template-columns: minmax(0, 1fr); }

  .act-row { grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 0.6rem; padding: 0.65rem 0.8rem; }
  .act-headrow { display: none; }
  .act-who { grid-column: 1; grid-row: 1; }
  .act-time { grid-column: 2; grid-row: 1; text-align: right; }
  .act-what { grid-column: 1 / -1; grid-row: 2; }
  .act-detail { grid-column: 1 / -1; grid-row: 3; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .act-detail:empty { display: none; }
}

@media (max-width: 400px) {
  .brand-name { font-size: 0.95rem; }
  .box { font-size: 0.64rem; gap: 0.45rem; padding: 0.25rem 0.45rem; }
  .set-grid { grid-template-columns: minmax(0, 1fr); }
  .gate-card { padding: 2rem 1.2rem 1.6rem; }
}
