/* AutoMiner — shared design system (UI v2, Chris redesign 2026-09-07)
   Ink-blue ground (AniList-adjacent) with layered card surfaces; the
   app's own status vocabulary (new/reviewing/gold/rejected/exported)
   still supplies the color vocabulary, and every literal data value
   (timestamps, counts, scores, ids) still sets in tabular mono.
   Every class UI v1 shipped keeps working — pages restyle for free. */

:root {
  /* ground + surfaces */
  --bg: #0b111c;
  --bg-deep: #080d15;
  --panel: #121a29;          /* v1 name, v2 value: card surface */
  --panel-raised: #182236;
  --panel-top: #1e2a42;
  --border: rgba(148, 170, 205, 0.13);
  --border-strong: rgba(148, 170, 205, 0.24);
  --border-soft: rgba(148, 170, 205, 0.09);
  --text: #e7edf7;
  --text-dim: #94a2ba;
  --text-faint: #5c6a83;

  /* status vocabulary — unchanged semantics, tuned values */
  --gold: #e2ab4c;
  --gold-dim: #a17b34;
  --gold-soft: rgba(226, 171, 76, 0.14);
  --teal: #4fc9bf;
  --teal-dim: #3f8b85;
  --teal-soft: rgba(79, 201, 191, 0.13);
  --red: #e56b64;
  --red-soft: rgba(229, 107, 100, 0.12);
  --orange: #e0964f;
  --orange-soft: rgba(224, 150, 79, 0.13);
  --ok: #6fbf73;
  --violet: #a99aff;
  --violet-soft: rgba(155, 140, 255, 0.14);

  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "Inter", -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", Roboto, "Noto Sans JP", sans-serif;
  --font-jp: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", var(--font-sans);
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code",
    "Consolas", "Roboto Mono", monospace;
  --rail-w: 200px;
  /* Issue #54: spacing + type tokens; the phone breakpoint below
     re-tunes these instead of restyling each block. */
  --pad-x: 32px;
  --pad-y: 18px;
  --fs-body: 13.5px;
  --fs-h1: 21px;
  --tabbar-h: 58px;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  background: var(--bg);
  color: var(--text);
}

body { background: var(--bg); color: var(--text); }

.skip-link {
  position: absolute; left: 8px; top: -48px;
  background: var(--gold); color: #241704; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm);
  z-index: 100; transition: top 0.12s ease;
}
.skip-link:focus { top: 8px; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(226, 171, 76, 0.35); }

a { color: inherit; }

.mono, .num, td.num, .stat-value, time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- app shell: left rail + scrollable content --------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.rail {
  width: var(--rail-w);
  flex: 0 0 var(--rail-w);
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.rail-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  padding: 6px 10px 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.rail-brand .dot { color: var(--gold); }

.rail-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }

.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.12s ease, background 0.12s ease;
}
.rail-link svg { width: 16px; height: 16px; opacity: 0.75; flex: 0 0 auto; }

.rail-link:hover { color: var(--text); background: var(--panel); }

.rail-link.active {
  color: var(--text);
  background: var(--panel-raised);
  font-weight: 600;
}
.rail-link.active svg { opacity: 1; color: var(--gold); }

.rail-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.rail-foot .pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(111, 191, 115, 0.15); flex: 0 0 auto;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: var(--pad-y) var(--pad-x);
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.app-header h1 {
  font-size: var(--fs-h1);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.app-header .sub { color: var(--text-faint); font-size: 12.5px; }

.app-body {
  padding: 8px var(--pad-x) 60px;
  max-width: 1120px;
  width: 100%;
  /* UI v2 fix (Chris): centered column; a .fluid page (Today) has no
     max-width, so the auto margins are a no-op there. */
  margin: 0 auto;
}

/* wide screens: pages that opt in (today) can go fluid */
.app-body.fluid, .app-header.fluid { max-width: none; }

/* ---------- primitives ------------------------------------------------ */

h2.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 32px 0 12px;
}
h2.section-title:first-child { margin-top: 0; }
h2.section-title .en {
  font-size: 11px; color: var(--text-faint); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; margin-left: 8px;
}

.hint { color: var(--text-dim); font-size: 12px; }

button, a.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  transition: background 0.13s ease, border-color 0.13s ease, transform 0.08s ease;
}
button:hover, a.btn:hover { background: var(--panel-top); }
button:active, a.btn:active { transform: translateY(1px); }
button.primary, a.btn.primary {
  background: linear-gradient(180deg, #eebb60, #d99c35);
  border-color: transparent; color: #241704; font-weight: 600;
  box-shadow: 0 1px 8px rgba(226, 171, 76, 0.28);
}
button.primary:hover, a.btn.primary:hover { background: linear-gradient(180deg, #f3c470, #e2a743); }
button.danger, a.btn.danger {
  background: transparent; border-color: rgba(229, 107, 100, 0.45);
  color: var(--red); font-weight: 500;
}
button.danger:hover, a.btn.danger:hover { background: var(--red-soft); }
button.ghost, a.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
button.ghost:hover, a.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button.small, a.btn.small { padding: 4px 10px; font-size: 12px; }

input[type=text], input[type=number], input[type=search], input[type=date],
input[type=password], input[type=file], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}
label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
label.checkbox-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim); cursor: pointer; margin-bottom: 0;
}
label.checkbox-label input { width: auto; touch-action: manipulation; }

/* ---------- cards (v2) ------------------------------------------------ */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.15s ease;
}
.card:hover { border-color: var(--border-strong); }

.panel-title {
  font-size: 12px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.panel-title .jp { text-transform: none; letter-spacing: 0; color: var(--text-dim); font-size: 13px; }
.panel-title .spacer { flex: 1; }

/* ledger rows: card rows with hairline separation ---------------------- */

.ledger { display: flex; flex-direction: column; gap: 10px; }
.ledger-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left-width: 3px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ledger-row.clickable { cursor: pointer; }
.ledger-row.clickable:hover,
.ledger-row[role="link"]:hover { background: var(--panel-raised); border-color: var(--border-strong); }
.ledger-row.accent-gold { border-left-color: var(--gold); }
.ledger-row.accent-red { border-left-color: var(--red); }
.ledger-row.accent-orange { border-left-color: var(--orange); }
.ledger-row.accent-teal { border-left-color: var(--teal); }
.ledger-empty {
  padding: 28px 14px; color: var(--text-dim); font-size: 13px;
  background: var(--panel); border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.ledger-empty.err { color: var(--red); }

.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-clamp: 2; overflow: hidden; text-overflow: ellipsis; word-break: break-word; }

/* media thumbnails (v2): YouTube mq thumbs / placeholder tiles --------- */

.thumb {
  width: 106px; height: 60px; flex: 0 0 106px;
  border-radius: 8px; object-fit: cover; display: block;
  background: var(--panel-top);
}
.thumb.ph {
  display: grid; place-items: center; color: var(--text-faint);
}
.thumb.ph svg { width: 20px; height: 20px; }

/* badges ---------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 2.5px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--panel-raised);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.teal { background: var(--teal-soft); color: var(--teal); }
.badge.ok { background: rgba(111, 191, 115, 0.13); color: var(--ok); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }

/* stat tiles: cards with big mono numerals ------------------------------ */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label {
  font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600;
}
.stat-label .jp { text-transform: none; letter-spacing: 0; font-weight: 500; }
.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 30px; font-weight: 700; line-height: 1.15;
  letter-spacing: -0.02em;
}
.stat-value.gold { color: var(--gold); }
.stat-value.teal { color: var(--teal); }
.stat-value .unit { font-size: 14px; color: var(--text-dim); font-weight: 400; margin-left: 4px; }

/* streak heat strip (today) */
.heat { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.heat i { width: 13px; height: 13px; border-radius: 3.5px; background: var(--panel-top); }
.heat i.on { background: var(--gold); box-shadow: 0 0 6px rgba(226, 171, 76, 0.4); }
.heat i.today { outline: 1.5px solid rgba(226, 171, 76, 0.7); outline-offset: 1.5px; }

/* bars (source activity, pipeline) --------------------------------------- */

.bar-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.bar-label { width: 96px; flex: 0 0 96px; font-size: 12px; color: var(--text-dim); }
.bar-track { flex: 1; height: 6px; background: var(--panel-top); border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--teal); border-radius: 3px; }
.bar-fill.gold { background: var(--gold); }
.bar-value { width: 64px; flex: 0 0 64px; text-align: right; font-size: 11.5px;
  color: var(--text-faint); font-family: var(--font-mono); }

/* side cards (today's responsive 2-col) --------------------------------- */

.tg-grid { display: block; }
.tg-side { min-width: 0; margin-top: 26px; }
details.side-card { margin-bottom: 14px; }
details.side-card > summary {
  cursor: pointer; list-style: none; user-select: none;
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
details.side-card > summary::-webkit-details-marker { display: none; }
details.side-card > summary .jp {
  text-transform: none; letter-spacing: 0; color: var(--text-dim); font-size: 12.5px;
}
details.side-card > summary::after {
  content: "▾"; color: var(--text-faint); font-size: 10px; transition: transform 0.15s ease;
}
details.side-card:not([open]) > summary::after { transform: rotate(-90deg); }
details.side-card > .side-body { margin-top: 12px; }

@media (min-width: 1400px) {
  .app-body.fluid .tg-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) 296px;
    gap: 26px; align-items: start;
  }
  .app-body.fluid .tg-side { position: sticky; top: 18px; margin-top: 0; }
  .app-body.fluid details.side-card > summary { pointer-events: none; }
  .app-body.fluid details.side-card > summary::after { display: none; }
}

/* toast + activity dock -------------------------------------------------- */

.toast {
  position: fixed; bottom: 20px; right: 20px;
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 13px; max-width: 400px; z-index: 50;
  border: 1px solid transparent;
}
.toast.ok { background: #14301f; color: var(--ok); border-color: rgba(111, 191, 115, 0.35); }
.toast.err { background: #331413; color: #f19a95; border-color: rgba(229, 107, 100, 0.45); }

#activity-dock {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  width: 300px; max-width: calc(100vw - 40px);
  pointer-events: none;
}
#activity-dock > * { pointer-events: auto; }
#activity-dock .toast { position: static; max-width: none; }

.activity {
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 10px 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.activity-row { display: flex; align-items: center; gap: 8px; }
.activity-label { flex: 1; font-size: 13px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-pct { font-family: var(--font-mono); font-size: 12px; color: var(--gold); }
.activity-sub { font-size: 11px; color: var(--text-dim); margin: 4px 0 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-sub:empty { display: none; }
.activity-bar { height: 4px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.10); overflow: hidden; }
.activity-bar i { display: block; height: 100%; border-radius: 3px;
  background: var(--gold); transition: width .4s ease; }
.activity-bar.indeterminate i { width: 40% !important; animation: activity-sweep 1.1s ease-in-out infinite; }
@keyframes activity-sweep {
  0% { transform: translateX(-100%); } 100% { transform: translateX(250%); }
}
.activity.done .activity-bar i { background: var(--ok); }
.activity.failed .activity-bar i { background: var(--red); }
.activity.failed .activity-pct { color: #f19a95; }

.activity-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: var(--gold);
  animation: activity-spin .8s linear infinite; }
.activity-dot.ok { border: 2px solid var(--ok); animation: none; }
.activity-dot.bad { border: 2px solid var(--red); animation: none; }
@keyframes activity-spin { to { transform: rotate(360deg); } }

/* modal ------------------------------------------------------------------ */

.modal-bg {
  position: fixed; inset: 0; background: rgba(5, 8, 14, 0.72);
  display: none; align-items: flex-start; justify-content: center;
  padding: 4vh 16px; z-index: 40; overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 14px; padding: 20px 24px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.modal h2 { font-size: 15px; margin: 0 0 14px; }
.modal .row { display: flex; gap: 12px; align-items: center; }
.field-group { margin-bottom: 16px; }

/* filters ---------------------------------------------------------------- */

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px 0; margin-bottom: 4px;
}
.filters label { margin: 0 0 5px; }
.filters .field { display: flex; flex-direction: column; gap: 0; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.toggle input { width: auto; }

/* issue #114 (follow-up): the dashed "not wired yet" block on Settings is a
   card heading with a ? like every other block there, so the rule that
   styled it is gone rather than left behind unused. */

/* --- shared list furniture ------------------------------------------- */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px 16px;
  margin-bottom: 16px;
}
details.panel > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "▸"; color: var(--text-dim); margin-left: auto; }
details.panel[open] > summary::after { content: "▾"; }
details.panel > summary .sub { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.panel-body { margin-top: 14px; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 20px;
  max-width: 720px;
}
.settings-grid .field-group { margin-bottom: 0; min-width: 0; }
.settings-grid input:not([type=checkbox]):not([type=radio]),
.settings-grid select,
.settings-grid textarea { width: 100%; }
/* overflow-wrap: an error string is one long unbreakable token (a URL, a
   JSON body) and pushed the Settings page sideways on a 360px phone (#59) */
.status-line { font-size: 12px; color: var(--text-dim); margin-top: 6px; overflow-wrap: anywhere; }
.status-line.err { color: var(--red); }
.status-line.ok { color: var(--ok); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* filter chips (UI.chips) */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 8px; }
.chip {
  display: inline-flex; gap: 6px; align-items: baseline;
  padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--text-dim); font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: all 0.13s ease;
}
.chip:hover { background: var(--panel-raised); color: var(--text); }
.chip .n { font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 11.5px; color: var(--text); opacity: 0.85; }
.chip.active { border-color: rgba(226, 171, 76, 0.5); color: var(--gold); background: var(--gold-soft); }
.chip.active .n { color: var(--gold); }
.chip.red.active { border-color: rgba(229, 107, 100, 0.5); color: var(--red); background: var(--red-soft); }
.chip.red.active .n { color: var(--red); }
.chip.orange.active { border-color: rgba(224, 150, 79, 0.5); color: var(--orange); background: var(--orange-soft); }
.chip.orange.active .n { color: var(--orange); }

/* pager */
.pager { display: flex; align-items: center; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.pager .grow { flex: 1; }
.pager .page-num { font-family: var(--font-mono); color: var(--text-dim); font-size: 12px; }

/* a severity/section header inside a ledger */
.group-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 16px 4px 6px; font-size: 12px; color: var(--text-dim);
  font-weight: 600;
}
.group-head .n { font-family: var(--font-mono); color: var(--text-faint); }
.group-head.red { color: var(--red); }
.group-head.orange { color: var(--orange); }

/* --- job progress ----------------------------------------------------- */

.job-progress { margin-top: 6px; font-size: 11px; color: var(--text-dim); }
.job-progress:empty { display: none; }
.job-line { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.job-stage { flex: 0 0 auto; color: var(--text); }
.job-kind { flex: 0 0 auto; color: var(--text-faint); }
.job-msg { flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.job-count { flex: 0 0 auto; }
.job-bar {
  flex: 1 1 120px; min-width: 60px; height: 3px; border-radius: 2px;
  background: var(--panel-top); overflow: hidden; position: relative;
}
.job-bar-fill {
  display: block; height: 100%; width: 0; border-radius: 2px;
  background: var(--teal); transition: width 0.3s ease;
}
.job-bar.indeterminate .job-bar-fill {
  width: 30%; animation: job-slide 1.4s ease-in-out infinite;
}
@keyframes job-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(333%); }
}
.job-line.settled .job-bar-fill { background: var(--ok); }
.job-line.settled.failed .job-stage { color: var(--red); }
.job-line.settled.failed .job-bar-fill { background: var(--red); }

/* --- v2: note-field rows + source tags (queue editor) ------------------ */

.frow { padding: 10px 0; border-bottom: 1px solid var(--border); }
.frow:last-child { border-bottom: 0; }
.frow .fhead { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.frow .fname { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint);
  word-break: break-all; }
.frow .fval { display: block; font-size: 13px; line-height: 1.55; }
.frow .fval input, .frow .fval textarea { width: 100%; }
.frow .fval.mono { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
  word-break: break-all; }
.ftag {
  flex: 0 0 auto; font-size: 9.5px; font-weight: 600; padding: 1.5px 7px;
  border-radius: 999px;
}
.ftag.yo { background: var(--violet-soft); color: var(--violet); }
.ftag.am { background: var(--gold-soft); color: var(--gold); }
.ftag.clip { background: var(--teal-soft); color: var(--teal); }
details.fmore > summary {
  cursor: pointer; list-style: none; font-size: 11.5px; color: var(--text-faint);
  padding: 8px 0 2px; user-select: none;
}
details.fmore > summary:hover { color: var(--text); }
details.fmore > summary::-webkit-details-marker { display: none; }

/* rendered definition (Yomitan / Jitendex) */
.defn-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.defn-word { font-size: 22px; font-weight: 700; font-family: var(--font-jp); }
.defn-read { font-size: 13px; color: var(--text-dim); }
.pitch-chip {
  font-family: var(--font-mono); font-size: 10px; padding: 1.5px 7px; border-radius: 5px;
  background: var(--violet-soft); color: var(--violet);
}
.pitch-chip.dim { background: var(--panel-top); color: var(--text-dim); }
.defn-body { margin-top: 10px; font-size: 13px; line-height: 1.7; max-height: 260px; overflow-y: auto; }
.defn-src { margin-top: 10px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); }

/* --- shared wide-content container (issue #54) ------------------------- */
/* Anything that must stay wider than a phone (a table, a timeline)
   scrolls inside this instead of pushing the page sideways. */
.scroll-x {
  max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}

/* --- bottom tab bar (issue #54; rendered by initShell) ----------------- */
.tabbar { display: none; }
.tab {
  flex: 1 1 0; min-width: 0; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 4px 2px; border: 0; background: none; font-family: inherit;
  border-radius: var(--radius-sm); color: var(--text-dim); text-decoration: none;
  font-size: 10.5px; font-weight: 500; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.tab svg { width: 20px; height: 20px; opacity: 0.75; }
.tab.active { color: var(--text); background: var(--panel-raised); font-weight: 600; }
.tab.active svg { opacity: 1; color: var(--gold); }
.tab-editor { display: none; }
body:has(#wordModal.open) .tab-editor { display: flex; }

/* --- responsive -------------------------------------------------------- */

@media (max-width: 880px) {
  /* 61 = 8px padding each side + 1px border + a 44px link (issue #59:
     landscape phones keep this rail and every link must be a 44px target) */
  :root { --rail-w: 61px; }
  .rail { padding: 14px 8px; }
  .rail-brand { padding: 0 0 14px; text-align: center; font-size: 0; }
  .rail-brand .dot { font-size: 24px; line-height: 1; }
  .rail-link { justify-content: center; padding: 10px; font-size: 0; gap: 0; }
  .rail-link svg { width: 19px; height: 19px; }
  .rail-foot { justify-content: center; padding: 12px 0 4px; }
  .rail-foot span:last-child { display: none; }
  :root { --pad-x: 16px; --pad-y: 14px; }
  .app-body { padding-top: 4px; padding-bottom: 48px; }
  .thumb { width: 88px; height: 50px; flex-basis: 88px; }
}

/* phones: rail -> bottom tab bar, tighter tokens, everything wraps ------ */
@media (max-width: 719.98px) {
  :root { --pad-y: 12px; --fs-body: 14px; --fs-h1: 19px; }
  .rail { display: none; }
  .tabbar {
    display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: var(--bg-deep); border-top: 1px solid var(--border);
    padding: 6px calc(8px + env(safe-area-inset-right))
      calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  }
  .app-header { padding-left: calc(var(--pad-x) + env(safe-area-inset-left));
    padding-right: calc(var(--pad-x) + env(safe-area-inset-right)); }
  .app-body {
    padding-left: calc(var(--pad-x) + env(safe-area-inset-left));
    padding-right: calc(var(--pad-x) + env(safe-area-inset-right));
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  }
  #activity-dock, .toast {
    right: 12px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  }
  .modal-bg { padding: 12px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }
  .modal { padding: 16px; }
  .stat-value { font-size: 26px; }
  h2.section-title { margin-top: 24px; }
  .ledger-row { gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
  .bar-label { width: 72px; flex-basis: 72px; }
  .bar-track { min-width: 0; }

  /* issue #58: stat tiles two-up, media rows as stacked cards */
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; min-width: 0; }
  /* .ledger-row.today-row: outranks the page's own .today-row { align-items: center },
     which today.html loads after this sheet. */
  .ledger-row.today-row { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px; }
  .today-row .thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; flex-basis: auto; }
  .today-actions { padding-right: 0; }
  .today-actions > * { flex: 1 1 auto; }

  /* issue #58: audit finding cards — badges on their own line, actions
     as a two-column tap grid, the config panel as a bottom sheet */
  .f-badges { margin-left: 0; flex-basis: 100%; }
  .f-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f-actions button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .filters .field { flex: 1 1 140px; }
  .filters .field select { width: 100%; }
  #configPanel[open] {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; margin: 0;
    max-height: 85vh; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 16px 16px 0 0; box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.6);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  body:has(#configPanel[open])::after {
    content: ""; position: fixed; inset: 0; z-index: 45; background: rgba(5, 9, 16, 0.6);
  }
  #configPanel .settings-grid { grid-template-columns: minmax(0, 1fr); }

  /* issue #58: settings — one column, every field the full width */
  .field-group { max-width: none !important; }
  .set-panel input:not([type=checkbox]):not([type=radio]),
  .set-panel select, .set-panel textarea { width: 100%; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

/* touch: 44px targets, 8px gaps (issue #54) ------------------------------ */
@media (pointer: coarse) {
  button, a.btn, .chip, .rail-link, .tab, select, textarea,
  input:not([type=checkbox]):not([type=radio]),
  details > summary, label.checkbox-label, .toggle,
  label:has(> input[type=checkbox]), label:has(> input[type=radio]) { min-height: 44px; }
  button, a.btn, .icon-btn, .play-btn, .cal-nav, .ctx-grow { min-width: 44px; min-height: 44px; }
  /* Plain text links: a 44px box that still sits on its line of prose. */
  a[href]:not(.btn):not(.rail-link):not(.tab) {
    display: inline-flex; align-items: center; min-width: 44px; min-height: 44px;
    margin-top: -12px; margin-bottom: -12px;
  }
  .skip-link { margin: 0; }
  .cal-d { min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; margin: 0 4px; }
  /* iOS zooms into any field under 16px on focus */
  input, select, textarea { font-size: 16px !important; }
  .actions, .pager, .chip-row, .filters, .rail-nav, .audio-tools,
  .src-actions, .f-actions, .today-actions, .word-chips, .ed-tabs { gap: 8px; }
}

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

/* ---------- help popovers + the page-level save bar (issue #114) --------
   Settings used to print a paragraph of prose above every field and carry
   a 保存 button per field. The prose is unchanged — it moved behind a "?"
   that opens it on hover, on keyboard focus and on tap (UI.initHelp wires
   the tap and Escape) — and the buttons collapsed into one .save-bar that
   writes whatever changed. Chris' follow-up put the section summaries and
   the descriptive tail of every label behind the same "?", so what a page
   shows in the open is the setting's TITLE and its control. All of it
   lives here, not in settings.html's own <style>, because any page with a
   form can use it. */

.label-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.label-row label { margin-bottom: 0; }

.help { position: relative; display: inline-block; vertical-align: middle; line-height: 1; }

.help-btn {
  width: 18px; height: 18px; min-width: 0; min-height: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--panel-raised); color: var(--text-dim);
  font-size: 11px; font-weight: 700; line-height: 1;
}
.help-btn:hover, .help.open > .help-btn {
  background: var(--gold-soft); color: var(--gold); border-color: var(--gold-dim);
}

.help-text {
  display: none;
  position: absolute; z-index: 60; top: calc(100% + 8px); left: 0;
  width: min(420px, calc(100vw - 48px));
  padding: 11px 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel-top); box-shadow: 0 14px 38px rgba(0, 0, 0, 0.5);
  color: var(--text-dim); font-size: 12px; font-weight: 400; line-height: 1.7;
  letter-spacing: 0; text-align: left; white-space: normal;
}
.help-text code { font-family: var(--font-mono); font-size: 11.5px; color: var(--text); }
.help-text strong { color: var(--text); font-weight: 600; }
.help-text ul { margin: 6px 0 0; padding-left: 18px; }
.help:hover > .help-text,
.help:focus-within > .help-text,
.help.open > .help-text { display: block; }

.save-bar {
  position: sticky; bottom: 0; z-index: 44;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 18px; padding: 12px 0;
  border-top: 1px solid var(--border); background: var(--bg);
}
.save-bar .status-line { margin-top: 0; }
.save-bar .grow { flex: 1; }

@media (max-width: 719.98px) {
  /* clear of the fixed tab bar, and the popover becomes a bottom sheet so
     a "?" on the right edge can never push the page sideways */
  .save-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .help-text {
    position: fixed; top: auto; left: 12px; right: 12px; width: auto;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 68px);
    max-height: 45vh; overflow-y: auto; overscroll-behavior: contain;
  }
}

@media (pointer: coarse) {
  /* keep the help trigger finger-friendly on touch devices */
  .help-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 14px; }
}
