/* Coding tool. Long sessions, high repetition: legibility and stillness over polish. */

:root {
  --bg:        #fbfaf8;
  --surface:   #ffffff;
  --sunken:    #f4f2ee;
  --ink:       #1c1b19;
  --ink-2:     #55524d;
  --ink-3:     #8a857e;
  --line:      #e3dfd8;
  --accent:    #1f5f5b;
  --accent-in: #ffffff;
  --warn:      #8a5a12;
  --bad:       #9b2c2c;
  --ok:        #2f6b3a;
  --radius:    10px;
  /* 12-principles: entrances arrive fast and settle; exits build momentum.
     Linear is reserved for the progress bar, which represents time. */
  --ease-out:  cubic-bezier(0, 0, 0.2, 1);
  --ease-in:   cubic-bezier(0.4, 0, 1, 1);
  --t-press:   120ms;   /* every interactive state change uses this one value */
  --t-panel:   220ms;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#15161a; --surface:#1c1e23; --sunken:#232630; --ink:#eceae6;
    --ink-2:#b3aea6; --ink-3:#7d786f; --line:#2f333c; --accent:#5fbfb5;
    --accent-in:#10221f; --warn:#d9a441; --bad:#e08585; --ok:#7fc48c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
b, strong { font-weight: 620; }
code, pre, kbd { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* `hidden` must beat every layout rule below. A class selector like `.screen`
   outranks the UA's `[hidden] { display:none }`, which silently stacked every
   screen on top of the next. */
[hidden] { display: none !important; }
.screen { display: block; }
.centred { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; width: min(460px, 100%);
  box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px -12px rgb(0 0 0 / .12);
}
h1 { font-size: 21px; margin: 0 0 6px; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase;
     letter-spacing: .07em; color: var(--ink-3); font-weight: 600; }
.lede  { color: var(--ink-2); margin: 0 0 18px; text-wrap: pretty; }
.quiet { color: var(--ink-3); font-size: 13px; }
.error { color: var(--bad); margin: 10px 0 0; font-size: 14px; }
.note  { color: var(--warn); font-size: 13px; margin: 10px 0 0; }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; }
input[type=text] {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--sunken); border: 1px solid var(--line); border-radius: 8px;
}
button { font: inherit; cursor: pointer; border-radius: 8px; }
.primary {
  width: 100%; padding: 11px 16px; font-weight: 560;
  background: var(--accent); color: var(--accent-in); border: 0;
  transition-property: transform, opacity;
  transition-duration: var(--t-press); transition-timing-function: var(--ease-out);
}
.primary:active { transform: scale(0.96); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.ghost {
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line); padding: 8px 13px;
  min-height: 40px; min-width: 40px;          /* desktop hit-area floor */
  transition-property: transform, color, border-color;
  transition-duration: var(--t-press); transition-timing-function: var(--ease-out);
}
.ghost:hover  { color: var(--ink); border-color: var(--ink-3); }
.ghost:active { transform: scale(0.96); }

dl.meta { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px;
          margin: 0 0 18px; font-size: 14px; }
dl.meta dt { color: var(--ink-3); }
dl.meta dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ── top bar ─────────────────────────────────────────────────────────────── */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar-left, .bar-right { display: flex; align-items: center; gap: 12px; }
.counter { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink-2); }
.counter b { color: var(--ink); }
.progress { width: 180px; height: 5px; background: var(--sunken);
            border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0%; background: var(--accent);
              transition-property: width; transition-duration: 240ms;
              transition-timing-function: linear; }
.pill {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--sunken); color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.pill.pending { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.saved   { background: color-mix(in srgb, var(--ok) 18%, transparent);   color: var(--ok); }

/* ── panes ───────────────────────────────────────────────────────────────── */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.pane { min-width: 0; }
.code {
  margin: 0; padding: 12px 14px; background: var(--sunken);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 12.5px; line-height: 1.5; overflow-x: auto; white-space: pre;
  max-height: 42vh;
}
.seg { border-left: 3px solid var(--accent); }
details#cfg-wrap { margin-top: 10px; }
details#cfg-wrap summary { font-size: 13px; color: var(--ink-2); cursor: pointer; padding: 4px 0; }
mark.here { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; }

.rules { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; }
.rule {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; min-height: 44px;
  padding: 10px 12px; text-align: left; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink);
  transition-property: border-color, background-color, transform;
  transition-duration: var(--t-press); transition-timing-function: var(--ease-out);
}
.rule:hover  { border-color: var(--ink-3); }
.rule:active { transform: scale(0.96); }
.rule[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.rule .num { font-variant-numeric: tabular-nums; color: var(--ink-3); min-width: 1.6em; }
.rule .ttl { font-weight: 560; }
.rule .bdy { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.rule .nobody { color: var(--ink-3); font-style: italic; font-size: 13px; margin-top: 3px; }

/* ── form ────────────────────────────────────────────────────────────────── */
.form { padding: 0 18px 96px; max-width: 1100px; }
/* Concentric: inner label radius 8 + 12px padding = 20px outer. */
.step {
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
  padding: 12px 16px; margin: 0 0 12px;
}
.step legend { font-size: 13px; font-weight: 600; padding: 0 6px; color: var(--ink); }
.hint { color: var(--ink-3); font-size: 13px; margin: 0 0 10px; }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opts label, .boxes label {
  display: flex; gap: 9px; align-items: flex-start; min-height: 40px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); cursor: pointer;
  transition-property: border-color, background-color, transform;
  transition-duration: var(--t-press); transition-timing-function: var(--ease-out);
}
.opts label:hover,  .boxes label:hover  { border-color: var(--ink-3); }
.opts label:active, .boxes label:active { transform: scale(0.96); }
.opts label:has(input:checked), .boxes label:has(input:checked) {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.boxes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.rulepick { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }

.actions {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px;
  padding: 12px 0; background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.actions .primary { width: auto; padding: 11px 22px; }
kbd { font-size: 11px; opacity: .7; border: 1px solid currentColor;
      border-radius: 4px; padding: 0 4px; margin-left: 6px; }

/* ── slide-over: readable BESIDE the item, never a modal ─────────────────── */
/* Deliberately NOT dimmed. `staging-dim-background` applies to modals, whose job
   is to take focus; this panel's whole purpose is to be read alongside the item,
   and dimming the item would defeat it. */
.slideover {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); z-index: 40;
  background: var(--surface); border-left: 1px solid var(--line);
  padding: 16px 18px; overflow-y: auto;
  box-shadow: -12px 0 32px -18px rgb(0 0 0 / .35);
  transform: translateX(100%); visibility: hidden;
  transition-property: transform, visibility;
  transition-duration: var(--t-panel);
  transition-timing-function: var(--ease-in);      /* exit builds momentum */
}
.slideover.open {
  transform: translateX(0); visibility: visible;
  transition-timing-function: var(--ease-out);     /* entrance settles gently */
}
.slideover header { display: flex; justify-content: space-between;
                    align-items: center; margin-bottom: 12px; }
.slideover p { font-size: 13.5px; color: var(--ink-2); }

.toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(6px);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  font-size: 13px; z-index: 60; opacity: 0; pointer-events: none;
  transition-property: opacity, transform;
  transition-duration: 180ms; transition-timing-function: var(--ease-in);
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
  transition-timing-function: var(--ease-out);
}

/* ── item map + previous-answer banner ───────────────────────────────────── */
.itemmap {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.dot {
  width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--sunken); color: var(--ink-3);
  font-variant-numeric: tabular-nums; font-size: 12px;
  transition-property: border-color, background-color, transform;
  transition-duration: var(--t-press); transition-timing-function: var(--ease-out);
}
.dot.answered {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--ink);
}
.dot.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.dot:not(:disabled):hover  { border-color: var(--ink-3); }
.dot:not(:disabled):active { transform: scale(0.96); }
.dot:disabled { opacity: .45; cursor: not-allowed; }

.prevbar {
  display: flex; align-items: center; gap: 12px; margin: 12px 18px 0;
  padding: 10px 14px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
}
.prevbar .ghost { margin-left: auto; white-space: nowrap; }

@media (max-width: 700px) {
  #eta { display: none; }
  .progress { width: 110px; }
}
.itemmap { max-height: 32vh; overflow-y: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
  .slideover { transform: none; }
}
