/* ============================================================
   THE SKIN LIVES HERE. Every colour, radius and font in the app
   reads a token from this block. Calvin's look reference lands by
   editing these values, not by touching components.
   ============================================================ */
:root {
  --ground:      #101215;
  --surface:     #171a1f;
  --surface-2:   #1e222a;
  --line:        #2a2f38;
  --ink:         #e7ebf0;
  --ink-dim:     #97a1af;
  --ink-faint:   #838d9c;
  --accent:      #58c9a0;
  --accent-ink:  #0c1512;
  --warn:        #e0a955;
  --danger:      #eb7a6d;
  --radius:      12px;
  --radius-sm:   8px;
  --font:        ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:        ui-monospace, "SF Mono", Menlo, monospace;
  --tap:         44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.45;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 14px; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--ground);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}
.top-row { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 650; letter-spacing: -0.01em; }
.status { margin-left: auto; display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-dim); font-family: var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.dot.on { background: var(--accent); }
.dot.off { background: var(--danger); }

/* ---------- sections ---------- */
.sec { margin: 18px 0; }
.sec-h { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; }
.sec-h h2 { font-size: 15px; margin: 0; font-weight: 620; letter-spacing: -0.01em; }
.count {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 1px 8px;
}
.count.zero { background: var(--surface-2); color: var(--ink-faint); }
.sec-h .more { margin-left: auto; font-size: 13px; color: var(--ink-dim);
  background: none; border: 0; padding: 4px; }

/* ---------- cards (quests) ---------- */
.card {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 8px; min-height: var(--tap);
}
.card:active { background: var(--surface-2); }
.card .who {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-2); color: var(--ink-dim);
  display: grid; place-items: center; font-family: var(--mono);
  font-size: 12px; font-weight: 600;
}
.card .who.money { background: var(--danger); color: #2a0f0c; }
.card .t { font-weight: 560; line-height: 1.35; display: block; }
.card .a { font-size: 13.5px; color: var(--ink-dim); margin-top: 2px; display: block; }
.card .amt { margin-left: auto; font-family: var(--mono); font-weight: 650;
  color: var(--danger); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- work in flight ---------- */
.flight { display: flex; align-items: center; gap: 10px; padding: 9px 2px;
  border-bottom: 1px solid var(--line); }
.flight:last-child { border-bottom: 0; }
.flight .t { flex: 1; min-width: 0; }
.flight .t b { font-weight: 550; display: block; }
.flight .t small { color: var(--ink-faint); font-size: 12.5px; }
.tag { font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; padding: 3px 7px; border-radius: 5px;
  background: var(--surface-2); color: var(--ink-dim); white-space: nowrap; }
.tag.on_pace { color: var(--accent); }
.tag.behind  { color: var(--warn); }
.tag.blocked { color: var(--danger); }

/* ---------- money ---------- */
.money { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.money > div { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; }
.money .n { font-family: var(--mono); font-size: 24px; font-weight: 650;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.money .n.owed { color: var(--danger); }
.money .n.blank { color: var(--ink-faint); }
.money .l { font-size: 12.5px; color: var(--ink-dim); margin-top: 2px; }

/* ---------- night log ---------- */
.night { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; font-size: 14px; color: var(--ink-dim); }
.night b { color: var(--ink); font-weight: 600; }

/* ---------- crew + the level bars ---------- */
.agent { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.agent-h { display: flex; align-items: center; gap: 10px; }
.agent-h .nm { font-weight: 600; }
.rl { font-size: 12.5px; color: var(--ink-faint); line-height: 1.4; }
.lvl { margin-top: 12px; }
.lvl + .lvl { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.lvl-h { display: flex; align-items: baseline; gap: 8px; font-size: 13.5px; }
.lvl-h code { font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim); }
.badge { margin-left: auto; font-family: var(--mono); font-size: 11px;
  font-weight: 700; padding: 2px 8px; border-radius: 5px; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-dim); }
.badge.l2 { background: var(--accent); color: var(--accent-ink); }
/* The fat literal progress bar: streak toward the level-up Calvin grants. */
.bar { height: 22px; background: var(--surface-2); border-radius: 6px;
  overflow: hidden; margin-top: 8px; position: relative; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px;
  transition: width .35s cubic-bezier(.22,1,.36,1); }
.bar-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.bar-row .bar { flex: 1; margin-top: 0; }
.pct { font-family: var(--mono); font-size: 19px; font-weight: 700; letter-spacing: -0.02em;
  min-width: 3.4em; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.pct.done { color: var(--accent); }
.lvl .meta { font-size: 12.5px; color: var(--ink-faint); margin-top: 6px; }
.promote { margin-top: 10px; width: 100%; min-height: var(--tap);
  background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: var(--radius-sm); font-weight: 650; }
.demote { margin-top: 8px; width: 100%; min-height: 36px; background: none;
  color: var(--ink-dim); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13px; }

/* ---------- chat ---------- */
.msgs { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 15px; }
.msg.owner { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.brain { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.msg small { display: block; font-size: 11px; opacity: .65; margin-top: 3px; }
.composer { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; background: var(--ground); padding: 8px 0; }
.composer textarea { flex: 1; resize: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink);
  padding: 11px 12px; font: inherit; font-size: 16px; max-height: 120px; }
.composer button { min-width: 64px; min-height: var(--tap); background: var(--accent);
  color: var(--accent-ink); border: 0; border-radius: var(--radius); font-weight: 650; }

/* ---------- detail sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 640px; max-height: 88vh;
  overflow: auto; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: rise .22s cubic-bezier(.22,1,.36,1); }
@keyframes rise { from { transform: translateY(14px); opacity: .6 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none } .bar i { transition: none } }
.sheet h3 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.01em; }
.sheet .ask { color: var(--accent); font-weight: 560; margin-bottom: 12px; }
.sheet .body { background: var(--ground); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px; white-space: pre-wrap;
  font-size: 14.5px; color: var(--ink-dim); }
.outcomes { display: grid; gap: 8px; margin: 12px 0; }
.outcome { background: var(--ground); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; }
.outcome b { display: block; font-size: 12px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; font-weight: 700; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.acts button { min-height: var(--tap); border-radius: var(--radius-sm); font-weight: 620; border: 0; }
.acts .yes { background: var(--accent); color: var(--accent-ink); }
.acts .no { background: var(--surface-2); color: var(--ink); }
.acts .full { grid-column: 1 / -1; background: none; border: 1px solid var(--line);
  color: var(--ink-dim); min-height: 38px; font-weight: 500; font-size: 13px; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav button { position: relative; flex: 1; background: none; border: 0; padding: 9px 0 10px;
  min-height: var(--tap); color: var(--ink-faint); font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px; }
.nav button.on { color: var(--accent); }
.nav .ic { font-size: 17px; line-height: 1; }
.nav .pip { position: absolute; top: 4px; left: 50%; margin-left: 4px; min-width: 17px;
  height: 17px; border-radius: 9px; background: var(--danger); color: #2a0f0c;
  font-size: 10px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth form { width: 100%; max-width: 340px; }
.auth h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
.auth p { color: var(--ink-dim); font-size: 14px; margin: 0 0 18px; }
.auth input { width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink); padding: 12px; font: inherit;
  font-size: 16px; margin-bottom: 10px; }
.auth button { width: 100%; min-height: var(--tap); background: var(--accent);
  color: var(--accent-ink); border: 0; border-radius: var(--radius); font-weight: 650; }
.err { color: var(--danger); font-size: 13.5px; margin: 8px 0 0; min-height: 18px; }

/* ---------- misc ---------- */
.empty { color: var(--ink-faint); font-size: 14px; padding: 14px 2px; }
.danger-btn { width: 100%; min-height: var(--tap); background: none;
  border: 1px solid var(--danger); color: var(--danger); border-radius: var(--radius);
  font-weight: 620; margin-top: 8px; }
.row-btn { width: 100%; min-height: var(--tap); background: var(--surface);
  border: 1px solid var(--line); color: var(--ink); border-radius: var(--radius);
  margin-top: 8px; text-align: left; padding: 0 12px; }
.audit-e { display: flex; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line);
  font-size: 13px; }
.audit-e code { font-family: var(--mono); color: var(--ink-dim); font-size: 12px; }
.audit-e .ts { color: var(--ink-faint); font-family: var(--mono); font-size: 11.5px;
  white-space: nowrap; }
.skin-note { font-size: 12px; color: var(--ink-faint); border: 1px dashed var(--line);
  border-radius: var(--radius-sm); padding: 9px 11px; margin-top: 14px; }

/* ---------- the Geoscape ---------- */
.geo { position: relative; margin: 6px -14px 4px; height: 300px; }
.geo canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.geo canvas:active { cursor: grabbing; }
.geo-legend { position: absolute; left: 14px; right: 14px; bottom: 2px;
  display: flex; gap: 14px; align-items: center;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint); pointer-events: none; }
.geo-legend .gl { display: flex; align-items: center; gap: 5px; }
.geo-legend .drag { margin-left: auto; }
.geo-legend .pin { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.geo-legend .pin.hot { background: var(--warn); box-shadow: 0 0 0 3px rgba(224,169,85,.25); }
