/* The phone's screen, in the desktop app's colours: black and white, one accent for attention, one for "live". */

:root {
  --bg: #000;
  --card: #1f1f1f;
  --card-2: #272727;
  --card-3: #303030;
  --line: #2a2a2a;
  --line-2: #3a3a3a;
  --text: #fff;
  --text-2: #c9c9c9;
  --muted: #858585;
  --faint: #5d5d5d;
  --attn: #ff9f43;
  --live: #6ee7a8;
  --ink: #fff;
  --on-ink: #000;
  --well: #0c0c0c;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fff;
    --card: #f1f1f1;
    --card-2: #e7e7e7;
    --card-3: #dadada;
    --line: #e4e4e4;
    --line-2: #cfcfcf;
    --text: #111;
    --text-2: #3d3d3d;
    --muted: #666;
    --faint: #a3a3a3;
    --attn: #b04a05;
    --live: #0b7a4a;
    --ink: #111;
    --on-ink: #fff;
    --well: #e6e6e6;
    color-scheme: light;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.sprite { position: absolute; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

button, input, select, textarea { color: inherit; font: inherit; }
button { border: 0; background: none; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

#app {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 720px;
  height: 100dvh;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}

.grow { min-width: 0; flex: 1; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: -0.01em; }
.brand img { border-radius: 8px; }

.top { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.top .brand { flex: 1; }

.state { flex: none; padding: 5px 11px 5px 24px; border-radius: 999px; background: var(--card); color: var(--muted); font-size: 12px; position: relative; white-space: nowrap; }
.state::before { content: ""; position: absolute; top: 50%; left: 10px; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--faint); }
.state[data-state="on"] { color: var(--text-2); }
.state[data-state="on"]::before { background: var(--live); }
.state[data-state="away"]::before { background: var(--attn); }

h1 { font-size: 24px; font-weight: 650; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
h2 { color: var(--muted); font-size: 12.5px; font-weight: 600; }

.card { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 24px; background: var(--card); }
.card.hero { gap: 12px; }
.card p { color: var(--text-2); }
.card .warn, .err { color: var(--attn); }
.err:empty { display: none; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field span { color: var(--text-2); font-size: 13px; font-weight: 600; }
.field input { width: 100%; padding: 13px 14px; border: 1px solid var(--line-2); border-radius: 14px; background: transparent; font-size: 16px; }
.field input:focus { border-color: var(--ink); outline: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 999px; background: var(--card-3); font-weight: 600; }
.btn.white { background: var(--ink); color: var(--on-ink); }
.btn.line { border: 1px solid var(--line-2); background: transparent; font-weight: 500; }
.link { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.round { display: grid; width: 40px; height: 40px; flex: none; place-items: center; border-radius: 50%; background: var(--card); }

/* ── home ── */

.list { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 8px; overflow-y: auto; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: 10px 16px; border-radius: 20px; background: var(--card); text-align: left; }
.row:active { background: var(--card-2); }
.row .grow { display: flex; flex-direction: column; }
.row b { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row small { overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.row .ic { color: var(--muted); }
.row .go { transform: rotate(-90deg); }
.dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--faint); }
.row.live .dot { background: var(--live); box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 18%, transparent); }
.empty { padding: 28px 12px; color: var(--muted); text-align: center; text-wrap: balance; }
.foot { display: flex; justify-content: center; }

/* ── chat ── */

#app.chat { gap: 10px; }
.title { display: flex; flex-direction: column; }
.title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title small { overflow: hidden; color: var(--muted); font-size: 11.5px; direction: rtl; text-align: left; text-overflow: ellipsis; white-space: nowrap; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--card); }
.tab { min-height: 36px; flex: 1; border-radius: 999px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.tab.on { background: var(--ink); color: var(--on-ink); }

.log { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 12px; overflow-y: auto; padding: 4px 0 8px; overscroll-behavior: contain; }
.hello { margin: auto 0; padding: 0 16px; color: var(--muted); text-align: center; text-wrap: balance; }
.note { align-self: center; color: var(--faint); font-size: 12px; text-align: center; }
.note.err { align-self: stretch; padding: 12px 16px; border: 1px solid color-mix(in srgb, var(--attn) 40%, transparent); border-radius: 16px; color: var(--attn); font-size: 13.5px; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }

.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.user { display: flex; flex-direction: column; align-self: flex-end; max-width: 86%; padding: 10px 16px; border-radius: 20px 20px 6px 20px; background: var(--card-2); white-space: pre-wrap; }
.msg.user small { color: var(--muted); }
.msg.bot > * + * { margin-top: 10px; }
.msg.bot.typing { color: var(--text-2); white-space: pre-wrap; }
.msg.bot h4 { font-size: 16px; font-weight: 600; }
.msg.bot ul, .msg.bot ol { padding-left: 22px; }
.msg.bot li + li { margin-top: 3px; }
.msg.bot a { color: var(--text); text-underline-offset: 3px; }
.msg.bot code { padding: 1px 6px; border-radius: 7px; background: var(--card-2); font: 13px var(--mono); }
.msg.bot pre.code { overflow-x: auto; padding: 12px 14px; border-radius: 16px; background: var(--well); }
.msg.bot pre.code code { padding: 0; background: none; font: 12.5px/1.6 var(--mono); white-space: pre; }

.dots { display: flex; gap: 5px; padding: 6px 2px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bob 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bob { 0%, 60%, 100% { opacity: 0.35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes turn { to { transform: rotate(360deg); } }

.tool { border-radius: 16px; background: var(--card); font-size: 13px; }
.tool-top { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 44px; padding: 8px 14px; color: var(--text-2); text-align: left; }
.tool-top .ic { width: 15px; height: 15px; color: var(--muted); }
.tool-top b { flex: none; font-weight: 600; }
.tool-top code { min-width: 0; flex: 1; overflow: hidden; color: var(--muted); font: 12px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.tool-state { flex: none; color: var(--live); font-size: 12px; }
.tool:not(.done) .tool-state { width: 13px; height: 13px; border: 2px solid var(--card-3); border-top-color: var(--text-2); border-radius: 50%; font-size: 0; animation: turn 0.8s linear infinite; }
.tool-state.bad { color: var(--attn); }
.tool-out { max-height: 220px; margin: 0 10px 10px; overflow: auto; padding: 10px 12px; border-radius: 12px; background: var(--well); color: var(--text-2); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-out[hidden] { display: none; }

.perm { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid color-mix(in srgb, var(--attn) 45%, transparent); border-radius: 20px; background: color-mix(in srgb, var(--attn) 7%, transparent); }
.perm-top { display: flex; align-items: center; gap: 8px; color: var(--attn); }
.perm-what { font: 13px var(--mono); overflow-wrap: anywhere; }
.perm .tool-out { margin: 0; }
.perm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm-actions .line { grid-column: 1 / -1; min-height: 40px; font-size: 13px; }
.perm.answered { flex-direction: row; align-items: center; gap: 9px; padding: 10px 14px; border-color: var(--line); background: transparent; color: var(--muted); font-size: 12.5px; }
.perm.answered .ic { width: 15px; height: 15px; }
.perm.answered.yes .ic { color: var(--live); }
.perm.answered.no .ic { color: var(--attn); }
.perm.answered span { flex: none; }
.perm.answered code { min-width: 0; flex: 1; overflow: hidden; font: 12px var(--mono); text-overflow: ellipsis; white-space: nowrap; }

.orq-plan { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: 20px; }
.orq-plan-top { display: flex; align-items: center; gap: 8px; }
.orq-plan-top .ic { color: var(--muted); }
.orq-plan p { color: var(--text-2); font-size: 13.5px; }
.orq-plan .orq-who { color: var(--muted); }
.orq-step { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13.5px; }
.orq-step span { color: var(--muted); }
.orq-state { width: 13px; height: 13px; border: 2px solid var(--card-3); border-top-color: var(--text-2); border-radius: 50%; animation: turn 0.8s linear infinite; }
.orq-end { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.orq-end .ic { width: 14px; height: 14px; }
.orq-step.ok .orq-end { color: var(--live); }
.orq-step.bad .orq-end { color: var(--attn); }

.composer { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 24px; background: var(--card); }
.picks { display: flex; gap: 8px; }
.picks select { min-width: 0; min-height: 36px; flex: 1; padding: 0 10px; border: 0; border-radius: 999px; background: var(--card-3); font-size: 13px; }
.line { display: flex; align-items: flex-end; gap: 8px; }
.line textarea { min-height: 44px; flex: 1; resize: none; padding: 10px 12px; border: 0; background: transparent; font-size: 16px; line-height: 1.45; }
.line textarea:focus { outline: none; }
.send { display: grid; width: 44px; height: 44px; flex: none; place-items: center; border-radius: 50%; background: var(--ink); color: var(--on-ink); }
.send.stop { background: var(--attn); color: #000; }
.send.stop .ic { fill: currentColor; stroke: none; }

@media (prefers-reduced-motion: reduce) {
  .dots i, .orq-state, .tool:not(.done) .tool-state { animation: none; }
}
