/* Claude Inbox — mini app
   Theme follows Telegram's own palette (--tg-theme-*), so the panel looks like
   part of the chat it opens from. The brand lives in the details: the warm
   "spark" of a working session, Vazirmatn for prose, JetBrains Mono only for
   code and terminals. */

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/vazirmatn-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --raised: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #121216);
  --hint: var(--tg-theme-hint-color, #7d7f87);
  --subtle: var(--tg-theme-subtitle-text-color, var(--hint));
  --head: var(--tg-theme-section-header-text-color, var(--hint));
  --link: var(--tg-theme-link-color, #2b7bd6);
  --accent: var(--tg-theme-button-color, #2b7bd6);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --sep: var(--tg-theme-section-separator-color, color-mix(in srgb, var(--text) 9%, transparent));

  /* status language */
  --spark: #e07a55;            /* working — Claude's warm coral */
  --ask: #e9a23b;              /* waiting on you */
  --ok: #2fb36a;
  --idle: color-mix(in srgb, var(--hint) 70%, transparent);

  --tint: color-mix(in srgb, var(--text) 5%, transparent);
  --tint-2: color-mix(in srgb, var(--text) 8%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --spark-soft: color-mix(in srgb, var(--spark) 15%, transparent);
  --ask-soft: color-mix(in srgb, var(--ask) 17%, transparent);

  --term-bg: #121317;
  --term-fg: #e3e3e8;

  --r-sm: 9px;
  --r: 14px;
  --r-lg: 20px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 6px 20px -8px rgb(0 0 0 / 0.14);
  --shadow-up: 0 -1px 0 var(--sep), 0 -8px 24px -12px rgb(0 0 0 / 0.18);

  --safe-top: max(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px), env(safe-area-inset-top, 0px));
  --safe-bottom: max(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  --vh: var(--tg-viewport-height, 100dvh);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #0f1013;
    --surface: #1a1b20;
    --raised: #1f2026;
    --text: #ececf1;
    --hint: #8b8d97;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-feature-settings: "ss01";
}
body { overscroll-behavior: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input, textarea { caret-color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: -0.01em; }

svg.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.85;
  stroke-linecap: round; stroke-linejoin: round;
}
svg.i.sm { width: 16px; height: 16px; }
svg.i.lg { width: 24px; height: 24px; }
.flip { transform: scaleX(-1); }

/* ------------------------------------------------------------------ shell */
#app {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  will-change: transform;
}
.screen.enter { animation: push-in 0.38s var(--ease-out) both; }
.screen.leave { animation: push-out 0.3s var(--ease-out) both; pointer-events: none; }
@keyframes push-in { from { transform: translateX(-28%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes push-out { to { transform: translateX(-24%); opacity: 0; } }

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar { display: none; }
.pad { padding: calc(var(--safe-top) + 14px) 16px 24px; }

/* ----------------------------------------------------------------- header */
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 4px 18px;
}
.top h1 {
  margin: 0;
  font-size: 29px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.top .sub { color: var(--hint); font-size: 13.5px; margin-top: 4px; }
.top .sub b { color: var(--text); font-weight: 600; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  flex: none;
  transition: transform 0.15s var(--ease-out);
}
.icon-btn:active { transform: scale(0.92); }

/* ---------------------------------------------------------------- sections */
.section { margin-bottom: 22px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 16px 7px;
  color: var(--head);
  font-size: 13px;
  font-weight: 600;
}
.section-head .act { color: var(--link); font-weight: 500; }
.group {
  background: var(--surface);
  border-radius: var(--r);
  overflow: hidden;
}
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  text-align: start;
  transition: background-color 0.18s;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0; inset-inline-start: 58px; inset-inline-end: 0;
  border-top: 0.5px solid var(--sep);
}
.row.plain + .row.plain::before { inset-inline-start: 16px; }
button.row:active, .row.tap:active { background: var(--tint); }
.row .body { flex: 1; min-width: 0; }
.row .title {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 15.5px; line-height: 1.35;
  min-width: 0;
}
.row .title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta {
  color: var(--hint); font-size: 13px; line-height: 1.4; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .end { flex: none; display: flex; align-items: center; gap: 6px; color: var(--hint); font-size: 13px; }
.chev { color: color-mix(in srgb, var(--hint) 60%, transparent); }
.leading {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent);
}
.leading.danger { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.leading.spark { background: var(--spark-soft); color: var(--spark); }
.leading.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.leading.ask { background: var(--ask-soft); color: var(--ask); }

/* --------------------------------------------------------- status language */
.dot {
  position: relative;
  width: 10px; height: 10px; border-radius: 50%;
  flex: none;
  background: var(--idle);
}
.dot.closed { background: transparent; box-shadow: inset 0 0 0 1.6px var(--idle); }
.dot.asking { background: var(--ask); }
.dot.busy { background: var(--spark); }
.dot.busy::after {
  content: "";
  position: absolute; inset: -5px;
  border-radius: 50%;
  background: var(--spark);
  opacity: 0;
  animation: breathe 2.2s var(--ease-out) infinite;
}
@keyframes breathe {
  0% { transform: scale(0.4); opacity: 0.45; }
  70%, 100% { transform: scale(1.45); opacity: 0; }
}
.session-row { align-items: flex-start; padding-top: 12px; padding-bottom: 12px; }
.session-row + .session-row::before { inset-inline-start: 70px; }
.avatar {
  position: relative; flex: none;
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: hsl(var(--h) 55% 55% / 0.14);
  color: hsl(var(--h) 45% 46%);
  font-family: var(--font); font-size: 15px; letter-spacing: -0.01em;
  direction: ltr;
}
.avatar b { font-weight: 800; }
.avatar > .dot {
  position: absolute; bottom: -2px; inset-inline-end: -2px;
  width: 13px; height: 13px;
  box-shadow: 0 0 0 2.5px var(--surface);
}
.avatar > .dot.closed { background: var(--surface); box-shadow: 0 0 0 2.5px var(--surface), inset 0 0 0 1.8px var(--idle); }
.avatar.busy { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--spark) 55%, transparent); }
.avatar.busy::before {
  content: ""; position: absolute; inset: -1.5px; border-radius: 14.5px;
  box-shadow: 0 0 14px -2px var(--spark);
  opacity: 0.5;
  animation: glow 2.4s ease-in-out infinite;
}
@keyframes glow { 50% { opacity: 0.1; } }
.avatar.asking { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ask) 60%, transparent); }
.avatar.closed { filter: grayscale(0.8); opacity: 0.7; }
@media (prefers-color-scheme: dark) { :root:not(.tg) .avatar { color: hsl(var(--h) 60% 70%); background: hsl(var(--h) 50% 60% / 0.16); } }
.tg.tg-dark .avatar { color: hsl(var(--h) 60% 70%); background: hsl(var(--h) 50% 60% / 0.16); }
.now {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px;
  color: var(--subtle);
  font-size: 13px;
  min-width: 0;
}
.now span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.now svg.i { width: 15px; height: 15px; color: var(--spark); }
.now.asking svg.i { color: var(--ask); }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: 99px;
  font-size: 12px; font-weight: 600;
  background: var(--tint);
  color: var(--subtle);
  white-space: nowrap;
}
.pill svg.i { width: 13px; height: 13px; }
.pill.spark { background: var(--spark-soft); color: var(--spark); }
.pill.ask { background: var(--ask-soft); color: color-mix(in srgb, var(--ask) 80%, var(--text)); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.timer { font-variant-numeric: tabular-nums; color: var(--spark); font-weight: 600; }

/* --------------------------------------------------------------- segmented */
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--tint-2);
  border-radius: 11px;
  margin: 0 0 16px;
}
.seg button {
  flex: 1;
  height: 32px;
  border-radius: 9px;
  font-size: 13.5px; font-weight: 600;
  color: var(--subtle);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 0.2s, color 0.2s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.seg .count { font-size: 11.5px; color: var(--hint); }

.chips {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 2px 16px 12px;
  margin: 0 -16px 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 34px; padding: 0 14px;
  border-radius: 99px;
  background: var(--surface);
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--sep);
}
.chip .c { font-size: 12px; color: var(--hint); font-weight: 600; }
.chip.on { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.chip.on .c { color: color-mix(in srgb, var(--on-accent) 75%, transparent); }

/* -------------------------------------------------------------- tab bar */
.tabbar {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  box-shadow: 0 -0.5px 0 var(--sep);
  position: relative;
  z-index: 3;
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 2px 0;
  color: var(--hint);
  font-size: 11px; font-weight: 600;
  position: relative;
  transition: color 0.2s;
}
.tabbar button .ic {
  position: relative;
  width: 58px; height: 30px; border-radius: 99px;
  display: grid; place-items: center;
  transition: background-color 0.25s var(--ease-out);
}
.tabbar button.on { color: var(--accent); }
.tabbar button.on .ic { background: var(--accent-soft); }
.tabbar button:active .ic { transform: scale(0.94); }
.tabbar svg.i { width: 22px; height: 22px; }
.tabbar button.on svg.i { stroke-width: 2.1; }
.tabbar .badge {
  position: absolute; top: -3px; inset-inline-start: calc(50% + 7px);
  box-shadow: 0 0 0 2px var(--surface);
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 99px;
  background: var(--danger); color: #fff;
  font-size: 10.5px; line-height: 17px; font-weight: 700;
  text-align: center;
}
.tabbar .badge.spark { background: var(--spark); }

/* --------------------------------------------------------- session header */
.navbar {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 10px) 12px 10px;
  background: var(--bg);
  position: relative; z-index: 2;
}
.navbar .back {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  color: var(--accent);
}
.navbar .back:active { background: var(--tint); }
.navbar .who { flex: 1; min-width: 0; }
.navbar .who h2 {
  margin: 0; font-size: 18px; font-weight: 800; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.navbar .who .meta { color: var(--hint); font-size: 12.5px; display: flex; gap: 6px; align-items: center; }
.navbar .icon-btn { width: 36px; height: 36px; box-shadow: none; background: var(--surface); }

.hero {
  --wash: transparent;
  background: linear-gradient(180deg, var(--wash), transparent 70%), var(--surface);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: inset 0 0 0 0.5px var(--sep);
}
.hero.busy { --wash: color-mix(in srgb, var(--spark) 13%, transparent); }
.hero.asking { --wash: color-mix(in srgb, var(--ask) 15%, transparent); }
.hero.busy .state { color: color-mix(in srgb, var(--spark) 80%, var(--text)); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.state {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px;
}
.state .dot { margin-inline: 2px; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
  border-top: 0.5px solid var(--sep);
  padding-top: 12px;
}
.stat { min-width: 0; }
.stat + .stat { border-inline-start: 0.5px solid var(--sep); padding-inline-start: 12px; }
.stat .k { color: var(--hint); font-size: 12px; }
.stat .v { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter {
  height: 4px; border-radius: 99px; background: var(--tint-2); margin-top: 6px; overflow: hidden;
}
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transform-origin: right; transform: scaleX(var(--p, 0)); transition: transform 0.6s var(--ease-out); }
.meter.warm > i { background: var(--ask); }
.meter.hot > i { background: var(--danger); }

.prompt {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--tint);
  font-size: 14px;
  line-height: 1.6;
}
.prompt .clamp {
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap; word-break: break-word;
}
.prompt.open .clamp { -webkit-line-clamp: unset; }
.hero.compact { padding: 12px 16px; }
.hero.compact .stats, .hero.compact .prompt { display: none; }
.prompt .via { color: var(--hint); font-size: 12px; display: flex; align-items: center; gap: 5px; margin-bottom: 2px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  margin: 0 -16px 12px;
  position: sticky; top: 0; z-index: 1;
  background: var(--bg);
  padding-top: 4px; padding-bottom: 8px;
}
.tabs button {
  height: 34px; padding: 0 14px;
  border-radius: 99px;
  font-weight: 600; font-size: 14px;
  color: var(--subtle);
  display: inline-flex; align-items: center; gap: 6px;
}
.tabs button.on { background: var(--text); color: var(--bg); }

/* ----------------------------------------------------------- todos/timeline */
.todo { display: flex; gap: 11px; align-items: flex-start; padding: 9px 16px; position: relative; }
.todo + .todo::before { content: ""; position: absolute; top: 0; inset-inline: 46px 0; border-top: 0.5px solid var(--sep); }
.todo .box {
  width: 20px; height: 20px; border-radius: 6px; flex: none; margin-top: 2px;
  box-shadow: inset 0 0 0 1.6px color-mix(in srgb, var(--hint) 70%, transparent);
  display: grid; place-items: center;
}
.todo.completed .box { background: var(--ok); box-shadow: none; color: #fff; }
.todo.completed .box svg.i { width: 14px; height: 14px; stroke-width: 3; }
.todo.completed .txt { color: var(--hint); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--hint) 60%, transparent); }
.todo.in_progress .box { box-shadow: inset 0 0 0 1.6px var(--spark); }
.todo.in_progress .box::after { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--spark); animation: blink 1.6s ease-in-out infinite; }
.todo.in_progress .txt { font-weight: 600; }
@keyframes blink { 50% { opacity: 0.25; } }
.todo .txt { font-size: 14.5px; line-height: 1.5; }

.tl { position: relative; padding: 4px 0; }
.ev {
  display: flex; gap: 11px; align-items: center;
  padding: 8px 16px;
  min-height: 42px;
}
.ev .ic {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--tint); color: var(--subtle);
}
.ev .ic svg.i { width: 16px; height: 16px; }
.ev.running .ic { background: var(--spark-soft); color: var(--spark); }
.ev.fail .ic { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.ev .what { flex: 1; min-width: 0; }
.ev .what .n { font-size: 12px; color: var(--hint); }
.ev .what .s { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev .t { font-size: 12px; color: var(--hint); flex: none; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.said {
  padding: 14px 16px;
  font-size: 14.5px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
}
.said code, .bubble code { font-family: var(--mono); font-size: 0.85em; background: var(--tint-2); padding: 1px 5px; border-radius: 5px; }
.more { display: block; width: 100%; padding: 10px 16px; color: var(--link); font-weight: 600; font-size: 14px; text-align: start; border-top: 0.5px solid var(--sep); }

/* -------------------------------------------------------------- chat tail */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.bubble {
  max-width: 88%;
  padding: 9px 13px 7px;
  border-radius: 18px;
  font-size: 14.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface);
  align-self: flex-end;
  border-end-start-radius: 6px;
}
.bubble.user {
  align-self: flex-start;
  background: var(--accent);
  color: var(--on-accent);
  border-end-start-radius: 18px;
  border-end-end-radius: 6px;
}
.bubble.user code { background: rgb(255 255 255 / 0.18); }
.bubble .at { display: block; font-size: 11px; opacity: 0.6; margin-top: 2px; text-align: end; }
.bubble.clip { max-height: 260px; overflow: hidden; position: relative; }
.bubble.clip::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 60px;
  background: linear-gradient(to bottom, transparent, var(--surface));
}
.bubble.user.clip::after { background: linear-gradient(to bottom, transparent, var(--accent)); }

/* --------------------------------------------------------------- terminal */
.term-wrap {
  background: var(--term-bg);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.term-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  color: #9a9ba3; font-size: 12px;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}
.term-bar .live { display: inline-flex; align-items: center; gap: 6px; }
.term-bar .live .dot { width: 7px; height: 7px; }
.term-bar button { color: #c9cad1; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 6px; border-radius: 6px; }
.term-bar button:active { background: rgb(255 255 255 / 0.08); }
.term {
  margin: 0;
  padding: 10px 12px 14px;
  color: var(--term-fg);
  font-family: var(--mono);
  font-size: var(--term-size, 9px);
  line-height: 1.32;
  white-space: pre;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  min-height: 220px;
  max-height: calc(var(--vh) - 330px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgb(255 255 255 / 0.18) transparent;
  -webkit-user-select: text;
  user-select: text;
}
.term::-webkit-scrollbar { height: 4px; width: 4px; }
.term::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 0.2); border-radius: 4px; }
.term .b { font-weight: 700; }
.term .d { opacity: 0.55; }
.keys {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 10px;
  background: #1a1b21;
  direction: ltr;
}
.keys button {
  height: 40px;
  border-radius: 10px;
  background: #2a2b33;
  color: #e7e7ec;
  font-family: var(--mono);
  font-size: 12.5px; font-weight: 600;
  display: grid; place-items: center;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.5);
  transition: transform 0.1s, background-color 0.15s;
}
.keys button:active { transform: translateY(1px); background: #3a3b45; }
.keys button.wide { grid-column: span 2; }
.keys button.warn { color: #ff9b8f; }
.keys svg.i { width: 17px; height: 17px; }

/* ---------------------------------------------------------------- diff */
.diff {
  margin: 0; padding: 8px 0;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  direction: ltr; text-align: left;
  overflow-x: auto; white-space: pre;
  background: var(--surface);
  border-radius: var(--r);
}
.diff span { display: block; padding: 0 12px; min-width: max-content; }
.diff .add { background: color-mix(in srgb, var(--ok) 13%, transparent); color: color-mix(in srgb, var(--ok) 70%, var(--text)); }
.diff .del { background: color-mix(in srgb, var(--danger) 11%, transparent); color: color-mix(in srgb, var(--danger) 70%, var(--text)); }
.diff .hunk { color: var(--link); background: var(--tint); margin-top: 6px; }
.diff .file { color: var(--text); font-weight: 700; background: var(--tint-2); padding-top: 6px; padding-bottom: 6px; margin-top: 10px; }
.diff .file:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- composer */
.composer {
  flex: none;
  padding: 8px 10px calc(var(--safe-bottom) + 8px);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  box-shadow: 0 -0.5px 0 var(--sep);
  position: relative; z-index: 3;
}
.composer .quick { display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 8px; scrollbar-width: none; }
.composer .quick.empty { display: none; }
.composer .quick::-webkit-scrollbar { display: none; }
.composer .quick button {
  flex: none; height: 30px; padding: 0 12px; border-radius: 99px;
  background: var(--tint); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; color: var(--text);
}
.composer .quick button.primary { background: var(--accent-soft); color: var(--accent); }
.composer .quick svg.i { width: 15px; height: 15px; }
.composer .line {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 4px;
  border-radius: 25px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--sep);
  transition: box-shadow 0.2s;
}
.composer .line:focus-within { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 60%, transparent); }
.composer textarea {
  flex: 1;
  min-height: 42px; max-height: 140px;
  resize: none;
  border: 0;
  border-radius: 21px;
  padding: 10px 12px;
  background: transparent;
  font-size: 16px; /* never below 16px: iOS zooms the page on focus otherwise */
  line-height: 1.4;
  outline: none;
}
.composer textarea::placeholder { color: var(--hint); opacity: 1; }
.send {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  transition: transform 0.18s var(--ease-out), opacity 0.2s;
}
.send:disabled { opacity: 0.35; }
.send:not(:disabled):active { transform: scale(0.9); }
.send svg.i { transform: scaleX(-1) translateX(1px); }

/* -------------------------------------------------------------- queue items */
.item { padding: 12px 16px; position: relative; display: flex; gap: 12px; }
.item + .item::before { content: ""; position: absolute; top: 0; inset-inline: 16px 0; border-top: 0.5px solid var(--sep); }
.item .body { flex: 1; min-width: 0; }
.item .txt {
  font-size: 14.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.item .txt.empty { color: var(--hint); }
.item .foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; color: var(--hint); font-size: 12.5px; }
.thumbs { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.thumbs img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none;
  background: var(--tint);
}
.item .menu-btn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--hint); flex: none; margin-top: -4px; }
.item .menu-btn:active { background: var(--tint); }
.item.delivered .txt { color: var(--subtle); }

/* ---------------------------------------------------------------- sheets */
.scrim {
  position: fixed; inset: 0; z-index: 20;
  background: rgb(0 0 0 / 0.38);
  animation: fade 0.25s ease both;
}
.scrim.out { animation: fade-out 0.22s ease both; }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.sheet {
  position: fixed; inset: auto 0 0 0; z-index: 21;
  max-height: calc(var(--vh) - var(--safe-top) - 40px);
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 8px 12px calc(var(--safe-bottom) + 12px);
  box-shadow: var(--shadow-up);
  animation: rise 0.42s var(--ease-out) both;
}
.sheet.out { animation: sink 0.25s ease-in both; }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes sink { to { transform: translateY(100%); } }
.sheet .grab { width: 38px; height: 5px; border-radius: 99px; background: var(--tint-2); margin: 0 auto 10px; flex: none; }
.sheet h3 { margin: 4px 6px 14px; font-size: 18px; font-weight: 800; }
.sheet .scroll { margin: 0 -12px; padding: 0 12px; }
.sheet .group { margin-bottom: 12px; }
.sheet .note { color: var(--hint); font-size: 12.5px; padding: 0 6px 12px; line-height: 1.6; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--hint); margin: 0 6px 6px; }
.field input, .field textarea {
  width: 100%;
  border: 0; outline: none;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
  font-size: 16px;
  box-shadow: inset 0 0 0 1px var(--sep);
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn {
  width: 100%; height: 50px; border-radius: 13px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s var(--ease-out), opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn.ghost { background: var(--surface); color: var(--accent); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 2px 14px; }
.choices button {
  height: 38px; padding: 0 16px; border-radius: 11px;
  background: var(--surface); font-weight: 600; font-size: 14px;
  box-shadow: inset 0 0 0 1px var(--sep);
}
.choices button.on { background: var(--accent); color: var(--on-accent); box-shadow: none; }

/* toggle */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i {
  position: absolute; inset: 0; border-radius: 99px;
  background: var(--tint-2);
  transition: background-color 0.25s;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 5px rgb(0 0 0 / 0.2);
  transition: transform 0.28s var(--ease-out);
}
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(-20px); }
[dir="ltr"] .switch input:checked + i::after { transform: translateX(20px); }

/* --------------------------------------------------------------- feedback */
.toast {
  position: fixed; z-index: 40;
  inset-inline: 16px;
  bottom: calc(var(--safe-bottom) + 84px);
  padding: 12px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--bg);
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.4);
  animation: toast-in 0.4s var(--ease-out) both;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.toast.out { animation: fade-out 0.25s ease both; }
.toast.bad { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } }

.empty-state {
  text-align: center;
  padding: 44px 24px;
  color: var(--hint);
}
.empty-state .art {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 20px;
  display: grid; place-items: center;
  background: var(--surface); color: var(--accent);
  box-shadow: var(--shadow);
}
.empty-state .art svg.i { width: 30px; height: 30px; stroke-width: 1.6; }
.empty-state h4 { margin: 0 0 4px; color: var(--text); font-size: 16px; }
.empty-state p { margin: 0; font-size: 14px; line-height: 1.7; }

.skeleton { border-radius: var(--r); background: var(--surface); height: 76px; margin-bottom: 10px; animation: wait 1.6s ease-in-out infinite alternate; }
@keyframes wait { to { opacity: 0.55; } }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 14px;
  border-radius: var(--r);
  background: var(--ask-soft);
  font-size: 13.5px; line-height: 1.6;
}
.banner svg.i { color: var(--ask); margin-top: 1px; }
.banner b { display: block; }
.banner.info { background: var(--accent-soft); }
.banner.info svg.i { color: var(--accent); }
.banner button { color: var(--link); font-weight: 700; margin-top: 4px; }

.qopts { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.qopts button {
  text-align: start; padding: 11px 14px; border-radius: 12px;
  background: var(--surface); font-weight: 600; font-size: 14px;
  display: flex; gap: 10px; align-items: center;
}
.qopts button .k { width: 24px; height: 24px; border-radius: 7px; background: var(--ask-soft); color: var(--ask); display: grid; place-items: center; font-size: 12.5px; flex: none; }

.gate {
  height: 100%; display: grid; place-items: center; text-align: center; padding: 32px;
}
.gate .mark {
  width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 24px;
  display: grid; place-items: center; background: var(--spark-soft); color: var(--spark);
}
.gate .mark svg.i { width: 36px; height: 36px; }
.gate h2 { margin: 0 0 6px; font-size: 21px; }
.gate p { margin: 0; color: var(--hint); line-height: 1.8; }

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

/* ------------------------------------------------------------ menu tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 78px; padding: 10px 4px 8px;
  border-radius: var(--r);
  background: var(--surface);
  color: var(--accent);
  transition: transform 0.15s var(--ease-out), background-color 0.2s;
}
.tile:active { transform: scale(0.96); background: var(--tint); }
.tile span { color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.3; }
.tile small {
  color: var(--hint); font-size: 11px; line-height: 1.2;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile.warn { color: var(--ask); }
.switch i.on { background: var(--ok); }
.switch i.on::after { transform: translateX(-20px); }
