:root {
  color-scheme: light dark;
  --bg: #f4f2ec;
  --surface: #ffffff;
  --text: #1b1b1a;
  --muted: #5f5d57;
  --line: #dcd8cd;
  --accent: #1b5e20;
  --accent-text: #ffffff;
  --error: #b3261e;
  --focus: #2e7d32;
  --switch-off: #8b877e; /* >= 3:1 against the card, so an off switch is still visible */
  /* Second mode color (a run of notes). Blue, not red or orange: red-green is the
     common color-blindness, and blue stays distinct from the green accent for it. */
  --strap: #15559f;
  --strap-text: #ffffff;
  --strap-ring: rgb(21 85 159 / .22);
  --accent-ring: rgb(46 125 50 / .22);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141513;
    --surface: #1f201d;
    --text: #ecebe6;
    --muted: #a9a79f;
    --line: #363731;
    --accent: #74c178;
    --accent-text: #0c1d0d;
    --error: #ff8a80;
    --focus: #8fd694;
    --switch-off: #7a7b74;
    --strap: #82b7f2;
    --strap-text: #0b1c2e;
    --strap-ring: rgb(130 183 242 / .28);
    --accent-ring: rgb(143 214 148 / .28);
  }
}

* { box-sizing: border-box; }
/* `hidden` must always win: several components set their own display (flex,
   inline-block), which would otherwise override the browser's hiding. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--sans);
}

.top, main {
  max-width: 640px;
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}

.top { padding-top: max(14px, env(safe-area-inset-top)); }
.top-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 12px; min-height: 32px; }
.account { margin-left: auto; }
.brand { margin: 0; color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.account { display: flex; align-items: center; gap: 4px; min-width: 0; color: var(--muted); font-size: .9rem; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

button.link {
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--text);
  font: 600 .9rem var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Sign-in form */
.signin input[type="text"], .signin input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 1.1rem var(--sans);
}
.signin input:focus { outline: none; border-color: var(--focus); }
.signin label.check { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; color: var(--text); font-weight: 400; }
.signin label.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.hint { margin: 14px 2px 0; color: var(--muted); font-size: .9rem; }

button.primary.wide {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font: 600 1.05rem var(--sans);
}
button.primary.wide:disabled { opacity: .6; }
h1 { margin: 0 0 6px; font-size: 1.5rem; line-height: 1.2; }

main { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

label { display: block; margin: 10px 0 6px; color: var(--muted); font-size: .9rem; font-weight: 600; }

.field { position: relative; }

/* One note (green) or a run of notes (blue): the mode buttons sit next to the label
   and hand their color to the box, so the two always read as the same choice. */
body { --mode-color: var(--accent); --mode-ring: var(--accent-ring); }
body[data-mode="run"] { --mode-color: var(--strap); --mode-ring: var(--strap-ring); }

.label-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.label-row label { flex: none; }
.modes { display: flex; gap: 6px; margin-bottom: 6px; }
.mode {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: 600 .85rem var(--sans);
}
.mode[data-mode="one"] { color: var(--accent); }
.mode[data-mode="run"] { color: var(--strap); }
.mode[data-mode="one"][aria-checked="true"] { border-color: transparent; background: var(--accent); color: var(--accent-text); }
.mode[data-mode="run"][aria-checked="true"] { border-color: transparent; background: var(--strap); color: var(--strap-text); }

/* Everything in the strap flow wears the same blue: here, and on the strap page
   (its <body> carries data-mode="run" for exactly this). */
body[data-mode="run"] .choice[aria-checked="true"] { background: var(--strap); color: var(--strap-text); }
body[data-mode="run"] .primary.wide { background: var(--strap); color: var(--strap-text); }
body[data-mode="run"] .serial-input:focus { border-color: var(--strap); }
body[data-mode="run"] .digit-counter[data-state="ready"] { color: var(--strap); }
.run-options { margin: -6px 0 16px; }
.run-options .status { margin-bottom: 10px; }
.run-options .end-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.run-options .end-row .serial-input { flex: 1 1 200px; min-width: 0; }
.run-options .primary.wide { margin-top: 12px; }

#serial {
  width: 100%;
  padding: 13px 54px 13px 14px;
  border: 2px solid var(--mode-color);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 700 1.5rem/1.2 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
#serial::placeholder { color: var(--muted); opacity: .45; }
#serial:focus { outline: none; box-shadow: 0 0 0 3px var(--mode-ring); }

#clear {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 44px;
  height: 44px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 1.7rem;
  line-height: 1;
}

.status { min-height: 1.45em; margin: 8px 2px 14px; color: var(--muted); font-size: .95rem; }
.status[data-kind="error"] { color: var(--error); }
.status[data-kind="done"] { color: var(--text); font-weight: 600; }

.scan-tip { display: flex; align-items: flex-start; gap: 10px; margin: -6px 2px 14px; color: var(--muted); font-size: .9rem; }
.scan-tip svg { flex: none; margin-top: 1px; color: var(--accent); }

.overlay svg { display: block; width: 100%; height: auto; border-radius: 8px; }

.matches { display: flex; flex-direction: column; gap: 10px; }

/* Expandable card: match cards, pattern libraries, fine-tune colors */
.expander {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.expander > summary {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 58px;
  padding: 10px 46px 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;
}
.expander > summary::-webkit-details-marker { display: none; }
.expander > summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 20px;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform .15s;
}
.expander[open] > summary::after { transform: translateY(-25%) rotate(225deg); }
.expander-body { padding: 0 14px 14px; }

.match-name { font-size: 1.05rem; font-weight: 650; overflow-wrap: anywhere; }
.match-meta { color: var(--muted); font-size: .85rem; }
.match-meta:empty { display: none; }

.match-message { margin: 0 0 10px; }

.actions { display: flex; gap: 10px; margin: 12px 0; }
.actions button {
  flex: 1;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: 600 1rem var(--sans);
}
.actions button.primary { border-color: transparent; background: var(--accent); color: var(--accent-text); }
.actions button:disabled { opacity: .6; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.desc { margin: 10px 0 0; color: var(--muted); font-size: .9rem; }

button, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button:active { transform: translateY(1px); }

@media (hover: hover) {
  .expander > summary:hover { background: var(--bg); }
  .actions button:hover { filter: brightness(.96); }
}

/* ---- Settings page ---------------------------------------------------------- */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

a.link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 8px; color: var(--text);
         font: 600 .9rem var(--sans); text-underline-offset: 3px; }
a.back { margin-left: -8px; text-decoration: none; font-size: 1rem; }
.signed-in { margin: 0 0 8px; color: var(--muted); font-size: .9rem; }

.panel { margin: 14px 0 22px; }
.panel h2 { margin: 0 0 4px; font-size: 1.2rem; }
.panel h3 { margin: 18px 0 8px; color: var(--muted); font-size: .9rem; font-weight: 600; }
.panel .hint { margin: 4px 2px 10px; }
.panel .overlay { margin: 10px 0 4px; }

.choices { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.choice {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 600 .95rem var(--sans);
}
.choice[aria-checked="true"] { border-color: transparent; background: var(--accent); color: var(--accent-text); }
.custom-note { color: var(--muted); font-size: .9rem; }

.fine-tune { margin-top: 18px; }
/* Each label stays with its own dropdown when the row wraps on a phone. */
.pad-row { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 10px 0 0; }
.pad-field { display: flex; align-items: center; gap: 8px; margin: 0; }
.pad-field label { margin: 0; white-space: nowrap; }
.pad-field select { width: auto; min-width: 8.5rem; }
.pad-field .num { width: 5.5rem; padding: 9px 10px; font: 600 1rem var(--sans); }
.pad-field label.check { display: flex; align-items: center; gap: 8px; margin: 0; }
.pad-field label.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.pad-row button.link { padding-left: 0; }
.slots { margin: 0 0 8px; padding: 0; list-style: none; }
.slot { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px;
        border-top: 1px solid var(--line); }
.slot label { display: flex; align-items: center; gap: 12px; }
.slot input[type="color"] { width: 52px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 8px;
                            background: none; }

.summary { margin: 8px 2px; font-weight: 600; }
.summary button.link { min-height: 32px; padding: 0 4px; }

#search {
  width: 100%;
  margin: 14px 0 4px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 1.05rem var(--sans);
}
#search:focus { outline: none; border-color: var(--focus); }

.library { margin-top: 10px; }
.library-name { font-size: 1.05rem; font-weight: 650; }
.library-count { color: var(--muted); font-size: .85rem; }
.library-actions { display: flex; gap: 8px; margin: -4px 0 4px -8px; }

.pattern-list { margin: 0; padding: 0; list-style: none; }
.pattern label, .slot label { margin: 0; color: var(--text); font-size: 1rem; font-weight: 400; }
.pattern label { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0;
                 border-top: 1px solid var(--line); cursor: pointer; }
.pattern-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.pattern-name { font-weight: 600; overflow-wrap: anywhere; }
.pattern-meta { overflow: hidden; color: var(--muted); font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }

input[type="checkbox"][role="switch"] {
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 15px;
  background: var(--switch-off);
  transition: background .15s;
  -webkit-appearance: none;
  appearance: none;
}
input[role="switch"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(0 0 0 / .35);
  transition: transform .15s;
}
input[role="switch"]:checked { background: var(--accent); }
input[role="switch"]:checked::before { transform: translateX(20px); }
input[role="switch"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.save-status {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  margin: 0;
  padding: 8px 16px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: .9rem;
  font-weight: 600;
  box-shadow: 0 2px 10px rgb(0 0 0 / .25);
}
.save-status[data-kind="error"] { background: var(--error); color: #ffffff; }

/* ---- Accounts (admin) page -------------------------------------------------- */

.nav-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 4px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1.05rem;
  text-decoration: none;
}
.nav-card .hint { font-size: .85rem; }
.nav-card > span:last-child { color: var(--muted); font-size: 1.6rem; line-height: 1; }

.card-form label:not(.check) { margin-top: 12px; }

.credentials {
  margin-top: 14px;
  padding: 14px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}
.credentials h3 { margin: 0 0 4px; color: var(--text); font-size: 1.05rem; }
.invite {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  font: 600 1rem/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

.people { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.person { padding: 12px 14px 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.person.is-disabled .person-name { color: var(--muted); text-decoration: line-through; }
.person-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.person-name { margin-right: 4px; font-size: 1.05rem; font-weight: 650; }
.badge { padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.person-meta { margin: 2px 0 4px; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.person-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-left: -8px; }
.person .status { min-height: 0; margin: 0 0 6px; }

/* ---- Install hint (lookup page) ---------------------------------------------- */

.install-hint {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
}
.install-hint p { margin: 0 0 6px; }
.install-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: -8px; }
.install-actions .choice.is-primary { margin-left: 8px; border-color: transparent; background: var(--accent); color: var(--accent-text); }

/* ---- Discussions -------------------------------------------------------------- */

.count-badge {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  vertical-align: 1px;
}
a.link .count-badge { text-decoration: none; }

.discussion-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.discussion-link::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.4rem; line-height: 1; }
.discussion-title { font-weight: 650; }
.discussion-meta { color: var(--muted); font-size: .88rem; }

.comments { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 18px; }
.comment { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.comment.is-issue { border-left: 4px solid var(--accent); }
.comment.is-hidden { opacity: .6; }
.comment.is-target { box-shadow: 0 0 0 3px var(--focus); }
.comment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.comment-head .when { color: var(--muted); font-size: .85rem; }
.comment-body { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-example { margin-top: 10px; }
.example-caption { margin: 0 0 4px; color: var(--muted); font-size: .82rem; font-weight: 600; }
.example-link { margin: 2px 0 0 -8px; }
.status-note { margin: 10px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--bg); font-size: .9rem; }
.comment-actions { display: flex; flex-wrap: wrap; gap: 2px; margin: 6px 0 0 -8px; }
.comment .status { min-height: 0; margin: 0; }
.comment-editor textarea { margin-top: 8px; }
.badge.status-open { border-color: var(--accent); color: var(--text); }
.badge.status-fixed { border-color: transparent; background: var(--accent); color: var(--accent-text); }

.composer h2 { margin-bottom: 8px; }
.field-label { margin-top: 14px; }
.optional { color: var(--muted); font-weight: 400; }
.example-row { display: flex; align-items: center; gap: 8px; }
.composer input[type="text"], .composer textarea, .comment-editor textarea {
  width: 100%;
  padding: 11px 13px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 1rem var(--sans);
}
.composer input[type="text"] { font: 700 1.05rem var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.composer textarea, .comment-editor textarea { min-height: 96px; resize: vertical; }
.composer input:focus, .composer textarea:focus, .comment-editor textarea:focus { outline: none; border-color: var(--focus); }
.example-preview { margin-top: 6px; }

#find {
  width: 100%;
  margin: 6px 0 4px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 1.05rem var(--sans);
}
#find:focus { outline: none; border-color: var(--focus); }
.find-results { margin: 0 0 8px; padding: 4px 0; list-style: none; }
.find-results li { padding: 2px 0; }
.tabs { margin: 12px 0; }
.thread-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.thread-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.thread-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 1.05rem; font-weight: 650; }
.thread-meta { color: var(--muted); font-size: .85rem; }
.thread-excerpt { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }

/* ---- Suggested fix (tap editor) --------------------------------------------------- */

.fix-open { margin-top: 10px; border-style: dashed; }
.fix-editor { margin-top: 10px; padding: 12px; border: 2px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.fix-intro { margin: 0 0 8px; font-weight: 600; }
.fix-canvas { position: relative; }
.fix-canvas .overlay svg { border-radius: 8px; }
.fix-hits { position: absolute; inset: 0; }
.fix-hit {
  position: absolute;
  top: 0;
  bottom: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.fix-hit:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.fix-hit.is-pending { background: rgb(27 94 32 / .18); outline: 3px dashed var(--accent); outline-offset: -3px; }
@media (hover: hover) { .fix-hit:hover { background: rgb(0 0 0 / .06); } }
.fix-editor .field-label { margin: 12px 0 6px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.fix-colors .choice { display: inline-flex; align-items: center; gap: 6px; min-width: 52px; padding: 0 12px; }
.swatch { display: inline-block; flex: none; width: 16px; height: 16px; border: 1px solid rgb(0 0 0 / .25); border-radius: 50%; }
.fix-hint { min-height: 2.9em; margin: 10px 0 4px; }
.fix-items { margin: 4px 0; padding: 0; list-style: none; }
.fix-items li { display: flex; align-items: center; gap: 8px; min-height: 40px; border-top: 1px solid var(--line); font-size: .92rem; }
.fix-items li span:nth-child(2) { flex: 1; }
.fix-actions { display: flex; flex-wrap: wrap; gap: 2px; margin: 4px 0 0 -8px; }
.change-list { margin: 2px 0 8px; padding-left: 20px; font-size: .92rem; }
.change-list li { margin: 2px 0; }

/* ---- Your account (settings) ------------------------------------------------------ */
#account { margin-top: 8px; }
#change-password .signin label:not(.check) { margin-top: 12px; }
#change-password .hint { margin: 10px 2px 0; }

.build { margin: 22px 2px 0; color: var(--muted); font: .78rem var(--mono); }
/* Try-it row under a browsed pattern: a serial of your own, or one the server picks. */
.browse-try { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 2px; }
.browse-try .browse-serial { flex: 1 1 11ch; min-width: 11ch; margin: 0; }
.browse-try .digit-counter { flex: 0 0 auto; }

/* A pattern's example drawing on the browse page, while it loads and once it is there. */
.browse-drawing { margin: 10px 0 2px; min-height: 40px; }
.browse-drawing .overlay { margin: 0 0 4px; }

/* The over-count table on the About page. Right-aligned numbers so the columns line up,
   and small enough to fit a phone without a horizontal scroll. */
.odds-table { width: 100%; margin: 10px 0 4px; border-collapse: collapse; font-size: .88rem; }
.odds-table th, .odds-table td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.odds-table th:first-child, .odds-table td:first-child { text-align: left; }
.odds-table th { color: var(--muted); font-size: .78rem; font-weight: 600; }

/* Small print that has to be readable, not hidden: the Green Guide reference. */
.credit { margin: 10px 2px 0; color: var(--muted); font-size: .78rem; line-height: 1.5; max-width: 60ch; }
.book-credit { margin: 12px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }

/* ---- Tools: shared inputs, links --------------------------------------------------- */

.serial-input, .text-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 1rem var(--sans);
}
.serial-input { font: 700 1.25rem var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.serial-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.serial-row .serial-input { flex: 1 1 200px; min-width: 0; }
.serial-input:focus, .text-input:focus { outline: none; border-color: var(--focus); }
select.text-input { appearance: auto; }
a.link.inline { display: inline; min-height: 0; padding: 0; }
.customize-link { margin: -4px 0 10px; font-size: .92rem; }
.customize-link a.link { padding-left: 0; }

/* ---- Check a strap ------------------------------------------------------------------ */

.end-row { margin-top: 8px; }
#range-form .status { margin-top: 10px; }
.progress { height: 6px; margin: 0 0 8px; overflow: hidden; border-radius: 3px; background: var(--line); }
#progress-bar { width: 0; height: 100%; background: var(--accent); transition: width .2s; }
.range-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.range-controls { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px; }
.range-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.range-pos { flex: none; min-width: 3.2em; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.range-main { display: flex; flex-direction: column; min-width: 0; }
.range-serial { font: 700 1.05rem var(--mono); letter-spacing: .04em; }
.range-patterns { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.range-group { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.range-group-title { margin: 0; font-weight: 650; }
.range-group-meta { margin: 0 0 4px; }
.range-group-notes { margin: 0; font: .92rem/1.9 var(--mono); }
.range-group-notes a.link.inline { margin-right: 10px; white-space: nowrap; }

/* ---- Overlay Studio ------------------------------------------------------------------ */

#studio .fix-editor { margin-top: 14px; }
.preview-title { margin: 20px 0 8px; font-size: 1.1rem; }
.studio-preview svg { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.studio-link { margin: 0 0 0 -8px; }

/* ---- Pattern review: duplicate groups (admin), laid out for a computer ------------- */

body.wide-page .top, body.wide-page main { max-width: 1480px; }
body.wide-page .top .signed-in { max-width: 80ch; }

.review-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 8px; }
.review-side {
  position: sticky; top: 12px; display: flex; flex-direction: column; gap: 8px;
  max-height: calc(100vh - 24px); padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.review-progress { display: flex; flex-direction: column; margin: 0; font-size: .9rem; }
.review-progress span { color: var(--muted); }
.review-bar { height: 6px; overflow: hidden; border-radius: 3px; background: var(--line); }
.review-bar span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.review-side .text-input { padding: 8px 12px; }
label.review-check { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-weight: 400; }
label.review-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.review-list { flex: 1 1 auto; min-height: 120px; margin: 4px -8px 0; padding: 0 4px; overflow-y: auto; }
.review-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 5px 8px;
  border: 0; border-radius: 8px; background: none; color: var(--text); font: .92rem var(--sans); text-align: left;
}
.review-item[aria-current="true"] { background: var(--accent); color: var(--accent-text); }
.review-item-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
/* Long names wrap instead of being cut off: "Chunky Ladder 4" and "Chunky Ladder 5"
   differ only at the end, which is exactly what an ellipsis would hide. */
.review-item-name { overflow-wrap: anywhere; }
.review-item-also { overflow: hidden; font-size: .78rem; opacity: .8; text-overflow: ellipsis; white-space: nowrap; }
.review-item-count { flex: none; margin-top: 2px; font: .8rem var(--mono); opacity: .75; }
.review-dot { flex: none; margin-top: 6px; width: 10px; height: 10px; border: 2px solid var(--switch-off); border-radius: 50%; }
.review-item[data-state="partial"] .review-dot { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.review-item[data-state="done"] .review-dot { border-color: var(--accent); background: var(--accent); }
.review-item[aria-current="true"] .review-dot { border-color: currentColor; }
.review-item[aria-current="true"][data-state="partial"] .review-dot { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.review-item[aria-current="true"][data-state="done"] .review-dot { background: currentColor; }
.review-keys { margin: 0 2px; font-size: .8rem; }
kbd { padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); font: .8rem var(--mono); }
/* The review switch reads as the page's subject, above the intro. */
.review-sets { margin: 4px 0 10px; }
.review-sets a.choice { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; }
.review-sets a.choice[aria-checked="true"] { color: var(--accent-text); }
/* A note for the reviewer on one pattern (the set's notes.json): hard to miss, not alarming. */
.review-callout { margin: 8px 0 4px; padding: 8px 10px; border-left: 4px solid var(--focus);
                  border-radius: 6px; background: var(--bg); font-size: .9rem; }
.review-export { display: flex; flex-wrap: wrap; gap: 6px; }
.review-export .choice { min-height: 36px; padding: 0 12px; font-size: .85rem; }
.review-export a.choice { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; }

.review-detail { min-width: 0; }
.review-detail-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.review-detail-head h2 { margin: 2px 0 0; font-size: 1.8rem; line-height: 1.15; }
.review-meta { margin: 2px 0 0; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.review-nav { display: flex; gap: 8px; }
.review-nav .choice { min-height: 40px; }
.review-nav .choice.is-primary { border-color: transparent; background: var(--accent); color: var(--accent-text); }
.review-desc { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }

/* The serial every member of the group is drawn on */
.dup-serials { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.dup-serials .field-label { margin: 0 0 8px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.dup-chips .dup-chip { min-height: 38px; padding: 0 14px; font: 600 .9rem var(--mono); letter-spacing: .03em; }
.dup-serial-own { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dup-serial-input { flex: 1 1 200px; min-width: 0; padding: 8px 12px; font-size: 1.05rem; }
.dup-serial-own .choice { flex: 0 0 auto; min-height: 42px; padding: 0 20px; border-color: transparent; background: var(--accent); color: var(--accent-text); }
.digit-counter { align-self: center; color: var(--muted); font-size: .85rem; }
.digit-counter[data-state="ready"] { color: var(--accent); font-weight: 600; }
.digit-counter:empty { display: none; }
.dup-serial-own .choice:disabled { opacity: .5; }
.dup-serial-status, .dup-draw-status { min-height: 0; margin: 8px 2px 0; color: var(--error); font-size: .88rem; }
.dup-draw-status:empty, .dup-serial-status:empty { display: none; }

.dup-members { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; margin-top: 16px; }
/* A pattern with no duplicate is on its own: don't stretch its card across the page. */
.dup-members:has(> :only-child) { grid-template-columns: minmax(0, 760px); }
.dup-member {
  display: flex; flex-direction: column; padding: 14px 16px; border: 1px solid var(--line); border-left-width: 5px;
  border-radius: var(--radius); background: var(--surface);
}
.dup-member.is-pinned { border-left-style: dashed; border-left-color: var(--focus); }
.badge-pinned { border-color: var(--focus); color: var(--text); }
button.link.dup-unpin { min-height: 0; padding: 0 4px; font-size: .8rem; }
.dup-member[data-decision="keep"] { border-left-color: var(--accent); }
.dup-member[data-decision="remove"] { border-left-color: var(--error); }
.dup-member[data-decision="unsure"] { border-left-style: dashed; }
.dup-member[data-decision="remove"] .dup-drawing { opacity: .55; }
.dup-drawing { min-height: 40px; }
.dup-member .dup-nomatch { display: none; margin: 6px 2px 0; }
.dup-member.no-match .dup-nomatch { display: block; }
.dup-member-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 10px; font-size: 1.05rem; }
.badge-essentials { border-color: var(--accent); color: var(--text); }
.dup-member .review-actions { margin-top: auto; padding-top: 12px; }

.review-actions { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.review-actions.is-saving, .dup-member.is-saving { opacity: .6; pointer-events: none; }
.review-decisions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.review-decisions .choice { min-height: 40px; padding: 0 6px; }
.review-decisions .decision-keep[aria-checked="true"] { background: var(--accent); color: var(--accent-text); }
.review-decisions .decision-remove[aria-checked="true"] { border-color: transparent; background: var(--error); color: #ffffff; }
.review-decisions .decision-unsure[aria-checked="true"] { border-color: transparent; background: var(--muted); color: var(--bg); }
.review-instead {
  min-height: 40px; padding: 4px 10px; border: 1px dashed var(--accent); border-radius: 10px;
  background: none; color: var(--text); font: 600 .88rem var(--sans);
}
.review-actions .review-note { padding: 8px 10px; font-size: .9rem; }
.review-who { display: flex; flex-direction: column; margin: 0 2px; color: var(--muted); font-size: .8rem; }
.review-who:empty { display: none; }
.review-error { min-height: 0; margin: 0 2px; font-size: .85rem; }

/* What's different + questions for Claude */
.dup-diff, .dup-questions { margin-top: 26px; }
.dup-diff-picks { display: flex; align-items: center; gap: 8px; }
.dup-diff-picks select { min-height: 36px; padding: 4px 8px; font-size: .9rem; }
.dup-diff-vs { color: var(--muted); font-size: .85rem; }
.dup-diff-body { margin-top: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.dup-diff-line { margin: 0 0 2px; font-size: .95rem; }
.dup-diff-side { margin-top: 10px; }
.dup-diff-side.is-empty .dup-diff-line { color: var(--muted); }
.dup-diff-serials { margin-top: 6px; }
.dup-diff-body .hint { margin: 10px 2px 0; }
.dup-diff-body button.link { margin: 8px 0 0 -8px; }
.dup-sources { display: grid; gap: 12px; }
.dup-sources[data-open="1"] { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.dup-source pre { max-height: 420px; margin: 4px 0 0; padding: 10px 12px; overflow: auto;
                  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.dup-source code { font: .8rem/1.5 var(--mono); white-space: pre; }

.dup-question-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.dup-question { padding: 12px 14px; border: 1px solid var(--line); border-left: 5px solid var(--switch-off);
                border-radius: var(--radius); background: var(--surface); }
.dup-question.is-answered { border-left-color: var(--accent); }
.dup-question-text { margin: 0; font-weight: 600; }
.dup-answer { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.dup-answer-text { margin: 2px 0 0; white-space: pre-wrap; }
/* Wraps on a phone: the box gets its own line rather than being squeezed to a sliver
   next to the button (and, in the workshop, the pattern picker as well). */
.dup-question-ask { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.dup-question-box { flex: 1 1 260px; min-width: 0; min-height: 78px; font: 1rem var(--sans); resize: vertical; }
.dup-question-ask .choice { flex: 1 0 auto; min-height: 44px; border-color: transparent; background: var(--accent); color: var(--accent-text); }
.dup-question-status { min-height: 0; margin: 8px 2px 0; color: var(--error); font-size: .88rem; }
.dup-question-status:empty { display: none; }
.dup-waiting { color: var(--text); font-weight: 600; }
.review-answers { font-size: .85rem; }
.review-answers summary { min-height: 32px; cursor: pointer; font-weight: 600; }
.review-answers .hint { margin: 6px 2px; font-size: .78rem; }
.review-answers textarea { font: .8rem var(--mono); }
.review-answers .choice { min-height: 34px; margin-top: 6px; padding: 0 12px; font-size: .85rem; }
.review-answers .status { min-height: 0; margin: 6px 2px 0; font-size: .8rem; }

/* Pattern workshop */
.dup-workshop { margin-top: 26px; }
.dup-workshop .dup-question-ask { align-items: flex-start; }
.dup-workshop select.text-input { flex: 1 1 200px; min-width: 0; min-height: 44px; }
.dup-workshop button.link { margin-left: -8px; }
.draft-list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.draft { padding: 14px 16px; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.draft-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 1.05rem; }
.draft-instruction { margin: 6px 0 0; font-size: .92rem; font-weight: 600; }
.draft-instruction.is-missing { color: var(--muted); font-weight: 400; font-style: italic; }
.draft-summary { margin: 6px 0 0; font-size: .92rem; }
.draft-preview { margin-top: 12px; }
.review-picture { margin: 0; }
.draft-row + .draft-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.draft-actions { margin-top: 12px; }
.draft-actions .choice { min-height: 38px; padding: 0 12px; font-size: .85rem; text-decoration: none; }
a.choice { display: inline-flex; align-items: center; }
.draft-status { min-height: 0; margin: 8px 2px 0; font-size: .85rem; }
.draft-status:empty { display: none; }
.draft-code { margin-top: 10px; }
.draft-code summary { min-height: 32px; cursor: pointer; color: var(--muted); font-size: .85rem; font-weight: 600; }
.draft-script { margin-top: 6px; font: .8rem/1.5 var(--mono); white-space: pre; overflow-wrap: normal; }

@media (hover: hover) {
  .review-item:not([aria-current="true"]):hover { background: var(--bg); }
  .review-instead:hover { filter: brightness(.96); }
}

/* Narrow windows and phones: the list above, the group below, members stacked. */
@media (max-width: 960px) {
  .review-layout { grid-template-columns: minmax(0, 1fr); }
  .review-side { position: static; max-height: none; }
  .review-list { max-height: 40vh; }
  .review-keys { display: none; }
  .dup-members { grid-template-columns: minmax(0, 1fr); }
}
