/* arcdr — colours follow the dracula theme herdr runs with; light values keep the same roles readable on white. */

:root {
  color-scheme: dark;
  --bg: #121318;
  --bg-elev: #17181f;
  --surface: #1d1e27;
  --surface-2: #262834;
  --line: #2a2c39;
  --line-strong: #393c4e;
  --text: #ecedf3;
  --muted: #a5a8bc;
  --dim: #6f7289;
  --cyan: #8be9fd;
  --purple: #bd93f9;
  --yellow: #f1fa8c;
  --green: #50fa7b;
  --orange: #ffb86c;
  --pink: #ff79c6;
  --red: #ff6e6e;
  --accent: var(--purple);
  --accent-ink: #17121f;
  --user-bubble: #2e2846;
  /* Typefaces already on the device: nothing is downloaded. Settings → Text picks one; code stays --mono. */
  --font-system: system-ui, -apple-system, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", Roboto, sans-serif;
  --font-serif: "Noto Serif KR", "Noto Serif CJK KR", "Nanum Myeongjo", AppleMyungjo, Batang, Georgia, serif;
  --mono: "JetBrains Mono", "D2Coding", "Cascadia Mono", ui-monospace, Menlo, Consolas, monospace;
  --font: var(--font-system);
  --text-scale: 1;
}
:root[data-font="serif"] {
  --font: var(--font-serif);
}
:root[data-font="mono"] {
  --font: var(--mono);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f6f6f9;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #eeeef4;
    --line: #e3e3eb;
    --line-strong: #cdced9;
    --text: #1b1c24;
    --muted: #555769;
    --dim: #8a8c9e;
    --cyan: #0e7490;
    --purple: #6d28d9;
    --yellow: #a16207;
    --green: #15803d;
    --orange: #c2410c;
    --pink: #be185d;
    --red: #dc2626;
    --accent-ink: #ffffff;
    --user-bubble: #ece6fd;
  }
}

/* Themes picked in Settings (web/theme.ts sets data-theme); without a pick the system's choice above holds. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f9;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eeeef4;
  --line: #e3e3eb;
  --line-strong: #cdced9;
  --text: #1b1c24;
  --muted: #555769;
  --dim: #8a8c9e;
  --cyan: #0e7490;
  --purple: #6d28d9;
  --yellow: #a16207;
  --green: #15803d;
  --orange: #c2410c;
  --pink: #be185d;
  --red: #dc2626;
  --accent-ink: #ffffff;
  --user-bubble: #ece6fd;
}

/* Arcness — the aurora palette of the Arcness workspace: navy canvas, blue accent, a soft light at the top. */
:root[data-theme="arcness"] {
  color-scheme: dark;
  --bg: #0a101b;
  --bg-image:
    radial-gradient(720px 420px at 12% -8%, rgb(70 130 220 / 0.16), transparent 62%),
    radial-gradient(560px 380px at 92% 4%, rgb(138 180 248 / 0.12), transparent 60%);
  --bg-elev: #0e1624;
  --surface: #121a29;
  --surface-2: #182335;
  --line: #1c2638;
  --line-strong: #2c384d;
  --text: #e8edf5;
  --muted: #a5b1c6;
  --dim: #7d889d;
  --cyan: #7fb0f2;
  --purple: #a3adff;
  --yellow: #f5ca7d;
  --green: #78dba3;
  --orange: #f2a65e;
  --pink: #f29ac4;
  --red: #ff9a9a;
  --accent: #5b97e8;
  --accent-ink: #0a101b;
  --user-bubble: #1a2c47;
}

:root[data-theme="arcness-light"] {
  color-scheme: light;
  --bg: #f2f5fa;
  --bg-image:
    radial-gradient(720px 420px at 12% -8%, rgb(29 91 171 / 0.14), transparent 62%),
    radial-gradient(560px 380px at 92% 4%, rgb(138 180 248 / 0.22), transparent 60%);
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --line: #e1e7f0;
  --line-strong: #c9d2df;
  --text: #16213a;
  --muted: #4d5b77;
  --dim: #7a8599;
  --cyan: #1a539c;
  --purple: #4f5bd5;
  --yellow: #96600a;
  --green: #1f7a47;
  --orange: #b4560f;
  --pink: #b8357a;
  --red: #c02f2f;
  --accent: #1d5bab;
  --accent-ink: #ffffff;
  --user-bubble: #e2ecfa;
}

:root[data-theme="nord"] {
  color-scheme: dark;
  --bg: #2b303b;
  --bg-elev: #2e3440;
  --surface: #353c4a;
  --surface-2: #3b4252;
  --line: #3f4758;
  --line-strong: #4c566a;
  --text: #eceff4;
  --muted: #c3cad6;
  --dim: #8c96a8;
  --cyan: #88c0d0;
  --purple: #b48ead;
  --yellow: #ebcb8b;
  --green: #a3be8c;
  --orange: #d08770;
  --pink: #c895bf;
  --red: #e0757f;
  --accent: #88c0d0;
  --accent-ink: #2e3440;
  --user-bubble: #3d4a5e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  /* Separate properties: a shorthand with a colour and several gradient layers is invalid, and dropped whole. */
  background-color: var(--bg);
  background-image: var(--bg-image, none);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font: calc(15px * var(--text-scale)) / 1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  overscroll-behavior-y: contain;
}

#app {
  height: 100dvh;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ellipsis {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- mark ---------- */

.mark-a {
  fill: var(--cyan);
}
.mark-b {
  fill: var(--purple);
}
.mark-c {
  fill: var(--pink);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 650;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
}
.btn-block {
  width: 100%;
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-row .btn {
  flex: 1;
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface);
}
.icon-btn[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.link-btn {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--cyan);
  font-weight: 650;
  cursor: pointer;
}

/* ---------- status ---------- */

.dot {
  flex: none;
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: calc(11px * var(--text-scale));
  font-weight: 800;
  line-height: 1;
}
.dot-working::before,
.dot-idle::before,
.dot-unknown::before {
  content: "";
  border-radius: 50%;
}
.dot-working::before {
  width: 8px;
  height: 8px;
  background: var(--yellow);
  animation: pulse 1.4s ease-in-out infinite;
}
.dot-blocked {
  background: var(--pink);
  color: var(--bg);
}
.dot-done {
  color: var(--green);
}
.dot-idle::before {
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--dim);
}
.dot-unknown::before {
  width: 6px;
  height: 6px;
  background: var(--dim);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.75);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dot-working::before,
  .conn-checking {
    animation: none;
  }
}

.conn-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dim);
}
.conn-online {
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 18%, transparent);
}
.conn-checking {
  background: var(--yellow);
  animation: pulse 1.2s ease-in-out infinite;
}
.conn-offline {
  background: var(--red);
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 2px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  white-space: nowrap;
}
.chip-blocked {
  background: color-mix(in srgb, var(--pink) 15%, transparent);
  color: var(--pink);
}
.chip .dot {
  width: 14px;
  height: 14px;
  font-size: calc(10px * var(--text-scale));
}

.tone-yellow {
  color: var(--yellow);
}
.tone-cyan {
  color: var(--cyan);
}
.tone-orange {
  color: var(--orange);
  font-weight: 700;
}
.tone-green {
  color: var(--green);
  font-weight: 700;
}
.tone-pink {
  color: var(--pink);
  font-weight: 700;
}
.tone-dim {
  color: var(--dim);
}
.tone-purple {
  color: var(--purple);
}

.tree {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.stage {
  white-space: nowrap;
}

/* parts drawn from the display spec (docs/mods.md) */
.tone-text {
  color: var(--text);
}
.tone-muted {
  color: var(--muted);
}
.part-bold {
  font-weight: 700;
}
.part-dim {
  opacity: 0.6;
}
.parts {
  min-width: 0;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.part {
  min-width: 0;
  white-space: nowrap;
}
.part-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: calc(12px * var(--text-scale));
  white-space: nowrap;
}
.part-badge {
  font-family: var(--mono);
  font-weight: 700;
}
.part-dots span {
  letter-spacing: 1px;
}
.part-meter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.meter-track {
  position: relative;
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: var(--line-strong);
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: currentColor;
}
.todo-list {
  width: 100%;
  margin: 2px 0 0;
  padding: 8px 10px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: calc(13px * var(--text-scale));
}
.todo-list li {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}
.todo-completed {
  color: var(--dim);
  text-decoration: line-through;
}
.todo-in_progress {
  color: var(--yellow);
  font-weight: 600;
}
.todo-box {
  flex: none;
  width: 1em;
}
.part-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  flex-wrap: wrap;
  padding: 0 4px;
  font-size: calc(13px * var(--text-scale));
}
.part-right {
  margin-left: auto;
  justify-content: flex-end;
}
/* In the band above the message box the right side keeps its place on the first line, and a long left side
   wraps beside it rather than pushing the right side onto a line of its own (a narrow phone did). */
.part-row.is-band {
  flex-wrap: nowrap;
  align-items: flex-start;
}
.part-row.is-band .part-left {
  flex: 1 1 0;
}
.part-row.is-band .part-left .part {
  white-space: normal;
  overflow-wrap: anywhere;
}
.part-row.is-band .part-right {
  flex: none;
  max-width: 60%;
}
.tree .part-badge {
  color: inherit;
}

/* ---------- connect ---------- */

.connect {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.connect-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.connect-brand h1 {
  margin: 0;
  font-size: calc(19px * var(--text-scale));
  font-weight: 700;
  letter-spacing: -0.01em;
}
.machine-card {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.machine-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.machine-name {
  font-size: calc(18px * var(--text-scale));
  font-weight: 700;
}
.machine-tag {
  margin-left: auto;
  padding: 2px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: calc(12px * var(--text-scale));
}
.machine-line {
  color: var(--muted);
}
.machine-hint {
  color: var(--dim);
  font-size: calc(14px * var(--text-scale));
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: calc(14px * var(--text-scale));
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.connect-foot {
  color: var(--dim);
  font-size: calc(13px * var(--text-scale));
}

.lang-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--dim);
  font-size: calc(13px * var(--text-scale));
}
.lang-picker select {
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* ---------- phone screens ---------- */

.screen-wrap {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.topbar-mark {
  width: 40px;
  display: grid;
  place-items: center;
}
.topbar-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar-title h1 {
  margin: 0;
  font-size: calc(17px * var(--text-scale));
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-machine {
  color: var(--dim);
  font-size: calc(12px * var(--text-scale));
}
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.space-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}
.space-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.space-card:active {
  background: var(--surface-2);
}
.space-card.has-blocked {
  border-color: color-mix(in srgb, var(--pink) 45%, var(--line));
}
.space-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.space-name {
  font-size: calc(17px * var(--text-scale));
  font-weight: 700;
}
.space-meta {
  color: var(--muted);
  font-size: calc(13px * var(--text-scale));
}
.row-chev {
  flex: none;
  color: var(--dim);
}

.agent-list {
  display: flex;
  flex-direction: column;
}
.agent-row {
  display: grid;
  grid-template-columns: minmax(2.4em, max-content) 16px minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 9px;
  min-height: 58px;
  padding: 10px 12px 10px 8px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--line);
}
.agent-row .tree {
  max-width: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  font-size: calc(14px * var(--text-scale));
  line-height: 22px;
}
.agent-row .dot {
  margin-top: 3px;
}
.agent-row .row-chev {
  align-self: center;
}
.agent-row:hover,
.agent-row:active {
  background: var(--surface);
}
.agent-row.st-blocked {
  background: color-mix(in srgb, var(--pink) 8%, transparent);
  border-left-color: var(--pink);
}
.agent-row.selected {
  background: var(--surface-2);
  border-left-color: var(--accent);
}
.row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.row-name {
  font-weight: 600;
  line-height: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: calc(13px * var(--text-scale));
}
/* One line, like herdr's sidebar: what does not fit is cut, never wrapped under. */
.parts.row-sub,
.parts.chat-sub {
  flex-wrap: nowrap;
  overflow: hidden;
}
.row-sub .part,
.chat-sub .part {
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-sub .part:not(:last-child),
.chat-sub .part:not(:last-child) {
  flex-shrink: 0;
}
.row-sub .part:last-child,
.chat-sub .part:last-child {
  flex: 1 1 auto;
  min-width: 0;
}
.row-conv {
  min-width: 0;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 28px 16px;
  color: var(--dim);
  text-align: center;
}

.update-banner {
  position: fixed;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  z-index: 40;
  color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 14%, var(--bg));
}
.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 7px 12px;
  background: color-mix(in srgb, var(--orange) 15%, var(--bg));
  color: var(--orange);
  font-size: calc(13px * var(--text-scale));
  font-weight: 600;
}

/* ---------- wide screens ---------- */

.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}
.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
}
.side-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.side-home {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.side-machine {
  flex: 1;
  font-weight: 700;
}
.side-label {
  margin: 16px 16px 6px;
  color: var(--dim);
  font-size: calc(11px * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.side-count {
  margin-left: 4px;
  color: var(--muted);
}
.space-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}
.space-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
}
.space-row:hover {
  background: var(--surface);
}
.space-row.selected {
  background: var(--surface-2);
}
.space-row-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar .agent-row {
  grid-template-columns: minmax(2.2em, max-content) 16px minmax(0, 1fr);
  min-height: 52px;
  padding: 8px 12px 8px 6px;
  border-bottom: 0;
}
.sidebar .row-chev {
  display: none;
}
.settings {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.settings-card h2 {
  margin: 0;
  font-size: calc(15px * var(--text-scale));
  font-weight: 700;
}
.settings-card .btn-block,
.settings-card .btn-row {
  width: 100%;
}
.field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: calc(13px * var(--text-scale));
}
.field input,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: calc(15px * var(--text-scale));
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.past-list {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.past-row {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  text-align: left;
  cursor: pointer;
}
.past-row:hover {
  border-color: var(--accent);
}
.past-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.past-at {
  flex: none;
  color: var(--dim);
  font-size: calc(12px * var(--text-scale));
}
.side-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-right: 10px;
}
.icon-btn.small {
  width: 28px;
  height: 28px;
}
.actions {
  position: relative;
  flex: none;
}
.actions-scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
}
.actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 21;
  min-width: 230px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.35);
}
.actions-menu button {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.actions-menu button:hover {
  background: var(--surface-2);
}
.actions-menu button.danger {
  color: var(--red);
}
.settings-line {
  color: var(--muted);
  font-size: calc(14px * var(--text-scale));
}
.settings-line.ok {
  color: var(--green);
}
.settings-line.warn {
  color: var(--orange);
}
.main {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}

/* ---------- chat ---------- */

.chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 6px;
  border-bottom: 1px solid var(--line);
}
.chat-title {
  flex: 1;
  min-width: 0;
}
.chat-name {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: calc(16px * var(--text-scale));
  font-weight: 700;
}
.chat-sub {
  min-width: 0;
  display: flex;
  gap: 8px;
  margin-top: 1px;
  color: var(--dim);
  font-size: calc(13px * var(--text-scale));
}
.status-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: calc(12px * var(--text-scale));
  font-weight: 650;
}
.status-pill.st-blocked {
  background: color-mix(in srgb, var(--pink) 18%, transparent);
  color: var(--pink);
}
.status-pill.st-working {
  color: var(--yellow);
}
.status-pill.st-done {
  color: var(--green);
}

.seg {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}
.seg button {
  flex: 1;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}
.seg button[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.messages {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.messages-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: 100%;
}
.msg-user {
  align-self: flex-end;
  max-width: 88%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.msg-user .bubble {
  padding: 9px 13px;
  border-radius: 18px 18px 5px 18px;
  background: var(--user-bubble);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.pending .bubble {
  opacity: 0.72;
}
.pending.is-queued .bubble {
  opacity: 1;
  outline: 1px dashed var(--yellow);
  outline-offset: -1px;
  background: transparent;
}
.pending-state {
  color: var(--dim);
  font-size: calc(11px * var(--text-scale));
}
.is-queued .pending-state {
  color: var(--yellow);
}
.is-unconfirmed .pending-state {
  color: var(--orange);
}
.pending-state.is-received {
  color: var(--green);
}
.msg-assistant {
  align-self: stretch;
  overflow-wrap: anywhere;
}
.msg-thinking {
  align-self: stretch;
  overflow-wrap: anywhere;
  color: var(--dim);
}
.msg-note {
  align-self: center;
  max-width: 90%;
  color: var(--dim);
  font-size: calc(12px * var(--text-scale));
  text-align: center;
  white-space: pre-wrap;
}
.ask-card {
  align-self: stretch;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
}
.ask-q + .ask-q {
  margin-top: 10px;
}
.ask-title {
  margin-bottom: 6px;
  font-weight: 650;
}
.ask-options {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}
.ask-options li + li {
  margin-top: 4px;
}
.ask-choice {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.ask-choice:hover {
  border-color: var(--pink);
}
.ask-choice:disabled {
  opacity: 0.6;
  cursor: progress;
}
.ask-choice.is-busy {
  border-color: var(--pink);
}

.tools {
  align-self: stretch;
  color: var(--muted);
  font-size: calc(13px * var(--text-scale));
}
.tools-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.tools-count {
  flex: none;
  font-weight: 650;
}
.tools-err {
  flex: none;
  color: var(--red);
  font-weight: 650;
}
.tools-last {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
}
.tools-last b {
  color: var(--muted);
  font-weight: 600;
}
.tools-list {
  list-style: none;
  margin: 6px 0 0 6px;
  padding: 0 0 0 8px;
  border-left: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tool-line {
  width: 100%;
  display: flex;
  gap: 8px;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
  text-align: left;
  cursor: pointer;
}
.tool-line:hover {
  background: var(--surface);
}
.tool-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tools-list li.err .tool-line b {
  color: var(--red);
}
.tool-detail {
  max-height: 40vh;
  overflow: auto;
  margin: 2px 0 6px 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-stats {
  flex: none;
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  white-space: nowrap;
}
.diff-stats .add {
  color: var(--green);
}
.diff-stats .del {
  color: var(--red);
}
.tool-line .diff-stats {
  margin-left: auto;
}
.diff {
  margin: 4px 0 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
  line-height: 1.5;
}
.diff-block + .diff-block {
  border-top: 1px dashed var(--line-strong);
}
.dl {
  display: flex;
  min-width: max-content;
  padding: 0 10px 0 0;
}
.dl-op {
  flex: none;
  width: 22px;
  text-align: center;
  color: var(--dim);
  user-select: none;
}
.dl-text {
  white-space: pre;
}
.dl-add {
  background: color-mix(in srgb, var(--green) 14%, transparent);
}
.dl-add .dl-op {
  color: var(--green);
}
.dl-del {
  background: color-mix(in srgb, var(--red) 14%, transparent);
}
.dl-del .dl-op {
  color: var(--red);
}
.dl-skip {
  padding: 2px 10px;
  color: var(--dim);
  background: var(--surface);
  font-family: var(--font);
  font-size: calc(11.5px * var(--text-scale));
}
.diff-note {
  padding: 6px 10px;
  color: var(--orange);
  font-family: var(--font);
}
.changes {
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.changes-empty {
  margin: 24px auto;
}
.change-file {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.change-file summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}
.change-file summary::-webkit-details-marker {
  display: none;
}
.change-file[open] summary {
  border-bottom: 1px solid var(--line);
}
.change-file .diff {
  margin: 8px;
}
.changes-root {
  padding: 0 4px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: calc(11.5px * var(--text-scale));
  overflow-wrap: anywhere;
}
.change-where {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.change-name,
.change-dir {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
}
.change-name {
  font-size: calc(13px * var(--text-scale));
  font-weight: 650;
}
.change-dir {
  color: var(--dim);
  font-size: calc(11.5px * var(--text-scale));
}
.change-new {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 16%, transparent);
  color: var(--green);
  font-size: calc(11px * var(--text-scale));
  font-weight: 650;
}
.seg-count {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--line-strong);
  font-size: calc(11px * var(--text-scale));
}

.to-bottom {
  position: sticky;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  margin: 0 auto;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: calc(13px * var(--text-scale));
  font-weight: 650;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  cursor: pointer;
}

/* markdown */
.md {
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.62;
}
.md-p,
.md-list li,
.md-quote {
  white-space: pre-wrap;
}
.md-h {
  margin-top: 4px;
  font-weight: 700;
}
.md-h1 {
  font-size: 1.15em;
}
.md-h2 {
  font-size: 1.07em;
}
.md code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.87em;
}
.md-code {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: calc(12.5px * var(--text-scale));
  line-height: 1.5;
}
.md-code code {
  padding: 0;
  background: none;
  font-size: inherit;
}
.md-list {
  margin: 0;
  padding-left: 1.3em;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.md-ol {
  list-style: none;
  padding-left: 0;
}
.md-ol li::before {
  content: attr(data-n) " ";
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.md-d1 {
  margin-left: 1.2em;
}
.md-d2 {
  margin-left: 2.4em;
}
.md-d3 {
  margin-left: 3.6em;
}
.md-quote {
  margin: 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}
.md-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.md-table table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: calc(13px * var(--text-scale));
}
.md-table th,
.md-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.md-table th {
  background: var(--surface);
  font-weight: 650;
  white-space: nowrap;
}
.md-table tr:last-child td {
  border-bottom: 0;
}
.md-hr {
  margin: 4px 0;
  border: 0;
  border-top: 1px solid var(--line);
}
.md a,
a.link {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
  cursor: pointer;
}
a.link code {
  color: inherit;
}

/* dock: menu, keys, composer */
.dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
}
.dock > * {
  width: 100%;
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}
.toast {
  width: auto;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: calc(13px * var(--text-scale));
  text-align: center;
}

.menu-panel {
  max-height: 55dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--pink) 50%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--pink) 6%, var(--surface));
}
/* The panel scrolls; nothing in it shrinks to make room, or the text above the question is cut to a sliver. */
.menu-panel > * {
  flex-shrink: 0;
}
.menu-badge {
  color: var(--pink);
  font-size: calc(12px * var(--text-scale));
  font-weight: 700;
}
.menu-context {
  max-height: 9.5em;
  overflow-y: auto;
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.menu-question {
  padding: 0 2px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.menu-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.choice {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.choice:hover {
  border-color: var(--muted);
}
.choice.at-cursor {
  border-color: var(--pink);
}
.choice:disabled {
  opacity: 0.6;
  cursor: progress;
}
.choice-n {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
  font-weight: 700;
}
.choice.at-cursor .choice-n {
  background: var(--pink);
  color: var(--bg);
}
.choice-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.choice-label {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.choice-detail {
  color: var(--muted);
  font-size: calc(12.5px * var(--text-scale));
}
.choice-box {
  margin-right: 6px;
}

.keybar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.keybar::-webkit-scrollbar {
  display: none;
}
.key {
  flex: 1 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: calc(13px * var(--text-scale));
  cursor: pointer;
}
.key:active {
  background: var(--surface-2);
}
.key-wide {
  min-width: 58px;
}

.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.composer.is-dragging textarea {
  border-color: var(--accent);
  border-style: dashed;
}
.uploading {
  position: absolute;
  left: 50px;
  bottom: calc(100% + 6px);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: calc(12px * var(--text-scale));
}
.upload-thumb {
  display: block;
  margin: 4px 0;
}
.upload-thumb img {
  display: block;
  max-width: min(240px, 100%);
  max-height: 240px;
  border-radius: 10px;
  object-fit: cover;
}
.suggest {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  max-height: min(42dvh, 340px);
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
}
.suggest button {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.suggest button[aria-selected="true"],
.suggest button:hover {
  background: var(--surface-2);
}
.sg-value {
  font-family: var(--mono);
  font-size: calc(13px * var(--text-scale));
  font-weight: 600;
  white-space: nowrap;
}
.sg-skill,
.sg-command {
  color: var(--purple);
}
.sg-builtin {
  color: var(--cyan);
}
.sg-dir {
  color: var(--cyan);
}
.sg-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: calc(12.5px * var(--text-scale));
}
.sg-kind {
  color: var(--dim);
  font-size: calc(11px * var(--text-scale));
}
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 35dvh;
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  resize: none;
  outline: none;
  overflow-y: hidden;
}
.composer textarea:focus {
  border-color: var(--accent);
}
.send-btn {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.send-btn:disabled {
  background: var(--surface-2);
  color: var(--dim);
  cursor: default;
}

.screen {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: calc(11.5px * var(--text-scale));
  line-height: 1.35;
  white-space: pre;
}

@media (pointer: coarse) {
  .composer textarea {
    /* An iPhone zooms into a field whose text is under 16px: never below that, whatever the size chosen. */
    font-size: max(16px, calc(16px * var(--text-scale)));
  }
}

/* A phone is narrower than the agent's terminal; wrapping beats scrolling sideways line by line. */
@media (max-width: 899px) {
  .screen {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: calc(11px * var(--text-scale));
  }
}

@media (min-width: 900px) {
  html,
  body {
    font-size: calc(14px * var(--text-scale));
  }
  .chat-head {
    padding: 12px 20px;
  }
  .seg {
    padding: 6px 20px;
  }
  .seg button {
    flex: none;
    padding: 0 18px;
  }
  .screen {
    padding: 16px 20px;
    font-size: calc(12.5px * var(--text-scale));
  }
  .dock {
    padding: 10px 20px 14px;
  }
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
}

.themes {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.theme-option {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  text-align: left;
  cursor: pointer;
}
.theme-option[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
.theme-swatch {
  display: flex;
  height: 26px;
  border-radius: 7px;
  overflow: hidden;
}
.theme-swatch span {
  flex: 1;
}
.theme-name {
  font-size: calc(13px * var(--text-scale));
  font-weight: 650;
}

/* file preview */
.file-view {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.file-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.file-path {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: calc(12.5px * var(--text-scale));
}
.file-body {
  flex: 1;
  margin: 0;
  overflow: auto;
  padding: 10px 0 calc(16px + env(safe-area-inset-bottom));
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
  line-height: 1.5;
  counter-reset: line;
}
.fl {
  display: block;
  padding-right: 14px;
  white-space: pre;
}
.fl::before {
  counter-increment: line;
  content: counter(line);
  display: inline-block;
  width: 4.2em;
  padding-right: 1em;
  color: var(--dim);
  text-align: right;
  user-select: none;
}
.file-note {
  padding: 10px 14px;
  color: var(--muted);
  font-size: calc(13px * var(--text-scale));
}
.file-note.warn {
  color: var(--orange);
}
.tool-file {
  margin: 0 0 4px 6px;
  padding: 1px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--cyan);
  font-size: calc(11.5px * var(--text-scale));
  cursor: pointer;
}
.code-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* the ＋ tray: key buttons, a photo or file, kept commands */
.plus-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
}
.plus-btn svg {
  transition: transform 0.18s ease;
}
.plus-btn[aria-expanded="true"] {
  background: var(--surface-2);
}
.plus-btn[aria-expanded="true"] svg {
  transform: rotate(45deg);
}
.tray {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 55dvh;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  animation: tray-in 0.16s ease-out;
}
@keyframes tray-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tray,
  .plus-btn svg {
    animation: none;
    transition: none;
  }
}
.tray-tiles {
  max-width: 420px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 72px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: calc(12.5px * var(--text-scale));
  cursor: pointer;
}
.tile svg {
  color: var(--accent);
}
.tile:hover {
  border-color: var(--line-strong);
}
.tile[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
}
.tray-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: calc(12px * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tray-head .link-btn {
  font-size: calc(13px * var(--text-scale));
  padding: 0;
}
.tray-hint {
  margin: 0;
  color: var(--dim);
  font-size: calc(13px * var(--text-scale));
}
.shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.shortcut {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: calc(13.5px * var(--text-scale));
  cursor: pointer;
}
.shortcut:hover {
  border-color: var(--muted);
}
.shortcut.is-command .shortcut-name {
  color: var(--purple);
  font-family: var(--mono);
  font-size: calc(13px * var(--text-scale));
}
.shortcut-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shortcut-bolt {
  flex: none;
  color: var(--yellow);
}
.shortcut-add {
  border-style: dashed;
  color: var(--muted);
}
.shortcut-rows {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.shortcut-rows li {
  display: flex;
  align-items: center;
  gap: 2px;
}
.shortcut-row {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  text-align: left;
  cursor: pointer;
}
.shortcut-row-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.shortcut-row-text {
  color: var(--muted);
  font-family: var(--mono);
  font-size: calc(12px * var(--text-scale));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn.danger {
  color: var(--red);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.shortcut-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.shortcut-form textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: calc(14px * var(--text-scale));
}
.shortcut-form .btn {
  height: 40px;
}
.shortcut-suggest {
  margin: -4px 0 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.shortcut-suggest button {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.shortcut-suggest button:hover {
  background: var(--surface-2);
}

/* the display editor */
.display-editor {
  max-width: 680px;
  padding-bottom: 0;
}
.preview {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.preview .agent-row {
  border: 1px solid var(--line);
  border-radius: 12px;
}
.preview-dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
}
.preview-input {
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  background: var(--surface);
  color: var(--dim);
}
.display-editor select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.value-list {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.value-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.value-row.is-open {
  border-color: var(--line-strong);
}
.value-head {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.value-name {
  font-family: var(--mono);
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  color: var(--purple);
}
.value-sample {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: calc(13px * var(--text-scale));
}
.value-sample.is-quiet {
  color: var(--dim);
  font-style: italic;
}
.value-place {
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-size: calc(11.5px * var(--text-scale));
  white-space: nowrap;
}
.value-place.at-none {
  background: var(--surface-2);
  color: var(--dim);
}
.value-edit {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 12px 14px;
}
.edit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.edit-label {
  color: var(--muted);
  font-size: calc(12.5px * var(--text-scale));
}
.edit-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.edit-choices button {
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: calc(13px * var(--text-scale));
  cursor: pointer;
}
.edit-choices button[aria-checked="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent);
  font-weight: 650;
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.swatch {
  width: 30px;
  height: 30px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  cursor: pointer;
}
.swatch-default {
  background: linear-gradient(135deg, var(--text) 0 50%, var(--surface-2) 50% 100%);
}
.swatch[aria-checked="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.edit-toggles {
  display: flex;
  gap: 18px;
}
.editor-bar {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -14px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
}
.editor-bar .btn {
  height: 40px;
}
.editor-note {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: calc(12.5px * var(--text-scale));
}
.editor-note.warn {
  color: var(--red);
}
.value-look {
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--bg-elev);
}
@media (max-width: 640px) {
  .value-head {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 4px;
  }
  .value-sample {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* desktop panes: up to four conversations at once */
.panes {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 1px;
  background: var(--line);
}
.panes-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.panes-three,
.panes-four {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
.panes-three > .pane:first-child {
  grid-row: span 2;
}
.pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.panes:not(.panes-one) .pane.is-focus::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  border: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  pointer-events: none;
}
.agent-item {
  position: relative;
}
.split-btn {
  position: absolute;
  top: 12px;
  right: 8px;
  background: var(--surface);
  opacity: 0;
}
.agent-item:hover .split-btn,
.split-btn:focus-visible {
  opacity: 1;
}
.agent-item:hover .row-chev {
  visibility: hidden;
}
@media (hover: none) {
  .split-btn {
    opacity: 1;
  }
  .agent-item .row-chev {
    visibility: hidden;
  }
}
.agent-row.in-pane {
  border-left-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
/* half-height panes give the conversation the room: a tighter frame */
.chat.is-compact .chat-head {
  padding: 5px 10px 5px 8px;
}
.chat.is-compact .seg {
  padding-top: 4px;
  padding-bottom: 4px;
}
.chat.is-compact .dock {
  gap: 5px;
  padding: 6px 8px;
}
/* A pane is its own measure: the answer panel takes at most part of the pane, not of the window. */
.pane {
  container-type: size;
}
.pane .menu-panel {
  max-height: min(55dvh, 50cqh);
}
.chat.is-compact .menu-panel {
  max-height: 42cqh;
  padding: 8px;
  gap: 6px;
}
.chat.is-compact .choice {
  min-height: 38px;
  padding: 7px 10px;
}
/* While a half-height pane waits for an answer, the question gets the room the mode chips and band had. */
.chat.is-compact .dock:has(.menu-panel) > .part-row {
  display: none;
}

/* Settings → open on another device */
.other-device {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.qr {
  width: 168px;
  height: 168px;
  flex: none;
  border-radius: 10px;
}
.other-device-text {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.other-device-url {
  font-family: var(--mono);
  font-size: calc(13px * var(--text-scale));
  overflow-wrap: anywhere;
}
/* While the agent works, the send button stops it. */
.send-btn.stop-btn {
  background: color-mix(in srgb, var(--red) 82%, var(--bg));
  color: #fff;
}
.send-btn.stop-btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

/* Settings → Text: each typeface choice is drawn in its own face */
.font-option.font-system {
  font-family: var(--font-system);
}
.font-option.font-serif {
  font-family: var(--font-serif);
}
.font-option.font-mono {
  font-family: var(--mono);
}
.text-preview {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
}

/* dragging agents into a new order */
.agent-item {
  -webkit-touch-callout: none;
  user-select: none;
}
.agent-list.is-dragging .agent-item {
  cursor: grabbing;
}
.agent-item.is-lifted {
  z-index: 6;
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.35);
  opacity: 0.96;
}
.agent-item.drop-before::before,
.drop-end {
  content: "";
  display: block;
  height: 3px;
  margin: 0 10px;
  border-radius: 2px;
  background: var(--accent);
}
.agent-item.drop-before::before {
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  z-index: 5;
}
