/* ══════════════════════════════════════════════════════════════════════
   OpenClaw — design system
   Jobs: taste is engineering. One accent, one type scale, no decoration.
   Cuban: the numbers are the interface. Make them unmissable.
   ══════════════════════════════════════════════════════════════════════ */

:root {
  /* Surface — near-black, four steps only */
  --bg:        #08090a;
  --surface:   #101214;
  --surface-2: #171a1d;
  --line:      #23272b;
  --line-soft: #1a1e21;

  /* Ink — three weights, no more */
  --ink:       #f2f4f5;
  --ink-2:     #9aa3a9;
  --ink-3:     #5d666c;

  /* One accent. The claw. */
  --accent:      #ff8a3d;
  --accent-soft: rgba(255,138,61,.12);
  --accent-line: rgba(255,138,61,.32);

  /* Semantics — used only on numbers, never decoratively */
  --good: #3ddc84;
  --warn: #ffc53d;
  --bad:  #ff5c5c;

  /* Type */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, monospace;

  /* Space — 4px base, 8 steps */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-full: 999px;

  --bar-h: 52px;
  --rail-h: 56px;

  --ease: cubic-bezier(.22,.61,.36,1);
}

*, *::before, *::after { box-sizing: border-box; }

/* Component display rules must never defeat the hidden attribute. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  padding-bottom: calc(var(--rail-h) + env(safe-area-inset-bottom));
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── The bar ─────────────────────────────────────────────────────────── */

.bar {
  position: sticky; top: 0; z-index: 40;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--s4) 0;
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
}

.bar__left, .bar__right { display: flex; align-items: center; gap: var(--s3); }

.mark { color: var(--accent); display: grid; place-items: center; }

.wordmark {
  font-size: 15px; font-weight: 600; letter-spacing: -.01em;
}

.pill {
  display: inline-flex; align-items: center; gap: var(--s2);
  height: 28px; padding: 0 var(--s3);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-full); color: var(--ink-2);
  font: inherit; font-size: 12px; cursor: pointer;
  transition: border-color .18s var(--ease), color .18s var(--ease);
}
.pill:hover { border-color: var(--line-soft); color: var(--ink); }

.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3);
  transition: background .2s var(--ease), box-shadow .2s var(--ease);
}
.dot[data-state="live"]    { background: var(--good); box-shadow: 0 0 0 3px rgba(61,220,132,.14); }
.dot[data-state="working"] { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.4s infinite; }
.dot[data-state="down"]    { background: var(--bad); box-shadow: 0 0 0 3px rgba(255,92,92,.14); }

@keyframes pulse { 50% { opacity: .35; } }

.ghost {
  height: 28px; padding: 0 var(--s3);
  background: transparent; border: 1px solid transparent;
  border-radius: var(--r-full); color: var(--ink-3);
  font: inherit; font-size: 12px; cursor: pointer;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.ghost:hover { color: var(--ink); border-color: var(--line); }
.ghost.install { color: var(--accent); border-color: var(--accent-line); }

/* ── Views ───────────────────────────────────────────────────────────── */

.view {
  max-width: 720px; margin: 0 auto;
  padding: var(--s6) var(--s4) var(--s8);
  animation: rise .32s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.hero { margin-bottom: var(--s6); }
.hero--tight { margin-bottom: var(--s5); }

.hero__kicker {
  margin: 0 0 var(--s2);
  font-size: 11px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent);
}

.hero__line {
  margin: 0;
  font-size: clamp(26px, 7vw, 38px);
  font-weight: 600; letter-spacing: -.03em; line-height: 1.12;
  text-wrap: balance;
}

.hero__sub {
  margin: var(--s3) 0 0;
  color: var(--ink-2); font-size: 14px;
}
.hero__sub [data-bind] { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── The one field ───────────────────────────────────────────────────── */

.field {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.field input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  color: var(--ink); font: inherit; font-size: 16px; /* 16px stops iOS zoom */
  padding: var(--s2) 0;
}
.field input::placeholder { color: var(--ink-3); }

.send {
  flex: none; width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--accent); color: #0b0b0b;
  border: 0; border-radius: var(--r-md); cursor: pointer;
  transition: transform .14s var(--ease), opacity .14s var(--ease);
}
.send:active { transform: scale(.94); }
.send[disabled] { opacity: .35; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }

.chip {
  padding: 6px var(--s3);
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--r-full); color: var(--ink-2);
  font: inherit; font-size: 12.5px; cursor: pointer;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }

/* ── Rule of three ───────────────────────────────────────────────────── */

.three {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--s2); margin-top: var(--s6);
}

.card {
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
.card__label {
  margin: 0; font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.card__value {
  margin: var(--s2) 0 0;
  font-size: 30px; font-weight: 600; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.card__note { margin: var(--s2) 0 0; font-size: 12px; color: var(--ink-3); }

.card[data-tone="good"] .card__value { color: var(--good); }
.card[data-tone="warn"] .card__value { color: var(--warn); }
.card[data-tone="bad"]  .card__value { color: var(--bad); }

/* ── Tiles (numbers) ─────────────────────────────────────────────────── */

.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s2);
}

.tile {
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
.tile__label {
  margin: 0; font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.tile__value {
  margin: var(--s2) 0 0;
  font-size: 26px; font-weight: 600; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.tile__value .unit { font-size: 15px; color: var(--ink-3); margin-left: 2px; }
.tile__delta { margin: var(--s2) 0 0; font-size: 12px; color: var(--ink-3); }
.tile__delta[data-tone="good"] { color: var(--good); }
.tile__delta[data-tone="warn"] { color: var(--warn); }
.tile__delta[data-tone="bad"]  { color: var(--bad); }

/* ── Chart ───────────────────────────────────────────────────────────── */

.chart {
  margin: var(--s6) 0 0;
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
.chart figcaption {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--ink-2); margin-bottom: var(--s3);
}
.chart__legend { color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); display: inline-block; }
.chart svg { display: block; width: 100%; height: 120px; overflow: visible; }

/* ── Ledger table ────────────────────────────────────────────────────── */

.table-wrap {
  margin-top: var(--s5);
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
  overflow-x: auto; background: var(--surface);
}
.ledger { width: 100%; border-collapse: collapse; font-size: 13px; }
.ledger th {
  text-align: left; padding: var(--s3) var(--s4);
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.ledger td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2); white-space: nowrap;
}
.ledger tr:last-child td { border-bottom: 0; }
.ledger td:first-child { color: var(--ink); }
.ledger .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }

/* ── Agents ──────────────────────────────────────────────────────────── */

.agents { display: grid; gap: var(--s2); }

.agent {
  display: grid; grid-template-columns: 34px 1fr auto;
  align-items: center; gap: var(--s3);
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  transition: border-color .18s var(--ease);
}
.agent:hover { border-color: var(--line); }

.agent__glyph {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent);
  font-size: 15px; font-weight: 600;
}
.agent__name { margin: 0; font-size: 14px; font-weight: 600; }
.agent__role { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.agent__stat { text-align: right; font-variant-numeric: tabular-nums; }
.agent__stat b { display: block; font-size: 15px; font-weight: 600; }
.agent__stat span { font-size: 11px; color: var(--ink-3); }

/* ── Section titles ──────────────────────────────────────────────────── */

.section-title {
  margin: var(--s7) 0 var(--s3);
  font-size: 12px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}
.section-note { margin: calc(var(--s3) * -1 + 2px) 0 var(--s3); font-size: 12.5px; color: var(--ink-3); }

/* ── Approvals ───────────────────────────────────────────────────────── */

.approvals { display: grid; gap: var(--s2); }

.approval {
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
}
.approval__what { margin: 0; font-size: 14px; font-weight: 600; }
.approval__why { margin: var(--s2) 0 0; font-size: 12.5px; color: var(--ink-2); }
.approval__cost { margin: var(--s2) 0 0; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.approval__acts { display: flex; gap: var(--s2); margin-top: var(--s4); }

.btn {
  height: 34px; padding: 0 var(--s4);
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: transparent; color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.btn:hover { border-color: var(--ink-3); }
.btn--go { background: var(--accent); border-color: var(--accent); color: #0b0b0b; font-weight: 600; }
.btn--go:hover { filter: brightness(1.08); }

/* ── Personas ────────────────────────────────────────────────────────── */

.personas { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s2); }

.persona {
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  cursor: pointer; text-align: left;
  transition: border-color .18s var(--ease), transform .18s var(--ease);
}
.persona:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.persona__name { margin: 0; font-size: 14px; font-weight: 600; }
.persona__meta { margin: var(--s2) 0 0; font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }
.persona__bar { margin-top: var(--s3); height: 3px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.persona__bar i { display: block; height: 100%; background: var(--accent); }

/* ── Memory ──────────────────────────────────────────────────────────── */

.memory { display: grid; gap: var(--s2); }
.mem {
  display: flex; align-items: baseline; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm); font-size: 13px; color: var(--ink-2);
}
.mem__kind {
  flex: none; font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--accent);
}

/* ── Punch line ──────────────────────────────────────────────────────── */

.punch {
  margin: var(--s7) 0 0;
  padding-top: var(--s4);
  border-top: 1px solid var(--line-soft);
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  letter-spacing: -.01em;
}

/* ── Rail ────────────────────────────────────────────────────────────── */

.rail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--rail-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line-soft);
}

.rail__item {
  background: none; border: 0; cursor: pointer;
  color: var(--ink-3); font: inherit; font-size: 13px; font-weight: 500;
  transition: color .18s var(--ease);
}
.rail__item[aria-current="page"] { color: var(--ink); }
.rail__item[aria-current="page"]::after {
  content: ""; display: block; width: 16px; height: 2px;
  margin: 4px auto 0; border-radius: 2px; background: var(--accent);
}

/* ── Palette ─────────────────────────────────────────────────────────── */

.palette {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: start center;
  padding-top: 12vh;
  background: rgba(0,0,0,.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade .16s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }

.palette__box {
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.palette__box input {
  width: 100%; padding: var(--s4);
  background: none; border: 0; border-bottom: 1px solid var(--line-soft);
  outline: none; color: var(--ink); font: inherit; font-size: 16px;
}
.palette__box ul { list-style: none; margin: 0; padding: var(--s2); max-height: 46vh; overflow-y: auto; }
.palette__box li {
  padding: var(--s3) var(--s4); border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink-2); cursor: pointer;
  display: flex; justify-content: space-between; gap: var(--s4);
}
.palette__box li[aria-selected="true"] { background: var(--accent-soft); color: var(--ink); }
.palette__box li kbd {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}

/* ── Seams overlay ───────────────────────────────────────────────────── */

.seams {
  position: fixed; inset: 0; z-index: 70;
  background: var(--bg);
  overflow-y: auto;
  padding: var(--s5) var(--s4) var(--s8);
  animation: rise .24s var(--ease) both;
}
.seams__head {
  display: flex; align-items: baseline; gap: var(--s3);
  max-width: 720px; margin: 0 auto var(--s5);
  padding-bottom: var(--s3); border-bottom: 1px solid var(--line);
}
.seams__head strong { font-size: 15px; }
.seams__head span { font-size: 12.5px; color: var(--ink-3); flex: 1; }
.seams__list { list-style: none; margin: 0 auto; padding: 0; max-width: 720px; display: grid; gap: var(--s2); }

.seam {
  padding: var(--s4);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
.seam__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.seam__el { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.seam__method {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 4px;
  background: var(--surface-2); color: var(--ink-2);
}
.seam__desc { margin: var(--s2) 0 0; font-size: 13px; color: var(--ink-2); }
.seam__wire {
  margin: var(--s3) 0 0; padding: var(--s3);
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  white-space: pre-wrap; word-break: break-word;
}

/* ── Toast ───────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--rail-h) + 20px);
  transform: translateX(-50%); z-index: 80;
  padding: var(--s3) var(--s4);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-full); font-size: 13px; color: var(--ink);
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
  animation: rise .2s var(--ease) both;
}

/* ── Seam highlighting ───────────────────────────────────────────────── */

body[data-seams="on"] [data-api] {
  outline: 1px dashed var(--accent-line);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .three { grid-template-columns: 1fr; }
  .card { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .card__value { margin: 0; font-size: 26px; }
  .card__note { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  .rail {
    position: fixed; left: 0; top: 0; bottom: 0; right: auto;
    width: 88px; height: 100%;
    grid-template-columns: 1fr; grid-template-rows: repeat(3, auto);
    align-content: center; gap: var(--s2);
    border-top: 0; border-right: 1px solid var(--line-soft);
    padding-top: 0;
  }
  .rail__item { height: 44px; }
  body { padding-bottom: 0; padding-left: 88px; }
  .bar { padding-left: calc(88px + var(--s4)); }
  .toast { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (prefers-contrast: more) {
  :root { --ink-2: #c3cace; --ink-3: #8b949a; --line: #3a4045; }
}