/* ============================================================
   OC Mobile — design system
   Neutral surfaces, one accent, iOS-grade rhythm.
   ============================================================ */

:root {
  /* Warm paper + ink: the whole shell reads like a printed page rather than a
     dashboard, which keeps long reading sessions (chat, logs) calm. */
  --bg: #f6f4ef;
  --bg-elev: #fffefb;
  --fg: #1a1713;
  --fg-soft: #4a453c;
  --muted: #857e72;
  --line: rgba(26, 23, 19, 0.085);
  --line-strong: rgba(26, 23, 19, 0.16);
  --accent: #a8322a;
  --accent-soft: rgba(168, 50, 42, 0.08);
  --accent-strong: #8c2620;
  --user-bubble: #ece8e0;
  --code-bg: #f1eee7;
  --danger: #b3382c;
  --ok: #1f7a58;
  --warn: #a86a10;
  --shadow-card: 0 1px 0 rgba(60, 48, 30, 0.03), 0 2px 10px rgba(60, 48, 30, 0.04);
  --shadow-float: 0 18px 48px rgba(60, 48, 30, 0.16);
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", serif;
  --r-card: 18px;
  --r-btn: 14px;
  --r-sheet: 26px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  /* Coordinate-paper grid: fine rule every step, one heavier rule every fifth. */
  --grid-step: 24px;
  --grid-step-5: 120px;
  --grid-line: rgba(74, 62, 43, 0.05);
  --grid-major: rgba(74, 62, 43, 0.075);
  --paper-light: radial-gradient(120% 62% at 50% -18%, rgba(255, 254, 249, 0.9), transparent 62%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0e;
    --bg-elev: #17171a;
    --fg: #f4f2ed;
    --fg-soft: #c7c2b9;
    --muted: #8d877d;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.18);
    --accent: #dc604d;
    --accent-soft: rgba(220, 96, 77, 0.15);
    --accent-strong: #c34a39;
    --user-bubble: #24242a;
    --code-bg: #101012;
    --danger: #f0574a;
    --ok: #34c98a;
    --warn: #f0a83c;
    --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.02);
    --shadow-float: 0 18px 50px rgba(0, 0, 0, 0.65);
    /* On ink the rule must be light, and fainter still — white lines read
       louder than dark ones at the same alpha. */
    --grid-line: rgba(255, 246, 230, 0.026);
    --grid-major: rgba(255, 246, 230, 0.042);
    --paper-light:
      radial-gradient(120% 58% at 50% -14%, rgba(255, 246, 232, 0.05), transparent 60%),
      radial-gradient(52% 34% at 50% 26%, rgba(220, 96, 77, 0.07), transparent 72%);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
/* With the keyboard up the home indicator is covered anyway — don't waste the
   extra 34px above the keys. */
body.kb-open { --safe-bottom: 0px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
::selection { background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* 纸的底子：一层暖光 + 一层坐标纸格线。格线是印刷裁切台的量规，不是仪表盘 —
   1px、5% 浓度、每五格加重一档，往下渐渐化开，正文区域永远干净。 */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    var(--paper-light),
    repeating-linear-gradient(to right, var(--grid-major) 0 1px, transparent 1px var(--grid-step-5)),
    repeating-linear-gradient(to bottom, var(--grid-major) 0 1px, transparent 1px var(--grid-step-5)),
    repeating-linear-gradient(to right, var(--grid-line) 0 1px, transparent 1px var(--grid-step)),
    repeating-linear-gradient(to bottom, var(--grid-line) 0 1px, transparent 1px var(--grid-step));
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 97%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 97%);
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  /* The light source comes from --paper-light now, so the grid layers survive. */
  body::after { opacity: 0.35; }
}

.app {
  position: fixed;
  top: var(--app-top, 0px);
  left: 0;
  right: 0;
  z-index: 1;
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
}

.embed-tip {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px; padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 9%, var(--bg-elev));
  border: 0.5px solid color-mix(in srgb, var(--warn) 22%, transparent);
  font-size: 12px; line-height: 1.55; color: var(--fg-soft);
}
.embed-tip span { flex: 1; }
.embed-tip button {
  flex: none; font-size: 12px; font-weight: 650; color: var(--accent);
  padding: 5px 9px; border-radius: 8px; background: var(--bg-elev);
}

/* ---------- boot ---------- */
.boot {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; color: var(--muted); font-size: 13px; letter-spacing: 0.01em;
}
.boot-mark {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- shared icon button ---------- */
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--fg-soft);
  transition: background 0.16s, transform 0.12s;
  flex: none;
}
.icon-btn:active { background: var(--user-bubble); transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 650;
  display: inline-grid; place-items: center; line-height: 1;
}

/* ============================================================
   Home
   ============================================================ */

.home-hero {
  flex: none;
  padding: calc(var(--safe-top) + 10px) 20px 14px;
}
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.brand-btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 4px 8px 4px 4px; margin-left: -4px; border-radius: 12px;
}
.brand-btn:active { background: var(--user-bubble); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: #111214;
  box-shadow: 0 2px 8px rgba(22, 24, 29, 0.16);
}
.brand-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
.brand-on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .brand-on-light { display: none !important; }
  .brand-on-dark { display: block !important; }
}
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; color: var(--fg); }
.brand-btn .dev-chev { width: 14px; height: 14px; display: grid; place-items: center; color: var(--muted); }
.brand-btn .dev-chev svg { width: 14px; height: 14px; }
.hero-actions { display: flex; gap: 2px; }

.hero-kicker {
  margin: 22px 0 0;
  font-size: 10px; font-weight: 650; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.hero-title {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 40px; line-height: 1.06; font-weight: 600; letter-spacing: -0.01em;
}
.hero-sub {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 9px 0 0;
  font-size: 12.5px; color: var(--muted); letter-spacing: 0.005em;
}
.hero-sub .dev-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--line-strong); flex: none;
}
.hero-sub .dev-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 16%, transparent);
}
.hero-sub .dot-sep { opacity: 0.45; }

.list-wrap {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 16px calc(16px + var(--safe-bottom));
  overscroll-behavior: contain;
  touch-action: pan-y;
}

/* search */
.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-elev);
  border-radius: 13px; padding: 0 13px;
  height: 42px; margin: 2px 0 12px;
  box-shadow: var(--shadow-card);
}
.search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 16px; letter-spacing: -0.01em;
}
.search input::placeholder { color: var(--muted); }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }

/* filter chips */
.chips { display: flex; gap: 8px; margin: 0 0 14px; }
.chip {
  height: 34px; padding: 0 15px; border-radius: 17px;
  background: var(--bg-elev); color: var(--fg-soft);
  font-size: 13.5px; font-weight: 500; letter-spacing: -0.005em;
  box-shadow: var(--shadow-card);
  transition: background 0.16s, color 0.16s, transform 0.12s;
}
.chip:active { transform: scale(0.96); }
.chip.on { background: var(--fg); color: var(--bg); box-shadow: none; font-weight: 600; }

/* section label */
.sect { margin-bottom: 18px; }
.sect-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.07em; text-transform: uppercase;
  margin: 0 2px 9px;
}

/* task card */
.day-band {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--muted); margin: 16px 4px 8px;
}
.day-band:first-child { margin-top: 2px; }
.task-card {
  position: relative;
  background: var(--bg-elev);
  border-radius: var(--r-card);
  padding: 13px 15px;
  margin-bottom: 8px;
  box-shadow: 0 0 0 0.5px var(--line), var(--shadow-card);
  transition: transform 0.14s cubic-bezier(0.2, 0.8, 0.3, 1), box-shadow 0.16s;
}
.task-card:active { transform: scale(0.978); }
/* A 2.5px rail on the left carries the only state that matters at a glance. */
.task-card.run::before,
.task-card.fail::before {
  content: ''; position: absolute; left: 7px; top: 15px; bottom: 15px;
  width: 2.5px; border-radius: 2px; background: var(--accent);
}
.task-card.fail::before { background: var(--danger); }
.task-card.run::before { animation: railPulse 1.9s ease-in-out infinite; }
@keyframes railPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.task-card.run, .task-card.fail { padding-left: 19px; }
.task-title {
  font-size: 15.5px; font-weight: 580; line-height: 1.36; letter-spacing: -0.012em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-meta {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted); margin-top: 6px; letter-spacing: 0.005em;
  min-height: 17px;
}
.task-meta .proj {
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--fg-soft); font-weight: 500;
}
.task-meta .proj::after { content: '·'; margin-left: 7px; opacity: 0.4; }
.task-meta .tc-right {
  flex: none;
  display: inline-flex; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums;
}
.task-meta .task-tag { margin-left: auto; }
.task-meta .tc-dot { opacity: 0.45; }
.task-tag {
  flex: none; font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em;
  padding: 2.5px 7px; border-radius: 6px;
}
.task-tag.running { color: var(--accent); background: var(--accent-soft); }
.task-tag.done { color: var(--muted); background: var(--user-bubble); }
.task-tag.failed { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.task-tag.draft { color: var(--fg-soft); background: var(--user-bubble); }

/* section header with a right-aligned "see all" */
.sect-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 2px 9px;
}
.sect-head .sect-label { margin: 0; }
.sect-all {
  display: inline-flex; align-items: center; gap: 1px; flex: none;
  font-size: 11.5px; font-weight: 550; color: var(--muted); white-space: nowrap;
  padding: 2px 0 2px 10px; margin: -2px 0;
}
.sect-all svg { width: 13px; height: 13px; opacity: 0.65; }
.sect-all:active { opacity: 0.5; }

/* new task */
.list-footer {
  flex: none; padding: 10px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 68%, transparent);
}
.new-task-btn {
  width: 100%; height: 52px; border-radius: var(--r-btn);
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 26%, transparent);
  transition: transform 0.14s, opacity 0.15s;
}
.new-task-btn:active { transform: scale(0.975); opacity: 0.94; }
.new-task-btn svg { width: 20px; height: 20px; }

/* empty / skeleton */
.empty {
  text-align: center; color: var(--muted); padding: 70px 24px; font-size: 14px;
}
.empty strong { display: block; color: var(--fg-soft); font-size: 16px; margin-bottom: 6px; font-weight: 600; }
.empty-task {
  text-align: center; color: var(--muted); padding: 60px 26px; font-size: 13.5px; line-height: 1.65;
}
.empty-task .empty-ico {
  width: 54px; height: 54px; border-radius: 17px; margin: 0 auto 18px;
  display: grid; place-items: center;
  background: var(--bg-elev); color: var(--accent);
  box-shadow: var(--shadow-card);
}
.empty-task .empty-ico svg { width: 26px; height: 26px; }
.empty-task strong { display: block; color: var(--fg); font-size: 17px; font-weight: 650; margin-bottom: 8px; }
.empty-task p { margin: 0; }

.skeleton { padding: 6px 0 18px; }
.sk-row { display: flex; gap: 11px; align-items: center; margin-bottom: 14px; }
.sk-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--line); flex: none; }
.sk-lines { flex: 1; display: grid; gap: 8px; }
.sk-line, .sk-block {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 40%, var(--bg-elev)) 50%, var(--line) 75%);
  background-size: 240% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk-block { height: 96px; border-radius: var(--r-card); margin-bottom: 14px; }
.sk-gap { height: 14px; }
.w30 { width: 30%; } .w40 { width: 40%; } .w45 { width: 45%; } .w55 { width: 55%; }
.w60 { width: 60%; } .w70 { width: 70%; } .w75 { width: 75%; } .w80 { width: 80%; } .w85 { width: 85%; } .w90 { width: 90%; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }


/* ---------- home ---------- */
.menu-btn {
  width: 40px; height: 40px; margin-left: -6px; border-radius: 12px;
  display: grid; place-items: center; color: var(--fg-soft);
  transition: background 0.15s, transform 0.12s, color 0.15s;
}
.menu-btn:active { background: var(--user-bubble); color: var(--fg); transform: scale(0.94); }
.menu-btn svg { width: 22px; height: 22px; }

.home-hero.compact { padding-bottom: 10px; }

/* Slim chrome only — the brand and the device state moved into the stage, so
   the header keeps nothing but the drawer, balance, alerts and settings. */
.home-head {
  flex: none;
  display: flex; align-items: center; gap: 6px;
  width: 100%; max-width: 720px; margin: 0 auto;
  padding: calc(var(--safe-top) + 8px) 12px 0;
}
.home-head .grow { flex: 1; min-width: 0; }

/* The stage centres itself in the leftover height. `margin: auto 0` (instead of
   justify-content: center) keeps the top edge reachable when the keyboard is up
   and the stage no longer fits. */
.home-body {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
  /* Extra bottom room lifts the stage a hair above true centre — optical
     centring always sits a little higher than the geometric middle. */
  padding: 0 22px calc(44px + var(--safe-bottom));
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.home-stage {
  margin: auto 0;
  margin-inline: auto;
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column;
  padding: 12px 0;
}

/* Staggered entrance — each block arrives 55ms after the one above it, which
   reads as "composed" rather than "sprang in all at once". */
.home-stage > * { animation: rise 0.62s cubic-bezier(0.16, 0.84, 0.3, 1) both; }
.home-stage > *:nth-child(1) { animation-delay: 0.02s; }
.home-stage > *:nth-child(2) { animation-delay: 0.07s; }
.home-stage > *:nth-child(3) { animation-delay: 0.12s; }
.home-stage > *:nth-child(4) { animation-delay: 0.17s; }
/* A cold start already paints a complete static frame from index.html. Running
   the staggered fade on top of it reads as a second blank screen. */
body.ocm-cold .home-stage > * { animation: none; }
/* Every render after the first replaces the same DOM; replaying the stagger
   there reads as a flash, not an entrance. */
.app.no-enter .home-stage > * { animation: none; }
@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

/* ---------- epigraph ---------- */
/* The page opens like a printed sheet: a quiet salutation, one line of type
   set large, then the machine state in small caps. No logo — the words do the
   branding. */
.ask-hero {
  position: relative; text-align: center; margin: 0 0 28px;
  padding-top: 2px;
}
/* A warm light source behind the type. Very low opacity — you should feel it
   before you see it. */
.ask-hero::before {
  content: "";
  position: absolute; left: 50%; top: -150px;
  width: 520px; height: 420px; transform: translateX(-50%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 5%, transparent), transparent 88%);
  pointer-events: none; z-index: -1;
}
.ask-kicker {
  margin: 0 0 15px;
  font-size: 12px; line-height: 1.4; font-weight: 500;
  letter-spacing: 0.16em; text-indent: 0.16em;
  color: var(--muted);
}
.ask-quote {
  margin: 0 0 19px;
  font-family: var(--serif);
  font-size: 31px; line-height: 1.5; font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--fg);
  text-wrap: balance;
}
.q-line { display: block; }
/* The last line is its own shrink-wrapped box so the seal can hang off its
   right edge without dragging the type off centre. */
.q-txt { position: relative; display: inline-block; }
/* 朱笔圈点 — a hairline of cinnabar under the two words that carry the
   antithesis, the way a reader would pencil a mark in a book margin. A wash
   behind the glyphs read as a highlighter; a rule reads as typography. */
.q-em {
  padding-bottom: 2px;
  border-bottom: 2px solid color-mix(in srgb, var(--accent) 34%, transparent);
}
/* A maker's seal, set on the last line like a signature at the foot of a
   scroll. Small enough to read as punctuation, not as a badge. */
.q-seal {
  position: absolute; left: 100%; bottom: 0.3em;
  display: inline-grid; place-items: center;
  font-size: 0.36em;              /* ≈11px on a 31px line */
  width: 1.85em; height: 1.85em;  /* ≈20px square */
  margin-left: -0.12em;
  transform: rotate(-2.5deg);
  border-radius: 0.14em;
  background: var(--accent);
  color: #fff;
  font-family: var(--serif);
  font-weight: 600; letter-spacing: 0;
  line-height: 1; text-indent: 0;
  opacity: 0.88;
}
.ask-sub {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0; font-size: 11.5px; color: var(--muted);
  letter-spacing: 0.05em;
  max-width: 100%;
}
.ask-sub > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-sub .dev-dot {
  width: 5px; height: 5px; border-radius: 50%; flex: none;
  background: var(--line-strong);
}
.ask-sub .dev-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 14%, transparent);
}
.ask-sub.off { color: var(--warn); }

/* ---------- composer ---------- */
.quick-card {
  position: relative;
  background: var(--bg-elev);
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow:
    0 1px 2px rgba(60, 48, 30, 0.03),
    0 26px 60px -32px rgba(60, 48, 30, 0.4);
  transition: box-shadow 0.28s ease, border-color 0.28s ease;
}
.quick-card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent),
    0 30px 70px -34px rgba(60, 48, 30, 0.5);
}
.quick-card textarea {
  display: block; width: 100%;
  border: 0; outline: 0; background: transparent; resize: none;
  padding: 18px 18px 4px;
  font-size: 16.5px; line-height: 1.55; letter-spacing: -0.005em;
  min-height: 78px; max-height: 168px;
}
.quick-card textarea::placeholder { color: var(--muted); opacity: 0.85; }
.quick-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}
.target-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 8px; border-radius: 9px;
  background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 500; letter-spacing: 0.01em; max-width: 64%;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.target-btn:active { background: var(--user-bubble); color: var(--fg-soft); transform: scale(0.98); }
.target-btn svg { width: 14px; height: 14px; flex: none; opacity: 0.6; }
.target-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-send {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: transparent; color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  display: grid; place-items: center;
  transition: background 0.22s, color 0.22s, box-shadow 0.22s, transform 0.12s;
}
.quick-send.ready {
  background: var(--accent); color: #fff;
  box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--accent) 75%, transparent);
}
.quick-send:active { transform: scale(0.9); }
.quick-send svg { width: 18px; height: 18px; }

/* ---------- below the composer ---------- */
.ask-foot { margin-top: 22px; }
.run-row {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 100%;
  padding: 9px 12px; margin-bottom: 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ok) 7%, transparent);
  font-size: 12px; color: var(--fg-soft); text-align: left;
  transition: background 0.15s;
}
.run-row:active { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.run-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 14%, transparent);
  animation: pulse 1.9s ease-in-out infinite;
}
.run-k {
  flex: none; font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em;
  color: color-mix(in srgb, var(--ok) 88%, var(--fg));
}
.run-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-go { flex: none; color: var(--muted); display: grid; place-items: center; }
.run-go svg { width: 12px; height: 12px; }

/* Colophon line: the page signs off like a printed sheet — navigation on the
   left, today's date on the right, separated from the composer by a hairline. */
.stage-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-top: 6px; padding-top: 13px;
  border-top: 1px solid var(--line);
}
.stage-link {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 6px 10px 6px 8px; margin-left: -8px; border-radius: 9px;
  font-size: 11.5px; color: var(--muted); letter-spacing: 0.035em;
  transition: background 0.15s, color 0.15s;
}
.stage-link:active { background: var(--user-bubble); color: var(--fg-soft); }
.stage-link svg { width: 11px; height: 11px; opacity: 0.45; }
.stage-date {
  font-size: 11px; color: var(--muted); letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
  /* In the dark the tile would be a bright white slab, so the monogram stands
     on its own — just the gradient strokes on ink. */
  .drawer-mark, .login .logo {
    background: transparent !important;
    box-shadow: none !important;
  }
  .drawer-mark img, .login .logo img {
    object-fit: contain;
    transform: scale(1.3);
  }
  /* On ink the accent glow turns into a maroon smudge — the dark keeps a clean
     field and lets the type carry the colour. */
  .ask-hero::before { display: none; }
  /* Cinnabar at 34% over near-black goes muddy; lift it so the rule holds. */
  .q-em {
    border-bottom-color: color-mix(in srgb, var(--accent) 52%, transparent);
  }
  .quick-card {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 26px 60px -34px rgba(0, 0, 0, 0.8);
  }
  .quick-card:focus-within {
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent),
      0 30px 70px -34px rgba(0, 0, 0, 0.85);
  }
}

.tasks-head {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: calc(var(--safe-top) + 6px) 10px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.tasks-head .grow { flex: 1; min-width: 0; padding-left: 2px; }
.tasks-head h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.tasks-head .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   Task detail
   ============================================================ */

.topbar {
  position: relative; z-index: 30; flex: none;
  padding: calc(var(--safe-top) + 6px) 8px 8px;
  display: flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
}
.topbar .grow { flex: 1; min-width: 0; }
.topbar .grow.center { text-align: center; }
.topbar h1 {
  font-size: 16px; font-weight: 620; margin: 0; letter-spacing: -0.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .sub {
  font-size: 11.5px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .icon-btn { width: 40px; height: 40px; }
.topbar .icon-btn svg { width: 21px; height: 21px; }

.status-bar { flex: none; display: none; }
.status-bar.running {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px;
  background: color-mix(in srgb, var(--accent) 4.5%, var(--bg));
  border-bottom: 0.5px solid color-mix(in srgb, var(--accent) 12%, transparent);
}
.sb-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--accent);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 16%, transparent);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.4; } }
.sb-text { flex: 1; font-size: 12.5px; color: var(--fg-soft); letter-spacing: 0.005em; }
.sb-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sb-stop {
  font-size: 12.5px; font-weight: 600; color: var(--danger);
  padding: 5px 10px; border-radius: 9px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.chat-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 16px 16px 8px;
  overscroll-behavior: contain;
  /* Do NOT lock this to pan-y: iOS WebKit inherits the restriction down the
     ancestor chain, which kills horizontal swipes on .dv-scroll / .am-strip /
     .table-wrap even when those containers explicitly allow pan-x. The page
     itself cannot be panned sideways anyway (overflow-x: hidden), and the
     inner strips use overscroll-behavior-inline: contain, so nothing leaks. */
  touch-action: pan-x pan-y;
}
.chat-inner { max-width: 820px; min-width: 0; margin: 0 auto; }

.turn { margin-bottom: 21px; min-width: 0; }

.task-instruction {
  min-width: 0; max-width: 100%;
  background: var(--bg-elev);
  border-radius: var(--r-card);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.task-instruction::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: 0.9;
}
.ti-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 6px;
}
.ti-label i {
  font-style: normal; font-weight: 500; letter-spacing: 0.02em;
  text-transform: none; opacity: 0.55; margin-left: 7px;
  font-variant-numeric: tabular-nums;
}
.ti-copy {
  width: 26px; height: 26px; margin: -6px -8px -6px 0; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.ti-copy:active { background: var(--user-bubble); color: var(--fg); }
.ti-copy svg { width: 14px; height: 14px; }
.ti-text {
  font-size: 15.5px; line-height: 1.58;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ti-files { display: flex; gap: 7px; margin-top: 10px; }
.ti-files img { width: 60px; height: 60px; object-fit: cover; border-radius: 10px; }

/* activity stream — the agent's work reads like a transcript, not a drawer */
.acts {
  min-width: 0; max-width: 100%;
  background: var(--bg-elev);
  border-radius: var(--r-card);
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.acts-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 13px 11px 14px;
  user-select: none;
}
.acts-pulse {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--line-strong);
}
.acts-pulse.on {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
  animation: pulse 1.6s ease-in-out infinite;
}
.acts-pulse.err { background: var(--danger); }
.acts-title { font-size: 12.5px; font-weight: 620; color: var(--fg); letter-spacing: -0.01em; }
.acts.live .acts-title { color: var(--accent); }
.acts-meta {
  flex: 1; min-width: 0; font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acts-toggle {
  flex: none; font-size: 11.5px; color: var(--muted);
  padding: 3px 7px; margin: -3px -4px -3px 0; border-radius: 8px;
}
.acts-toggle:active { background: var(--user-bubble); color: var(--fg-soft); }
.acts-body { border-top: 0.5px solid var(--line); padding: 7px 0 9px; }
.acts-body[hidden] { display: none; }

.step-list { padding: 0; }
.step { display: block; position: relative; }
.step::before {
  content: ""; position: absolute; left: 19.5px; top: 22px; bottom: 0;
  width: 1px; background: var(--line);
}
.step:last-child::before { display: none; }
.step > summary {
  display: flex; gap: 9px; padding: 6px 14px;
  list-style: none; user-select: none; -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary:active { background: var(--user-bubble); }
.step-rail { width: 8px; flex: none; position: relative; }
.step-dot {
  display: block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg-elev); margin-top: 4px; position: relative; z-index: 1;
  box-shadow: inset 0 0 0 2px var(--line-strong);
}
.step.completed .step-dot { box-shadow: inset 0 0 0 2px var(--ok); }
.step.running .step-dot {
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
  animation: pulse 1.2s infinite;
}
.step.error .step-dot { box-shadow: inset 0 0 0 2px var(--danger); }
.step-body { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: flex-start; }
.step-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* The frame that step just captured — a thumbnail, never a full-size image, so
   it can sit in the row without pushing anything around. */
.step-thumb {
  flex: none; width: 56px; height: 38px; padding: 0; margin-top: 1px;
  border: 0; border-radius: 7px; overflow: hidden; cursor: zoom-in;
  background: var(--code-bg); box-shadow: inset 0 0 0 1px var(--line);
}
.step-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.step-thumb:active { opacity: 0.85; }
.step-page {
  font-size: 11px; color: var(--muted); opacity: 0.75;
  margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.step-head { display: flex; align-items: baseline; gap: 8px; }
.step-name {
  font-size: 13px; font-weight: 600; color: var(--fg-soft);
  letter-spacing: -0.005em;
}
.step-dur { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.step-status { font-size: 10.5px; font-weight: 500; color: var(--danger); }
.step-chev {
  margin-left: auto; width: 15px; height: 15px; flex: none;
  display: grid; place-items: center; color: var(--muted); opacity: 0.5;
  transition: transform 0.18s ease;
}
.step-chev svg { width: 13px; height: 13px; }
.step[open] .step-chev { transform: rotate(180deg); }
.step-sum {
  display: block;
  font-size: 12px; color: var(--muted);
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.005em;
}
/* a step in flight — three quiet dots so the run never looks frozen */
.step-live { display: inline-flex; gap: 3px; margin-left: 2px; }
.step-live i {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--accent); opacity: 0.35;
  animation: stepPulse 1.1s ease-in-out infinite;
}
.step-live i:nth-child(2) { animation-delay: 0.16s; }
.step-live i:nth-child(3) { animation-delay: 0.32s; }
@keyframes stepPulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-1.5px); }
}
/* the current line of a running command — proof the agent is alive */
.step-tail {
  display: block; margin-top: 3px;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.4;
  color: var(--muted); opacity: 0.8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  direction: ltr;
}
.turn-receipt {
  font-size: 11.5px; color: var(--muted);
  margin: 4px 0 2px; letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.turn-receipt.bad { color: color-mix(in srgb, var(--danger) 78%, var(--muted)); }

/* step detail (input / output / error) */
.step-detail { padding: 1px 16px 10px 34px; }
.sd-block {
  border-radius: 10px; background: var(--user-bubble);
  overflow: hidden;
}
.sd-block + .sd-block { margin-top: 8px; }
.sd-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 10px 2px; }
.sd-label {
  font-size: 10px; font-weight: 650; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
}
.sd-copy {
  font-size: 11px; color: var(--muted); padding: 2px 7px; border-radius: 6px;
}
.sd-copy:active { background: var(--accent-soft); color: var(--accent); }
.sd-pre {
  margin: 0; padding: 2px 10px 9px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  color: var(--fg-soft);
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  max-height: 240px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sd-block.err { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.sd-block.err .sd-label { color: var(--danger); }

/* tool-generated images (screenshots / QR codes) */
.sd-imgs { display: flex; flex-direction: column; gap: 8px; margin: 0 0 8px; }
.sd-img {
  padding: 0; border: 0; background: transparent; display: block;
  border-radius: 12px; overflow: hidden; cursor: zoom-in;
  box-shadow: inset 0 0 0 1px var(--line);
}
.sd-img img { display: block; width: 100%; height: auto; }
.sd-img:active { opacity: 0.85; }

/* The agent's screen, parked above the composer instead of inside the thread.
   Collapsed it is a 52px bar; opened it borrows a slice of the screen and the
   thread shrinks above it, so text is never covered — only resized. */
.media-dock {
  flex: none; margin: 0 12px 6px;
  background: var(--bg-elev);
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card);
  overflow: hidden;
}
.md-bar {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 10px 6px 6px; border: 0; background: transparent;
  text-align: left; font: inherit; color: var(--fg);
  min-height: 52px;
}
.md-bar:active { background: color-mix(in srgb, var(--fg) 5%, transparent); }
/* A frame the reader has not opened yet: pulse the border instead of pushing
   the thread around. */
.media-dock.fresh { animation: md-flash 1.4s ease-out 2; }
@keyframes md-flash {
  0% {
    box-shadow: inset 0 0 0 1px var(--accent),
      0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent), var(--shadow-card);
  }
  100% { box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card); }
}
.md-thumb {
  flex: none; width: 56px; height: 40px; border-radius: 9px; overflow: hidden;
  background: var(--code-bg); box-shadow: inset 0 0 0 1px var(--line);
}
.md-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.md-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.md-title { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; }
.md-sub {
  font-size: 11px; color: var(--muted); letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.md-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: md-pulse 1.4s ease-in-out infinite;
}
@keyframes md-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }
.md-chev { flex: none; color: var(--muted); display: grid; place-items: center; transition: transform 0.18s; }
.md-chev svg { width: 15px; height: 15px; }
.media-dock.open .md-chev { transform: rotate(180deg); }
.media-dock.open .md-bar { min-height: 44px; padding-top: 0; padding-bottom: 0; }

.media-dock.open { max-height: 50vh; }
/* A player plus its strip needs more room than a single still. */
.media-dock.has-video.open { max-height: 64vh; }
.md-body { padding: 0 10px 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.md-head {
  display: flex; align-items: center; gap: 8px;
  margin: 0 2px 7px; font-size: 11px; color: var(--muted);
}
.md-hint { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-collapse {
  flex: none; height: 24px; padding: 0 10px; border: 0; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent); font-size: 11.5px; font-weight: 600;
}
.md-shot {
  display: block; width: 100%; padding: 0; margin: 0;
  border: 0; background: var(--code-bg);
  border-radius: 12px; overflow: hidden; cursor: zoom-in;
  box-shadow: inset 0 0 0 1px var(--line);
}
.md-shot img {
  display: block; width: 100%; height: auto;
  max-height: min(32vh, 260px); object-fit: contain;
}
.md-shot:active { opacity: 0.9; }

/* earlier frames from the same run — swipeable strip under the live one */
.am-strip {
  display: flex; gap: 8px; margin-top: 8px; padding-bottom: 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* The chat scroller is `pan-y`; without this, iOS never lets a horizontal
     swipe begin on the strip and the row is stuck on its first cards. */
  touch-action: pan-x pan-y;
  overscroll-behavior-inline: contain;
}
.am-strip::-webkit-scrollbar { display: none; }
.am-thumb {
  flex: 0 0 68px; height: 48px; padding: 0; border: 0;
  border-radius: 9px; overflow: hidden; cursor: zoom-in;
  background: var(--code-bg); box-shadow: inset 0 0 0 1px var(--line);
}
.am-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.am-thumb:active { opacity: 0.85; }

/* A clip in the dock: the poster stands in for the frame, and a play glyph is
   the only hint needed that tapping starts playback instead of zooming. */
.md-thumb.is-video, .am-thumb.is-video { position: relative; }
.md-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.3));
  color: #fff;
}
.md-play svg { width: 15px; height: 15px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45)); }
.am-thumb .md-play svg { width: 13px; height: 13px; }
.md-video {
  display: block; width: 100%; max-height: min(40vh, 300px);
  border-radius: 12px; background: #000;
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- deliverables ---------- */
.deliverables { margin: 22px 0 8px; }
.dv-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 2px 10px;
}
.dv-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 620; color: var(--fg-soft);
  letter-spacing: 0.01em;
}
.dv-title svg { width: 14px; height: 14px; color: var(--accent); }
.dv-count { font-size: 11.5px; color: var(--muted); }
.dv-scroll {
  display: flex; gap: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px; scrollbar-width: none;
  /* No scroll-snap here: on iOS a short swipe that does not reach the next
     snap point gets pulled back to 0, which reads as "the row won't scroll". */
  touch-action: pan-x pan-y;
  overscroll-behavior-inline: contain;
}
.dv-scroll::-webkit-scrollbar { display: none; }
.dv-right { display: inline-flex; align-items: center; gap: 9px; }
.dv-all {
  height: 25px; padding: 0 11px; border: 0; border-radius: 13px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
}
.dv-all.on { background: var(--line); color: var(--fg-soft); }
/* Fallback for when the OS refuses horizontal gestures altogether: two columns,
   every clip visible at once, no swipe required. Kept in sync by state so a
   streaming re-render cannot snap the reader back to the strip. */
.dv-scroll.grid {
  flex-wrap: wrap; overflow: visible; scroll-snap-type: none;
}
.dv-scroll.grid .dv-card { flex: 0 0 calc((100% - 10px) / 2); }
.dv-card {
  flex: 0 0 168px; padding: 0; border: 0; background: none; text-align: left;
  scroll-snap-align: start;
  /* Flex items default to min-width:auto: a long filename keeps the card wider
     than its basis and the two-column grid silently collapses to one. */
  min-width: 0;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.dv-card:active { opacity: 0.85; }
.dv-poster {
  position: relative; display: block; aspect-ratio: 9 / 12;
  border-radius: 14px; overflow: hidden; background: var(--code-bg);
  box-shadow: 0 1px 2px rgba(60, 48, 30, 0.1), 0 12px 26px -16px rgba(60, 48, 30, 0.5);
}
.dv-poster img { display: block; width: 100%; height: 100%; object-fit: cover; }
.dv-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(12, 12, 14, 0.5); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}
.dv-play svg { width: 17px; height: 17px; margin-left: 2px; }
.dv-dur {
  position: absolute; right: 7px; bottom: 7px;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(12, 12, 14, 0.62); color: #fff;
  font-size: 10.5px; font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.dv-name {
  display: block; margin: 8px 2px 1px;
  font-size: 12.5px; font-weight: 540; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dv-meta { display: block; margin: 0 2px; font-size: 11px; color: var(--muted); }

/* Full-screen player. Unlike the image viewer this one has chrome: a title and
   an explicit close, because a video cannot be dismissed by a stray tap. */
#vid-viewer {
  position: fixed; inset: 0; z-index: 9999;
  display: none; place-items: center;
  background: #0a0908;
  padding: calc(var(--safe-top) + 18px) 14px calc(var(--safe-bottom) + 18px);
}
#vid-viewer.show { display: grid; }
.vv-inner { width: 100%; max-width: 820px; display: flex; flex-direction: column; gap: 10px; }
.vv-inner video {
  width: 100%; max-height: 74vh; border-radius: 14px; background: #000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.vv-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 4px; color: rgba(255, 255, 255, 0.72); font-size: 12.5px;
}
.vv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vv-close {
  flex: none; height: 32px; padding: 0 14px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 12.5px;
}
/* iOS/微信把 JS 自动播放拦掉时，这是一枚“真手势”播放键，声音不会再丢 */
.vv-stage { position: relative; }
.vv-tap-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 64px; height: 64px; border-radius: 50%;
  display: none; place-items: center;
  background: rgba(12, 12, 14, 0.55); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}
.vv-tap-play svg { width: 26px; height: 26px; margin-left: 3px; }
#vid-viewer.need-tap .vv-tap-play { display: grid; }
#vid-viewer.need-tap .vv-inner video { pointer-events: none; }

/* Wide window: the dock becomes the right column the desktop app has, so the
   thread keeps the middle and nothing floats over it. */
@media (min-width: 1080px) {
  .media-dock {
    position: fixed; right: 18px;
    bottom: calc(var(--safe-bottom) + 96px);
    width: 380px; margin: 0; z-index: 30;
    box-shadow: inset 0 0 0 1px var(--line), var(--shadow-float);
  }
  .media-dock.open { max-height: calc(100% - 180px); overflow-y: auto; }
  .md-shot img { max-height: 44vh; }
  body:has(.media-dock) .chat-scroll { padding-right: 414px; }
  /* Keep the composer in the same 820px column as the thread instead of
     letting the reserved column push it off-centre. */
  body:has(.media-dock) .composer-wrap {
    padding-left: max(12px, calc((100vw - 414px - 820px) / 2));
    padding-right: calc(414px + max(12px, calc((100vw - 414px - 820px) / 2)));
  }
  body:has(.media-dock) .attach-bar {
    padding-left: max(14px, calc((100vw - 414px - 820px) / 2));
    padding-right: calc(414px + max(14px, calc((100vw - 414px - 820px) / 2)));
  }
}
#img-viewer {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.93);
  display: flex; align-items: center; justify-content: center;
  padding: 10px; cursor: zoom-out;
}
#img-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

.turn-actions { display: flex; gap: 8px; margin-top: 7px; padding: 0 2px; }
.ta-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0;
  font-size: 11.5px; color: var(--muted);
  background: transparent;
  transition: color 0.15s, opacity 0.15s;
  opacity: 0.9;
}
.ta-btn:active { color: var(--fg); opacity: 0.55; }
.ta-btn svg { width: 12px; height: 12px; }

.task-result {
  font-size: 16px; line-height: 1.72; letter-spacing: -0.005em;
  padding: 2px 2px 0;
  min-width: 0; max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.task-result > *:first-child { margin-top: 0; }
.task-result > *:last-child { margin-bottom: 0; }

.run-inline {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 12.5px; padding: 8px 2px;
}
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 4px; height: 4px; border-radius: 50%; background: var(--muted);
  animation: bounce 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.turn-files { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; max-width: 100%; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%;
  height: 32px; padding: 0 11px; border-radius: 9px;
  background: var(--bg-elev); color: var(--fg-soft);
  font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-card);
  transition: transform 0.12s;
}
.file-chip:active { transform: scale(0.96); }
.file-chip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-ico { width: 14px; height: 14px; display: grid; place-items: center; color: var(--muted); }
.file-ico svg { width: 14px; height: 14px; }

.file-preview {
  background: var(--code-bg); border-radius: 14px;
  padding: 14px; font-family: var(--mono); font-size: 12px; line-height: 1.65;
  max-height: 58vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
  margin: 0 0 14px;
}

/* markdown */
.md > * { max-width: 100%; }
.md p, .md li, .md td, .md th, .md blockquote { overflow-wrap: anywhere; word-break: break-word; }
.md img { max-width: 100%; height: auto; border-radius: 12px; display: block; }
.md a { word-break: break-word; }
.md p { margin: 0 0 12px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { margin: 20px 0 10px; line-height: 1.3; font-weight: 680; letter-spacing: -0.015em; }
.md h1 { font-size: 21px; } .md h2 { font-size: 18.5px; } .md h3 { font-size: 16.5px; }
.md ul, .md ol { margin: 8px 0 12px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--code-bg); padding: 2px 6px; border-radius: 6px;
}
.md pre {
  position: relative; background: var(--code-bg);
  border-radius: 14px; padding: 14px;
  max-width: 100%;
  overflow: hidden;
  margin: 12px 0;
}
.md pre code {
  background: none; padding: 0; font-size: 12.5px; line-height: 1.65; display: block;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.md blockquote {
  margin: 12px 0; padding: 2px 0 2px 14px;
  border-left: 3px solid var(--line-strong); color: var(--fg-soft);
}
.md hr { border: 0; border-top: 0.5px solid var(--line); margin: 20px 0; }
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 12px 0;
  border-radius: 12px;
  touch-action: pan-x pan-y;
}
.md table {
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  font-size: 13px;
}
.md table.t5, .md table.t6, .md table.t7 {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}
.md th, .md td {
  border: 0.5px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: top;
}
.md th { background: var(--code-bg); font-weight: 600; }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.copy-code {
  position: absolute; top: 8px; right: 8px;
  font-size: 11px; font-weight: 500; color: var(--muted);
  background: var(--bg-elev); border-radius: 8px; padding: 4px 9px;
  box-shadow: var(--shadow-card);
}

/* reasoning (legacy, kept harmless) */
.reasoning { border-radius: 12px; }

/* ============================================================
   Composer
   ============================================================ */

.composer-wrap {
  position: relative; z-index: 25; flex: none;
  padding: 8px 12px calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.composer {
  display: flex; align-items: flex-end; gap: 5px;
  background: var(--bg-elev);
  border-radius: 26px; padding: 6px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.18s;
}
.composer:focus-within {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow-card);
}
.composer input,
.composer textarea {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; resize: none;
  font-family: inherit; font-size: 16px; line-height: 1.45; letter-spacing: -0.01em;
  padding: 9px 2px;
}
.composer input::placeholder,
.composer textarea::placeholder { color: var(--muted); }
.composer #input {
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none;
  /* Text paints into the bottom padding, which leaves a sliced line at the
     rounded edge — clip at the content edge and pad with margin instead. */
  padding-bottom: 0;
  margin-bottom: 9px;
}
.composer #input::-webkit-scrollbar { display: none; }
.attach-btn {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: var(--muted);
  transition: background 0.15s;
}
.attach-btn:active { background: var(--user-bubble); }
.attach-btn svg { width: 20px; height: 20px; }
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  transition: opacity 0.15s, transform 0.12s, background 0.15s;
}
.send-btn:disabled { opacity: 0.28; }
.send-btn:active:not(:disabled) { transform: scale(0.9); }
.send-btn svg { width: 19px; height: 19px; }
.send-btn.stop { background: var(--danger); }

.attach-bar {
  flex: none; display: flex; gap: 9px; padding: 8px 14px 2px;
  overflow-x: auto; background: var(--bg);
}
.attach-item { position: relative; flex: none; }
.attach-item img {
  width: 62px; height: 62px; object-fit: cover;
  border-radius: 12px; box-shadow: var(--shadow-card);
  background: var(--user-bubble);
}
.attach-idx {
  position: absolute; left: 4px; bottom: 4px;
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 7px;
  background: rgba(20, 20, 24, 0.66); color: #fff;
  font-size: 10px; font-weight: 650; line-height: 15px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Drag a screenshot anywhere over the conversation to attach it. */
body.dragging .app::after {
  content: '松手添加图片';
  position: fixed; inset: 10px;
  z-index: 200; border-radius: 18px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600; color: var(--accent);
  pointer-events: none;
}
.attach-x {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(20, 20, 24, 0.82); color: #fff;
  display: grid; place-items: center;
  backdrop-filter: blur(4px);
}
.attach-x svg { width: 12px; height: 12px; }

.jump-bottom {
  position: fixed; right: 16px; z-index: 26;
  bottom: calc(100px + var(--safe-bottom) + var(--kb-inset, 0px) + var(--dock-h, 0px));
  display: flex; align-items: center; gap: 5px;
  height: 36px; padding: 0 13px 0 10px; border-radius: 18px;
  background: var(--bg-elev); color: var(--fg-soft);
  box-shadow: var(--shadow-float);
  font-size: 12.5px; font-weight: 550;
  opacity: 0; transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.jump-bottom.show { opacity: 1; transform: none; pointer-events: auto; }
.jump-bottom:active { transform: scale(0.95); }
.jump-bottom svg { width: 15px; height: 15px; }

.load-more {
  display: block; width: 100%; height: 40px;
  margin-bottom: 16px; border-radius: 12px;
  background: var(--bg-elev); color: var(--muted);
  font-size: 12.5px; box-shadow: var(--shadow-card);
}

/* ============================================================
   Permission
   ============================================================ */

.perm-dock {
  flex: none; max-height: 42vh; overflow-y: auto;
  padding: 8px 12px;
  background: var(--bg);
  border-top: 0.5px solid var(--line);
}
.perm-stack { display: grid; gap: 9px; }
.perm {
  background: var(--bg-elev);
  border-radius: 16px; padding: 14px 15px;
  box-shadow: var(--shadow-card);
  border-left: 3px solid var(--warn);
}
.perm-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 620; letter-spacing: -0.01em;
}
.perm-title .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none;
}
.perm-desc {
  font-size: 12.5px; color: var(--fg-soft);
  margin-top: 7px; word-break: break-word; line-height: 1.55;
}
.perm-desc code {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--code-bg); padding: 2px 6px; border-radius: 6px;
}
.perm-actions { display: flex; gap: 8px; margin-top: 12px; }
.perm-actions button {
  flex: 1; height: 38px; border-radius: 11px;
  font-size: 13px; font-weight: 570;
  background: var(--user-bubble); color: var(--fg);
  transition: transform 0.12s, opacity 0.15s;
}
.perm-actions button:active { transform: scale(0.97); }
.perm-actions .allow { background: var(--accent); color: #fff; font-weight: 600; }
.perm-actions .deny { color: var(--danger); }

/* ============================================================
   Sheets
   ============================================================ */

.sheet-backdrop {
  position: fixed; left: 0; right: 0; z-index: 60;
  top: var(--app-top, 0px); height: var(--app-h, 100dvh);
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; overflow-x: hidden;
  background: var(--bg-elev);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  padding: 8px 18px calc(18px + var(--safe-bottom));
  animation: slide 0.26s cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: var(--shadow-float);
}
@keyframes slide { from { transform: translateY(34px); opacity: 0.5; } }
.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--line-strong); margin: 4px auto 16px;
}
.sheet h2 { font-size: 19px; margin: 0 0 14px; font-weight: 680; letter-spacing: -0.02em; }
.sheet-list { max-height: 62vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
  border: 0; background: var(--bg); outline: 0; font-size: 16px;
}
.field input:focus, .field textarea:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }

.btn {
  width: 100%; height: 50px; border-radius: var(--r-btn);
  font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em;
  background: var(--accent); color: #fff; text-align: center;
  transition: transform 0.12s, opacity 0.15s;
}
.btn:active { transform: scale(0.985); }
.btn.ghost { background: var(--user-bubble); color: var(--fg); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; }
.row-btns { display: flex; gap: 9px; margin-top: 6px; }

.option {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 14px; border-radius: 14px;
  background: var(--bg); margin-bottom: 8px;
  transition: background 0.15s, transform 0.12s;
}
.option:active { background: var(--user-bubble); transform: scale(0.99); }
.option .o-main { flex: 1; min-width: 0; }
.option .o-title {
  font-size: 15px; font-weight: 560; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.option .o-sub {
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.option .check { color: var(--accent); width: 18px; height: 18px; flex: none; }
.option .o-ico {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center; color: var(--muted);
}
.option .o-ico svg { width: 19px; height: 19px; }
.sw {
  flex: none; width: 42px; height: 26px; border-radius: 13px;
  background: var(--line-strong); position: relative;
  transition: background 0.18s;
}
.sw i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s;
}
.sw.on { background: var(--ok); }
.sw.on i { transform: translateX(16px); }

.info-list {
  background: var(--bg); border-radius: 14px;
  overflow: hidden; margin-bottom: 16px;
}
.info-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 14px; font-size: 13.5px;
  border-bottom: 0.5px solid var(--line);
}
.info-row:last-child { border-bottom: 0; }
.info-row span { color: var(--muted); }
.info-row b {
  font-weight: 550; font-size: 13px; color: var(--fg-soft);
  text-align: right; max-width: 60%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================
   Drawer
   ============================================================ */

.drawer-mask {
  position: fixed; left: 0; right: 0; z-index: 70;
  top: var(--app-top, 0px); height: var(--app-h, 100dvh);
  background: rgba(0, 0, 0, 0.38);
  opacity: 0; pointer-events: none; transition: opacity 0.24s;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; left: 0; z-index: 71;
  top: var(--app-top, 0px); height: var(--app-h, 100dvh);
  width: 86%; max-width: 380px;
  background: var(--bg);
  border-radius: 0 24px 24px 0;
  transform: translateX(-102%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 18px) 14px calc(16px + var(--safe-bottom));
  box-shadow: 12px 0 48px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.drawer.show { transform: none; }

.drawer-head {
  display: flex; align-items: center; gap: 11px;
  padding: 2px 6px 14px;
}
.drawer-mark {
  width: 40px; height: 40px; border-radius: 12px;
  overflow: hidden; flex: none;
  background: #111214;
  box-shadow: 0 4px 14px rgba(22, 24, 29, 0.18);
}
.drawer-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
.drawer-dev-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.drawer-close {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted);
  background: var(--bg-elev); box-shadow: var(--shadow-card);
}
.drawer-close:active { opacity: .7; }
.drawer-close svg { width: 15px; height: 15px; }
.drawer-dev { font-size: 16.5px; font-weight: 660; letter-spacing: -0.02em; }
.drawer-dev-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* drawer search + space groups */
.drawer-search {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px; margin-bottom: 10px;
  border-radius: 12px; background: var(--bg-elev);
  box-shadow: 0 0 0 0.5px var(--line), var(--shadow-card);
  flex: none;
}
.drawer-search svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.drawer-search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 14.5px; color: var(--fg); -webkit-appearance: none;
}
.drawer-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.grp { margin-bottom: 2px; }
.grp-head { display: flex; align-items: center; gap: 2px; padding-right: 2px; }
.grp-toggle {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 4px; border-radius: 9px;
  color: var(--muted); transition: background 0.15s;
}
.grp-toggle:active { background: var(--user-bubble); }
.grp-toggle svg { width: 13px; height: 13px; flex: none; transition: transform 0.18s ease; opacity: 0.8; }
.grp.closed .grp-toggle svg { transform: rotate(-90deg); }
.grp-name {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.grp-count { font-size: 11px; color: var(--muted); opacity: 0.7; margin-left: 1px; }
.grp-add {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  display: grid; place-items: center; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.grp-add:active { background: var(--user-bubble); color: var(--fg); }
.grp-add svg { width: 16px; height: 16px; }
.grp-body { padding-bottom: 4px; }
.grp.closed .grp-body { display: none; }

.drawer-new {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 48px; border-radius: var(--r-btn);
  background: var(--bg-elev); color: var(--fg);
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  box-shadow: var(--shadow-card); margin-bottom: 14px;
  transition: transform 0.12s;
}
.drawer-new:active { transform: scale(0.98); }
.drawer-new svg { width: 19px; height: 19px; }

.drawer-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.drawer-foot { flex: none; padding-top: 8px; border-top: 0.5px solid var(--line); margin-top: 8px; }
.drawer-foot-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 44px; padding: 0 8px; border-radius: 10px;
  font-size: 14.5px; color: var(--fg-soft);
}
.drawer-foot-btn:active { background: var(--user-bubble); }
.drawer-foot-btn svg { width: 19px; height: 19px; color: var(--muted); }

.sect-row { display: flex; align-items: center; justify-content: space-between; padding-right: 4px; }
.sect-row .sect-label {
  margin: 0 0 0 4px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.sect-more { width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); }
.sect-more svg { width: 15px; height: 15px; }

.drawer-task {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 9px 8px; border-radius: 10px;
  font-size: 14.5px; color: var(--fg); letter-spacing: -0.01em;
  transition: background 0.15s;
}
.dt-time {
  flex: none; font-size: 10.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; opacity: 0.9;
}
.dt-dot {
  width: 5px; height: 5px; border-radius: 50%; flex: none;
  background: transparent;
}
.dt-dot.run { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 16%, transparent); }
.dt-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-task .si-spin { flex: none; }
.drawer-task:active { background: var(--user-bubble); }
.dt-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-draft {
  flex: none; font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--muted); background: var(--user-bubble);
  padding: 2px 6px; border-radius: 5px;
}
.drawer-empty { font-size: 12.5px; color: var(--muted); padding: 2px 10px 10px; }

.space { margin-bottom: 1px; }
.space-head { display: flex; align-items: center; }
.space-toggle {
  width: 30px; height: 40px; flex: none;
  display: grid; place-items: center; border-radius: 9px; color: var(--muted);
}
.space-toggle:active { background: var(--user-bubble); }
.space-chev { width: 14px; height: 14px; display: grid; place-items: center; }
.space-chev svg { width: 14px; height: 14px; }
.space-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  height: 40px; border-radius: 10px; text-align: left; color: var(--fg);
  transition: background 0.15s;
}
.space-main:active { background: var(--user-bubble); }
.space-ico { width: 19px; height: 19px; color: var(--fg-soft); flex: none; display: grid; place-items: center; }
.space-ico svg { width: 19px; height: 19px; }
.space-name {
  flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.space-count { font-size: 11px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.space-add {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center; color: var(--muted); border-radius: 9px;
}
.space-add:active { background: var(--user-bubble); }
.space-add svg { width: 16px; height: 16px; }

.space-items { padding-left: 39px; }
.space-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left; padding: 8px 8px;
  border-radius: 9px; font-size: 13.5px; color: var(--fg-soft);
  transition: background 0.15s;
}
.space-item:active { background: var(--user-bubble); }
.si-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-spin {
  width: 11px; height: 11px; flex: none; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--ok));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  animation: spin 0.9s linear infinite;
}

/* ============================================================
   Login
   ============================================================ */

.login {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  padding: 32px 26px calc(52px + var(--safe-bottom));
  width: 100%; max-width: 400px; margin: 0 auto;
}
.login .logo {
  width: 64px; height: 64px; border-radius: 19px; margin-bottom: 26px;
  display: grid; place-items: center; overflow: hidden;
  background: #14110f;
  box-shadow:
    0 0 0 1px rgba(26, 23, 19, 0.06),
    0 16px 34px -14px rgba(60, 48, 30, 0.5);
}
.login .logo img { width: 100%; height: 100%; display: block; object-fit: cover; }
.login-kicker {
  font-size: 9.5px; font-weight: 650; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 14px;
}
.login h1 {
  font-family: var(--serif);
  font-size: 36px; margin: 0 0 12px; font-weight: 600; letter-spacing: 0.01em;
}
.login p { color: var(--muted); font-size: 13px; margin: 0 0 34px; letter-spacing: 0.03em; }
.pin-input::placeholder { font-size: 13px; letter-spacing: 0.14em; color: var(--muted); }
.pin-input {
  width: 100%; max-width: 300px; height: 58px; border-radius: 16px; text-align: center;
  font-size: 26px; letter-spacing: 0.4em; font-weight: 600;
  border: 1px solid var(--line); background: var(--bg-elev); outline: 0;
  box-shadow: 0 1px 2px rgba(60, 48, 30, 0.03), 0 18px 40px -28px rgba(60, 48, 30, 0.4);
  transition: box-shadow 0.24s, border-color 0.24s;
}
.pin-input:focus {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent),
    0 18px 44px -26px rgba(60, 48, 30, 0.45);
}
.login .btn {
  margin-top: 14px; max-width: 300px; height: 50px; border-radius: 15px;
  font-size: 15px; letter-spacing: 0.06em;
}
/* The embed banner is prose, not a centred headline — keep it full width. */
.login .embed-tip { align-self: stretch; text-align: left; margin-bottom: 26px; }
.login .hint {
  font-size: 11.5px; color: var(--muted); margin-top: 26px;
  line-height: 1.7; text-align: center; letter-spacing: 0.02em;
}
.login .err { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-bottom) + var(--kb-inset, 0px));
  transform: translate(-50%, 8px); z-index: 90;
  background: rgba(22, 22, 26, 0.94); color: #fff;
  font-size: 13px; font-weight: 500;
  padding: 10px 16px; border-radius: 12px; max-width: 86vw;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* Keep toasts clear of the pending bar so neither hides the other. */
body.has-pending-bar .toast { bottom: calc(var(--safe-bottom) + var(--pb-top, 104px)); }

/* ============================================================
   Desktop
   ============================================================ */

@media (min-width: 720px) {
  .list-wrap { max-width: 720px; margin: 0 auto; width: 100%; }
  .home-hero { max-width: 720px; margin: 0 auto; width: 100%; }
  .home-head { max-width: 720px; margin: 0 auto; width: 100%; }
  .composer-wrap { padding-left: max(12px, calc(50vw - 410px)); padding-right: max(12px, calc(50vw - 410px)); }
  /* Attachments sit above the composer: keep them in the same 820px column
     instead of hugging the far-left edge of a wide window. */
  .attach-bar {
    padding-left: max(14px, calc(50vw - 408px));
    padding-right: max(14px, calc(50vw - 408px));
  }
  .list-footer { padding-left: max(16px, calc(50vw - 360px)); padding-right: max(16px, calc(50vw - 360px)); }
  .pending-bar { left: 50%; transform: translateX(-50%); width: 440px; right: auto; }
}

/* ============================================================
   v21 — model picker, pending bar, voice input
   ============================================================ */

/* --- topbar: tappable model chip --- */
.topbar .sub {
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.topbar .sub-rest {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.model-chip {
  display: inline-flex; align-items: center; gap: 3px; max-width: 56vw;
  padding: 2px 5px 2px 7px; border-radius: 7px; flex: none;
  background: var(--user-bubble); color: var(--fg-soft);
  font-size: 11.5px; font-weight: 620; letter-spacing: -0.01em;
  transition: opacity 0.15s;
}
.model-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-chip svg { width: 10px; height: 10px; flex: none; opacity: 0.5; }
.model-chip:active { opacity: 0.6; }

/* --- model sheet: free / paid sections --- */
.sheet h2 .md-cur {
  font-size: 11.5px; font-weight: 500; color: var(--muted);
  margin-left: 8px; letter-spacing: 0;
}
.model-search {
  display: flex; align-items: center; gap: 8px; height: 42px;
  padding: 0 12px; border-radius: 12px; margin-bottom: 10px;
  background: var(--bg);
}
.model-search .ms-ico { display: grid; place-items: center; width: 15px; height: 15px; flex: none; color: var(--muted); }
.model-search .ms-ico svg { width: 15px; height: 15px; }
.model-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0;
  background: transparent; font-size: 16px;
}
.md-list { max-height: 52vh; padding-top: 2px; padding-bottom: 6px; }
.md-list + .row-btns { margin-top: 12px; }

/* ---------- provider balance strip (desktop only) ---------- */
.bal-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px;
  margin: 2px 0 10px; padding: 9px 12px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 0.5px solid var(--line);
}
.bal-item { display: inline-flex; align-items: baseline; gap: 5px; }
.bal-name { font-size: 11.5px; color: var(--muted); }
.bal-item b { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; color: var(--fg); }
.bal-item i { font-style: normal; font-size: 11px; color: var(--muted); }
.bal-item.off b { color: var(--muted); font-weight: 550; }
.bal-item.low b { color: var(--danger); }
.bal-ts { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bal-empty { font-size: 12px; color: var(--muted); }
.bal-hint { margin: 10px 2px 0; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.info-row.bal-row b {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 12px;
  white-space: normal; overflow: visible;
}
.info-row.bal-row .bal-name { color: var(--muted); }
.info-row.bal-row .bal-item b { color: var(--fg-soft); font-size: 13px; }
@media (max-width: 719px) {
  .bal-strip { display: none; }
  .bal-chip { display: none; }
}

/* Compact wallet chip in the home header (desktop only). */
.bal-chip {
  display: inline-flex; align-items: center; gap: 11px;
  flex: none; padding: 6px 11px; border-radius: 11px;
  background: var(--bg-elev);
  border: 0.5px solid var(--line);
  color: var(--muted); font-size: 11.5px;
  transition: background 0.15s, transform 0.12s;
}
.bal-chip:active { background: var(--user-bubble); transform: scale(0.97); }
.bc-item { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.bc-item b {
  font-size: 12.5px; font-weight: 650; letter-spacing: -0.01em;
  color: var(--fg-soft); font-variant-numeric: tabular-nums;
}
.bc-item.off b { color: var(--muted); font-weight: 550; }
.bc-txt { font-size: 12px; }

.md-sect {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px 8px; margin-top: 2px;
  background: var(--bg-elev);
  font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.md-sect:not(:first-child) { padding-top: 12px; }
.md-sect span {
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  background: var(--bg); padding: 1px 6px; border-radius: 6px;
  letter-spacing: 0;
}
/* Rows read as one continuous list instead of a wall of nested cards. */
.md-row, .option.md-row {
  background: transparent; border-radius: 0; margin: 0;
  padding: 11px 8px;
  border-top: 0.5px solid var(--line);
}
.md-sect + .md-row { border-top: 0; }
.option.md-row .o-title { font-size: 14.5px; font-weight: 560; }
.option.md-row:active { background: var(--user-bubble); transform: none; }
.option.md-row.on {
  background: var(--accent-soft);
  border-radius: 11px;
  border-top-color: transparent;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent);
}
.option.md-row.on + .md-row { border-top-color: transparent; }
.md-list .md-row:last-child { margin-bottom: 4px; }
.md-now {
  font-size: 10px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); padding: 1px 6px; border-radius: 5px;
  margin-left: 6px; vertical-align: 1.5px; letter-spacing: 0;
}
.md-price { color: var(--fg-soft); font-weight: 500; }
.md-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 0; }

/* --- pending approvals: slim bar instead of a full-screen sheet --- */
.pending-bar {
  position: fixed; left: 12px; right: 12px; z-index: 55;
  bottom: calc(var(--safe-bottom) + 12px + var(--kb-inset, 0px));
  display: flex; pointer-events: none;
  animation: pbin 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes pbin { from { transform: translateY(10px); opacity: 0; } }
/* Inside a chat the composer sits at the bottom: float above it.
   Its height changes as the text wraps, so it comes from JS. */
.pending-bar.chat { bottom: calc(var(--safe-bottom) + var(--composer-h, 84px) + 4px + var(--kb-inset, 0px) + var(--dock-h, 0px)); }
.pending-bar button {
  pointer-events: auto; width: 100%;
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 11px 10px 13px; border-radius: 16px;
  background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.14), inset 0 0 0 0.5px var(--line-strong);
}
.pending-bar button:active { transform: scale(0.99); }
.pending-bar .pb-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--warn);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--warn) 18%, transparent);
  animation: pulse 1.6s ease-in-out infinite;
}
.pending-bar .pb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pending-bar .pb-line {
  font-size: 13.5px; font-weight: 650; letter-spacing: -0.01em;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pending-bar .pb-line b { font-weight: 700; margin-right: 1px; }
.pending-bar .pb-text em {
  font-style: normal; font-size: 11px; color: var(--muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pending-bar .pb-go {
  flex: none; font-size: 12px; font-weight: 600; color: var(--accent);
  padding: 6px 10px; border-radius: 9px; background: var(--accent-soft);
}

/* --- voice input --- */
.mic-btn {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.mic-btn svg { width: 20px; height: 20px; }
.mic-btn:active { background: var(--user-bubble); }
.mic-btn.rec {
  color: #fff; background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent);
  animation: pulse 1.5s ease-in-out infinite;
}
.voice-bar {
  display: flex; align-items: center; gap: 9px;
  margin: 0 4px 8px; padding: 9px 12px; border-radius: 14px;
  background: var(--bg-elev); box-shadow: var(--shadow-card);
  font-size: 12.5px; color: var(--fg-soft);
}
.voice-bar .vb-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--danger); animation: pulse 1.2s ease-in-out infinite;
}
.voice-bar.busy .vb-dot { background: var(--accent); }
.voice-bar .vb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-bar .voice-sec { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; flex: none; }
.voice-bar .vb-stop {
  flex: none; font-size: 12px; font-weight: 600; color: var(--accent);
  padding: 5px 11px; border-radius: 9px; background: var(--accent-soft);
}

/* ============================================================
   Wider screens — the sheet gets bigger, not just wider
   ============================================================ */
@media (min-width: 760px) {
  .ask-quote { font-size: 37px; letter-spacing: 0.06em; }
  .ask-kicker { font-size: 12.5px; margin-bottom: 17px; }
  .ask-hero { margin-bottom: 32px; }
}

/* ============================================================
   Motion preferences
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Short landscape viewports (rotated iPhone, in-app browsers)
   At 390px tall the portrait stack leaves only ~200px for the
   thread: header + dock + composer eat the rest. Reclaim that
   space and spend the extra WIDTH instead of stacking vertically.
   ============================================================ */
@media (orientation: landscape) and (max-height: 520px) {
  /* --- chrome: three rows have to fit in ~100px total --- */
  .topbar { padding: 2px 10px 3px; }
  .topbar h1 { font-size: 14px; }
  .topbar .sub { display: none; }
  .topbar .icon-btn { width: 32px; height: 32px; }
  .topbar .icon-btn svg { width: 18px; height: 18px; }
  .status-bar.running { padding: 5px 14px; }
  /* In-app browsers add their own toolbar on top of ours; the notice must not
     cost another 50px of a 390px-tall window. */
  .embed-tip { margin-bottom: 4px; padding: 3px 8px; font-size: 11px; line-height: 1.3; }
  .embed-tip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .embed-tip button { padding: 3px 7px; font-size: 11px; }

  .composer-wrap { padding: 4px 14px calc(4px + var(--safe-bottom)); }
  .composer { border-radius: 20px; padding: 3px; }
  .composer input, .composer textarea { font-size: 14px; padding: 5px 2px; }
  .composer #input { margin-bottom: 4px; }
  .attach-btn { width: 32px; height: 32px; }

  .media-dock { margin: 0 12px 3px; border-radius: 12px; flex: 0 1 auto; min-height: 0; }
  .md-bar { min-height: 34px; padding: 3px 8px 3px 4px; }
  /* An open player (180px) plus a pending-approval card (157px) used to push
     the composer below a 375px-tall viewport. Both docks have to yield to the
     input; their own bodies stay scrollable. */
  .media-dock.open { max-height: 30vh; }
  .media-dock.has-video.open { max-height: 34vh; }
  .perm-dock { max-height: 22vh; flex: 0 1 auto; min-height: 0; padding: 4px 12px; }

  /* --- home: motto on the left, composer on the right --- */
  .home-body { padding: 0 24px 6px; }
  .home-stage {
    max-width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "hero card" "foot card";
    align-content: center; align-items: center;
    column-gap: 32px; padding: 0;
  }
  .ask-hero { grid-area: hero; margin: 0; text-align: left; }
  .ask-hero::before { display: none; }
  .ask-kicker { margin-bottom: 6px; font-size: 11px; }
  .ask-quote { margin-bottom: 8px; font-size: clamp(20px, 2.9vw, 27px); line-height: 1.35; }
  .ask-sub { margin-top: 4px; font-size: 11px; }
  .quick-card { grid-area: card; }
  .quick-card textarea { min-height: 60px; max-height: 110px; padding: 12px 14px 2px; font-size: 14.5px; }
  .quick-foot { padding: 6px 10px 7px; }
  .ask-foot { grid-area: foot; }
  .stage-foot { margin-top: 4px; padding-top: 8px; }

  /* --- chat: use the width, every clip visible without swiping --- */
  .chat-scroll { padding: 8px 20px 4px; }
  .chat-inner { max-width: 100%; }
  .deliverables { margin: 14px 0 6px; }
  .dv-scroll, .dv-scroll.grid {
    display: grid;
    /* auto-fit collapses unused tracks, so 6 clips become one tidy row of 6
       rather than an orphan card on a second line. */
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px; overflow: visible; scroll-snap-type: none;
  }
  .dv-card, .dv-scroll.grid .dv-card { flex: initial; width: 100%; }
  .dv-poster { aspect-ratio: 4 / 3; }
  .dv-all { display: none; }
}

/* ============================================================
   Landscape sidebar — the desktop "all tasks" pane, always on
   A portrait phone can only afford a drawer that has to be
   opened. Rotated, there is room for the full session list to
   sit beside the thread; this is what "everything synced from
   the desktop" actually means on a phone.
   ============================================================ */
@media (orientation: landscape) and (min-width: 640px) {
  /* Only scope the offset when the sidebar actually exists: the login and
     error screens have no drawer and must not be pushed 268px to the right. */
  body.has-drawer .app { left: 268px; }

  body.has-drawer .drawer, body.has-drawer .drawer.show {
    width: 268px; max-width: none;
    transform: none !important;
    border-radius: 0;
    border-right: 0.5px solid var(--line);
    box-shadow: none;
    padding: calc(var(--safe-top) + 10px) 10px calc(10px + var(--safe-bottom));
  }
  body.has-drawer .drawer-mask, body.has-drawer .drawer-mask.show { display: none !important; }
  body.has-drawer .drawer-close, body.has-drawer [data-act="open-drawer"] { display: none !important; }

  body.has-drawer .drawer-head { padding-bottom: 8px; }
  body.has-drawer .drawer-dev { font-size: 14px; }
  body.has-drawer .drawer-search { height: 34px; margin-bottom: 8px; }
  body.has-drawer .drawer-new { height: 38px; margin-bottom: 10px; font-size: 13.5px; }
  body.has-drawer .drawer-foot { padding-top: 6px; margin-top: 6px; }
  /* The 720px desktop rules center content against 50vw; with a 268px pane
     that would drift the composer off-centre. Keep it centred in what's left. */
  body.has-drawer .composer-wrap,
  body.has-drawer .attach-bar,
  body.has-drawer .list-footer { padding-left: 12px; padding-right: 12px; }
}

/* ============================================================
   UX pass: one home for clips, a populated landing screen,
   and touch targets a thumb can actually hit
   ============================================================ */
.media-dock.mini { margin-bottom: 4px; border-radius: 12px; }
.md-mini {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 34px; padding: 5px 12px;
  border: 0; background: transparent; color: var(--fg-soft);
  font-size: 12px; text-align: left;
}
.md-mini:active { background: color-mix(in srgb, var(--fg) 5%, transparent); }
.md-mini svg { width: 15px; height: 15px; flex: none; opacity: 0.7; }
.md-mini span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.recent-box {
  margin: 0 0 4px; padding: 4px 0 2px;
  border-top: 1px solid var(--line);
}
.recent-head {
  padding: 8px 2px 6px; font-size: 11px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.06em;
}
.recent-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  min-height: 40px; padding: 5px 4px;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--fg); font-size: 13px; text-align: left;
}
.recent-row:active { background: var(--user-bubble); }
.recent-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--line-strong);
}
.recent-dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 14%, transparent); }
.recent-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-time { flex: none; font-size: 11px; color: var(--muted); }

/* A dead button teaches nothing. `disabled` / `aria-disabled` are skipped by
   taps (and by accessibility tools), so use a visual-only flag: the button
   stays tappable and the tap explains why nothing was sent. */
.quick-send[data-empty="true"] { opacity: 0.62; }
.send-btn[data-empty="true"] { opacity: 0.28; }

@media (pointer: coarse) {
  .quick-send, .send-btn, .attach-btn, .mic-btn, .icon-btn, .menu-btn {
    min-width: 44px; min-height: 44px;
  }
  .chip { height: 40px; }
  .dv-all { height: 44px; }
  .vv-close { height: 44px; }
  .model-chip { min-height: 32px; padding: 6px 8px; }
  .md-mini { min-height: 44px; }
  .jump-bottom { min-height: 44px; }
  [data-act="copy-result"] { min-height: 40px; }
}

/* A 375px-tall rotated window cannot afford 44px chrome everywhere; the
   recent list is also redundant when the full sidebar is permanently on. */
@media (orientation: landscape) and (max-height: 520px) {
  .quick-send, .send-btn, .attach-btn, .mic-btn { min-width: 34px; min-height: 34px; }
  .icon-btn, .menu-btn { min-width: 32px; min-height: 32px; }
  .recent-box { display: none; }
  .media-dock.mini { margin-bottom: 2px; }
  .md-mini { min-height: 28px; padding: 2px 10px; font-size: 11px; }
}

/* ---------- v95: instant tap feedback + runtime connectivity ---------- */
.qs-spin {
  display: inline-block; width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: spin .75s linear infinite;
}
.quick-card.busy textarea { opacity: .55; }
.quick-card.busy .quick-send {
  pointer-events: none; opacity: 1;
  background: var(--accent); color: #fff;
  box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--accent) 75%, transparent);
}
.quick-hint {
  display: flex; align-items: center; gap: 7px;
  margin: 8px 2px 2px; color: var(--accent); font-size: 12px;
}
.quick-hint::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); animation: pulse 1.1s ease-in-out infinite;
}
.sheet-loading {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 4px; color: var(--muted); font-size: 14px;
}
.sheet-loading .qs-spin { border-color: var(--line-strong); border-top-color: var(--accent); }
.net-banner {
  position: fixed; z-index: 90; left: 0; right: 0;
  top: var(--safe-top);
  padding: 7px 14px calc(7px + 1px); text-align: center;
  background: var(--accent-strong); color: #fff;
  font-size: 12px; letter-spacing: .02em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
  pointer-events: none;
}
@media (min-width: 640px) {
  .net-banner { left: 268px; }
}

/* Offline read-only replay: the frozen composer should look frozen, while
   every read affordance (list, transcript, drawer) stays fully usable. */
.quick-card.offline { border-style: dashed; }
.quick-card.offline .quick-send,
.composer.offline .send-btn,
.composer.offline .attach-btn,
.composer.offline .mic-btn { opacity: .55; }
.quick-card.offline textarea,
.composer.offline textarea { cursor: default; }
.composer.offline { opacity: .84; }
