/* Tools Berry — global design system.
   Light is the default; dark is a prefers-color-scheme override.
   Tokens first, then base, then shared shell, then components. */

:root {
  /* Surfaces & ink */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --border: #e2e6ec;
  --border-strong: #cdd4dd;
  --text: #18212f;
  --muted: #5a6675;

  /* Brand: a warm, trustworthy berry + a calm money-green */
  --accent: #146c43;        /* primary green — buttons, positive numbers */
  --accent-hover: #0f5132;
  --accent-ink: #ffffff;    /* text on the primary button — AA on --accent */
  --accent-soft: #e7f3ec;   /* tinted backgrounds, soft fills */
  --brand: #b4126b;         /* "berry" — logo dot, accents */
  --brand-soft: #fbe9f3;
  --link: #1c5fc4;
  --danger: #b4341c;

  /* Shape */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Shadows — soft, modern, low-contrast */
  --shadow-sm: 0 1px 2px rgba(20, 30, 50, .06), 0 1px 3px rgba(20, 30, 50, .05);
  --shadow-md: 0 4px 12px rgba(20, 30, 50, .07), 0 2px 4px rgba(20, 30, 50, .05);
  --shadow-lg: 0 12px 28px rgba(20, 30, 50, .12);
  --ring: 0 0 0 3px rgba(28, 95, 196, .28);

  /* Layout & rhythm */
  --maxw: 940px;
  --space: 16px;
}

/* Dark palette. Two entry points, identical values:
   1. The OS prefers dark AND the visitor has not forced light with the header
      toggle — `:root:not([data-theme="light"])` inside the media query. Preserves
      the pre-existing no-JS, system-following behaviour.
   2. The visitor explicitly chose dark via the toggle — `:root[data-theme="dark"]`
      below, which wins even on a light OS.
   Keep the two token lists in sync when editing colours. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131a;
    --surface: #161d27;
    --surface-2: #1d2632;
    --border: #2a3543;
    --border-strong: #3a4655;
    --text: #e8edf3;
    --muted: #9eabba;

    --accent: #3fb863;
    --accent-hover: #54c878;
    --accent-ink: #08130c;    /* dark text on bright-green button — AA in dark */
    --accent-soft: #16321f;
    --brand: #f06bb0;
    --brand-soft: #2c1322;
    --link: #6fb0ff;
    --danger: #f08a72;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
    --shadow-lg: 0 14px 32px rgba(0, 0, 0, .55);
    --ring: 0 0 0 3px rgba(111, 176, 255, .4);
  }
}
:root[data-theme="dark"] {
  --bg: #0e131a;
  --surface: #161d27;
  --surface-2: #1d2632;
  --border: #2a3543;
  --border-strong: #3a4655;
  --text: #e8edf3;
  --muted: #9eabba;

  --accent: #3fb863;
  --accent-hover: #54c878;
  --accent-ink: #08130c;    /* dark text on bright-green button — AA in dark */
  --accent-soft: #16321f;
  --brand: #f06bb0;
  --brand-soft: #2c1322;
  --link: #6fb0ff;
  --danger: #f08a72;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 32px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(111, 176, 255, .4);
}
/* Match native UI (form controls, scrollbars, date pickers) to a forced theme,
   so choosing light on a dark OS doesn't leave dark scrollbars behind. */
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font: 400 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Keyboard focus: a soft ring for normal viewing, plus a transparent outline
   that becomes visible in Windows High Contrast / forced-colors mode (where
   box-shadow is dropped). Never remove the indicator outright. */
:focus-visible { outline: 2px solid transparent; outline-offset: 2px; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* Skip to content — visually hidden until focused via keyboard (Tab). */
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 1000;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-md);
  font-weight: 700; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; text-decoration: none; }

img, canvas, svg { max-width: 100%; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---- Header / nav ---------------------------------------------------- */
header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(1.2);
}
header.site .wrap {
  display: flex; align-items: center;
  gap: 16px; padding: 14px 20px; min-height: 60px;
}
header.site .brand {
  font-weight: 800; font-size: 19px; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
  margin-right: auto; /* push the nav + theme toggle to the right edge */
}
header.site .brand::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft);
}
header.site nav { display: flex; flex-wrap: wrap; gap: 4px; }
header.site nav a {
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 8px 12px; border-radius: var(--radius-pill);
}
header.site nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

/* ---- Theme (dark mode) toggle --------------------------------------- */
.theme-toggle {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; margin-left: 2px;
  color: var(--muted); background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  cursor: pointer; transition: color .15s, background .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.theme-toggle:focus-visible { box-shadow: var(--ring); }
.theme-toggle svg { width: 20px; height: 20px; display: block; }
/* Icon shown mirrors the palette that is ACTIVE: a moon in light mode (click to go
   dark) and a sun in dark mode (click to go light). Driven purely by CSS — using the
   same conditions as the palette above — so the icon is correct at first paint,
   before the toggle's click handler binds. */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---- Typography ------------------------------------------------------ */
main { padding: 36px 0 56px; }
h1 {
  font-size: clamp(28px, 6vw, 40px); line-height: 1.15; letter-spacing: -.025em;
  margin: 0 0 10px; font-weight: 800;
}
h2 { font-size: 23px; line-height: 1.25; letter-spacing: -.015em; margin: 40px 0 14px; font-weight: 700; }
h3 { font-size: 18px; margin: 0 0 8px; font-weight: 700; }
.lede { color: var(--muted); font-size: 19px; margin: 0 0 26px; max-width: 60ch; }
.updated { font-size: 13px; color: var(--muted); margin: 2px 0 10px; }

/* ---- Hero (home) ----------------------------------------------------- */
.hero { padding: 16px 0 8px; }
.hero h1 { max-width: 16ch; }
.hero .badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  padding: 7px 13px; border-radius: var(--radius-pill); box-shadow: var(--shadow-sm);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* ---- Card form (calculator / tool shells) --------------------------- */
.calc {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow-md);
}
@media (max-width: 680px) { .calc { grid-template-columns: 1fr; padding: 20px; gap: 18px; } }
/* Opt-in: on tools where the result/preview matters most, show it before the
   form on mobile instead of making the visitor scroll past every control.
   Scoped to .results-first so this doesn't change every tool's mobile order. */
@media (max-width: 680px) { .calc .results.results-first { order: -1; } }

.field { margin-bottom: 18px; }
.field label, .field-label { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: inherit;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--muted); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--link); box-shadow: var(--ring);
}
.field select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6675' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.field .inline { display: flex; gap: 12px; }
.field .inline > * { flex: 1; }
/* On narrow phones, stack the side-by-side label+input pairs to full width so
   they don't cramp/overflow. Only the input-pair wrappers (> span / > .field)
   wrap to their own line; intentionally-horizontal children stay put — the tip
   stepper buttons (.btn-secondary) keep their fixed width beside the input, and
   inline unit chips (span.muted-small) stay beside their input. */
@media (max-width: 480px) {
  .field .inline { flex-wrap: wrap; }
  .field .inline > span:not(.muted-small),
  .field .inline > .field { flex: 1 1 100%; min-width: 0; }
}
.field .combo { display: flex; gap: 6px; }
.field .combo input { flex: 1; min-width: 0; }
.field .combo select { flex: 0 0 70px; padding-right: 28px; background-position: right 8px center; }

/* ---- Results panel --------------------------------------------------- */
.results { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.net-big { font-size: clamp(32px, 8vw, 40px); font-weight: 800; letter-spacing: -.02em; color: var(--accent); margin: 0; }
.net-sub { color: var(--muted); font-size: 14px; margin: 3px 0 20px; }
/* gap guarantees a minimum label-to-value separation: without it, space-between
   only pads leftover width, so a short label ("RGB") next to a wide value+button
   pair could end up glued together ("RGBrgb(30, 144, 255)") on a narrow screen. */
.line { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 15.5px; }
.line:last-child { border-bottom: 0; }
.line[hidden] { display: none; } /* author .line{display:flex} otherwise beats the UA [hidden] rule */
.line .lbl { color: var(--muted); }
.line.total { font-weight: 800; color: var(--text); font-size: 17px; border-top: 2px solid var(--border-strong); margin-top: 4px; padding-top: 12px; }
.rate-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; font-size: 13.5px; color: var(--muted); }

/* ---- Color converter (swatch + R/G/B, H/S/L trios) -------------------- */
/* Both classes previously had zero rules: the swatch collapsed to 0x0 (the
   picked/converted color was invisible) and .trio's <label> elements inherited
   `.field label { display:block }`, so R/G/B and H/S/L each stacked as their
   own full-width row instead of reading as one related group. */
.color-swatch { width: 100%; height: 72px; border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.field .trio { display: flex; gap: 8px; }
.field .trio label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 0; }
.field .trio input { width: 100%; }

/* ---- OBBBA / tax tool results (shared) ------------------------------- */
/* The output container (#out) inherits the code-tool monospace font used by
   the text utilities; the answer-first card + bars are prose, so pin them to
   the body sans stack. */
.stat-card, .compare-bars, .derivation > summary {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
/* R1: #out{font-family:monospace} (below, text-tool rule) was leaking into
   every .obbba-out results panel, rendering derivation prose (.line/.obbba-note/
   .takeaway text, not just the stat-card) in a terminal font. #out.obbba-out
   (ID+class, specificity 110) outranks the bare #out rule (100) so this wins
   the cascade; the plain .obbba-out arm covers the one panel that isn't id="out"
   (ss-wage-base-calculator's #ficaOut). Numeric alignment doesn't need a literal
   monospace font — .num and .stat-value keep font-variant-numeric: tabular-nums
   below, which aligns digits in any font. */
#out.obbba-out, .obbba-out { font-family: inherit; }
.stat-card { border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--border); padding: 16px 18px; margin-bottom: 14px; }
.stat-kicker { margin: 0 0 2px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.stat-value  { margin: 0; font-size: clamp(30px, 8vw, 40px); font-weight: 800;
  letter-spacing: -.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-value.is-zero { color: var(--text); }
.stat-sub    { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

.obbba-out .line { display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0; border-bottom: 1px solid rgba(128,128,128,.18); }
.obbba-out .line.big { font-size: 1.15rem; font-weight: 700;
  border-bottom: 2px solid rgba(128,128,128,.35); }
.obbba-out .num { font-variant-numeric: tabular-nums; }
.obbba-note { font-size: .9rem; opacity: .85; margin-top: 8px; }
.phaseout-flag { color: #b26b00; font-weight: 600; }
.ineligible-flag { color: #b23a00; font-weight: 600; }
.torpedo-warn { margin-top: 10px; padding: 12px 14px; border-left: 4px solid #b23a00;
  border-radius: 8px; background: rgba(178,58,0,.08); font-size: .95rem; }
.takeaway { margin-top: 12px; padding: 11px 14px; border-left: 4px solid #2f6f4f;
  border-radius: 8px; background: rgba(47,111,79,.09); font-size: .95rem; }
.mythbust { margin-top: 10px; padding: 14px 16px; border-left: 4px solid #b26b00;
  border-radius: 8px; background: rgba(178,107,0,.08); }
.mythbust h2 { margin-top: 0; }

.derivation { margin-top: 4px; }
.derivation > summary { cursor: pointer; font-size: 14px; font-weight: 600;
  color: var(--link); padding: 8px 0; }

.compare-bars { margin: 10px 0 4px; display: grid; gap: 6px; font-size: 13px; }
.compare-bars .cb-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; color: var(--muted); }
.compare-bars .cb-track { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; }
.compare-bars .cb-fill { height: 100%; border-radius: 5px; background: var(--accent); display: block; }
.compare-bars .cb-fill.cb-over { background: #b23a00; }

/* Two-up money fields (SALT income tax / property tax, overtime hrs/rate) */
.est-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Equal-weight tile pairs — two results that are both "the answer" and
   neither should read as primary/secondary (e.g. weighted vs unweighted
   GPA). Pairs with .stat-card/.stat-kicker/.stat-value above. */
.tile-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (max-width: 380px) { .tile-pair { grid-template-columns: 1fr; } }

/* Dark mode: the flag text colours above are too dark on a dark surface
   (about 2.5:1), so lift them to lighter, AA-passing variants. Box tints
   read fine because their body text uses --text. Follows the site's dual
   dark-mode pattern: OS-dark unless the visitor forced light, plus the
   explicit data-theme="dark" toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .phaseout-flag { color: #f0b86e; }
  :root:not([data-theme="light"]) .ineligible-flag { color: #f08a72; }
}
:root[data-theme="dark"] .phaseout-flag { color: #f0b86e; }
:root[data-theme="dark"] .ineligible-flag { color: #f08a72; }

/* ---- OBBBA state-conformity verdict box (overtime, tips) ------------- */
.state-verdict { margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  background: rgba(128,128,128,.10); font-size: .95rem; }

/* ---- Overtime premium estimator <details> ----------------------------- */
details.estimator { margin-top: 6px; }
details.estimator summary { cursor: pointer; font-size: .92rem; opacity: .9; }

/* ---- Senior deduction 65+ checkboxes ----------------------------------- */
.check-field { display: flex; align-items: flex-start; gap: 10px; }
.check-field input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; flex: none; }

/* ---- W-4 overtime/tips withholding calculator -------------------------- */
.empty-flag { color: #b23a00; font-weight: 600; }
.w4box { margin-top: 14px; padding: 14px 16px; border: 2px solid #2f6f4f;
  border-radius: 10px; background: rgba(47,111,79,.06); }
.w4box h3 { margin: 0 0 8px; font-size: 1rem; }
.w4box .wline { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0;
  font-variant-numeric: tabular-nums; border-bottom: 1px dashed rgba(47,111,79,.35); }
.w4box .wline.total { font-weight: 700; border-bottom: none; margin-top: 4px; }
.w4box .w4-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ot-modes { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.ot-modes label { cursor: pointer; font-weight: 500; }
.ot-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .ot-row { grid-template-columns: 1fr; } }

/* ---- Bonus tax calculator (withheld-now vs true-cost columns) --------- */
.ok-flag { color: #2f6f4f; font-weight: 700; }
.bt-headline { margin: 4px 0 14px; padding: 12px 15px; border-radius: 9px; font-size: 1.02rem; }
.bt-headline.refund { border-left: 4px solid #2f6f4f; background: rgba(47,111,79,.10); }
.bt-headline.owe { border-left: 4px solid #b26b00; background: rgba(178,107,0,.10); }
.bt-headline.even { border-left: 4px solid #4a6785; background: rgba(74,103,133,.10); }
.bt-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 6px; }
.bt-col h3 { margin: 0 0 6px; font-size: 1rem; }
@media (max-width: 640px) { .bt-cols { grid-template-columns: 1fr; } }

/* ---- QR colour pickers + scannability warning ----------------------- */
.field input[type="color"] { height: 44px; padding: 4px; cursor: pointer; }
.qr-warn { margin: 10px 0 0; padding: 9px 12px; font-size: 13px; border-radius: var(--radius-sm);
  color: #8a4b00; background: #fff4e5; border: 1px solid #f0c98a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .qr-warn { color: #ffcf99; background: #3a2a14; border-color: #6b4f24; }
}
:root[data-theme="dark"] .qr-warn { color: #ffcf99; background: #3a2a14; border-color: #6b4f24; }

/* ---- Simple / Advanced toggle --------------------------------------- */
.mode-row { grid-column: 1 / -1; display: flex; gap: 8px; }
.mode-row .seg { flex: 1; margin: 0; position: relative; cursor: pointer; }
.mode-row .seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.mode-row .seg span {
  display: block; text-align: center; padding: 10px 12px; font-size: 14.5px; font-weight: 700;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); transition: background .15s, color .15s, border-color .15s;
}
.mode-row.view-toggle { margin-bottom: 16px; }
.mode-row .seg input:checked + span { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.mode-row .seg input:focus-visible + span { box-shadow: var(--ring); }

/* ---- Advanced fieldset ---------------------------------------------- */
.adv { grid-column: 1 / -1; margin: 4px 0 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 2px; background: var(--surface-2); }
.adv legend { padding: 0 8px; font-size: 13.5px; font-weight: 700; color: var(--text); }
.adv-hint { margin: 0 0 14px; font-size: 13px; color: var(--muted); }

/* ---- Federal bracket breakdown (collapsible) ------------------------ */
.brackets { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.brackets summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--link); }
.brackets summary:hover { text-decoration: underline; }
.bracket-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13.5px; }
.bracket-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.bracket-table th:nth-child(n+2), .bracket-table td:nth-child(n+2) { text-align: right; }
.bracket-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.bracket-table .bk-range { color: var(--muted); font-weight: 400; }
.cmp-result { margin-top: 4px; }
.cmp-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.cmp-delta { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.cmp-fy { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---- Money-flow breakdown bar --------------------------------------- */
.breakdown { margin: 4px 0 20px; }
.breakdown .bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--border); }
.breakdown .bar span { height: 100%; }
.breakdown .seg-net { background: var(--accent); }
.breakdown .seg-tax { background: #e0795b; }
.breakdown .seg-ded { background: #6b8cce; }
.breakdown .legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.breakdown .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: baseline; }
.breakdown .legend b { color: var(--text); font-weight: 700; }
.breakdown .legend .k-net { background: var(--accent); }
.breakdown .legend .k-tax { background: #e0795b; }
.breakdown .legend .k-ded { background: #6b8cce; }
/* Stat-row lists: `.breakdown` used as a <ul> of <li><span class="lbl">label</span><span>value</span></li>
   (average / fraction / sleep / tile). Without this, label+value rendered with no separator ("Count6"). */
ul.breakdown { list-style: none; padding: 0; }
.breakdown > li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 15.5px; }
.breakdown > li:last-child { border-bottom: 0; }
.breakdown > li .lbl { color: var(--muted); }

/* ---- Buttons --------------------------------------------------------- */
.btn-primary {
  width: 100%; padding: 13px 18px; font-size: 16px; font-weight: 700; font-family: inherit;
  color: var(--accent-ink); background: var(--accent); border: 0; border-radius: var(--radius-sm);
  cursor: pointer; margin-bottom: 8px; box-shadow: var(--shadow-sm);
  transition: background .15s, transform .05s, box-shadow .15s;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { box-shadow: var(--ring); }
.btn-secondary {
  padding: 11px 16px; font-size: 14px; font-weight: 600; font-family: inherit;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-secondary:focus-visible { box-shadow: var(--ring); }
.muted-small { font-size: 12.5px; color: var(--muted); min-height: 14px; margin: 0 0 12px; }
.muted-small.error { color: var(--danger); }

/* ---- Unit toggle (imperial / metric) -------------------------------- */
.unit-toggle { display: flex; gap: 8px; margin: 0 0 16px; }
.unit-toggle button {
  flex: 1; padding: 10px 12px; font-size: 14px; font-weight: 600; font-family: inherit;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); cursor: pointer; transition: background .15s, border-color .15s;
}
.unit-toggle button:hover { background: var(--surface-2); border-color: var(--muted); }
.unit-toggle button:focus-visible { box-shadow: var(--ring); }
.unit-toggle button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---- BMI category badge --------------------------------------------- */
.bmi-badge { display: inline-block; min-height: 22px; font-weight: 700; font-size: 15px; margin: 0 0 16px; }
.bmi-badge.cat-under  { color: #2563eb; }
.bmi-badge.cat-normal { color: var(--accent); }
.bmi-badge.cat-over   { color: #b45309; }
.bmi-badge.cat-obese  { color: #dc2626; }

/* ---- Medical / informational disclaimer ----------------------------- */
.disclaimer {
  margin: 16px 0; padding: 12px 14px; font-size: 13.5px; line-height: 1.5;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}

/* ---- Ad slots (do not remove) --------------------------------------- */
/* Hidden while AdSense is unapproved — empty "Advertisement" boxes read as
   made-for-AdSense to a manual reviewer. Restore the rules below on approval. */
.ad-slot { display: none; }
/*
.ad-slot {
  margin: 32px 0; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
}
*/

/* ---- Tool cards (home — the first impression) ----------------------- */
.tool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px; margin-top: 4px;
}
/* Subsection labels inside a section (e.g. the Money & Finance groups): separate
   each labeled group from the grid above it. */
.money-subhead { margin-top: 34px; }
.money-subhead:first-of-type { margin-top: 18px; }
.tool-card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--text);
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tool-card--hot { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow-sm); }
.tool-card .t-tag {
  position: absolute; top: 12px; right: 12px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 9px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
}
.tool-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-lg);
  border-color: var(--brand); text-decoration: none;
}
.tool-card .ic {
  width: 44px; height: 44px; border-radius: var(--radius-sm); margin-bottom: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-size: 22px;
}
.tool-card .t-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.tool-card .t-desc { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---- State grid (paycheck links) ------------------------------------ */
.state-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.state-grid a, .state-grid span {
  display: block; padding: 13px 16px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.state-grid a:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }
.state-grid span { color: var(--muted); opacity: .5; cursor: default; }

/* ---- Related tools (cross-links injected on tool pages) ------------- */
.more-tools { margin: 40px 0 8px; }
.more-tools h2 { font-size: 20px; letter-spacing: -.01em; margin: 0 0 14px; }
.more-tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.more-tools-grid a {
  display: block; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.more-tools-grid a:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }

/* Focused cross-link cluster (e.g. health calculators) — a small inline list. */
.related-tools { margin: 28px 0 8px; }
.related-tools h2 { font-size: 17px; letter-spacing: -.01em; margin: 0 0 10px; }
.related-tools ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.related-tools a {
  display: inline-block; padding: 9px 13px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.related-tools a:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }

/* Inline muted annotation (e.g. kcal alongside macro grams). */
.muted { color: var(--muted); }

/* Color converter: preview swatch + R/G/B and H/S/L field trios. */

/* ---- Prose ----------------------------------------------------------- */
.prose { color: var(--text); }
.prose p { margin: 0 0 15px; }
.prose a { font-weight: 600; }
.prose table { width: 100%; border-collapse: collapse; margin: 8px 0 18px; font-size: 14.5px; }
.prose th, .prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.table-scroll { overflow-x: auto; margin: 10px 0; -webkit-overflow-scrolling: touch; }
.prose thead th { color: var(--muted); font-weight: 700; border-bottom: 2px solid var(--border-strong); }
.note {
  font-size: 14px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--brand); border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 20px 0;
}
.year-fallback {
  font-size: 15px; color: var(--text, inherit);
  background: #fff8e1; border: 1px solid #f0d98a;
  border-left: 4px solid #e0a800; border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 0 0 20px;
}
.year-fallback strong { color: #9a6a00; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .year-fallback { background: #3a2f10; border-color: #6b5410; }
  :root:not([data-theme="light"]) .year-fallback strong { color: #ffd55e; }
}
:root[data-theme="dark"] .year-fallback { background: #3a2f10; border-color: #6b5410; }
:root[data-theme="dark"] .year-fallback strong { color: #ffd55e; }
.calc-load-error {
  font-size: 15px; font-weight: 600; color: #611a15;
  background: #fdecea; border: 1px solid #f5c2c0;
  border-left: 4px solid #d93025; border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 0 0 20px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .calc-load-error { background: #3a1613; border-color: #6b2b26; color: #ffb4ab; }
}
:root[data-theme="dark"] .calc-load-error { background: #3a1613; border-color: #6b2b26; color: #ffb4ab; }

/* ---- Invoice generator ---------------------------------------------- */
.inv { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .inv { grid-template-columns: 1fr; } }
.inv-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-md); }
.inv-form h2 { font-size: 13px; margin: 24px 0 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.inv-form h2:first-child { margin-top: 0; }
.inv-form textarea { width: 100%; padding: 12px 14px; font: inherit; font-size: 15px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); resize: vertical; }
.inv-side { position: sticky; top: 80px; }

.item-row { display: grid; grid-template-columns: 1fr 56px 80px 80px 28px; gap: 6px; margin-bottom: 6px; align-items: center; }
.item-row input { padding: 9px; font-size: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; width: 100%; }
.item-row .rm { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 18px; line-height: 1; }
.item-head { display: grid; grid-template-columns: 1fr 56px 80px 80px 28px; gap: 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
/* Narrow phones: the 5-column item row (Description/Qty/Rate/Amount/×) crushes
   Description below ~480px with no breakpoint. Drop to 2 columns and let the
   description span both; hide the header row since it no longer lines up. */
@media (max-width: 480px) {
  .item-row, .item-head { grid-template-columns: 1fr 1fr; }
  .item-head { display: none; }
  .item-row .d { grid-column: 1 / -1; }
}

.tc-row { display: grid; grid-template-columns: 1fr 132px 132px 64px 1fr 28px; gap: 6px; margin-bottom: 6px; align-items: center; }
.tc-row input { padding: 9px; font-size: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; width: 100%; }
.tc-row .out { font-size: 13.5px; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; padding-right: 4px; }
.tc-row .rm { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 18px; line-height: 1; padding: 0; }
.tc-head { display: grid; grid-template-columns: 1fr 132px 132px 64px 1fr 28px; gap: 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.tc-row .dl { display: none; }
@media (max-width: 680px) {
  .tc-row, .tc-head { grid-template-columns: 1fr 1fr; }
  .tc-head { display: none; }
  .tc-row .out { text-align: left; }
  /* The header row no longer lines up with the 2-col layout, so instead of
     leaving fields unlabeled, show a small per-field label above each input. */
  .tc-row .dl { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
  .tc-row .tc-f { display: flex; flex-direction: column; min-width: 0; }
}

.gpa-row { display: grid; grid-template-columns: 1fr 84px 104px 64px 28px; gap: 6px; margin-bottom: 6px; align-items: center; }
.gpa-row input, .gpa-row select { padding: 9px; font-size: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; width: 100%; min-width: 0; }
.gpa-row select { appearance: none; -webkit-appearance: none; }
.gpa-row .rm { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 18px; line-height: 1; padding: 0; }
.gpa-head { display: grid; grid-template-columns: 1fr 84px 104px 64px 28px; gap: 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
/* Narrow phones: trim the fixed columns so the 5-input grade row fits 390px without overflow. */
@media (max-width: 480px) {
  .gpa-row, .gpa-head { grid-template-columns: 1fr 64px 72px 52px 24px; gap: 5px; }
  /* Remove-row "×" buttons need a >=44px tap target on touch (WCAG 2.5.5). */
  .item-row .rm, .tc-row .rm, .gpa-row .rm { min-width: 44px; min-height: 44px; }
}

.inv-preview { background: #fff; color: #1a1a1a; border-radius: var(--radius); padding: 24px; font-size: 13px; line-height: 1.45; box-shadow: var(--shadow-md); }
.inv-preview h3 { margin: 0 0 2px; font-size: 20px; color: #111; }
.inv-preview .pv-logo { display: block; max-height: 56px; max-width: 160px; margin-bottom: 8px; object-fit: contain; }
.inv-preview .pv-row { display: flex; justify-content: space-between; gap: 16px; }
.inv-preview .pv-parties { display: flex; justify-content: space-between; gap: 16px; margin: 16px 0; }
.inv-preview .pv-parties .lbl { color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.inv-preview table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.inv-preview th { text-align: left; border-bottom: 2px solid #222; padding: 6px 4px; font-size: 11px; text-transform: uppercase; color: #555; }
.inv-preview th.num, .inv-preview td.num { text-align: right; }
.inv-preview td { padding: 6px 4px; border-bottom: 1px solid #eee; }
.inv-preview .pv-totals { margin-left: auto; width: 60%; }
.inv-preview .pv-totals .pv-row { padding: 3px 0; }
.inv-preview .pv-totals .grand { font-weight: 700; font-size: 15px; border-top: 2px solid #222; margin-top: 4px; padding-top: 6px; }
.inv-preview .pv-notes { margin-top: 16px; color: #555; white-space: pre-wrap; }
.inv-preview .pv-meta { color: #555; white-space: pre-wrap; }

/* ---- Image editor (circle-crop, photo maker) ------------------------ */
.dropzone {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 130px; padding: 24px; border: 2px dashed var(--border-strong); border-radius: var(--radius);
  color: var(--muted); cursor: pointer; background: var(--surface-2);
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.editor-wrap { display: inline-block; max-width: 100%; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md);
  background-image: linear-gradient(45deg,#2a2a2a 25%,transparent 25%),linear-gradient(-45deg,#2a2a2a 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#2a2a2a 75%),linear-gradient(-45deg,transparent 75%,#2a2a2a 75%);
  background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0; }
.editor-wrap canvas { display: block; width: 320px; height: 320px; max-width: 100%; }

/* ---- Images to PDF list --------------------------------------------- */
.pdf-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.pdf-item { display: grid; grid-template-columns: 22px 48px 1fr auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; }
.pdf-item .pdf-num { color: var(--muted); font-size: 12px; text-align: center; font-weight: 700; }
.pdf-item .pdf-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.pdf-item .pdf-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-item .pdf-actions { display: flex; gap: 4px; }
.pdf-item .pdf-actions button { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  cursor: pointer; border-radius: 6px; width: 30px; height: 30px; font-size: 15px; line-height: 1; }
.pdf-item .pdf-actions button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pdf-item .pdf-actions button:disabled { opacity: .4; cursor: default; }
.pdf-item .pdf-actions .rm { color: var(--danger); }
.pdf-item .pdf-actions .rm:hover { border-color: var(--danger); color: var(--danger); }

/* ---- Footer ---------------------------------------------------------- */
footer.site { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; color: var(--muted); font-size: 13.5px; margin-top: 24px; }
footer.site .wrap { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; align-items: center; }
footer.site a { color: var(--muted); font-weight: 600; }
footer.site a:hover { color: var(--text); }

/* ---- Tip calculator helpers ----------------------------------------- */
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.presets .btn-secondary { flex: 1; min-width: 64px; padding: 9px 8px; }
.presets .btn-secondary[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.field .inline #people { text-align: center; }
.field .inline .btn-secondary { flex: 0 0 48px; font-size: 20px; line-height: 1; padding: 0; }
.field label.check { display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--text); cursor: pointer; }
.field label.check input { width: auto; margin: 0; }

/* ---- Holiday countdown ---------------------------------------------- */
.preset-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-grid .preset { flex: 1 1 auto; min-width: 100px; }
.preset.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cd-big { font-size: clamp(56px, 18vw, 104px); font-weight: 800; letter-spacing: -.03em; color: var(--accent); line-height: 1; margin: 0; }
.cd-big .unit { font-size: clamp(18px, 5vw, 28px); font-weight: 700; color: var(--muted); margin-left: 10px; letter-spacing: 0; }
.cd-note { color: var(--muted); font-size: 15.5px; margin: 8px 0 22px; }
.cd-clock { display: flex; gap: 10px; flex-wrap: wrap; }
.cd-clock .seg { flex: 1; min-width: 64px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 6px; }
.cd-clock .seg b { display: block; font-size: 28px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.cd-clock .seg span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 4px; }
/* Scoped variant for age-calculator's "totals lived" strip: it feeds up-to-8-digit numbers
   (minutes lived) into a component sized for the countdown-timer's 2-digit values. Shrink the
   number + let cells flex to 0 so big totals wrap instead of clipping. Do NOT touch base .cd-clock
   (shared with countdown-timer). */
.cd-clock--totals .seg { min-width: 0; flex: 1 1 0; }
.cd-clock--totals .seg b { font-size: 19px; overflow-wrap: anywhere; }
/* age-calculator's 5-tile totals strip carries a ~10-digit "minutes lived" value (worst
   case a 100-year-old: 52,879,680 minutes). Squeezing five tiles onto one flex row makes
   each cell too narrow, so big numbers wrap per-character and MONTHS/MINUTES labels spill
   into neighbours — and this happens at EVERY width, not just on phones: above 680px the
   page's .calc becomes a 2-column grid whose results column is only ~365px wide, so the
   same five tiles squeeze just as badly on desktop (a viewport media query can't see the
   narrow column). This add-on (applied only on age-calculator, via --wrap2) caps the strip
   at 2 tiles per row at all widths: the five tiles fall into a 2 + 2 + 1 stack and the lone
   minutes tile grows to the full row width, so every number stays on one line. The results
   column never exceeds ~365px anywhere, so one row of five is never viable. base .cd-clock
   (countdown-timer) and the 2-3 tile --totals strips (chronological-age / days-between,
   which lack --wrap2) are untouched. */
.cd-clock--totals.cd-clock--wrap2 .seg { flex: 1 1 45%; }

/* Password generator -------------------------------------------------------- */
.pw-output { display: flex; gap: 8px; align-items: stretch; }
.pw-output input {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px; letter-spacing: .04em; padding: 14px 14px; word-break: break-all;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text);
}
.pw-output .btn-secondary { flex: 0 0 auto; width: auto; padding: 0 16px; }
.pw-output .btn-secondary.copied { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.strength { margin: 16px 0 4px; }
.strength-track { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.strength-bar { height: 100%; width: 0; border-radius: 999px; transition: width .2s ease, background .2s ease; }
.strength-bar.vw, .strength-bar.weak { background: var(--danger); }
.strength-bar.fair { background: #c98a16; }
.strength-bar.strong { background: #2e8b57; }
.strength-bar.vs { background: var(--accent); }
.strength-label { font-size: 13.5px; font-weight: 600; color: var(--muted); margin: 7px 0 0; min-height: 18px; }
.pw-error { color: var(--danger); font-size: 14px; margin: 4px 0 12px; }

/* ---- Countdown timer (duration) -------------------------------------- */
.timer-readout {
  font-size: clamp(56px, 17vw, 104px); font-weight: 800; letter-spacing: -.02em;
  color: var(--text); line-height: 1; margin: 0 0 6px;
  font-variant-numeric: tabular-nums; text-align: center;
}
.timer-readout.running { color: var(--accent); }
/* Stopwatch's HH:MM:SS.cc readout runs longer (11 chars) than the countdown/
   pomodoro formats sharing .timer-readout, so it needs a lower size floor
   plus wrap safety to avoid horizontal overflow at narrow widths. */
#swReadout { overflow-wrap: anywhere; font-size: clamp(40px, 14vw, 104px); }
.timer-status { min-height: 26px; text-align: center; font-weight: 700; font-size: 18px; color: var(--accent); margin: 0 0 16px; }
#cdTimer.done .timer-readout { color: var(--danger); }
#cdTimer.done { animation: timer-flash 1s ease-in-out 0s 4; }
#cdTimer.done .timer-status { color: var(--danger); font-size: 22px; }
@keyframes timer-flash { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.timer-actions { display: flex; gap: 10px; margin-top: 4px; }
.timer-actions .btn-primary, .timer-actions .btn-secondary { flex: 1; }
.timer-mute { margin-top: 12px; text-align: center; }
.timer-mute .btn-secondary { width: auto; padding: 8px 16px; font-size: 14px; }

/* ---- Stopwatch lap table -------------------------------------------- */
.lap-table { margin-top: 18px; }
.lap-table td, .lap-table th { font-variant-numeric: tabular-nums; }
.lap-table .lap-best td { color: var(--ok, #16a34a); font-weight: 700; }
.lap-table .lap-worst td { color: var(--danger, #dc2626); font-weight: 700; }
.lap-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }

/* ---- Pomodoro timer ------------------------------------------------- */
.pomo-box { text-align: center; transition: border-color .25s ease; }
.pomo-box.is-work { border-color: var(--accent); }
.pomo-box.is-break { border-color: var(--ok, #16a34a); }
.pomo-phase { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; }
.pomo-box.is-break .pomo-phase { color: var(--ok, #16a34a); }
.pomo-meta { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin: 0 0 14px; }
#pomoSettings { margin-top: 18px; }
.pomo-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1 1 0; min-width: 72px; }
.pomo-field input { width: 100%; }
.pomo-auto { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; }
.pomo-auto input { width: auto; }

/* ---- Text case converter helpers ------------------------------------ */
.case-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.case-buttons .btn-secondary { flex: 0 1 auto; padding: 9px 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn-primary, .btn-row .btn-secondary { flex: 1; }
/* was: #out { font-family: ui-monospace,… }, which leaked terminal font into prose outputs.
   Monospace is now opt-in: apply .code-out only where the output is genuinely code/data. */
#out.code-out, .code-out { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* JSON formatter */
#input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; overflow-wrap: normal; }
.json-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.json-toolbar .btn-primary, .json-toolbar .btn-secondary { width: auto; }
.json-toolbar .field { margin: 0; display: flex; align-items: center; gap: 8px; }
.json-toolbar .field label { margin: 0; }
.json-toolbar select { width: auto; }
.json-status { margin: 6px 0 0; font-weight: 600; }
.json-status.ok { color: var(--accent); }
.json-status.err { color: var(--danger); }

/* Random number generator */
.rng-actions { display: flex; gap: 10px; margin-top: 4px; }
.rng-actions .btn-primary { flex: 1; }
.rng-actions .btn-secondary { flex: 0 0 auto; width: auto; padding: 0 16px; }
.rng-actions .btn-secondary.copied { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rng-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.rng-list[hidden] { display: none; }
.rng-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text);
}

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

/* ===== merged tool styles ported from main (invoice/qr/word-counter/circle-crop/passport) ===== */

/* ---- Age calculator alternates (results panel) ---------------------- */
.age-alt { list-style: none; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.age-alt li { background: var(--surface-1, var(--surface-2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: 14px; }
#ageResults[hidden] { display: none; }

/* ---- Word & character counter --------------------------------------- */
.wc-input { width: 100%; min-height: 220px; padding: 14px 16px; font: inherit; font-size: 15px; line-height: 1.55; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); resize: vertical; }
.wc-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.wc-toolbar { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.wc-toolbar .btn-secondary { width: auto; padding: 8px 16px; flex: 0 0 auto; }
.wc-toolbar .btn-secondary.copied { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.wc-toolbar .wpm { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.wc-toolbar .wpm input { width: 78px; padding: 7px 10px; }
.wc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0; }
@media (max-width: 560px) { .wc-stats { grid-template-columns: repeat(2, 1fr); } }
.wc-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.wc-stat .n { font-size: 1.5rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.wc-stat .l { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.kw-list { margin: 6px 0 0; padding-left: 20px; }
.kw-list li { margin: 0 0 6px; }
.kw-word { font-weight: 600; color: var(--text); }
.kw-meta { color: var(--muted); font-size: 13px; margin-left: 8px; }
.limit-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.limit-ok { color: var(--muted); }
.limit-near { color: #b8860b; font-weight: 600; }
.limit-over { color: var(--danger); font-weight: 600; }

/* ---- Percentage calculator ------------------------------------------ */
.field .inline > span.muted-small { flex: 0 0 auto; align-self: center; white-space: nowrap; margin: 0; min-height: 0; }
.result-line { margin: 12px 0 0; font-size: 1.15rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- State page differentiation blocks (payroll/bracket tables, facts, sources) ---- */
.prose .data-table { width: 100%; border-collapse: collapse; margin: 12px 0 4px; font-size: 0.95rem; }
.prose .data-table th, .prose .data-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border, #e5e7eb); font-variant-numeric: tabular-nums; }
.prose .data-table thead th { background: var(--surface-2, #f6f8fa); font-weight: 600; }
.prose .data-table tr:last-child td { border-bottom: 0; }
.prose ul.facts { margin: 8px 0; padding-left: 20px; }
.prose ul.facts li { margin: 6px 0; }
.sources { margin: 20px 0; padding: 14px 16px; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; background: var(--surface-2, #f9fafb); }
.sources h2 { font-size: 1.05rem; margin: 0 0 4px; }
.sources ul { margin: 6px 0 0; padding-left: 18px; column-gap: 24px; }
.sources li { margin: 3px 0; font-size: 0.9rem; word-break: break-word; }
.sources a { color: var(--muted, #6b7280); }

/* ---- Global tool search / command palette (Cmd+K) -------------------- */
/* Header trigger: sits between the brand and the primary nav, pushed to the
   right by margin-left:auto so brand hugs the left edge and the trigger + nav
   group on the right. */
.tb-search-trigger {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 8px 12px; cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.tb-search-trigger:hover { color: var(--text); border-color: var(--border-strong); }
.tb-search-trigger:focus-visible { outline: none; box-shadow: var(--ring); }
.tb-search-trigger .tb-search-ic { color: var(--muted); flex: 0 0 auto; }
.tb-search-trigger:hover .tb-search-ic { color: var(--text); }
.tb-search-trigger-kbd {
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 5px; white-space: nowrap;
}

.tb-search-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Overlay + dialog */
.tb-search-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
  background: rgba(10, 16, 24, .5);
  backdrop-filter: blur(2px);
}
.tb-search-overlay[hidden] { display: none; }
.tb-search-panel {
  width: 100%; max-width: 560px; max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: tb-search-in .12s ease;
}
@keyframes tb-search-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.tb-search-field {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.tb-search-field .tb-search-ic { color: var(--muted); flex: 0 0 auto; }
.tb-search-input {
  flex: 1 1 auto; min-width: 0;
  font: 400 18px/1.4 inherit; color: var(--text);
  background: transparent; border: 0; outline: none; padding: 4px 0;
}
.tb-search-input::placeholder { color: var(--muted); }
.tb-search-esckbd {
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 5px; padding: 4px 6px; flex: 0 0 auto;
}

.tb-search-list {
  list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1 1 auto;
}
.tb-search-opt {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
}
.tb-search-opt[aria-selected="true"] { background: var(--accent-soft); }
.tb-search-opt-main { display: flex; align-items: baseline; gap: 10px; }
.tb-search-opt-name { font-weight: 700; font-size: 15px; color: var(--text); }
.tb-search-opt[aria-selected="true"] .tb-search-opt-name { color: var(--accent-hover); }
.tb-search-opt-cat {
  font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  border-radius: var(--radius-pill); padding: 2px 8px; flex: 0 0 auto; margin-left: auto;
}
.tb-search-opt-desc {
  font-size: 13px; color: var(--muted); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-search-empty { margin: 0; padding: 20px 16px; color: var(--muted); font-size: 14px; text-align: center; }

.tb-search-foot {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.tb-search-foot span { display: inline-flex; align-items: center; gap: 5px; }
.tb-search-foot kbd {
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 2px 5px;
}

/* Compact the header trigger to an icon-only control on narrow screens. */
@media (max-width: 560px) {
  .tb-search-trigger-txt, .tb-search-trigger-kbd { display: none; }
  .tb-search-trigger { padding: 8px; }
  .tb-search-overlay { padding: 6vh 10px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .tb-search-panel { animation: none; }
}

/* ------------------------------------------------------------------------- *
   Feedback widget — "Was this tool helpful?" rating toast (feedback-widget.js).
   Small, non-modal, dead-center of the viewport at every width — no backdrop,
   the page stays fully interactive around it. z-index sits BELOW the search
   palette (1000) so it can never cover an open command palette. All colours
   are theme tokens, so light/dark follow automatically.
 * ------------------------------------------------------------------------- */
.fbw-toast {
  position: fixed; z-index: 900;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100vw - 32px); max-width: 320px;
  box-sizing: border-box;
  padding: 16px 16px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: fbw-in .16s ease;
}
@keyframes fbw-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.fbw-x {
  position: absolute; top: 4px; right: 4px;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); background: transparent; border: 0; border-radius: var(--radius-sm);
  cursor: pointer;
}
.fbw-x:hover { color: var(--text); background: var(--surface-2); }
.fbw-x:focus-visible { outline: none; box-shadow: var(--ring); }

.fbw-q {
  margin: 0 28px 10px 0;
  font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--text);
}

.fbw-stars { display: flex; gap: 2px; }
.fbw-star {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  color: var(--border-strong); background: transparent; border: 0; border-radius: var(--radius-sm);
  cursor: pointer; transition: color .1s ease, transform .1s ease;
}
.fbw-star:hover:not([disabled]) { transform: scale(1.08); }
.fbw-star.is-on, .fbw-star.is-hover { color: var(--brand); }
.fbw-star:focus-visible { outline: none; box-shadow: var(--ring); }
.fbw-star[disabled] { cursor: default; }

.fbw-step { margin-top: 12px; }
.fbw-comment {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 48px;
  font: 400 14px/1.4 inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.fbw-comment::placeholder { color: var(--muted); }
.fbw-comment:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.fbw-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.fbw-send {
  font: 600 14px/1 inherit; color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: var(--radius-pill); padding: 9px 18px; cursor: pointer;
}
.fbw-send:hover { background: var(--accent-hover); }
.fbw-send:focus-visible { outline: none; box-shadow: var(--ring); }
.fbw-skip {
  font: 500 14px/1 inherit; color: var(--muted);
  background: transparent; border: 0; padding: 6px 4px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.fbw-skip:hover { color: var(--text); }
.fbw-skip:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

.fbw-thanks { margin: 0; font-size: 15px; font-weight: 600; color: var(--accent); }

/* Still dead-center on phones, just wider relative to the smaller viewport. */
@media (max-width: 480px) {
  .fbw-toast {
    width: calc(100vw - 24px); max-width: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fbw-toast { animation: none; }
  .fbw-star { transition: none; }
}

/* ---------------------------------------------------------------------------
   Report widget — "Report a wrong result" inline reporter (report-widget.js).
   Unlike the rating toast this is a plain in-flow block placed as a sibling
   immediately after a tool's result element: an always-present text-button that
   expands into a small comment form. No fixed positioning, no card, no media
   query — it flows with the page. Fully theme-token driven (no hex, no separate
   dark-mode block), same convention as the .fbw-* block above.
 * ------------------------------------------------------------------------- */
.rpt-link {
  display: inline-block; margin-top: 10px; padding: 2px 0;
  font: 500 13px/1.4 inherit; color: var(--muted);
  background: transparent; border: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.rpt-link:hover { color: var(--text); }
.rpt-link:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

.rpt-form {
  margin-top: 10px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.rpt-recap {
  margin: 0 0 8px; font-size: 12px; line-height: 1.4; color: var(--muted);
}
.rpt-comment {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 60px;
  font: 400 14px/1.4 inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.rpt-comment::placeholder { color: var(--muted); }
.rpt-comment:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.rpt-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.rpt-send {
  font: 600 14px/1 inherit; color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: var(--radius-pill); padding: 9px 18px; cursor: pointer;
}
.rpt-send:hover:not([disabled]) { background: var(--accent-hover); }
.rpt-send:focus-visible { outline: none; box-shadow: var(--ring); }
.rpt-send[disabled] { opacity: .5; cursor: default; }
.rpt-cancel {
  font: 500 14px/1 inherit; color: var(--muted);
  background: transparent; border: 0; padding: 6px 4px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.rpt-cancel:hover { color: var(--text); }
.rpt-cancel:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

.rpt-thanks { margin: 10px 0 0; font-size: 14px; font-weight: 600; color: var(--accent); }
.rpt-error { margin: 8px 0 0; font-size: 13px; color: var(--danger); }
