/* ---------- Theme tokens: light by default, dark by system setting or the theme switch ---------- */
/* Jotted: Figtree for text, Bricolage Grotesque for the wordmark and headings. Self-hosted (public/fonts, SIL OFL). */
@font-face { font-family: "Figtree"; font-weight: 400; font-display: swap; src: url("fonts/figtree-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 500; font-display: swap; src: url("fonts/figtree-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 600; font-display: swap; src: url("fonts/figtree-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 700; font-display: swap; src: url("fonts/figtree-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 800; font-display: swap; src: url("fonts/bricolage-grotesque-latin-800-normal.woff2") format("woff2"); }

:root {
  --bg: #eceff5;
  --panel: #ffffff;
  --text: #151a2d;
  --muted: #444b61;
  --border: #c3c9d6;
  /* Outlines that keep light mode readable (dark mode keeps its flatter look: see its overrides). */
  --panel-border: #d0d5e0;
  --control-border: #858ea2; /* buttons and fields: at least 3:1 against white */
  --secondary-border: #7d9be6;
  --ghost-border: #858ea2;
  --ghost-text: #2c3349;
  --note-border: #b8c8f0;
  --segmented-border: #c3c9d6;
  /* KSB evidence tiles: none / 1-2 / 3+. Deep enough to tell apart at a glance, and they differ in
     lightness as well as colour so they still read for colour-blind users. */
  --ksb-none: #f5b9b3; --ksb-none-edge: #d4675d;
  --ksb-low: #fcdca6; --ksb-low-edge: #d99a3a;
  --ksb-ok: #a9dcbc; --ksb-ok-edge: #3f9e66;
  --accent: #2456d6;
  --accent-text: #ffffff;
  --accent-soft: #e3eafb;
  --accent-ink: #1a3fa0;
  --good: #1f8a4c;
  --good-text: #ffffff;
  --good-soft: #e3f4ea;
  --warn: #9a3412;
  --warn-soft: #fff4ec;
  --bad: #c0352b;
  --bad-soft: #fbe7e5;
  --mark: #fff1b8;
  --grid: #eceef4;
  --field: #ffffff;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 3px rgba(21, 26, 45, .10);
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10131c; --panel: #181c28; --text: #e8ebf2; --muted: #a2a9bb; --border: #2b3142;
    --accent: #7fa2ff; --accent-text: #0b1020; --accent-soft: #1e2944; --accent-ink: #b9ccff;
    --good: #4cc483; --good-text: #08130d; --good-soft: #15291d; --warn: #f5a35c; --warn-soft: #33220f;
    --bad: #ff7b70; --bad-soft: #3a1b19; --mark: #5a4c0c; --grid: #232838; --field: #141823; --shadow: none;
    --panel-border: #2b3142; --control-border: #2b3142; --secondary-border: transparent; --ghost-border: transparent; --ghost-text: #a2a9bb; --note-border: transparent; --segmented-border: transparent;
    --ksb-none: #3a1b19; --ksb-none-edge: transparent; --ksb-low: #33220f; --ksb-low-edge: transparent; --ksb-ok: #15291d; --ksb-ok-edge: transparent;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10131c; --panel: #181c28; --text: #e8ebf2; --muted: #a2a9bb; --border: #2b3142;
  --accent: #7fa2ff; --accent-text: #0b1020; --accent-soft: #1e2944; --accent-ink: #b9ccff;
  --good: #4cc483; --good-text: #08130d; --good-soft: #15291d; --warn: #f5a35c; --warn-soft: #33220f;
  --bad: #ff7b70; --bad-soft: #3a1b19; --mark: #5a4c0c; --grid: #232838; --field: #141823; --shadow: none;
    --panel-border: #2b3142; --control-border: #2b3142; --secondary-border: transparent; --ghost-border: transparent; --ghost-text: #a2a9bb; --note-border: transparent; --segmented-border: transparent;
    --ksb-none: #3a1b19; --ksb-none-edge: transparent; --ksb-low: #33220f; --ksb-low-edge: transparent; --ksb-ok: #15291d; --ksb-ok-edge: transparent;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* so `display: flex/grid` rules can't override the hidden attribute */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.15rem; }
h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; font-weight: 700; }
.center { text-align: center; }
p { margin: .25rem 0 .75rem; }
code { font-size: .9em; }
mark { background: var(--mark); color: inherit; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); }
.note { background: var(--accent-soft); border: 1px solid var(--note-border); border-radius: 8px; padding: .5rem .75rem; }
.note ol { margin: .25rem 0 .6rem; padding-left: 1.2rem; }
.empty { color: var(--muted); font-size: .9rem; padding: .5rem 0; }

/* ---------- Header & tabs ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2rem) .6rem; background: var(--bg);
}
.brand { display: flex; gap: .9rem; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.brand p { margin: 0; font-size: .85rem; }
.wordmark { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 1.75rem; letter-spacing: -.02em; line-height: 1; color: var(--accent); }
.wordmark span { color: var(--good); }
.hours-pill { background: var(--accent-soft); color: var(--accent-ink); padding: .4rem .85rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.hours-pill b { font-variant-numeric: tabular-nums; }

/* Tabs: a row under the header on wider screens, a bottom tab bar on phones (see Phone). */
.tabs {
  display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none;
  padding: .25rem clamp(1rem, 4vw, 2rem) .5rem; background: var(--bg);
  max-width: 1180px; margin: 0 auto;
}
.tabs button {
  display: inline-flex; align-items: center; gap: .45rem; position: relative;
  background: none; border: 0; border-radius: 999px; min-height: 44px;
  padding: .5rem 1rem; color: var(--muted); font-weight: 600; white-space: nowrap;
}
.tabs button.active { color: var(--accent-ink); background: var(--accent-soft); }
.tabs button:hover:not(.active) { color: var(--text); }
.count {
  background: var(--bad); color: #fff; border-radius: 999px; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem;
  font-size: .72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}

main { padding: .75rem clamp(1rem, 4vw, 2rem) 3rem; max-width: 1180px; margin: 0 auto; }
.panel, .card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 1.15rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); min-width: 0;
}
.panel.narrow { max-width: 700px; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.grid.two > .panel { margin-bottom: 0; }
@media (max-width: 860px) { .grid.two { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.space { justify-content: space-between; }

/* ---------- Controls ---------- */
button, .file-btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm); min-height: 44px;
  padding: .6rem 1.05rem; border: 1px solid var(--control-border); background: var(--panel); color: var(--text); display: inline-block;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary.big { display: block; width: 100%; padding: .85rem 1rem; font-size: 1.05rem; font-weight: 700; margin-top: .75rem; }
button.save, button.good { background: var(--good); border-color: var(--good); color: var(--good-text); }
button.secondary, .file-btn.secondary { background: var(--accent-soft); border-color: var(--secondary-border); color: var(--accent-ink); }
button.ghost { background: none; border-color: var(--ghost-border); color: var(--ghost-text); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.busy::after { content: "…"; }
.small-btn { padding: .35rem .75rem; font-size: .88rem; min-height: 36px; }
.icon-btn { width: 44px; height: 44px; padding: 0; justify-content: center; background: var(--panel); display: inline-flex; align-items: center; color: var(--text); }
.icon-btn.listening { background: var(--bad-soft); border-color: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--control-border); border-radius: var(--radius-sm); padding: .6rem .75rem; width: 100%; min-height: 44px;
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: auto; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.label { display: block; font-weight: 600; margin: .75rem 0 .35rem; }
#api-key { flex: 1; min-width: 220px; width: auto; }

/* Sign-up tick boxes (hosted mode) */
button.primary.danger { background: var(--bad); border-color: var(--bad); }
#delete-form { margin-top: .75rem; }
a.file-btn { text-decoration: none; display: inline-block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.auth-panel { margin-top: 1.5rem; }
.auth-panel form { display: grid; gap: .5rem; }
.consents { border: 0; padding: 0; margin: .5rem 0; display: grid; gap: .6rem; }
.consent { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.consent input { width: 1.15rem; height: 1.15rem; flex: none; margin: .15rem 0 0; padding: 0; accent-color: var(--accent); }
.site-footer { text-align: center; padding: 0 1rem 2rem; }
.site-footer a, .consent a, .doc a { color: var(--accent); }
.doc table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: .9rem; }
.doc th, .doc td { border: 1px solid var(--border); padding: .35rem .5rem; text-align: left; vertical-align: top; }
.doc blockquote { margin: 0 0 1rem; padding: .5rem .75rem; background: var(--accent-soft); border-radius: 8px; }

.segmented { display: inline-flex; background: var(--grid); border: 1px solid var(--segmented-border); border-radius: var(--radius-sm); padding: 3px; }
.segmented button { border: 0; background: none; padding: .4rem .85rem; color: var(--muted); border-radius: 9px; min-height: 38px; }
.segmented button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(21, 26, 45, .12); }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .6rem 0 0; }
.chip { font-size: .88rem; font-weight: 500; padding: .35rem .8rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); min-height: 36px; }
.chip.gap { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .72rem; font-weight: 700; border-radius: 4px; padding: .05rem .35rem; margin-left: .35rem; background: var(--bg); color: var(--muted); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.ksb-code { display: inline-block; font-weight: 700; background: var(--accent-soft); border-radius: 6px; padding: .05rem .45rem; margin-right: .35rem; }

/* ---------- Week strip ---------- */
.week { margin-bottom: .9rem; }
.week-head { margin-bottom: .4rem; color: var(--muted); }
.week-head b { color: var(--text); }
.week-days { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: .4rem; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: .4rem .2rem; font-weight: 400;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; font-size: .78rem; color: var(--muted); min-height: 0;
}
.day b { font-size: 1rem; color: var(--text); }
.day i { font-style: normal; font-size: .74rem; }
.day.has i { color: var(--good); font-weight: 700; }
.day.today { border: 2px solid var(--accent); padding: calc(.4rem - 1px) .2rem; }
.day.today b { color: var(--accent); }
@media (max-width: 560px) { .week-days { grid-template-columns: repeat(5, minmax(0, 1fr)); } .week-days .day:nth-child(-n+5) { display: none; } }

/* ---------- Compose ---------- */
.compose .label { margin-top: .9rem; }
.compose textarea#description { font-size: 1rem; }
#usage-line { margin: .55rem 0 0; }
#hint { margin: .5rem 0 0; text-align: center; }

/* ---------- Loading ---------- */
.loading { display: flex; gap: 1rem; align-items: flex-start; }
.loading > div:last-child { flex: 1; }
.loading-step { font-weight: 600; margin: 0 0 .6rem; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--grid), var(--bg), var(--grid)); background-size: 200% 100%; animation: shimmer 1.4s infinite; margin-bottom: .5rem; }
.skeleton.short { width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .spinner, .skeleton, .icon-btn.listening { animation: none; } }

/* ---------- Draft card ---------- */
.draft { box-shadow: 0 2px 10px rgba(21, 26, 45, .08); }
.draft-head { display: flex; align-items: baseline; gap: .5rem; }
.draft-head h3 { margin: 0 0 .6rem; font-size: 1.1rem; }
.draft button.primary[data-save] { background: var(--good); border-color: var(--good); color: var(--good-text); }
.when { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.when label, .ksb-row label, .fields label { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--muted); font-weight: 600; }
.when label { width: 9.5rem; }
.dur { font-size: .85rem; color: var(--muted); padding-bottom: .55rem; font-variant-numeric: tabular-nums; }
.ksb-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: .6rem; margin-top: .6rem; }
@media (max-width: 640px) { .ksb-row { grid-template-columns: minmax(0, 1fr); } .when label { width: calc(50% - .3rem); } }
details > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .88rem; margin: .5rem 0 .25rem; }
details.why > div { background: var(--bg); border-radius: 8px; padding: .6rem .75rem; font-size: .9rem; }
.statement { border-left: 3px solid var(--accent); padding-left: .65rem; margin: 0 0 .5rem; }
.evidence { list-style: none; padding: 0; margin: .4rem 0; }
.evidence li { margin-bottom: .35rem; }
.evidence q { background: var(--mark); padding: 0 .2rem; border-radius: 3px; }

/* Commentary with highlights: the text is drawn twice, marks behind a transparent textarea. */
.hl-wrap { position: relative; }
.hl-wrap textarea, .hl-backdrop {
  font: inherit; line-height: 1.55; padding: .6rem .7rem; border: 1px solid transparent; border-radius: 8px;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; margin: 0; width: 100%; letter-spacing: normal;
}
.hl-backdrop { position: absolute; inset: 0; color: transparent; pointer-events: none; overflow: hidden; background: var(--bg); border-color: var(--border); }
.hl-backdrop mark { color: transparent; }
.hl-wrap textarea { position: relative; background: transparent; resize: none; overflow: hidden; min-height: 4.5rem; }

.confirm { display: flex; align-items: center; gap: .45rem; font-weight: 600; font-size: .9rem; cursor: pointer; margin-top: .6rem; }
.confirm input { width: auto; }
.concern { background: var(--warn-soft); border-radius: 8px; padding: .45rem .7rem; margin-top: .5rem; font-size: .88rem; }
.term-ask { background: var(--accent-soft); border-radius: 8px; padding: .55rem .7rem; margin-top: .5rem; font-size: .88rem; }
.term-ask .row { margin-top: .35rem; }
.term-ask input { flex: 1; width: auto; min-width: 180px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.fields .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: minmax(0, 1fr); } }
.followup p { font-weight: 600; margin-bottom: .3rem; }
.followups .secondary { margin-top: .25rem; }
.draft-foot { display: flex; justify-content: flex-end; align-items: center; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }
.draft-foot .small { margin-right: auto; }

.checks { list-style: none; padding: 0; margin: .7rem 0 0; display: grid; gap: .35rem; }
.checks li { border-radius: 8px; padding: .4rem .65rem; font-size: .86rem; }
.checks .error { background: var(--bad-soft); color: var(--text); }
.checks .error::before { content: "✕ "; color: var(--bad); font-weight: 700; }
.checks .warn { background: var(--warn-soft); }
.checks .warn::before { content: "! "; color: var(--warn); font-weight: 700; }
.checks .ok { background: var(--good-soft); }
.checks .ok::before { content: "✓ "; color: var(--good); font-weight: 700; }

.dropzone { display: flex; flex-direction: column; align-items: center; gap: .25rem; cursor: pointer; border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem 1rem; margin: 1rem 0; text-align: center; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }

/* ---------- Progress ---------- */
.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat .big { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.gaps-panel .chips { margin-top: .25rem; }
#review-intro { margin: .25rem 0 .75rem; }
#review-progress { margin-top: .75rem; }
#review-progress .bar { height: 10px; }
#review-results { margin-top: .75rem; }
.review-card .head .tag { margin-left: .4rem; }
.review-card textarea { margin-top: .2rem; }
.review-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.review-card.folded { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .5rem .85rem; background: var(--bg); }
.review-card.folded .small { flex: 1 1 14rem; color: var(--muted); }
.review-card.folded .tag { margin-left: 0; }
#epa-progress { margin-top: .75rem; }
#epa-progress .bar { height: 10px; }
#epa-results { margin-top: .75rem; }
.epa-theme { border-top: 1px solid var(--border); padding: .4rem 0; }
.epa-theme > summary { font-size: 1rem; color: var(--text); padding: .5rem 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: baseline; min-height: 44px; }
.epa-theme > summary > span:first-child { font-weight: 700; }
.epa-question { margin: 0 0 .35rem; }
.draft-label { margin: .6rem 0 .3rem; font-size: .85rem; font-weight: 600; color: var(--warn); }
.draft-label .tag { margin-left: 0; margin-right: .35rem; }
.epa-draft { white-space: pre-line; background: var(--field); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: .7rem .8rem; font-size: .95rem; line-height: 1.55; }
.row-ref { display: inline-block; font-size: .75rem; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); border-radius: 6px; padding: 0 .35rem; }
.stat .sub { color: var(--muted); font-size: .82rem; }
.behind .big { color: var(--warn); }
.bar { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; position: relative; margin-top: .4rem; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 999px; }

.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .bar path { fill: var(--accent); }
.chart .bar.on path { fill: color-mix(in srgb, var(--accent) 75%, var(--text)); }
.chart .hit { fill: transparent; }
.chart .target, .chart .target-line { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }
.chart .target-label, .chart .end-label { fill: var(--text); font-size: 11.5px; font-weight: 600; }
.chart .end-label.muted { fill: var(--muted); }
.chart .actual-line { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; }
.chart .end-dot, .chart .hover-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 10px)); pointer-events: none; white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: .8rem; padding: .35rem .55rem; border-radius: 6px; z-index: 2;
}
.chart-table summary { font-size: .8rem; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.chart-table th, .chart-table td { text-align: left; padding: .2rem .4rem; border-bottom: 1px solid var(--border); }
.legend { display: flex; align-items: center; gap: .35rem; color: var(--muted); margin-bottom: .3rem; }
.key-line { display: inline-block; width: 18px; border-top: 2px solid var(--accent); margin-left: .4rem; }
.key-line.dashed { border-top: 2px dashed var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: .4rem; border: 1px solid transparent; }
.dot.none, .ksb.none { background: var(--ksb-none); border-color: var(--ksb-none-edge); }
.dot.low, .ksb.low { background: var(--ksb-low); border-color: var(--ksb-low-edge); }
.dot.ok, .ksb.ok { background: var(--ksb-ok); border-color: var(--ksb-ok-edge); }

.ksb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: .5rem; margin-top: .5rem; }
.ksb { text-align: left; border: 1px solid transparent; border-radius: 8px; padding: .5rem .6rem; font-weight: 400; display: flex; flex-direction: column; gap: .1rem; min-height: 72px; }
.ksb.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.ksb strong { font-size: .95rem; }
.ksb span { font-size: .78rem; color: var(--muted); }
.ksb-detail { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.ksb-detail .item { padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }

.list-item { padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.list-item:last-child { border-bottom: 0; }
.list-item .meta { color: var(--muted); font-size: .8rem; }
.list-item .small-btn { margin-top: .4rem; }
.rewrite-slot .card { margin: .6rem 0 0; }
.amend-head { flex-wrap: nowrap; align-items: flex-start; }
.amend-x { flex: none; width: 40px; height: 40px; min-height: 40px; color: var(--muted); font-size: 1rem; }
.amend-x:hover { color: var(--bad); border-color: var(--bad); }
.amend-item.removed { opacity: .7; }
.feedback { background: var(--warn-soft); border-radius: 6px; padding: .35rem .55rem; margin-top: .3rem; }
.epa-ksb { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.epa-ksb:last-child { border-bottom: 0; }
.epa-item { font-size: .88rem; padding: .3rem 0 .3rem .8rem; border-left: 2px solid var(--border); margin: .3rem 0; }
.duty-list { display: grid; gap: .5rem; }
.duty { display: grid; grid-template-columns: 70px minmax(0, 1fr) 40px; gap: .75rem; align-items: center; font-size: .88rem; }
.duty .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Saved entries & settings ---------- */
.entry-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .85rem 1rem; margin-bottom: .6rem; }
.entry-card .head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-weight: 600; }
.entry-card p { margin: .4rem 0; font-size: .9rem; }
#paste-help { margin: .75rem 0; }
#paste-fallback { margin-bottom: .5rem; font-size: .8rem; }
.glossary { list-style: none; padding: 0; margin: 0 0 .75rem; }
.glossary li { padding: .35rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.glossary-add input { flex: 1; width: auto; min-width: 140px; }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); max-width: calc(100% - 2rem);
  background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 8px; font-size: .9rem; z-index: 10;
}

/* More menu: phones only (on wider screens every tab fits in the row). */
@media (min-width: 768px) { .more-btn, .more-menu { display: none !important; } }

/* ---------- Phone: bottom tab bar (Layout A) ---------- */
@media (max-width: 767px) {
  .topbar { padding: .85rem 1rem .5rem; }
  .brand p { display: none; } /* the standard's title is in Settings > Tracker */
  .wordmark { font-size: 1.6rem; }
  .hours-pill { font-size: .8rem; }
  main { padding: .5rem 1rem calc(var(--nav-h) + 2rem + env(safe-area-inset-bottom)); }
  .panel, .card { padding: 1rem; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; margin: 0; max-width: none;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
    background: var(--panel); border-top: 1px solid var(--border);
  }
  .tabs button {
    flex-direction: column; gap: .15rem; border-radius: 12px; padding: .3rem .2rem; min-height: 52px;
    font-size: .74rem; font-weight: 500;
  }
  .tabs button.active { background: none; color: var(--accent); font-weight: 700; }
  .tabs .count { position: absolute; top: 0; left: calc(50% + 6px); }
  .tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tabs .more-item { display: none; }
  .tabs .more-btn.active { color: var(--accent); font-weight: 700; }
  .more-menu {
    position: fixed; left: .75rem; right: .75rem; bottom: calc(var(--nav-h) + .5rem + env(safe-area-inset-bottom)); z-index: 9;
    display: flex; flex-direction: column; padding: .35rem; gap: .15rem;
    background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(21, 26, 45, .2);
  }
  .tabs .more-menu button { flex-direction: row; justify-content: space-between; font-size: 1rem; font-weight: 600; padding: .75rem 1rem; min-height: 48px; color: var(--text); }
  .tabs .more-menu button.active { background: var(--accent-soft); color: var(--accent-ink); }
  .tabs .more-menu .count { position: static; }
  .toast { bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat { padding: .8rem .85rem; }
  .stat .big { font-size: 1.35rem; }
}

/* ---------- Print: EPA evidence only ---------- */
@media print {
  body.print-epa .topbar, body.print-epa .tabs, body.print-epa .toast,
  body.print-epa #tab-epa > :not(#epa-panel), body.print-epa #epa-print { display: none !important; }
  body.print-epa main { padding: 0; max-width: none; }
  body.print-epa .panel { border: 0; box-shadow: none; }
  body.print-epa .epa-ksb { break-inside: avoid; }
}
