:root {
  --bg: #0c0e11;
  --panel: #14181d;
  --panel-2: #191e24;
  --line: #262d35;
  --line-bright: #3a444f;
  --ink: #e7ebf0;
  --ink-dim: #9aa5b1;
  /* Carries every micro-label. Held at 4.5:1 or better on all three surfaces —
     this gets read on a phone in direct sun, where dim grey disappears. */
  --ink-faint: #7d8896;
  --amber: #f0a92c;
  --green: #46c08b;
  --red: #e2565b;
  --blue: #63a4ff;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

/* One motion rule for the whole app: interactive colour shifts, nothing else.
   Gloved hands and bright screens want feedback, not choreography. */
button, select, input { transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease; }

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, sans-serif;
}

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

.bar {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.bar-title {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}

.craft { display: flex; gap: 2px; }

.craft button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  padding: 7px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  line-height: 1.2;
}
.craft button:first-child { border-radius: 4px 0 0 4px; }
.craft button:last-child { border-radius: 0 4px 4px 0; }
.craft button + button { border-left: none; }
.craft button:hover { color: var(--ink); }
.craft button[aria-pressed="true"] {
  background: var(--amber);
  border-color: var(--amber);
  color: #1a1204;
  font-weight: 600;
}

.tabs { display: flex; gap: 20px; margin-left: auto; }

.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink-faint);
  font: inherit;
  padding: 4px 0 6px;
  cursor: pointer;
}
.tabs button:hover { color: var(--ink-dim); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--amber); }

/* ---------- layout ---------- */

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }

.split { display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start; }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .tabs { margin-left: 0; width: 100%; justify-content: space-between; }

  /* Stacked, the answer goes above the inputs — settings persist, so opening
     the app on site should show last night's numbers without scrolling. */
  .split > :first-child { order: 2; }
  .split > :last-child { order: 1; }
}

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

@media (max-width: 640px) {
  .bar {
    gap: 12px;
    padding: 10px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .bar-title { display: none; }
  .craft { flex: 1; }
  .craft button { flex: 1; padding: 10px 12px; }

  .tabs { gap: 0; border-top: 1px solid var(--line); padding-top: 2px; }
  .tabs button { flex: 1; padding: 11px 0 10px; text-align: center; }

  main {
    padding: 16px max(16px, env(safe-area-inset-right))
             max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  /* Four readouts across is unreadable on a phone — go two by two. */
  .cell { flex-basis: 40%; padding: 14px; }
  .cell .v { font-size: 24px; }

  .rows td { padding: 9px 12px; }
  .rows td:first-child { width: 96px; }

  .alt { flex-direction: column; gap: 3px; }
  .check label { padding: 12px 14px; }
  .check input { width: 20px; height: 20px; }
  .move { padding: 14px; }
}

.panel { border: 1px solid var(--line); background: var(--panel); border-radius: 4px; }
.panel + .panel { margin-top: 20px; }

.panel h2 {
  margin: 0;
  padding: 12px 16px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.panel-body { padding: 16px; }

/* ---------- form controls ---------- */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

select, input[type="number"], input[type="text"] {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line-bright);
  border-radius: 3px;
  padding: 9px 10px;
  font: inherit;
  /* Under 16px iOS zooms the whole page when the field takes focus. */
  font-size: 16px;
}
select:focus, input:focus { outline: 2px solid var(--amber); outline-offset: -1px; }

.hint { font-size: 13px; color: var(--ink-faint); margin-top: 6px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  background: var(--panel-2);
  border: 1px solid var(--line-bright);
  border-radius: 3px;
  color: var(--ink-dim);
  padding: 6px 11px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); }

/* ---------- readout ---------- */

.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.cell { flex: 1 1 130px; background: var(--panel-2); padding: 18px 16px; }

.cell .k {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 7px;
}
.cell .v { font-family: var(--mono); font-size: 27px; letter-spacing: -0.01em; color: var(--amber); }
/* Word values need less size than numbers — they are read, not glanced at. */
.cell .v.plain { color: var(--ink); font-size: 18px; }
.cell .n { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }

.note {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 3px;
  font-size: 14px;
  margin-top: 14px;
  border: 1px solid;
  line-height: 1.45;
}
.note::before { font-family: var(--mono); font-weight: 700; }
.note.ok { border-color: #23503d; background: #101d18; color: #a9dcc5; }
.note.ok::before { content: "OK"; color: var(--green); }
.note.warn { border-color: #5c3f13; background: #1d1508; color: #e8cd9d; }
.note.warn::before { content: "!"; color: var(--amber); }
.note.bad { border-color: #5c2124; background: #1e0f10; color: #eeb2b4; }
.note.bad::before { content: "×"; color: var(--red); }

.alts { margin-top: 18px; }
.alts h3 {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 8px;
  font-weight: 600;
}
.alt {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-dim);
}
.alt + .alt { margin-top: 5px; }
.alt .why { font-family: system-ui, sans-serif; color: var(--ink-faint); font-size: 13px; }

/* ---------- tables and lists ---------- */

.rows { width: 100%; border-collapse: collapse; font-size: 14px; }
.rows td { padding: 10px 16px; border-top: 1px solid var(--line); vertical-align: top; }
.rows tr:first-child td { border-top: none; }
.rows td:first-child {
  width: 150px;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 12px;
}

.check { list-style: none; margin: 0; padding: 0; }
.check li { border-top: 1px solid var(--line); }
.check li:first-child { border-top: none; }
.check label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 16px;
  cursor: pointer;
  line-height: 1.45;
}
.check input { margin: 4px 0 0; width: 15px; height: 15px; accent-color: var(--amber); flex: none; }
.check input:checked + span { color: var(--ink-faint); text-decoration: line-through; }

.phase-head { display: flex; justify-content: space-between; align-items: center; padding-right: 16px; }
.count { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

.reset {
  background: none;
  border: 1px solid var(--line-bright);
  color: var(--ink-dim);
  border-radius: 3px;
  padding: 7px 13px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  margin-top: 20px;
}
.reset:hover { color: var(--ink); border-color: var(--ink-faint); }

.move { padding: 16px; border-top: 1px solid var(--line); }
.move:first-child { border-top: none; }
.move h3 { margin: 0 0 6px; font-size: 16px; }
.move p { margin: 0 0 8px; color: var(--ink-dim); line-height: 1.55; }
.move p:last-child { margin-bottom: 0; }
.move .lead { color: var(--ink); }
.move .tip { color: var(--amber); font-size: 14px; }

.foot { color: var(--ink-faint); font-size: 13px; margin-top: 28px; line-height: 1.6; }
