/* Spot the Violation - app.css
 * Mobile first. Design tokens on :root; dark mode via prefers-color-scheme and a manual [data-theme] override.
 */

/* ---------- tokens ---------- */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f3f0ea;
  --surface-3: #ebe7df;
  --text: #1c1e21;
  --muted: #5b616a;
  --border: #ddd8ce;
  --border-strong: #c7c0b3;
  --accent: #e8590c;
  --accent-strong: #c2410c;     /* filled buttons: white text passes AA */
  --accent-hover: #a8380a;
  --accent-text: #b8470a;       /* accent used as text on light surfaces */
  --accent-soft: #fdeee4;
  --on-accent: #ffffff;
  --ok: #2e7d32;
  --ok-text: #1f6b24;
  --ok-soft: #e7f3e8;
  --bad: #c62828;
  --bad-text: #b02323;
  --bad-soft: #fcebea;
  --warn: #f59f00;
  --warn-text: #8a5300;
  --warn-soft: #fff4d9;
  --info-soft: #e9eef6;
  --info-text: #2f4f7f;
  --hotspot: #e03131;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(30, 25, 15, 0.06), 0 4px 14px rgba(30, 25, 15, 0.06);
  --scrim: rgba(15, 17, 20, 0.4);   /* dims the page under the open phone menu */
  --shadow-lg: 0 2px 4px rgba(30, 25, 15, 0.06), 0 12px 32px rgba(30, 25, 15, 0.10);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --gutter: 16px;
  --maxw: 1200px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121417;
    --surface: #1b1e23;
    --surface-2: #22262c;
    --surface-3: #2a2f36;
    --text: #ecebe8;
    --muted: #a3a9b1;
    --border: #343941;
    --border-strong: #4a5059;
    --accent-text: #ff9a5c;
    --accent-soft: rgba(232, 89, 12, 0.16);
    --ok-text: #86cf8a;
    --ok-soft: rgba(46, 125, 50, 0.22);
    --bad-text: #f19a9a;
    --bad-soft: rgba(198, 40, 40, 0.22);
    --warn-text: #ffc552;
    --warn-soft: rgba(245, 159, 0, 0.16);
    --info-soft: rgba(110, 150, 220, 0.16);
    --info-text: #a9c4f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  --scrim: rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121417;
  --surface: #1b1e23;
  --surface-2: #22262c;
  --surface-3: #2a2f36;
  --text: #ecebe8;
  --muted: #a3a9b1;
  --border: #343941;
  --border-strong: #4a5059;
  --accent-text: #ff9a5c;
  --accent-soft: rgba(232, 89, 12, 0.16);
  --ok-text: #86cf8a;
  --ok-soft: rgba(46, 125, 50, 0.22);
  --bad-text: #f19a9a;
  --bad-soft: rgba(198, 40, 40, 0.22);
  --warn-text: #ffc552;
  --warn-soft: rgba(245, 159, 0, 0.16);
  --info-soft: rgba(110, 150, 220, 0.16);
  --info-text: #a9c4f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
}
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); }
ul, ol { padding-left: 1.25rem; }
p, li, h1, h2, h3, dd, figcaption, .choice-text { overflow-wrap: anywhere; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  padding: 10px 14px; border-radius: var(--radius-sm); border: 0;
  background: var(--accent-strong); color: var(--on-accent); font-weight: 700; cursor: pointer;
}
.skip-link:focus { top: 8px; }

/* ---------- header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  position: relative;
  z-index: 20;
}
.header-inner { display: flex; align-items: center; gap: 12px; min-height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.08rem; letter-spacing: -0.01em; margin-right: auto; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand:hover { text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .icon { width: 22px; height: 22px; }
/* borderless icon button: dialog and sheet closes, dismisses (named by aria-label and title like every icon-only control) */
.icon-btn.btn-ghost { background: transparent; border-color: transparent; }
.icon-btn.btn-ghost:hover { background: var(--surface-2); }
#theme-toggle .icon-sun { display: none; }
#theme-toggle[aria-pressed="true"] .icon-sun { display: block; }
#theme-toggle[aria-pressed="true"] .icon-moon { display: none; }

.site-nav { display: none; }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.site-nav a, .nav-more > summary {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.95rem;
}
/* "More": a native <details> (Tab, Enter and Space for free, and it works with JavaScript off on the prerendered
   pages); js/theme.js adds Escape, outside-click and pick-to-close. Nothing forces it open: it opens on a click or tap only. */
.nav-more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary .chev { width: 18px; height: 18px; transition: transform 0.15s; }
.nav-more[open] > summary .chev { transform: rotate(180deg); }
@media (hover: hover) {
  .site-nav a:hover, .nav-more > summary:hover { background: var(--surface-2); }
}
/* the current page: an accent-soft pill (a full-width row in the phone menu); a current page inside More lights up its summary */
.site-nav a[aria-current="page"], .nav-more:has(a[aria-current="page"]) > summary { color: var(--accent-text); background: var(--accent-soft); }

/* The trade switcher, the nav's first item: a native <details> like More ("[icon] Trade: Electrical", a chip right of the
   brand from 960 px, the phone menu's first row). js/app.js shows the current trade (index.html's copy is neutral,
   "Trade: Choose"); js/theme.js adds Escape, Tab-out and outside-click; the prerendered pages use it as is, no script. */
.trade-switch[hidden] { display: none !important; }
.trade-switch > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 700; font-size: 0.95rem;
}
.trade-switch > summary::-webkit-details-marker { display: none; }
.trade-switch-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; color: var(--accent-text); }
.trade-switch-icon .icon { width: 20px; height: 20px; }
.trade-switch > summary .chev { width: 16px; height: 16px; flex: none; margin-left: auto; transition: transform 0.15s; }
.trade-switch[open] > summary .chev { transform: rotate(180deg); }
/* index.html before js/app.js syncs it: the icon and the name keep their room and show nothing (no wrong trade flashes) */
.trade-switch.is-pending .trade-switch-icon, .trade-switch.is-pending .trade-switch-name { visibility: hidden; }
.site-nav .trade-list a { display: flex; align-items: center; gap: 8px; }
.site-nav .trade-list a .icon { width: 18px; height: 18px; flex: none; color: var(--accent-text); }
.trade-list-code { margin-left: auto; padding-left: 8px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.site-nav .trade-list a[aria-current="true"] { color: var(--accent-text); background: var(--accent-soft); }
@media (hover: hover) {
  .trade-switch > summary:hover { background: var(--surface-2); }
}

/* Header breakpoints are in em (60em = 960 px, 71.25em = 1140 px at the default text size), so a larger browser text
   size collapses the nav to the menu button sooner instead of pushing the row past the window.
   Below 60em: the menu button opens the nav as one column under the header, three groups split by dividers (More is
   the third, a disclosure row). The prerendered pages open it with a CSS-only checkbox (.nav-check), hence the selector
   list. The panel's second shadow is the scrim: it dims the page under the header without changing layout or scrolling. */
@media (max-width: 59.99em) {
  .site-nav.is-open, .nav-check:checked ~ .site-nav {
    display: block; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--surface); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg), 0 100vmax 0 100vmax var(--scrim);
    padding: 8px var(--gutter) 12px; max-height: calc(100vh - 62px); overflow-y: auto; overscroll-behavior: contain;
  }
  .site-nav ul { display: block; }
  .site-nav a, .nav-more > summary { display: flex; align-items: center; min-height: 48px; padding: 12px; }
  .nav-more > summary { justify-content: space-between; }
  .nav-sep, .nav-more { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
  .nav-secondary a { padding-left: 24px; }
  /* the trade row first ("Trade: Electrical"), its own group; it expands to the trades in place, indented like More's */
  .trade-switch { border-bottom: 1px solid var(--border); margin-bottom: 6px; padding-bottom: 6px; }
  .trade-switch > summary { min-height: 48px; padding: 12px; }
  .site-nav .trade-list a { padding-left: 24px; }
}

/* 60em (960 px) up: five links and More inline next to the brand; More opens as a dropdown under its summary. The open-panel
   selectors are reset too, so a menu left open while the window grows becomes the inline row. index.html,
   sandbox.html and the prerendered pages share this header. */
@media (min-width: 60em) {
  .nav-toggle { display: none; }
  .site-nav, .site-nav.is-open, .nav-check:checked ~ .site-nav {
    display: flex; align-items: center; gap: 2px; position: static; margin-right: auto;
    box-shadow: none; border: 0; padding: 0; background: none; max-height: none; overflow: visible;
  }
  .site-nav .nav-primary { display: flex; gap: 2px; }
  .site-nav a, .nav-more > summary { padding: 8px 10px; font-size: 0.92rem; white-space: nowrap; }
  .brand { margin-right: 12px; }
  .nav-more { position: relative; }
  .site-nav .nav-secondary {
    position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; min-width: 200px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  }
  .site-nav .nav-secondary a { display: flex; align-items: center; min-height: 40px; padding: 10px 12px; }
  /* the switcher: a bordered chip right of the brand, its trades a dropdown like More's */
  .trade-switch { position: relative; flex: none; margin-right: 6px; }
  .trade-switch > summary {
    min-height: 38px; padding: 7px 10px; font-size: 0.92rem; white-space: nowrap;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  }
  .site-nav .trade-list {
    position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; min-width: 240px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  }
  .site-nav .trade-list a { min-height: 40px; padding: 10px 12px; }
}
/* 60em-71.24em (960-1139 px): the chip is the trade's icon and the chevron ("Trade: Electrical" stays its accessible
   name), and the links and the brand give up a little padding, so the row ends clear of the theme toggle */
@media (min-width: 60em) and (max-width: 71.24em) {
  .trade-switch > summary { padding: 7px 6px; gap: 2px; }
  .trade-switch-pre, .trade-switch-name {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .site-nav .nav-primary a, .nav-more > summary { padding-left: 7px; padding-right: 7px; }
  .brand { margin-right: 6px; }
}
/* 71.25em (1140 px) up: "[bolt] Electrical"; "Trade: " is read, not shown. Before a pick it reads "Trade: Choose" in full. */
@media (min-width: 71.25em) {
  .trade-switch[data-trade] .trade-switch-pre {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

/* ---------- layout ---------- */
.view { flex: 1 0 auto; padding-top: 20px; padding-bottom: 40px; }
.view:focus { outline: none; }
.page-head { margin-bottom: 18px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { color: var(--muted); margin: 0; }
.section { margin-top: 32px; }
.section-title { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
}
.empty {
  text-align: center; padding: 32px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.empty h2 { font-size: 1.15rem; }
.empty p { color: var(--muted); }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 0.85rem; padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); }
.site-footer p { margin: 0 0 6px; }
.site-footer .disclaimer { color: var(--text); opacity: 0.8; margin: 0; padding-top: 12px; border-top: 1px solid var(--border); }
/* four link groups (Practice, Reference, More, About) over the disclaimer: two columns on phones, four from 720 px */
.footer-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin-bottom: 16px; }
@media (min-width: 720px) { .footer-nav { grid-template-columns: repeat(4, max-content); gap: 16px 64px; } }
.footer-title { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 32px; color: var(--text); text-decoration: none; }
.footer-nav a:hover { color: var(--accent-text); text-decoration: underline; }
/* phones and touch screens: full-size tap targets for the footer links */
@media (max-width: 719px), (pointer: coarse) {
  .footer-nav a { min-height: 44px; }
}

/* ---------- buttons, chips, controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: var(--radius); border: 1.5px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 700; font-size: 0.95rem; line-height: 1.2;
  text-decoration: none; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
/* the one filled action of its surface (a view, a card that is its own task, a dialog, a popover or sheet, a banner) */
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-lg { min-height: 52px; padding: 12px 22px; font-size: 1.05rem; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; }
/* dense rows keep 36 px buttons with a mouse; on touch screens every button is a 44 px target */
@media (pointer: coarse) { .btn-sm { min-height: 44px; } }
/* tertiary: text only, a tint on hover; .is-danger for a quiet destructive trigger in a row (Forget key, a row's trash) */
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-ghost.is-danger { color: var(--bad-text); }
.btn-ghost.is-danger:hover { background: var(--bad-soft); border-color: transparent; }
/* outlined danger opens an inline confirm; the solid one is the confirm button inside it */
.btn-danger { color: var(--bad-text); border-color: var(--bad); background: var(--surface); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: #a61f1f; border-color: #a61f1f; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
/* a disabled primary goes neutral (never a faded orange); a muted reason line always sits right under its row */
.btn-primary[disabled], .btn-primary[aria-disabled="true"], .btn-primary[disabled]:hover, .btn-primary[aria-disabled="true"]:hover {
  background: var(--surface-3); border-color: var(--surface-3); color: var(--muted); opacity: 1; cursor: not-allowed; transform: none;
}
/* option buttons: a single choice that must wrap (role=group .opt-group); pressed is accent-soft, no checkmark */
.opt-group .btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
/* a row of buttons: one height (one size class per row), 8 px apart. Page content and forms read left to right
   (primary, secondary, tertiary) with a reset or destructive action set apart at the far right (.is-apart); overlays and
   inline confirms are right-aligned (.is-end) with the confirm last */
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row.is-end { justify-content: flex-end; }
.btn-row > .is-apart { margin-left: auto; }
/* phones: a row of two or more buttons stacks full width, the primary on top (an .is-end row reverses, so its confirm
   is on top and Cancel last). The sandbox keeps its own rows (box view, job reset). */
@media (max-width: 559px) {
  :where(.view:not(.sbx-view)) .btn-row > .btn:not(:only-child) { flex: 1 1 100%; }
  :where(.view:not(.sbx-view)) .btn-row.is-end { flex-direction: column-reverse; align-items: stretch; }
  :where(.view:not(.sbx-view)) .btn-row.is-end > .btn { flex: 0 0 auto; }
  :where(.view:not(.sbx-view)) .btn-row > .is-apart { margin-left: 0; }
}

.kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px; background: var(--surface-2); font-family: var(--mono); font-size: 0.75rem; line-height: 1.4; text-align: center; color: var(--text);
}

/* chips are multi-select toggles only (the Filters categories); single choices are .seg or .opt-group, jumps are .jump-link */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px;
  border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 0.875rem; font-weight: 600; cursor: pointer; line-height: 1.2; text-align: left;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.chip[aria-pressed="true"]::before {
  content: ""; width: 0.55em; height: 0.9em; border: solid currentColor; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -2px); flex: none;
}
.chip .count { font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.chip[aria-pressed="true"] .count { color: inherit; opacity: 0.8; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; line-height: 1.3; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  white-space: nowrap;
}
.pill .icon { width: 1.05em; height: 1.05em; vertical-align: 0; }
.pill-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok-text); }
.pill-bad { background: var(--bad-soft); border-color: transparent; color: var(--bad-text); }
.pill-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn-text); }
.pill-info { background: var(--info-soft); border-color: transparent; color: var(--info-text); }
.pill-gray { background: var(--surface-3); border-color: transparent; color: var(--muted); }
/* tonal and borderless: "#gfci", "Confidence: medium" and the L1-L3 counts are labels, never mistaken for chips */
.pill-tag { background: var(--surface-2); border-color: transparent; color: var(--muted); font-weight: 600; }

.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); max-width: 100%; }
.seg button {
  min-height: 36px; padding: 6px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  font-weight: 700; font-size: 0.875rem; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }

.field { display: grid; gap: 6px; }
.field label, .field .label { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.input, .select {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.input:focus-visible, .select:focus-visible { outline-offset: 0; border-color: var(--accent); }
.search-input { padding-left: 40px; background-image: none; }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ---------- home ---------- */
.hero { display: grid; gap: 20px; padding: 8px 0 4px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 10px; }
.hero h1 { font-size: 2.2rem; letter-spacing: -0.02em; margin-bottom: 10px; }
.hero .lede { font-size: 1.1rem; color: var(--muted); max-width: 36em; margin-bottom: 20px; }
/* Start drilling and Browse drills, both large; stacked full width on phones with the primary on top */
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hero-actions .btn { flex: 0 0 auto; }
@media (max-width: 559px) { .hero-actions .btn { flex: 1 1 100%; } }
.hero-note { margin-top: 14px; font-size: 0.9rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.hero-note span { display: inline-flex; align-items: center; gap: 6px; }
.hero-preview { display: block; text-decoration: none; color: var(--text); border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.hero-preview img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-3); }
.hero-preview .preview-body { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hero-preview .preview-title { font-weight: 700; }
.hero-preview:hover .card-go { text-decoration: underline; }
/* the cue at the bottom right of a whole-card link: "Start", "Continue", "See your stats", with a trailing arrow */
.card-go { color: var(--accent-text); font-weight: 700; font-size: 0.95rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
a.card-go:hover { text-decoration: underline; }
a.card-go { text-decoration: none; }

.stat-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; min-width: 0;
}
.stat .stat-value { display: block; font-size: 1.4rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .stat-label { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.stat-more { margin: 10px 0 0; }

.track-icon { width: 34px; height: 34px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }

/* the trade chooser: Home on a first visit and every trade-scoped view until a pick (js/app.js tradeChooser); the
   prerendered hubs (/codes/, /minnesota/) use its cards as links. One column of whole-card buttons, three from 720 px. */
.trade-chooser { padding: 8px 0 4px; }
.trade-chooser h1 { font-size: 2rem; letter-spacing: -0.02em; margin-bottom: 8px; }
.chooser-lede { font-size: 1.05rem; color: var(--muted); max-width: 40em; margin: 0 0 18px; }
.chooser-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.chooser-grid > li { display: flex; min-width: 0; }
.chooser-card {
  width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 16px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer; text-decoration: none;
}
.chooser-card:hover { border-color: var(--accent); text-decoration: none; }
.chooser-card:hover .card-go { text-decoration: underline; }
.chooser-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.chooser-head { display: flex; align-items: center; gap: 10px; }
.chooser-name { font-size: 1.15rem; font-weight: 800; min-width: 0; }
.chooser-desc { font-size: 0.95rem; }
.chooser-code { font-size: 0.85rem; color: var(--muted); }
.chooser-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 0.9rem; }
.chooser-count { color: var(--muted); font-weight: 600; }
.chooser-note { margin: 14px 0 0; font-size: 0.92rem; color: var(--muted); }
/* "Also available: Plumbing · Framing" (Minnesota), "Your drills in other trades: ..." (Contribute): links that switch trade */
.also-row { margin: 20px 0 0; color: var(--muted); }
.also-row a { font-weight: 700; }
@media (pointer: coarse) { .also-row a { display: inline-flex; align-items: center; min-height: 44px; } }
@media (min-width: 720px) {
  .trade-chooser h1 { font-size: 2.4rem; }
  .chooser-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.cat-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
.cat-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 52px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer; text-align: left;
}
.cat-btn:hover { border-color: var(--accent); }
.cat-btn .cat-name { font-weight: 700; font-size: 0.95rem; }
.cat-btn .cat-articles { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 500; }
/* "6 drills ->" at the card's right: a muted count and the accent arrow (a disabled card shows "0 drills" alone) */
.cat-btn .cat-go { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.cat-btn .count { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.cat-btn .cat-go .icon { width: 18px; height: 18px; color: var(--accent-text); }
.cat-btn[disabled] { opacity: 0.55; cursor: default; }
.cat-btn[disabled]:hover { border-color: var(--border); }

.how { display: grid; gap: 10px; counter-reset: how; }
.how li { list-style: none; display: flex; gap: 12px; align-items: flex-start; }
.how li::before { counter-increment: how; content: counter(how); flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); font-weight: 800; font-size: 0.85rem; }
.how { padding: 0; margin: 0; }

@media (min-width: 720px) {
  .hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: 36px; padding-top: 24px; }
  .hero h1 { font-size: 2.8rem; }
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .how { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1040px) {
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- drill view ---------- */
.drill-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
@media (max-width: 479px) {
  .drill-toolbar .seg button { padding: 6px 11px; font-size: 0.85rem; }
  .filter-toggle { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .filter-toggle .chev { display: none; }
}
.drill-toolbar .seg { flex: 0 1 auto; }
/* touch screens: the mode buttons are 36 px tall in a 44 px track; an overlay across the track's padding makes each a
   44 px tap target without making the toolbar row taller (the first screen keeps its room) */
@media (pointer: coarse) {
  .mode-seg button { position: relative; }
  .mode-seg button::after { content: ""; position: absolute; inset: -4px 0; }
}
.filter-anchor { position: relative; margin-left: auto; min-width: 0; }
.drill-meta .meta-track { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); }
.drill-meta .meta-track .icon { width: 14px; height: 14px; }
.filter-toggle { max-width: 100%; }
.filter-toggle > .icon { flex: none; }
.filter-label { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; }
.filter-toggle .filter-summary { font-weight: 500; color: var(--muted); max-width: 16em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-toggle .filter-summary-short { display: none; }
/* phones: "Filters" over a short summary of up to two lines ("All categories", "2 categories · Level 3"), so an
   active level is never cut off; the button keeps its 44 px minimum and the toolbar one row */
@media (max-width: 719px) {
  .drill-toolbar .filter-anchor { flex: 1 1 0; display: flex; justify-content: flex-end; }
  .filter-toggle { min-height: 44px; padding: 0 8px 0 10px; gap: 6px; min-width: 0; }
  .filter-label { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.1; text-align: left; }
  .filter-toggle .filter-summary { display: none; }
  .filter-toggle .filter-summary-short {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; white-space: normal;
    max-width: 100%; font-size: 0.72rem; line-height: 1.2;
  }
}
/* small phones: the funnel icon gives its width to the summary (the label still says "Filters") */
@media (max-width: 399px) {
  .filter-toggle > .icon:first-child { display: none; }
}
.filter-toggle .chev { flex: none; transition: transform 0.15s; }
.filter-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* Filters: a popover under its button (720 px up), a bottom sheet with a dimmed backdrop below 720 px.
   It overlays the page and never pushes the drill down. */
.filter-panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 15; width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 140px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.filter-head { display: none; }
.filter-body { display: grid; gap: 14px; padding: 14px 14px 4px; }
.filter-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.filter-panel legend { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; padding: 0; }
.filter-foot {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-top: 10px; background: var(--surface); border-top: 1px solid var(--border); font-size: 0.875rem; color: var(--muted);
}
.filter-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.filter-panel .chip-list { gap: 6px; }
.filter-panel .chip { min-height: 32px; padding: 4px 10px; gap: 5px; font-size: 0.8125rem; }
.filter-backdrop { display: none; }
@media (max-width: 719px) {
  .filter-panel {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 45; width: auto; max-height: 85vh;
    border-radius: 16px 16px 0 0; border-bottom: 0; animation: sheet-up 0.2s ease-out both;
  }
  .filter-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 0 16px; }
  .filter-title { margin: 0; font-size: 1.05rem; }
  .filter-close { width: 44px; height: 44px; background: transparent; border-color: transparent; }
  .filter-body { padding: 8px 16px 4px; }
  .filter-panel .chip { min-height: 36px; }
  .filter-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .filter-foot .filter-apply { min-height: 44px; padding-left: 18px; padding-right: 18px; }
  .filter-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(0, 0, 0, 0.45); animation: marker-fade 0.2s ease-out both; }
  html.filters-open, html.filters-open body { overflow: hidden; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
/* touch screens: 44 px chips and segments in Filters (Difficulty, categories); the gaps between them stay */
@media (pointer: coarse) {
  .filter-panel .chip, .filter-panel .seg button { min-height: 44px; }
}
/* Difficulty: four equal segments on one row that never wraps; each a number over its name ("1 Apprentice") */
.diff-seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.diff-seg button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-width: 0; padding: 4px; line-height: 1.15; }
.diff-seg .seg-sub { font-size: 0.7rem; font-weight: 600; }

.hud { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 0.875rem; color: var(--muted); margin-bottom: 14px; }
.hud-item { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.hud-item strong { color: var(--text); }
.hud-item .icon { width: 18px; height: 18px; }
.hud-streak.is-hot strong, .hud-streak.is-hot .icon { color: var(--accent-text); }
.hud .timer-btn { margin-left: auto; min-height: 32px; padding: 4px 10px; font-size: 0.8rem; font-weight: 700; border-radius: var(--radius); border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.hud .timer-btn:hover { background: var(--surface-2); }
.hud .timer-btn[aria-pressed="true"] { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }
.hud .timer-btn .icon { width: 16px; height: 16px; }
/* small phones: the timer toggle is icon-only (44 x 44, named by aria-label), so the HUD stays on one row; the
   negative margins keep that row 32 px tall */
@media (max-width: 399px) {
  .hud .timer-btn { width: 44px; height: 44px; min-height: 44px; margin-top: -6px; margin-bottom: -6px; padding: 0; justify-content: center; }
  .hud .timer-btn .icon { width: 18px; height: 18px; }
  .hud .timer-label { display: none; }
}
/* touch screens from 400 px up: the labelled toggle is a 44 px tap target too, with the same negative margins */
@media (pointer: coarse) {
  .hud .timer-btn { min-height: 44px; margin-top: -6px; margin-bottom: -6px; }
}

.drill-layout { display: grid; gap: 16px; align-items: start; }
.drill-main { min-width: 0; }
.drill-side { min-width: 0; }
/* one eyebrow line, "Electrical · GFCI, AFCI & receptacle devices · Level 2"; the category gives way with an ellipsis */
.drill-meta { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; min-width: 0; }
.drill-meta > span { flex: none; }
.drill-meta > .meta-cat { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.drill-meta > span + span:not(.pill)::before { content: "·"; margin-right: 6px; color: var(--muted); }
.drill-meta .meta-level { color: var(--text); }
.drill-title { font-size: 1.35rem; margin-bottom: 12px; }
/* "← Back to results" over the eyebrow when the drill was opened from Browse, Code index or Stats */
.back-results { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin: -4px 0 4px; font-size: 0.875rem; font-weight: 700; }
.back-results .icon { width: 18px; height: 18px; }
@media (pointer: coarse) { .back-results { min-height: 44px; margin: -10px 0 0; } }
/* phones: a little less air between the HUD, the eyebrow and the picture, so the question starts higher */
@media (max-width: 719px) {
  .view-drill { padding-top: 12px; }
  .hud { margin-bottom: 10px; }
  .drill-layout { gap: 12px; }
}

/* scene */
.scene { margin: 0; }
.scene-wrap {
  position: relative; width: 100%; max-width: 800px; aspect-ratio: 4 / 3; margin: 0 auto;
  border-radius: var(--radius); overflow: hidden; background: var(--surface-3);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.scene-frame { position: absolute; inset: 0; }
.scene-frame > svg, .scene-frame > img { display: block; width: 100%; height: 100%; }
.scene-frame > img { object-fit: contain; user-select: none; -webkit-user-select: none; }
.scene-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.scene-markers { position: absolute; inset: 0; pointer-events: none; }
.scene-caption { margin-top: 8px; font-size: 0.875rem; line-height: 1.4; color: var(--muted); text-align: center; }
.scene-fallback { display: grid; place-items: center; height: 100%; padding: 16px; text-align: center; color: var(--muted); }

.scene-wrap.is-spot { cursor: crosshair; outline: 2px dashed var(--accent); outline-offset: 3px; }
.scene-hit {
  position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; margin: 0; border: 0; background: transparent;
  cursor: crosshair; border-radius: var(--radius); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.scene-hit:focus-visible { outline: 3px solid var(--accent); outline-offset: -4px; }

/* fades out 2.5 s after the drill appears or on the first touch of the picture (app.js adds .is-out, then removes it) */
.spot-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 2; pointer-events: none;
  transition: opacity 0.3s ease;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: rgba(20, 22, 25, 0.78); color: #fff; font-size: 0.8rem; font-weight: 700; white-space: nowrap;
}
.spot-hint .icon { width: 16px; height: 16px; }
.spot-hint.is-out { opacity: 0; }

/* enlarge: a corner button over the picture whenever taps don't mark it (multiple choice, or after the answer) */
.scene-wrap.can-zoom { cursor: zoom-in; }
.zoom-btn {
  position: absolute; top: 6px; right: 6px; z-index: 3; display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 10px; background: rgba(20, 22, 25, 0.62); color: #fff; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.zoom-btn:hover { background: rgba(20, 22, 25, 0.82); }
.zoom-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.zoom-btn .icon { width: 20px; height: 20px; }
/* the full-screen view: scene scaled to fit, browser pinch zoom, scroll to pan; the page behind does not scroll */
html.zoom-open, html.zoom-open body { overflow: hidden; }
.scene-zoom {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #101114; color: #fff; display: flex; flex-direction: column; overscroll-behavior: contain;
}
.scene-zoom:not([open]) { display: none; }
.scene-zoom::backdrop { background: rgba(0, 0, 0, 0.85); }
.zoom-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
.zoom-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 0.95rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zoom-close { flex: none; background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.zoom-close:hover { background: rgba(255, 255, 255, 0.2); }
.zoom-stage {
  flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center;
  padding: 8px 8px max(16px, env(safe-area-inset-bottom)); touch-action: pinch-zoom pan-x pan-y;
}
.zoom-stage .scene { margin: 0; width: min(100%, calc((100vh - 140px) * var(--zoom-ar, 1.333))); width: min(100%, calc((100dvh - 140px) * var(--zoom-ar, 1.333))); }
.zoom-stage .scene-wrap { max-width: none; box-shadow: none; }
.zoom-stage { flex-direction: column; }
.zoom-stage .scene-caption { color: #c9cdd3; }
.zoom-hint { margin: 10px 0 0; font-size: 0.85rem; color: #aeb3ba; text-align: center; }   /* touch screens only (app.js) */

/* under the choices and in the spot panel: "Show answer" (and "Enlarge picture" in spot it) as quiet text buttons */
.drill-aux { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; margin-top: -4px; }
.drill-aux .btn-ghost { color: var(--muted); font-weight: 600; padding-left: 8px; padding-right: 8px; }
.drill-aux .btn-ghost:hover { color: var(--text); }
.drill-aux .show-answer { text-decoration: underline; text-underline-offset: 3px; }
.drill-aux .show-answer:only-child { margin-left: -8px; }
.drill-aux .zoom-link { margin-left: -8px; }
.drill-aux .zoom-link .icon { width: 18px; height: 18px; }
.spot-panel .drill-aux { margin-top: -6px; }
@media (max-width: 719px), (pointer: coarse) { .drill-aux .btn-ghost { min-height: 44px; } }

.hs-reveal { animation: hs-pop 0.35s ease-out both; transform-box: fill-box; transform-origin: center; }
.hs-halo { fill: none; stroke: #fff; stroke-opacity: 0.92; stroke-width: 8px; vector-effect: non-scaling-stroke; }
.hs-line { fill: rgba(224, 49, 49, 0.12); stroke: var(--hotspot); stroke-width: 4px; vector-effect: non-scaling-stroke; }
@keyframes hs-pop { from { opacity: 0; transform: scale(1.12); } to { opacity: 1; transform: none; } }

.marker { position: absolute; width: 36px; height: 36px; transform: translate(-50%, -50%); border-radius: 50%; }
.marker-miss { border: 2px dashed rgba(255, 255, 255, 0.95); background: rgba(20, 22, 25, 0.28); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); opacity: 0.85; }
.marker-miss::before, .marker-miss::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2.5px; background: #fff; border-radius: 2px; }
.marker-miss::before { transform: translate(-50%, -50%) rotate(45deg); }
.marker-miss::after { transform: translate(-50%, -50%) rotate(-45deg); }
.marker-hit { border: 3px solid #2fbf55; background: rgba(47, 191, 85, 0.25); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9); animation: marker-pop 0.3s ease-out both; }
.marker-label {
  position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  padding: 2px 8px; border-radius: 999px; background: rgba(20, 22, 25, 0.75); color: #fff; font-size: 0.72rem; font-weight: 700;
}
.marker.label-above .marker-label { top: auto; bottom: calc(100% + 4px); }
.marker.label-right .marker-label { left: 0; transform: none; }
.marker.label-left .marker-label { left: auto; right: 0; transform: none; }
@keyframes marker-pop { from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

.crosshair { position: absolute; width: 44px; height: 44px; transform: translate(-50%, -50%); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgba(0, 0, 0, 0.25); }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: #fff; box-shadow: 0 0 0 1px var(--accent); }
.crosshair::before { left: 50%; top: -12px; bottom: -12px; width: 2px; transform: translateX(-50%); }
.crosshair::after { top: 50%; left: -12px; right: -12px; height: 2px; transform: translateY(-50%); }

.scene-badge {
  position: absolute; left: 10px; top: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 800; color: #fff; background: var(--ok); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  animation: marker-fade 0.3s ease-out both;
}
.scene-badge-ok::before { content: ""; width: 0.5em; height: 0.85em; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -2px); }
@keyframes marker-fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* question + choices */
.question { display: grid; gap: 12px; }
.prompt { font-size: 1.2rem; margin: 0; display: flex; align-items: baseline; gap: 10px; }
.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; min-height: 60px; padding: 14px 14px;
  text-align: left; font-size: 1rem; line-height: 1.38; background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; box-shadow: var(--shadow);
  transition: border-color 0.15s, background 0.15s, transform 0.06s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
/* phones: a long scenario prompt in body-size type, and slightly tighter choices, so choice 1 starts on screen */
@media (max-width: 719px) {
  .prompt.is-long { font-size: 0.92rem; line-height: 1.4; }
  .choice { padding: 12px 14px; }
}
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.choice:active { transform: scale(0.995); }
.choice .key {
  flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; margin-top: -2px;
  border-radius: 7px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface-2);
  font-family: var(--mono); font-weight: 800; font-size: 0.9rem; color: var(--muted);
}
.choice .key .icon { width: 18px; height: 18px; vertical-align: 0; }
.choice-text { flex: 1 1 auto; min-width: 0; padding-top: 1px; }
.choice-flag { display: block; margin-top: 6px; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.choices.is-answered .choice { cursor: default; box-shadow: none; }
.choices.is-answered .choice:hover { background: var(--surface); border-color: var(--border-strong); }
.choices.is-answered .choice:active { transform: none; }
.choice.is-correct, .choices.is-answered .choice.is-correct:hover { border-color: var(--ok); background: var(--ok-soft); border-width: 2px; }
.choice.is-correct .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.is-correct .choice-flag { color: var(--ok-text); }
.choice.is-wrong, .choices.is-answered .choice.is-wrong:hover { border-color: var(--bad); background: var(--bad-soft); border-width: 2px; }
.choice.is-wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice.is-wrong .choice-flag { color: var(--bad-text); }
.choice.is-dim, .choices.is-answered .choice.is-dim:hover { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.choice.is-dim .key { color: var(--muted); }

.spot-panel { display: grid; gap: 12px; padding: 14px; border-radius: var(--radius); border: 1px dashed var(--accent); background: var(--accent-soft); }
.spot-panel p { margin: 0; }
.spot-instr { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.spot-instr .icon { color: var(--accent-text); width: 22px; height: 22px; margin-top: 1px; }
.spot-tries { font-size: 0.9rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.tries-dots { display: inline-flex; gap: 4px; }
.tries-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.tries-dots i.used { background: transparent; border: 2px solid var(--border-strong); }
.spot-feedback { font-weight: 700; color: var(--bad-text); }
.looks-fine { width: 100%; min-height: 52px; }
.key-hints { font-size: 0.8rem; color: var(--muted); display: none; gap: 4px 12px; flex-wrap: wrap; }
.key-hints span { display: inline-flex; align-items: center; gap: 4px; }
@media (hover: hover) and (pointer: fine) { .key-hints { display: flex; } }

/* reveal panel */
.reveal {
  margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  animation: reveal-in 0.28s ease-out both;
}
.reveal:focus { outline: none; }
@keyframes reveal-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--border); }
.banner-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; }
.banner-icon .icon { width: 20px; height: 20px; vertical-align: 0; }
.banner-ok { background: var(--ok-soft); border-bottom-color: var(--ok); }
.banner-ok .banner-icon { background: var(--ok); }
.banner-ok .banner-title { color: var(--ok-text); }
.banner-bad { background: var(--bad-soft); border-bottom-color: var(--bad); }
.banner-bad .banner-icon { background: var(--bad); }
.banner-bad .banner-title { color: var(--bad-text); }
.banner-title { font-size: 1.15rem; font-weight: 800; margin: 2px 0 4px; }
.banner-body { min-width: 0; flex: 1; }
.banner-body p { margin: 0 0 4px; font-size: 0.95rem; }
.banner-body .why { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(127, 127, 127, 0.25); }
.banner-body .lbl { font-weight: 700; }

.reveal-body { padding: 16px; display: grid; gap: 20px; }
.reveal-block h3 { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.reveal-block h3 .icon { width: 16px; height: 16px; }
.answer-text { font-weight: 800; font-size: 1.08rem; line-height: 1.4; margin: 0 0 8px; }
.explain { margin: 0; }
.fix-box { padding: 12px 14px; border-radius: 8px; background: var(--ok-soft); border-left: 4px solid var(--ok); }
.fix-box p { margin: 0; }

.refs { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0; }
.ref-card { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px; background: var(--surface-2); }
.ref-card.is-secondary { border-left-color: var(--border-strong); }
.ref-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 4px; }
.code-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--text); color: var(--surface); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.ref-section { font-family: var(--mono); font-size: 1.08rem; font-weight: 800; letter-spacing: -0.01em; }
.ref-primary { margin-left: auto; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-text); }
.ref-title { font-weight: 700; margin: 0 0 4px; }
.ref-summary { margin: 0; font-size: 0.92rem; line-height: 1.45; }
.ref-link { display: inline-block; margin-top: 6px; font-size: 0.8rem; font-weight: 600; }

.mn-note { padding: 12px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); }
.mn-note.is-amended { background: var(--warn-soft); border-left-color: var(--warn); }
.mn-note.is-unverified { border-left-color: var(--muted); }
.mn-note.is-mn-specific { border-left-color: var(--info-text); }
.mn-note .mn-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.mn-note p { margin: 0; font-size: 0.92rem; }
.mn-note .mn-more { display: inline-block; margin-top: 6px; font-size: 0.8rem; font-weight: 600; }
.verify-note { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--text); font-size: 0.875rem; display: flex; gap: 8px; align-items: flex-start; }
.verify-note .icon { color: var(--warn-text); margin-top: 1px; }

.chips-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mastery-row { display: flex; align-items: center; gap: 10px; font-size: 0.875rem; color: var(--muted); flex-wrap: wrap; }
.mastery-meter { display: inline-flex; gap: 3px; }
.mastery-meter i { width: 18px; height: 6px; border-radius: 3px; background: var(--surface-3); display: inline-block; }
.mastery-meter i.on { background: var(--ok); }
.reveal-links { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 0.875rem; }
.reveal-links a, .reveal-links button.linklike { display: inline-flex; align-items: center; gap: 5px; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: inherit; }
/* an in-page jump ("Jump to  Electrical 185"): accent text with the trade icon and a muted count, underlined on hover */
.jump-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0; border: 0; background: none;
  color: var(--accent-text); font-weight: 700; font-size: 0.95rem; text-decoration: none; cursor: pointer;
}
.jump-link:hover { text-decoration: underline; }
.jump-link .icon { width: 16px; height: 16px; }
.jump-link .count { color: var(--muted); font-weight: 600; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .jump-link { min-height: 44px; } }

.next-bar {
  position: sticky; bottom: 0; z-index: 5; margin-top: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.next-btn { flex: 1; min-height: 52px; font-size: 1.05rem; }
.next-bar .key-hint { display: none; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .next-bar .key-hint { display: inline-flex; gap: 4px; align-items: center; } }

.not-found { max-width: 560px; margin: 24px auto; }

@media (min-width: 720px) {
  .drill-title { font-size: 1.5rem; }
}
@media (min-width: 1080px) {
  .drill-layout { grid-template-columns: minmax(0, 1.45fr) minmax(360px, 1fr); gap: 28px; }
  .drill-main { position: sticky; top: 16px; }
}

/* ---------- browse ---------- */
.browse-controls { display: grid; gap: 10px; margin-bottom: 12px; }
.browse-controls .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-count { font-size: 0.875rem; color: var(--muted); margin: 0 0 12px; }
.result-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin: 0 0 12px; }
.result-bar .result-count { margin: 0; }
.result-bar .btn-ghost { color: var(--accent-text); padding-left: 8px; padding-right: 8px; }
.empty .btn { margin-top: 4px; }
.card-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.drill-card {
  display: flex; flex-direction: column; height: 100%; text-decoration: none; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: border-color 0.15s, transform 0.15s;
}
.drill-card:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.thumb { aspect-ratio: 4 / 3; background: var(--surface-3); position: relative; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.2s; }
.thumb img.is-loaded { opacity: 1; }
.drill-card .card-body { padding: 10px 12px 12px; display: grid; gap: 6px; flex: 1; align-content: start; }
.card-title { font-size: 1rem; margin: 0; line-height: 1.3; }
.card-meta { font-size: 0.8rem; color: var(--muted); margin: 0; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 4px; }
.mastery { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.mastery-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.mastery-dot.b-new { border: 2px solid var(--border-strong); background: transparent; }
.mastery-dot.b0 { background: var(--bad); }
.mastery-dot.b1 { background: var(--warn); }
.mastery-dot.b2 { background: #3b82c4; }
.mastery-dot.b3 { background: var(--ok); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.78rem; color: var(--muted); margin-bottom: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

@media (max-width: 559px) {
  .card-grid { gap: 8px; }
  .drill-card { flex-direction: row; align-items: stretch; }
  .drill-card .thumb { flex: 0 0 116px; aspect-ratio: auto; min-height: 87px; }
  .drill-card .thumb img { position: absolute; inset: 0; }
  .drill-card .card-body { padding: 8px 10px; gap: 3px; }
  .drill-card .card-title { font-size: 0.95rem; }
  .drill-card .card-foot { flex-wrap: wrap; gap: 4px 8px; }
}
@media (min-width: 720px) {
  .browse-controls { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); align-items: end; }
  .browse-controls .row { display: contents; }
}

/* ---------- code index ---------- */
.code-group { margin-top: 24px; }
.code-group h2, .code-group-title { display: flex; align-items: center; gap: 10px; }
h3.code-group-title { font-size: 1.05rem; }
.codes-filter-field { margin-bottom: 8px; }
/* a jump row of .jump-link anchors, one per code group (the prerendered /codes/<trade>/ pages) */
.code-jump { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 4px 0 4px; }
.code-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.code-list > li + li { border-top: 1px solid var(--border); }
.code-row > summary {
  list-style: none; display: grid; grid-template-columns: minmax(7.5em, auto) minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 12px 14px; cursor: pointer; min-height: 52px;
}
.code-row > summary::-webkit-details-marker { display: none; }
.code-row > summary:hover { background: var(--surface-2); }
.code-row .sec { font-family: var(--mono); font-weight: 800; }
.code-row .sec-title { min-width: 0; }
.code-row .sec-count { font-size: 0.8rem; color: var(--muted); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.code-row .chev { color: var(--muted); transition: transform 0.15s; }
.code-row[open] .chev { transform: rotate(180deg); }
.code-row[open] > summary { background: var(--surface-2); }
.code-drills { list-style: none; margin: 0; padding: 4px 14px 12px; display: grid; gap: 2px; background: var(--surface-2); }
.code-drills a { display: flex; align-items: center; gap: 8px; padding: 8px 4px; font-weight: 600; min-height: 40px; }
.code-row.is-target > summary { box-shadow: inset 4px 0 0 var(--accent); }
@media (max-width: 520px) {
  .code-row > summary { grid-template-columns: minmax(0, 1fr) auto auto; }
  .code-row .sec-title { grid-column: 1 / -1; grid-row: 2; font-size: 0.9rem; color: var(--muted); }
}

/* ---------- stats ---------- */
/* "Plumbing stats: these numbers count plumbing drills only. ..." under the page head (several trades) */
.stats-scope { margin: -8px 0 16px; font-size: 0.92rem; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.cat-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.cat-table th, .cat-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cat-table tr:last-child td { border-bottom: 0; }
.cat-table th { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.cat-table td.num, .cat-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-table tr.is-weak td { background: var(--warn-soft); }
.cat-table .cat-cell { min-width: 9em; }
.cat-table .cat-cell .pill { margin-top: 4px; }
.cat-table .cat-actions { margin-top: 6px; }
.acc-bar { display: block; height: 4px; border-radius: 2px; background: var(--surface-3); margin-top: 4px; overflow: hidden; min-width: 40px; }
.acc-bar > span { display: block; height: 100%; background: var(--ok); }
.recent-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.recent-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 0.92rem; }
.recent-list li:first-child { border-top: 0; }
.recent-list .res { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; }
.recent-list .res.ok { background: var(--ok); }
.recent-list .res.bad { background: var(--bad); }
.recent-list .res .icon { width: 14px; height: 14px; vertical-align: 0; }
.recent-list a { flex: 1; min-width: 0; font-weight: 600; }
.recent-list .when { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.data-actions { display: grid; gap: 12px; }
.data-actions p.small { margin: 0; }
/* Reset sits in its own sub-row under a divider, with what it erases (or "Nothing to erase yet.") */
.data-reset { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.confirm-box { padding: 12px 14px; border-radius: var(--radius); border: 1.5px solid var(--bad); background: var(--bad-soft); display: grid; gap: 10px; }
.confirm-box p { margin: 0; font-weight: 600; }
.status-msg { font-size: 0.9rem; font-weight: 600; margin: 0; }
.status-msg:empty { display: none; }
.status-msg.ok { color: var(--ok-text); }
.status-msg.bad { color: var(--bad-text); }
.prefs { display: grid; gap: 14px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent-strong); }

/* ---------- shared: callouts, external links, confidence, form extras ---------- */
a .icon.ext { width: 0.9em; height: 0.9em; margin-left: 3px; vertical-align: -0.08em; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: 0.92rem; margin-bottom: 16px; }
.callout > .icon { margin-top: 1px; }
.callout-body { min-width: 0; }
.callout-body p { margin: 0; }
.callout-warn { background: var(--warn-soft); border-color: transparent; border-left: 4px solid var(--warn); }
.callout-warn > .icon { color: var(--warn-text); }
.callout-info { background: var(--info-soft); border-color: transparent; border-left: 4px solid var(--info-text); }
.callout-info > .icon { color: var(--info-text); }

.pill-conf { background: var(--surface-2); border-color: transparent; color: var(--text); font-weight: 600; }
.conf-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.conf-bars i { display: block; width: 3px; border-radius: 1px; background: var(--border-strong); }
.conf-bars i:nth-child(1) { height: 5px; }
.conf-bars i:nth-child(2) { height: 8px; }
.conf-bars i:nth-child(3) { height: 11px; }
.conf-high .conf-bars i.on { background: var(--ok); }
.conf-medium .conf-bars i.on { background: var(--warn); }
.conf-low .conf-bars i.on { background: var(--bad); }

.textarea { min-height: 72px; resize: vertical; line-height: 1.45; }
.input.mono { font-family: var(--mono); }
.input-sm { min-height: 36px; padding: 6px 8px; }
.field-hint { margin: 0; font-size: 0.82rem; color: var(--muted); }
.field-error { margin: 0; font-size: 0.85rem; font-weight: 700; color: var(--bad-text); display: flex; gap: 6px; align-items: flex-start; }
.field-error .icon { width: 16px; height: 16px; margin-top: 2px; }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.file-input:focus-visible + .file-btn { outline: 3px solid var(--accent); outline-offset: 2px; }
.file-btn { cursor: pointer; }
.field .check-row { font-size: 0.95rem; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; min-height: 40px; }
.btn.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

/* ---------- edition notice + 2026 NEC line ---------- */
.edition-notice {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px 8px 14px; margin: 0 0 14px;
  border-radius: var(--radius); background: var(--info-soft); border-left: 4px solid var(--info-text); font-size: 0.9rem; line-height: 1.45;
}
.edition-notice > .icon { color: var(--info-text); margin-top: 3px; }
.edition-notice p { margin: 0; flex: 1; min-width: 0; padding: 2px 0; }
.edition-notice a { font-weight: 700; white-space: nowrap; }
.edition-notice .edition-dismiss { width: 36px; height: 36px; flex: none; background: transparent; border-color: transparent; color: var(--muted); }
.edition-notice .edition-dismiss:hover { background: rgba(127, 127, 127, 0.14); color: var(--text); }
.edition-notice .edition-dismiss .icon { width: 18px; height: 18px; }
.view-home .edition-notice { margin-top: 2px; }
/* the drill view's compact bar: "Citations: NEC 2023. <caveat> Details", the full notice opens in place */
.edition-notice.is-compact { align-items: flex-start; gap: 6px; padding: 2px 2px 2px 10px; margin-bottom: 10px; font-size: 0.78rem; line-height: 1.4; }
.edition-short > .icon { width: 15px; height: 15px; margin-right: 6px; vertical-align: -3px; color: var(--info-text); }
.edition-body { flex: 1; min-width: 0; padding: 5px 0; }
.edition-notice .edition-short { padding: 0; }
.edition-more { font-weight: 700; white-space: nowrap; padding: 2px 0; }
.edition-details p { margin-top: 6px; }
.edition-notice.is-compact .edition-dismiss { width: 32px; height: 32px; }
/* touch screens: 44 px tap targets for x and Details. In the compact bar the x reaches over the padding and the gap
   (negative margins) and Details gets an overlay, so the bar keeps its height and its two lines at 375 px */
@media (pointer: coarse) {
  #edition-dismiss { min-width: 44px; min-height: 44px; }
  .edition-notice.is-compact .edition-dismiss { margin: -6px; }
  .edition-more { position: relative; }
  .edition-more::after { content: ""; position: absolute; inset: -12px -6px; }
}
/* next-edition line: "2026 NEC: same rule and number" (electrical) or "2024 IRC: ..." (other tracks) */
.edition-line { margin: 10px 0 0; display: block; font-size: 0.875rem; line-height: 1.5; color: var(--muted); }
.edition-line .pill-conf { margin-left: 6px; vertical-align: 1px; }
.edition-label { font-weight: 800; color: var(--text); margin-right: 6px; }
.edition-line.is-changed .edition-label, .edition-line.is-renumbered .edition-label { color: var(--warn-text); }
.edition-text { min-width: 0; }
.cf-sub-sep { padding-top: 12px; border-top: 1px solid var(--border); }
.cf-n26 { display: grid; gap: 12px; }
.cf-card-body { display: grid; gap: 14px; min-width: 0; }

/* ---------- minnesota ---------- */
.mn-layout { display: grid; gap: 16px; }
.mn-aside { min-width: 0; }
.mn-toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.mn-toc-title {
  list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; cursor: pointer;
  font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.mn-toc-title::-webkit-details-marker { display: none; }
.mn-toc-count { font-size: 0.72rem; letter-spacing: 0; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); }
.mn-toc-title .chev { margin-left: auto; transition: transform 0.15s; }
.mn-toc[open] .mn-toc-title .chev { transform: rotate(180deg); }
.mn-toc ol { list-style: none; margin: 0; padding: 0 14px 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.mn-toc a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 0.875rem; font-weight: 600; line-height: 1.25;
}
.mn-toc a:hover { border-color: var(--accent); }
.mn-toc a[aria-current] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.mn-content { min-width: 0; display: grid; gap: 16px; }
.mn-intro { display: grid; gap: 12px; }
.mn-intro .callout { margin: 0; }
.mn-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--muted); margin: 0; }
.mn-meta span { display: inline-flex; align-items: center; gap: 6px; }
.mn-meta .icon { width: 16px; height: 16px; }
.mn-lede { font-size: 1.05rem; line-height: 1.6; margin: 0; max-width: 48em; }
.mn-legend { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.mn-legend > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; font-weight: 700; font-size: 0.92rem; min-height: 44px; }
.mn-legend > summary::-webkit-details-marker { display: none; }
.mn-legend > summary .icon { color: var(--muted); }
.mn-legend > summary .chev { margin-left: auto; transition: transform 0.15s; }
.mn-legend[open] > summary .chev { transform: rotate(180deg); }
.mn-legend dl { margin: 0; padding: 2px 14px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; align-items: center; font-size: 0.9rem; }
.mn-legend dt { margin: 0; }
.mn-legend dd { margin: 0; color: var(--muted); }
.mn-section { padding: 18px 16px; scroll-margin-top: 12px; }
.mn-sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mn-sec-head h2, .mn-sec-head h3 { margin: 0; font-size: 1.25rem; }
.mn-sec-icon { width: 34px; height: 34px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.mn-sec-body p { max-width: 48em; }
.mn-sec-body p:last-child { margin-bottom: 0; }
.mn-items { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.mn-item { border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 8px; padding: 12px 14px; background: var(--surface-2); min-width: 0; }
.mn-item.is-amended { border-left-color: var(--warn); background: var(--warn-soft); }
.mn-item h3, .mn-item h4 { font-size: 1rem; margin: 0 0 6px; }
.mn-item.is-mn-specific { border-left-color: var(--info-text); }
.mn-item p { margin: 0; font-size: 0.95rem; }
.mn-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.mn-cite { display: inline-block; max-width: 100%; font-family: var(--mono); font-size: 0.74rem; font-weight: 700; line-height: 1.45; padding: 3px 8px; border-radius: 4px; background: var(--text); color: var(--surface); white-space: normal; overflow-wrap: anywhere; }
.mn-links { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.mn-links h3, .mn-links-title { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.mn-links ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mn-links a { display: inline-flex; align-items: center; min-height: 36px; font-weight: 600; }
.mn-links.is-grid ul { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; }
.mn-link-card { display: grid; gap: 2px; height: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); text-decoration: none; }
.mn-link-card:hover { border-color: var(--accent); }
.mn-link-card .mn-link-label { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.mn-link-card:hover .mn-link-label { text-decoration-thickness: 2px; }
.mn-host { display: block; min-width: 0; font-size: 0.75rem; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* "Practice it": the text, the trade's one Minnesota-rules button (the primary), then a line of related links */
.mn-cta { display: grid; gap: 12px; }
.mn-cta h2 { font-size: 1.1rem; margin-bottom: 4px; }
.mn-cta p { margin: 0; color: var(--muted); max-width: 36em; }
.mn-cta .btn-row, .mn-cta .mn-cta-links { max-width: none; }
.mn-missing { max-width: 640px; margin: 8px auto 0; }
.mn-fallback-links { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 4px; justify-items: center; }
@media (min-width: 1000px) {
  .mn-layout { grid-template-columns: 230px minmax(0, 1fr); gap: 28px; align-items: start; }
  .mn-aside { position: sticky; top: 16px; }
  .mn-toc { padding: 6px 6px 10px; }
  .mn-toc-title { padding: 6px 10px; min-height: 0; }
  .mn-toc ol { display: grid; gap: 2px; padding: 0; }
  .mn-toc a { display: flex; border: 0; border-left: 3px solid transparent; background: none; border-radius: 0 6px 6px 0; padding: 8px 10px; min-height: 0; }
  .mn-toc a:hover { background: var(--surface-2); }
  .mn-toc a[aria-current] { border-left-color: var(--accent); }
  .mn-section { padding: 22px 24px; }
}
@media (max-width: 480px) {
  .mn-legend dl { grid-template-columns: 1fr; gap: 4px; }
  .mn-legend dd { margin-bottom: 8px; }
}

/* ---------- contribute ---------- */
.cf-layout { display: grid; gap: 16px; align-items: start; }
.cf-media-col { min-width: 0; }
.cf-fields { display: grid; gap: 16px; min-width: 0; }
.cf-card { display: grid; gap: 14px; min-width: 0; }
.cf-card-title { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; margin: 0; }
/* "Trade: Plumbing (2018 UPC). Change it with the trade switcher in the header." at the top of The basics */
.cf-trade { margin: 0; font-size: 0.95rem; }
.cf-card-title .step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 0.8rem; font-weight: 800; flex: none; }
.cf-row { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.cf-sub { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0; }
.cf-stage-host { display: grid; gap: 10px; min-width: 0; }
.cf-stage-host > p { margin: 0; }
.cf-media-card .status-msg { margin: 0; }
.cf-media-errors:empty { display: none; }
.cf-drop {
  display: grid; justify-items: center; align-content: center; gap: 10px; text-align: center; min-height: 260px; padding: 28px 16px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
}
.cf-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.cf-drop p { margin: 0; }
.cf-drop-icon { width: 52px; height: 52px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.cf-drop-icon .icon { width: 26px; height: 26px; }
.cf-drop-title { font-weight: 800; font-size: 1.05rem; }
.cf-stage { position: relative; width: 100%; border-radius: var(--radius); overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); user-select: none; -webkit-user-select: none; }
.cf-stage.is-drawing { outline: 2px dashed var(--accent); outline-offset: 3px; }
.cf-img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.cf-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.cf-stage.is-drawing .cf-svg { pointer-events: auto; cursor: crosshair; touch-action: none; }
.cf-svg .hs-line.is-temp { stroke-dasharray: 7 5; fill: rgba(224, 49, 49, 0.08); }
.cf-stage.is-compliant .cf-img { opacity: 0.92; }
.cf-tags { position: absolute; inset: 0; pointer-events: none; }
.cf-tag {
  position: absolute; transform: translate(-35%, -35%); min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--hotspot); color: #fff; font-size: 0.75rem; font-weight: 800; display: inline-grid; place-items: center; box-shadow: 0 0 0 2px #fff;
}
.cf-tag.is-static { position: static; transform: none; margin-right: 8px; box-shadow: none; }
.cf-stage-note {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); pointer-events: none; display: inline-flex; gap: 6px; align-items: center;
  padding: 6px 12px; border-radius: 999px; background: rgba(20, 22, 25, 0.78); color: #fff; font-size: 0.8rem; font-weight: 700; white-space: nowrap;
}
.cf-stage-note .icon { width: 16px; height: 16px; }
.cf-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cf-toolbar-spacer { flex: 1 1 auto; }
@media (max-width: 559px) { .cf-toolbar-spacer { display: none; } }
.cf-hs-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cf-hs-list > li { border: 1px solid var(--border); border-radius: 8px; padding: 6px 6px 6px 10px; background: var(--surface-2); }
.cf-hs-row { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.cf-hs-name { font-weight: 700; display: inline-flex; align-items: center; }
.cf-hs-dims { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); flex: 1 1 auto; }
.cf-hs-adjust > summary { cursor: pointer; font-size: 0.8rem; font-weight: 700; color: var(--accent-text); padding: 4px 0; min-height: 28px; }
.cf-nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 4px 4px 6px 0; }
.cf-num { display: grid; gap: 2px; font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cf-choices { display: grid; gap: 10px; }
.cf-choice { border: 1.5px solid var(--border); border-radius: var(--radius); padding: 10px 12px 12px; display: grid; gap: 8px; background: var(--surface); }
.cf-choice.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.cf-choice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cf-choice-label { font-size: 0.8rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.cf-correct { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 700; cursor: pointer; min-height: 36px; }
.cf-correct input { width: 18px; height: 18px; accent-color: var(--ok); }
.cf-choice.is-correct .cf-correct { color: var(--ok-text); }
.cf-choice.is-locked .input { background: var(--surface-2); color: var(--muted); }
.cf-why > label { font-size: 0.72rem; }
.cf-refs { display: grid; gap: 12px; }
.cf-ref { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); min-width: 0; }
.cf-ref:first-child { border-left-color: var(--accent); }
.cf-ref-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
#cf-ref-add { justify-self: start; }
.cf-actions { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.cf-actions > p { margin: 0; }
.cf-errors { border: 1.5px solid var(--bad); background: var(--bad-soft); border-radius: var(--radius); padding: 12px 14px; }
.cf-errors:focus { outline: none; }
.cf-errors-title { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--bad-text); margin: 0 0 6px; }
.cf-errors ul { margin: 0; padding: 0 0 0 18px; display: grid; gap: 4px; list-style: none; }
.cf-errors li { position: relative; }
.cf-errors li::before { content: ""; position: absolute; left: -13px; top: 0.6em; width: 6px; height: 6px; border-radius: 50%; background: var(--bad-text); }
.cf-errors .linklike { display: block; text-align: left; color: var(--text); font-weight: 600; line-height: 1.4; }
.cf-saved { border: 1px solid var(--ok); border-radius: var(--radius); margin-bottom: 16px; }
.cf-saved .btn-row { margin-top: 10px; }
.cf-saved .cf-howto { font-weight: 700; font-size: 0.9rem; }
.cf-warnings { margin: 6px 0 0; padding-left: 1.2rem; font-size: 0.9rem; }

.my-drills { padding: 0; margin-bottom: 16px; overflow: hidden; }
.my-drills > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; min-height: 52px; }
.my-drills > summary::-webkit-details-marker { display: none; }
.my-drills > summary h2 { margin: 0; font-size: 1.05rem; }
.my-drills > summary .chev { margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.my-drills[open] > summary .chev { transform: rotate(180deg); }
.my-drill-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.my-drill { display: grid; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.my-drill.is-editing { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.my-main { display: flex; gap: 12px; align-items: center; min-width: 0; }
.my-thumb { flex: none; width: 88px; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); }
.my-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.my-body { min-width: 0; }
.my-title { font-weight: 700; margin: 0 0 4px; line-height: 1.3; }
.my-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 0.8rem; color: var(--muted); margin: 0; }
/* Try, Edit, Export, then the icon-only delete set apart; below 760 px a grid of three equal buttons and a 44 px trash */
.my-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.my-actions .btn .icon { width: 16px; height: 16px; }
.my-actions .my-del { margin-left: auto; width: 36px; padding: 0; }
@media (pointer: coarse) { .my-actions .my-del { width: 44px; } }
@media (max-width: 759px) {
  .my-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 44px; }
  .my-actions .btn { min-height: 44px; }
  .my-actions .my-del { margin-left: 0; width: 44px; }
}
.my-note { padding: 10px 16px 14px; margin: 0; }
@media (min-width: 560px) {
  .cf-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cf-row-ref { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
}
@media (min-width: 760px) {
  .my-drill { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .my-drill .confirm-box { grid-column: 1 / -1; }
}
@media (min-width: 1000px) {
  .cf-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; }
  .cf-stage { --stage-max-h: 56vh; margin: 0 auto; }
}
@media (min-width: 1000px) and (min-height: 700px) {
  .cf-media-col { position: sticky; top: 16px; }
}
/* narrow phones: three equal columns cannot hold an icon and "Export", so the labels carry the verbs there */
@media (max-width: 439px) {
  .my-actions .btn { padding-left: 6px; padding-right: 6px; white-space: nowrap; }
  .my-actions .btn:not(.my-del) .icon { display: none; }
}

/* ---------- AI mode ---------- */
.ai-grid { display: grid; gap: 16px; align-items: start; }
.ai-col { display: grid; gap: 16px; min-width: 0; }
.ai-card { display: grid; gap: 12px; min-width: 0; }
.ai-card > p { margin: 0; }
.ai-card-title { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; margin: 0; }
.ai-card-title .icon { color: var(--accent-text); }
.ai-card-title .pill { margin-left: 4px; }
.ai-privacy { background: var(--info-soft); border-color: transparent; box-shadow: none; display: grid; gap: 10px; }
.ai-privacy .ai-card-title .icon { color: var(--info-text); }
.ai-privacy-lead { font-weight: 700; margin: 0; }
.ai-privacy-list { margin: 0; padding-left: 1.2rem; display: grid; gap: 6px; font-size: 0.92rem; }
.ai-key-status { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: 0.95rem; }
.ai-key-status > span:last-child { min-width: 0; }
.ai-key-status .ai-dot { margin-top: 0.45em; }
.ai-key-status code { font-family: var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); overflow-wrap: anywhere; }
.ai-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.ai-dot.ok { background: var(--ok); }
.ai-key-form { display: grid; gap: 10px; }
/* Show/Hide sits inside the key field, at its right end */
.ai-key-row { position: relative; }
.ai-key-row .input { padding-right: 72px; }
.ai-key-row .ai-show { position: absolute; right: 4px; top: 4px; bottom: 4px; min-height: 0; padding-top: 0; padding-bottom: 0; }
.ai-model { padding-top: 12px; border-top: 1px solid var(--border); }
.ai-gen-form, .ai-an-form { display: grid; gap: 12px; }
.ai-needkey { display: flex; align-items: center; gap: 6px; color: var(--muted); margin: 0; }
.ai-needkey .icon { width: 16px; height: 16px; }
.ai-status:empty, .ai-results-host:empty { display: none; }
.ai-progress { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.ai-progress-body { flex: 1; min-width: 0; }
.ai-progress-body p { margin: 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-error { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1.5px solid var(--bad); background: var(--bad-soft); }
.ai-error-icon { color: var(--bad-text); flex: none; }
.ai-error-icon .icon { width: 22px; height: 22px; }
.ai-error-body { min-width: 0; flex: 1; display: grid; gap: 6px; justify-items: start; }
.ai-error-body p { margin: 0; }
.ai-error-title { font-weight: 800; color: var(--bad-text); }
.ai-error-details > summary { cursor: pointer; font-size: 0.85rem; font-weight: 700; }
.ai-error-details ul, .ai-error-details p { margin: 4px 0 0; font-size: 0.85rem; overflow-wrap: anywhere; }
.ai-error-details ul { padding-left: 1.2rem; }
.ai-note-msg { display: flex; gap: 6px; align-items: center; margin: 0; color: var(--muted); }
.ai-note-msg.ok .icon { color: var(--ok-text); }
.ai-photo { display: grid; gap: 8px; }
.ai-photo img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: contain; border-radius: var(--radius); background: var(--surface-3); border: 1px solid var(--border); }
.ai-photo-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ai-drop { min-height: 0; padding: 20px 16px; }
.ai-results { display: grid; gap: 12px; }
.ai-summary { display: grid; gap: 8px; justify-items: start; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.ai-summary p { margin: 0; }
.ai-findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ai-finding { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px; background: var(--surface); display: grid; gap: 6px; justify-items: start; min-width: 0; }
.ai-finding h3 { margin: 0; font-size: 1rem; }
.ai-finding p { margin: 0; font-size: 0.92rem; }
.ai-finding-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ai-look { display: flex; gap: 6px; align-items: flex-start; }
.ai-look .icon { width: 16px; height: 16px; margin-top: 3px; color: var(--accent-text); }
.ai-to-drill { margin-top: 4px; }
.ai-mine-list { list-style: none; margin: 0; padding: 0; display: grid; }
.ai-mine-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.ai-mine-list li:first-child { border-top: 0; }
.ai-mine-title { font-weight: 700; flex: 1 1 12em; min-width: 0; }
@media (min-width: 1000px) {
  .ai-grid { grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.4fr); gap: 24px; }
}

/* ---------- placeholder / misc ---------- */
.placeholder { padding: 28px 0; }
/* toasts sit at the bottom of the screen, away from the page heading and the controls people just used;
   app.js sets --toast-lift so they clear the sticky Next bar on the drill page */
.toast-region { position: fixed; left: 50%; bottom: max(calc(16px + env(safe-area-inset-bottom)), calc(var(--toast-lift, 0px) + 12px)); transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
@media (min-width: 1080px) {
  /* wide screens: bottom-right corner, clear of the drill picture in the left column */
  .toast-region { left: auto; right: 24px; transform: none; justify-items: end; max-width: min(440px, calc(100vw - 48px)); }
}
.toast { padding: 10px 16px; border-radius: var(--radius); background: var(--text); color: var(--surface); font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow-lg); animation: marker-fade 0.2s ease-out both; }
.error-card { border: 1.5px solid var(--bad); background: var(--bad-soft); border-radius: var(--radius); padding: 16px; }
.noscript { padding: 24px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .drill-toolbar, .hud, .filter-panel, .filter-backdrop, .next-bar,
  .reveal-links, .zoom-btn, .drill-aux, .key-hints, .edition-notice, .back-results, .retry-note,
  .toast-region, .why-others > summary .chev { display: none !important; }
  .reveal-block, .ref-card { break-inside: avoid; }
  /* the verdict icons are white on a disc that does not print: on paper the stroke takes the verdict color, ringed */
  .choice.is-correct .key, .banner-ok .banner-icon { background: transparent !important; color: var(--ok-text) !important; border: 2px solid currentColor; }
  .choice.is-wrong .key, .banner-bad .banner-icon { background: transparent !important; color: var(--bad-text) !important; border: 2px solid currentColor; }
}

/* home: wiring sandbox call-to-action */
.sbx-cta { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow); }
.sbx-cta:hover { border-color: var(--accent); }
.sbx-cta:hover .card-go { text-decoration: underline; }
.sbx-cta-icon { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); }
.sbx-cta-icon .icon { width: 24px; height: 24px; }
.sbx-cta-body { display: grid; gap: 4px; min-width: 0; flex: 1 1 auto; }
.sbx-cta-title { font-weight: 800; font-size: 1.1rem; }
.sbx-cta-text { color: var(--muted); }
.sbx-cta-meta { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.sbx-cta .card-go { flex: none; white-space: nowrap; }
@media (max-width: 560px) { .sbx-cta { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: start; column-gap: 12px; row-gap: 10px; } .sbx-cta .card-go { grid-column: 2; justify-self: end; } }

/* ---------- Terms & disclaimer, Privacy (#/terms, #/privacy and the prerendered /terms/, /privacy/) ---------- */
.legal { max-width: 760px; display: grid; gap: 14px; }
.legal-meta { margin: 0; font-size: 0.875rem; color: var(--muted); }
.legal-section h2 { font-size: 1.15rem; margin: 0 0 8px; }
.legal-section p { margin: 0 0 10px; line-height: 1.55; }
.legal-section p:last-child, .legal-section ul:last-child { margin-bottom: 0; }
.legal-section ul { margin: 0 0 10px; padding-left: 1.2em; line-height: 1.55; }

/* ---------- polish from the navigation/buttons QA ---------- */
/* the AI key field's inset Show/Hide toggle reaches 44 px on touch */
@media (pointer: coarse) { .ai-key-row .input { min-height: 52px; } }

/* a toast raised while the phone menu is open sits under its scrim like the rest of the page */
body:has(#site-nav.is-open) .toast-region, body:has(.nav-check:checked) .toast-region { z-index: 15; }

/* ---------- lane drill-loop: reveal teaching, relearn, review round ---------- */
/* the verdict's "Rule: <code> <section>, <title>": a jump to the primary reference card; it wraps, never ellipsized */
.banner-body .rule-line { margin: 8px 0 0; }
.rule-jump { text-align: left; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
@media (pointer: coarse) { .rule-jump { display: inline-flex; align-items: center; min-height: 44px; } }
/* the reference card it lands on: a 2 px accent outline for 1.2 s */
.refs .ref-card { outline: 2px solid transparent; outline-offset: 2px; transition: outline-color 0.2s ease-out; }
.refs .ref-card.is-flash { outline-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .refs .ref-card { transition: none; } }

/* "Why the other choices are wrong": a closed disclosure styled like the reveal's block headings */
.why-others > summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; list-style: none;
  font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.why-others > summary::-webkit-details-marker { display: none; }
.why-others > summary:hover .why-others-title { color: var(--text); }
.why-others > summary .pill { letter-spacing: 0; }
.why-others > summary .chev { width: 16px; height: 16px; margin-left: auto; transition: transform 0.15s; }
.why-others[open] > summary .chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .why-others > summary .chev { transition: none; } }
.why-list { margin: 4px 0 0; padding-left: 1.2em; display: grid; gap: 8px; font-size: 0.92rem; line-height: 1.45; }

/* a drill served again from the relearn queue: one muted line over the eyebrow */
.retry-note { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 0.85rem; color: var(--muted); white-space: nowrap; min-width: 0; }
.retry-note > span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.retry-note .icon { width: 16px; height: 16px; color: var(--accent-text); }

/* a review round: "Misses: 3 left" and "Exit review" in the Filters button's place */
.drill-toolbar .filter-anchor[hidden], .review-bar[hidden] { display: none; }
.review-bar { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.review-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; color: var(--muted); white-space: nowrap; }
.review-label strong { color: var(--text); font-variant-numeric: tabular-nums; }
.review-label .icon { width: 16px; height: 16px; color: var(--accent-text); }
.review-exit { white-space: nowrap; }
/* below 400 px a tighter count and button, so the toolbar stays one row from 360 px up */
@media (max-width: 399px) {
  .review-label .icon { display: none; }
  .review-bar { gap: 4px; }
  .review-exit { padding-left: 10px; padding-right: 10px; }
}
/* phones: "3 left" below 560 px (still read "Misses: 3 left"), and "Exit" below 440 px (still named "Exit review"), so
   the mode segment, the count and the button keep one row */
.review-exit { position: relative; }
@media (max-width: 559px) {
  .review-label .review-word { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
}
@media (max-width: 439px) {
  .review-exit .review-exit-more { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
}
.review-done .btn-row { justify-content: center; }
/* the round's end replaces the drill: across both columns on wide screens, centred */
.drill-layout > .review-done { grid-column: 1 / -1; justify-self: center; width: 100%; max-width: 640px; }

/* ---------- lane progress-home-stats: misses list, needs work, import confirm, stacked category table ---------- */
/* Home: "Review my misses (n)" under the stat strip; full width on phones, like the hero buttons */
.home-review { margin-top: 12px; }
@media (max-width: 559px) { .home-review .btn { width: 100%; } }

/* Stats: six tiles, 2 x 3 on phones, 3 x 2 on tablets, one row on wide screens */
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 60em) { .stat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* Stats: Missed, not yet fixed */
.missed-section > p.small { margin: 0 0 10px; }
.missed-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.missed-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 0.92rem; }
.missed-list li:first-child { border-top: 0; }
.missed-list .res { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; background: var(--bad); }
.missed-list .res .icon { width: 14px; height: 14px; vertical-align: 0; }
.missed-list a { flex: 1 1 12em; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
/* section and time as one unit at the right; when it does not fit beside the title it wraps whole, still at the right */
.missed-list .missed-meta { display: inline-flex; align-items: baseline; gap: 8px; margin-left: auto; flex: none; max-width: 100%; }
.missed-list .mono { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
.missed-list .when { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
/* phones: every row puts it on its own line under the title (24 px icon + 10 px gap in) */
@media (max-width: 419px) {
  .missed-list .missed-meta { flex: 1 1 100%; margin-left: 0; padding-left: 34px; }
}
@media (pointer: coarse) {
  .missed-list li { min-height: 44px; }
  .missed-list a { display: inline-flex; align-items: center; min-height: 44px; }
}
.missed-more { margin: 8px 0 0; }
.missed-actions { margin-top: 12px; }
@media (max-width: 559px) { .missed-actions .btn { width: 100%; } }

/* Stats: categories not started yet */
.not-started { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }
.not-started-label { font-size: 0.875rem; font-weight: 700; color: var(--muted); }

/* Stats: the import confirm (neutral; Replace is the red one inside it) */
.import-confirm { border-color: var(--border-strong); background: var(--surface-2); }
.import-confirm p.small { font-weight: 400; }

/* Stats: the By category table stacks on phones (one block per category, its three figures in a row under the name);
   the role attributes in the markup keep the table semantics through the display change */
@media (max-width: 559px) {
  .table-wrap { overflow-x: visible; }
  .cat-table, .cat-table tbody { display: block; width: 100%; }
  .cat-table thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .cat-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); }
  .cat-table tbody tr:last-child { border-bottom: 0; }
  .cat-table td { border-bottom: 0; }
  .cat-table td.cat-cell { grid-column: 1 / -1; display: block; padding: 0 0 6px; min-width: 0; }
  .cat-table td.num { display: block; text-align: left; padding: 0; white-space: normal; }
  .cat-table td.num::before {
    content: attr(data-label); display: block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--muted);
  }
  .cat-table tr.is-weak { background: var(--warn-soft); }
  .cat-table tr.is-weak td { background: transparent; }
  .cat-table tbody tr:first-child { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
  .cat-table tbody tr:last-child { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
  .cat-table .acc-bar { max-width: 96px; }
}

/* ---------- lane search-reference: search states, progress select, code summaries ---------- */
/* Browse controls with the Progress select: below 720 px Category on its own line, then Difficulty and Progress side
   by side; from 720 px one row of four */
@media (max-width: 719px) {
  .browse-controls.has-progress .row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .browse-controls.has-progress .browse-cat-field { grid-column: 1 / -1; }
}
@media (min-width: 720px) {
  .browse-controls.has-progress { grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.3fr); }
}
.browse-controls.has-progress .select { min-width: 0; text-overflow: ellipsis; }
/* zero results (Browse and the Code index): the line names the search, then a link that carries it to the other list */
.browse-empty p, .codes-empty p { overflow-wrap: anywhere; }
.browse-empty .jump-link, .codes-empty .jump-link { display: flex; justify-content: center; width: fit-content; max-width: 100%; margin: 0 auto 10px; text-align: center; overflow-wrap: anywhere; }
.browse-empty .jump-link[hidden], .codes-empty .jump-link[hidden] { display: none; }
.codes-empty { margin-top: 16px; }
/* Code index rows: what the section says, as the citing drills paraphrase it (built when the row first opens) */
.sec-summary { padding: 10px 14px 4px; background: var(--surface-2); display: grid; gap: 4px; }
.sec-sum-text { margin: 0; padding-left: 10px; border-left: 3px solid var(--border-strong); line-height: 1.5; overflow-wrap: anywhere; }
.sec-sum-from { margin: 0 0 4px; padding-left: 13px; font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }
.sec-sum-more > summary { cursor: pointer; font-size: 0.9rem; font-weight: 700; color: var(--accent-text); padding: 6px 0; }
.sec-sum-more[open] > summary { margin-bottom: 4px; }
.sec-sum-alt { display: grid; gap: 4px; margin-bottom: 6px; }
@media (pointer: coarse) { .sec-sum-more > summary { min-height: 44px; padding: 11px 0; box-sizing: border-box; } }

/* ---------- lane shell-a11y: toasts, forced colors, touch targets, contrast, boot loading ---------- */
/* forced colors (Windows contrast themes) drop the toast's background: the system's own colors and a border instead */
@media (forced-colors: active) {
  .toast { background: Canvas; color: CanvasText; border: 2px solid CanvasText; forced-color-adjust: none; }
}
/* touch screens: the reveal's and the references' text links are 44 px tap targets too */
@media (pointer: coarse) {
  .reveal-links a, .reveal-links .linklike, .ref-link, .mn-note .mn-more, .mn-links a, .edition-notice p a {
    display: inline-flex; align-items: center; min-height: 44px;
  }
}
/* a Minnesota source card stacks its title over its one-line domain (.mn-links a would make it a row, which squeezed
   the domain into a sliver) */
.mn-links a.mn-link-card { display: grid; align-content: start; }
/* "Loading the drills…" in main#view while the scripts arrive on a slow connection (html.js: never shown without
   JavaScript); renderRoute clears it. An indeterminate bar under the text, a still one under reduced motion. */
.boot-loading { display: none; }
.js .boot-loading { display: block; margin: 0; padding: 32px 0; color: var(--muted); }
.js .boot-loading::after {
  content: ""; display: block; width: min(240px, 100%); height: 4px; margin-top: 12px; border-radius: 2px;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat, var(--surface-3);
  background-size: 40% 100%, auto; animation: boot-bar 1.2s ease-in-out infinite alternate;
}
@keyframes boot-bar { from { background-position: 0 0, 0 0; } to { background-position: 100% 0, 0 0; } }
@media (prefers-reduced-motion: reduce) { .js .boot-loading::after { animation: none; } }
/* while the scripts load, the header's switcher (its trade not known yet) is not shown as a bare "Trade:"; it keeps
   its room. Without JavaScript (no html.js) the static switcher and its links stay. */
.js .trade-switch.is-pending { visibility: hidden; }
/* data/drills.js did not load over the network (loadFailedView in js/app.js): heading, reason, Try again, status */
.load-failed { display: grid; gap: 12px; padding: 24px 0; max-width: 40em; }
.load-failed h1, .load-failed p { margin: 0; }
/* More contrast asked for in the system settings: stronger borders and muted text, 2 px choice borders. Last in the
   file so it wins on order; the dark selectors match the base token blocks', so a forced light or dark theme holds. */
@media (prefers-contrast: more) {
  :root { --border: #8f8676; --border-strong: #6f6759; --muted: #41464d; }
  .choice { border-width: 2px; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --border: #6b727c; --border-strong: #8a919b; --muted: #c4c9d0; }
}
@media (prefers-contrast: more) {
  :root[data-theme="dark"] { --border: #6b727c; --border-strong: #8a919b; --muted: #c4c9d0; }
}
