/* Hermes Mobile — compact operator surface for one hand.
   Telegram-like light/dark palette. All measurements respect iPhone safe areas.
   Text colours keep WCAG AA on the surfaces where they render. */

@import url('./task-environment.css');

:root {
  color-scheme: light dark;
  /* Light */
  --bg: #ffffff;              /* app + list background */
  --chat-bg: #e6ebee;         /* chat area (soft, pattern-free tint) */
  --topbar-bg: #ffffff;       /* header + composer bar */
  --bg-raised: #ffffff;       /* cards, inputs, raised chrome */
  --bg-inset: #f0f2f5;        /* code blocks, notices */
  --fg: #14181d;              /* main text (AA on every light surface) */
  --fg-muted: #5f6b76;        /* secondary text (AA on light surfaces) */
  --hairline: #e3e7ea;
  --accent: #3390ec;          /* non-text accents: live dot, jump arrow */
  --accent-strong: #155a9e;   /* pressed accent surface */
  --accent-ink: #1a73c7;      /* text-bearing blue: links, Send, badges */
  --on-accent: #ffffff;
  --on-danger: #ffffff;
  --link: #1a73c7;
  --link-on-user: #1a73c7;
  --danger: #a12622;
  --ok: #1b7f4d;
  --bubble-user: #effdde;     /* outgoing */
  --bubble-user-text: #14181d;
  --bubble-assistant: #ffffff; /* incoming */
  --bubble-assistant-text: #14181d;
  --bubble-shadow: 0 1px 2px rgba(16, 24, 40, 0.10);
  --msg-time: #5f6b76;        /* bubble timestamps (AA on both bubbles) */
  --radius: 12px;
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1621;
    --chat-bg: #0e1621;
    --topbar-bg: #17212b;
    --bg-raised: #17212b;
    --bg-inset: #0e1621;
    --fg: #eef3f7;
    --fg-muted: #7d90a5;      /* AA on list, header and bubbles */
    --hairline: #22303f;
    --accent: #5288c1;
    --accent-strong: #5288c1;
    --accent-ink: #6ab3f3;
    --on-accent: #0e1621;
    --on-danger: #0e1621;
    --link: #6ab3f3;
    --link-on-user: #8fc9f8;
    --danger: #ff6b6b;
    --ok: #4cc98a;
    --bubble-user: #2b5278;
    --bubble-user-text: #eef3f7;
    --bubble-assistant: #182533;
    --bubble-assistant-text: #eef3f7;
    --bubble-shadow: 0 1px 2px rgba(0, 0, 0, 0.30);
    --msg-time: #b3c8da;      /* AA on both dark bubbles */
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app { height: 100dvh; }

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--hairline);
  background: var(--topbar-bg);
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: var(--tap);
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--fg);
  font-size: 20px;
  text-decoration: none;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.icon-btn.back { font-size: 26px; }
.icon-btn.text { font-size: 14px; font-weight: 600; padding: 0 10px; width: auto; }

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

.status-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--fg-muted);
  white-space: nowrap;
}
.status-pill.online { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--hairline)); }
.status-pill.offline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--hairline)); }
.status-pill.working { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 40%, var(--hairline)); }

/* ---------- list ---------- */

.list-actions {
  display: flex;
  gap: 8px;
  padding: 10px 12px 4px;
}

.list-actions a.new-chat {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius);
  background: var(--accent-ink);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  flex: 1;
  justify-content: center;
}
.list-actions a.new-chat:active { background: var(--accent-strong); }

button.ghost {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--bg-raised);
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-overflow-scrolling: touch;
}

a.session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  min-height: 60px;
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
a.session-row:active { background: color-mix(in srgb, var(--fg) 8%, transparent); }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--hairline);
  flex: none;
}
.dot.live { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

.session-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.session-title {
  font-weight: 600;
  font-size: 15.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-preview {
  color: var(--fg-muted);
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-meta { display: flex; align-items: center; gap: 8px; color: var(--fg-muted); font-size: 12.5px; flex: none; }
.session-count {
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-ink);
  color: var(--on-accent);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.session-count:empty { display: none; }

/* ---------- transcript ---------- */

.chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
}

.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

/* ---------- jump to latest ---------- */

.transcript-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.jump-latest {
  position: absolute;
  right: 10px;
  bottom: 12px;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: var(--bg-raised);
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--fg) 18%, transparent);
  -webkit-tap-highlight-color: transparent;
}
.jump-latest:active { background: color-mix(in srgb, var(--fg) 8%, var(--bg-raised)); }
.jump-arrow { font-size: 18px; }
.jump-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-ink);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.turn {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 14px;
  overflow-wrap: anywhere;
  white-space: normal;
}
.turn.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border: none;
  border-bottom-right-radius: 5px; /* smaller corner on the tail side */
}
.turn.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  color: var(--bubble-assistant-text);
  border: none;
  border-bottom-left-radius: 5px; /* smaller corner on the tail side */
  box-shadow: var(--bubble-shadow);
}
.turn p { margin: 0 0 8px; }
.turn p:last-child { margin-bottom: 0; }
.turn pre {
  margin: 8px 0;
  padding: 10px;
  background: var(--bg-inset);
  border-radius: 8px;
  overflow-x: auto;
  max-width: 100%;
  font-size: 13px;
}
.turn code { font-family: var(--mono); font-size: 13.5px; }
.turn :not(pre) > code {
  background: var(--bg-inset);
  padding: 1px 5px;
  border-radius: 5px;
}
.turn a { color: var(--link); overflow-wrap: anywhere; }
.turn.user a { color: var(--link-on-user); }
.turn ul, .turn ol { margin: 6px 0; padding-left: 22px; }
.turn h1, .turn h2, .turn h3, .turn h4 { font-size: 16px; margin: 8px 0 4px; }
.turn blockquote {
  margin: 6px 0;
  padding-left: 10px;
  border-left: 3px solid var(--hairline);
  color: var(--fg-muted);
}
/* Quotes inside the user's own bubble need a lighter mix for AA. */
.turn.user blockquote { color: color-mix(in srgb, var(--fg) 82%, var(--fg-muted)); }

/* ---------- timestamps, day separators, event cards, tool/interim steps ---------- */

.turn-row {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.day-sep {
  align-self: center;
  margin: 2px 0 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.3;
}

.msg-time {
  display: block;
  margin-top: 3px;
  text-align: right;
  font-size: 11px;
  line-height: 1.2;
  color: var(--msg-time);
  user-select: none;
}

/* Non-human machine notices: full-width muted card with a small label. */
.turn.event {
  align-self: stretch;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--fg) 6%, var(--chat-bg));
  border: 1px solid var(--hairline);
  box-shadow: none;
}
.event-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 3px;
}
.event-body {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--fg-muted);
  font-size: 13px;
}
.turn.event.expanded .event-body {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.event-toggle {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Tool progress: compact single-line muted step. */
.turn.tool {
  align-self: stretch;
  max-width: 100%;
  padding: 2px 4px 2px 8px;
  border: none;
  border-left: 2px solid var(--hairline);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--fg-muted);
  font-size: 12px;
}
.tool-line {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

/* Interim/tool-progress assistant text: compact muted row until the final reply. */
.turn.interim {
  padding: 2px 4px;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--fg-muted);
  font-size: 13px;
  font-style: italic;
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}

.readonly-note {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  color: var(--fg-muted);
  font-size: 13px;
  border-top: 1px solid var(--hairline);
}

.load-earlier { padding: 8px 14px; text-align: center; }
.load-earlier button {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--bg-raised);
  color: var(--fg);
  cursor: pointer;
}

/* ---------- notices / attention ---------- */

.notices { padding: 8px 12px 0; display: flex; flex-direction: column; gap: 6px; }
.notice {
  background: var(--bg-inset);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--fg-muted);
}
.attention {
  margin: 8px 12px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  font-size: 13px;
}

/* ---------- approval card ---------- */

.approval-card {
  margin: 8px 12px 0;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--hairline));
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.approval-title { margin: 0 0 6px; font-weight: 600; font-size: 14px; }
.approval-command {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg-inset);
  border-radius: 6px;
  padding: 8px;
  margin: 0 0 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.approval-desc { margin: 0 0 8px; color: var(--fg-muted); font-size: 13px; }
.approval-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.approval-actions button {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  font-size: 14px;
  cursor: pointer;
}
.approval-actions button.primary { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--on-accent); font-weight: 600; }
.approval-actions button.deny { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--hairline)); }

/* ---------- composer ---------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
  background: var(--topbar-bg);
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--hairline);
  background: var(--bg-raised);
  color: var(--fg);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  line-height: 1.35;
  max-height: 132px;
  min-height: var(--tap);
}

.composer button {
  min-width: 74px;
  min-height: var(--tap);
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.composer button.send { background: var(--accent-ink); color: var(--on-accent); }
.composer button.send:disabled { opacity: 0.55; }
.composer button.stop { background: var(--danger); color: var(--on-danger); }

/* ---------- login ---------- */

.login-screen { justify-content: center; align-items: center; padding: 24px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; }
.login a.new-chat { min-height: var(--tap); display: flex; align-items: center; justify-content: center; padding: 12px 16px; border-radius: 10px; background: var(--accent-ink); color: var(--on-accent); font-weight: 600; text-decoration: none; }
.readonly-note button.retry { min-height: var(--tap); display: block; width: 100%; margin-top: 8px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--bg-raised); color: var(--fg); font: inherit; cursor: pointer; }
.brand { font-size: 26px; margin: 0 0 4px; letter-spacing: 0.02em; }
.login-sub { color: var(--fg-muted); margin: 0 0 20px; font-size: 14.5px; }
form.login label { font-size: 13.5px; color: var(--fg-muted); margin: 10px 0 4px; }
form.login input {
  min-height: var(--tap);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--fg);
  padding: 10px 12px;
  font-size: 16px;
}
form.login button {
  margin-top: 18px;
  min-height: var(--tap);
  border: none;
  border-radius: 10px;
  background: var(--accent-ink);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 16px;
}
form.login button:disabled { opacity: 0.6; }
.login-error { color: var(--danger); font-size: 13.5px; min-height: 18px; margin: 8px 0 0; }
.login-foot { color: var(--fg-muted); font-size: 12.5px; margin-top: 18px; }

/* ---------- states ---------- */

.state-block {
  padding: 20px 16px;
  color: var(--fg-muted);
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.state-block.error { color: var(--danger); }
.state-block a.retry, .state-block button.retry {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--bg-raised);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
}
.muted { color: var(--fg-muted); font-size: 13px; margin: 0; }

.boot { height: 100dvh; display: grid; place-items: center; }
.boot-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--hairline);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .boot-spinner { animation: none; }
}

.noscript { padding: 24px; font-family: system-ui, sans-serif; }

/* ---------------------------------------------------------------------------
 * Parent / Task tabs (approved layout from .private/parent-task-tabs-preview)
 *
 * Only existing tokens are used. The tab bar sits at the bottom of both root
 * lists; conversation screens keep the current chat layout. 44px minimum on
 * every tap target.
 * ------------------------------------------------------------------------- */

.tabbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--hairline);
  background: var(--topbar-bg);
  padding-bottom: env(safe-area-inset-bottom);
  flex: none;
}
.tabbar a.tab {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  color: var(--fg-muted);
  font-size: 15px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a.tab:active { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.tabbar a.tab[aria-current="page"] { color: var(--accent-ink); }
.tab-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-ink);
  color: var(--on-accent);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.tab-badge:empty { display: none; }

/* Task rows reuse a.session-row; status text and needs-answer dot follow it. */
.task-status {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-muted);
  white-space: nowrap;
}
.task-status.needs { color: var(--accent-ink); }
.dot.needs {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Task conversation: the full task title wraps in the header. */
.topbar-title.wrap { white-space: normal; overflow: visible; overflow-wrap: anywhere; line-height: 1.25; }

/* Outgoing reply footer: time + delivery state on one right-aligned line. */
.msg-foot {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 5px;
  margin-top: 3px;
}
.msg-foot .msg-time { display: inline; margin-top: 0; }
.msg-state {
  font-size: 11px;
  line-height: 1.2;
  color: var(--msg-time);
  user-select: none;
  white-space: nowrap;
}

/* A failed reply notice can offer one bounded re-check action. */
.notices button.retry {
  min-height: var(--tap);
  align-self: flex-start;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}

/* ---------------------------------------------------------------------------
 * Implementation review (wave-4 Task tab extension)
 *
 * Review rows share a.session-row; the review screen extends the chat layout
 * with cards on the chat background and a bottom action area in place of the
 * composer. Only existing tokens are used; 44px minimum on every tap target.
 * ------------------------------------------------------------------------- */

/* Task list: one heading per group inside the shared session list. */
.list-section-title {
  padding: 10px 14px 4px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.list-section-note { padding: 4px 14px 10px; }
.list-section-error {
  padding: 4px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.list-section-error button.retry {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--bg-raised);
  color: var(--fg);
  cursor: pointer;
}

/* A review notice can carry an error tone (stale / uncertain actions). */
.notice.error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--hairline));
}

.review-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--chat-bg);
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.review-card {
  background: var(--bg-raised);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--bubble-shadow);
}
.review-card h2 {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  margin: 0 0 6px;
}
.review-card .rows { display: flex; gap: 8px; margin-top: 8px; }
.review-card .rows button {
  flex: 1;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.review-card .rows button:active { background: color-mix(in srgb, var(--fg) 8%, var(--bg-raised)); }
.review-card .rows button:disabled { opacity: 0.55; }

.review-text { overflow-wrap: anywhere; }
.review-text p { margin: 0 0 8px; }
.review-text p:last-child { margin-bottom: 0; }
.review-text pre {
  margin: 8px 0;
  padding: 10px;
  background: var(--bg-inset);
  border-radius: 8px;
  overflow-x: auto;
  max-width: 100%;
  font-size: 13px;
}
.review-text code { font-family: var(--mono); font-size: 13.5px; }
.review-text ul, .review-text ol { margin: 6px 0; padding-left: 22px; }

.review-list { margin: 0; padding-left: 20px; }
.review-list li { margin: 2px 0; overflow-wrap: anywhere; }

.review-quote {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  background: var(--bg-inset);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0;
}

.review-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13.5px;
  min-width: 0;
}
.review-kv + .review-kv { margin-top: 5px; }
.review-kv .k { color: var(--fg-muted); flex: none; }
.review-kv .v { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.review-kv .mono { font-family: var(--mono); font-size: 13px; }

.review-note { color: var(--fg-muted); font-size: 12.5px; margin: 6px 0 0; }

.review-warn {
  margin: 6px 0 0;
  padding: 7px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  font-size: 12.5px;
}
.review-warn.neutral {
  background: var(--bg-inset);
  border-color: var(--hairline);
  color: var(--fg-muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  line-height: 1.5;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--fg-muted);
  white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--hairline)); }
.chip.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--hairline)); }

.test-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.test-row + .test-row { margin-top: 6px; }
.test-row .name { font-size: 13.5px; overflow-wrap: anywhere; }
.test-row .note { color: var(--fg-muted); font-size: 12.5px; width: 100%; }

.points-group + .points-group { margin-top: 8px; }
.points-group .pool {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fg-muted);
  margin-bottom: 2px;
}
.points-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  min-width: 0;
  flex-wrap: wrap;
}
.points-row .who { font-weight: 600; flex: none; }
.points-row .pts {
  margin-left: auto;
  font-weight: 600;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.points-row .why { color: var(--fg-muted); font-size: 12.5px; width: 100%; }

.action-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.action-history li { font-size: 13px; color: var(--fg-muted); overflow-wrap: anywhere; }
.action-history .ev { color: var(--fg); font-weight: 600; }
.action-history .fb { display: block; margin-top: 2px; }

.review-state { font-size: 13.5px; color: var(--fg-muted); margin: 0; }
.review-state strong { color: var(--fg); }

/* Bottom action area: like the composer, one panel at a time. */
.review-footer {
  flex: none;
  border-top: 1px solid var(--hairline);
  background: var(--topbar-bg);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.review-footer .row { display: flex; gap: 8px; }
.review-footer button {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--bg-raised);
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  padding: 0 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.review-footer button:active { background: color-mix(in srgb, var(--fg) 8%, var(--bg-raised)); }
.review-footer button.primary {
  background: var(--accent-ink);
  color: var(--on-accent);
  border-color: var(--accent-ink);
}
.review-footer button.primary:active { background: var(--accent-strong); }
.review-footer button:disabled { opacity: 0.55; }

.review-footer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--hairline);
  background: var(--bg-raised);
  color: var(--fg);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  line-height: 1.35;
  max-height: 132px;
  min-height: var(--tap);
}
.review-footer .hint { color: var(--fg-muted); font-size: 12.5px; margin: 0; }
.review-footer .panel-title { font-size: 14px; font-weight: 600; margin: 0; }
