/* Kotoba SRS — mobile-first styles.
   Layout is a fixed bottom tab bar over a scrolling view, sized with dvh and
   safe-area insets so it behaves as an installed phone app. */

:root {
  color-scheme: dark;

  --bg: #0e1117;
  --surface: #161b24;
  --surface-2: #1d2430;
  --surface-3: #262f3d;
  --border: #2a3341;
  --border-strong: #3a4657;
  --text: #e8edf5;
  --text-2: #a4b0c2;
  --text-3: #71809a;

  --accent: #5b83ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(91, 131, 255, 0.16);

  --good: #22a878;
  --good-soft: rgba(34, 168, 120, 0.16);
  --bad: #e05264;
  --bad-soft: rgba(224, 82, 100, 0.16);
  --warn: #dd7f2a;

  /* SRS stage identity — validated for CVD separation and contrast.
     Always paired with a text label, never colour alone. */
  --stage-lesson: #71809a;
  --stage-apprentice: #e8629f;
  --stage-guru: #8b5cf6;
  --stage-master: #2f9fe0;
  --stage-enlightened: #22a878;
  --stage-burned: #dd7f2a;

  --meaning: #e8edf5;
  --reading: #1d2430;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --tap: 48px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP",
    "Noto Sans CJK JP", "MS Gothic", var(--font);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 62px;
}

html[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --surface-3: #e3e8f0;
  --border: #dde2ec;
  --border-strong: #c4ccd9;
  --text: #131922;
  --text-2: #4d5a6d;
  --text-3: #6f7d92;

  --accent: #3559e8;
  --accent-soft: rgba(53, 89, 232, 0.12);
  --good: #12805c;
  --good-soft: rgba(18, 128, 92, 0.12);
  --bad: #c8324a;
  --bad-soft: rgba(200, 50, 74, 0.12);

  --stage-lesson: #6f7d92;
  --stage-apprentice: #d1467f;
  --stage-guru: #7245d4;
  --stage-master: #1f7fbd;
  --stage-enlightened: #11876b;
  --stage-burned: #b0641c;

  --meaning: #131922;
  --reading: #1d2430;

  --shadow: 0 10px 26px rgba(19, 25, 34, 0.1);
}

* { box-sizing: border-box; }

/* Author display rules would otherwise beat the UA sheet's [hidden]. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  overflow-x: clip;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  outline: none;
}

.view.view-full {
  padding-left: 0;
  padding-right: 0;
  max-width: none;
}

/* ------------------------------------------------------------- typography */

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }

.jp { font-family: var(--font-jp); }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.mono { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }
.hidden { display: none !important; }
.spacer { height: 12px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h1 { margin: 0; }

/* ---------------------------------------------------------------- surfaces */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-title h2 { margin: 0; font-size: 1rem; letter-spacing: .01em; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
}
.empty .big { font-size: 2.4rem; margin-bottom: 8px; font-family: var(--font-jp); }

/* ---------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  text-align: center;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: .875rem; border-radius: 10px; }
.btn-lg { min-height: 56px; font-size: 1.05rem; border-radius: 16px; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; min-width: 130px; }

/* ------------------------------------------------------------------ tabbar */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tab {
  flex: 1;
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: none;
}
.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab[aria-current="page"] { color: var(--accent); }
.tab-add svg {
  background: var(--accent);
  fill: var(--accent-ink);
  border-radius: 50%;
  padding: 3px;
  width: 28px;
  height: 28px;
}
.tab-add[aria-current="page"] svg { background: var(--accent); }

/* --------------------------------------------------------------- dashboard */

.hero {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 12px;
}
.hero-greeting { color: var(--text-2); font-size: .9rem; }
.hero-jp { font-family: var(--font-jp); font-size: 1.5rem; margin: 2px 0 14px; }

.queue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.queue-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  min-height: 92px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.queue-btn .n { font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.queue-btn .label { font-size: .82rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.queue-btn.is-ready { border-color: var(--accent); background: var(--accent-soft); }
.queue-btn.is-ready .n { color: var(--accent); }
.queue-btn.is-empty { opacity: .62; }

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
}
.stage-tile {
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--tile, var(--stage-lesson));
  text-decoration: none;
  color: inherit;
  display: block;
}
.stage-tile .n { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stage-tile .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); font-weight: 700; }

.stage-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px; /* 2px surface gap between adjacent fills */
  margin-top: 4px;
}
.stage-bar span { display: block; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--text-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--tile); flex: none; }

/* ---------------------------------------------------------------- forecast */

.forecast {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 2px; /* 2px surface gap between adjacent bars */
  height: 132px;
  margin: 6px 0 4px;
}
.fc-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
  position: relative;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  min-width: 0;
}
.fc-bar {
  background: var(--accent);
  border-radius: 4px 4px 0 0; /* rounded data-end, anchored to the baseline */
  min-height: 2px;
  width: 100%;
}
.fc-col.is-empty .fc-bar { background: var(--surface-3); }
.fc-col.is-now .fc-bar { background: var(--good); }
.fc-val {
  font-size: .62rem;
  color: var(--text-2);
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-height: 1em;
}
.fc-axis {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  font-size: .6rem;
  color: var(--text-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.fc-axis span { overflow: hidden; white-space: nowrap; }
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 34px;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 44px; }
.spark span { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; min-height: 2px; }
.spark span.on { background: var(--accent); }

/* ------------------------------------------------------------------- lists */

/* minmax(0,…) keeps nowrap text from sizing the track to max-content. */
.item-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  min-height: 62px;
}
.item-row:active { background: var(--surface-2); }
.item-chars {
  font-family: var(--font-jp);
  font-size: 1.5rem;
  line-height: 1.2;
  min-width: 2.2em;
  text-align: center;
  flex: none;
}
.item-main { min-width: 0; flex: 1; display: block; }
.item-meaning {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-reading {
  display: block;
  font-family: var(--font-jp);
  font-size: .85rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
  flex: none;
}
.pill-stage { background: color-mix(in srgb, var(--tile) 22%, transparent); color: var(--tile); }
.pill-kanji { background: color-mix(in srgb, var(--stage-apprentice) 20%, transparent); color: var(--stage-apprentice); }
.pill-vocab { background: color-mix(in srgb, var(--stage-guru) 20%, transparent); color: var(--stage-guru); }

.card-chips { display: flex; gap: 6px; flex-direction: column; align-items: flex-end; flex: none; }

/* ------------------------------------------------------------------ inputs */

label, .label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin-bottom: 6px;
}
input[type="text"], input[type="search"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font: inherit;
  padding: 12px 14px;
  border-radius: var(--radius);
  min-height: var(--tap);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
.field { margin-bottom: 16px; }
.field .hint { font-size: .78rem; color: var(--text-3); margin-top: 6px; }

.field-jp input, .field-jp textarea { font-family: var(--font-jp); font-size: 1.05rem; }

.chip-input {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px;
}
.chip-input:focus-within { outline: 2px solid var(--accent); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:not(:empty) { margin-bottom: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  padding: 6px 6px 6px 12px;
  font-size: .9rem;
  max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.jp { font-family: var(--font-jp); }
.chip button {
  appearance: none;
  border: 0;
  background: var(--surface);
  color: var(--text-2);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  flex: none;
}
.chip-entry { display: flex; gap: 8px; align-items: center; }
.chip-entry input { background: transparent; border: 0; min-height: 42px; padding: 6px 6px; }
.chip-entry input:focus { outline: none; }
.chip-add {
  flex: none;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-2);
  border-radius: 10px;
  min-height: 36px;
  padding: 0 12px;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}

.ime-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  text-transform: none;
  min-height: 30px;
}
.ime-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ime-preview {
  font-family: var(--font-jp);
  font-size: .85rem;
  color: var(--text-3);
  margin-top: 6px;
  min-height: 1.2em;
}

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch label { margin: 0; text-transform: none; font-size: .95rem; letter-spacing: 0; color: var(--text); font-weight: 600; }
.switch .hint { font-size: .78rem; color: var(--text-3); font-weight: 400; text-transform: none; letter-spacing: 0; }
.switch input[type="checkbox"] { width: 52px; height: 32px; flex: none; accent-color: var(--accent); }
.switch select, .switch input[type="number"] { width: auto; min-width: 110px; flex: none; }

.upload-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  color: var(--text-2);
  font-size: .9rem;
}
.upload-tile img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; }
.mnemonic-image { width: 100%; border-radius: var(--radius); margin: 10px 0 0; display: block; }

/* ----------------------------------------------------------------- quizzing */

.session {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--safe-bottom) + 8px);
}
.session-top {
  padding: calc(var(--safe-top) + 10px) 14px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.session-count { font-size: .8rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

.prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  text-align: center;
}
.prompt-chars {
  font-family: var(--font-jp);
  font-size: clamp(3.4rem, 22vw, 6rem);
  line-height: 1.1;
  font-weight: 500;
  word-break: break-word;
}
.prompt-type {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 700;
  color: var(--text-3);
}

.answer-band {
  padding: 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.answer-kind {
  text-align: center;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 8px;
  margin: -14px -14px 12px;
  background: var(--surface-3);
  color: var(--text-2);
}
.answer-kind.for-meaning { background: var(--meaning); color: var(--bg); }
.answer-kind.for-reading { background: var(--reading); color: #e8edf5; }

.answer-form { display: flex; gap: 8px; align-items: stretch; }
.answer-input {
  flex: 1;
  font-size: 1.25rem !important;
  text-align: center;
  min-height: 56px;
  border-radius: 14px;
}
.answer-input.for-reading { font-family: var(--font-jp); }
.answer-submit { flex: none; width: 56px; padding: 0; }

.answer-form.is-correct .answer-input { background: var(--good-soft); border-color: var(--good); color: var(--text); }
.answer-form.is-wrong .answer-input { background: var(--bad-soft); border-color: var(--bad); color: var(--text); }
.answer-form.is-nudge .answer-input { animation: shake .3s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.answer-msg { margin-top: 10px; font-size: .9rem; color: var(--text-2); text-align: center; min-height: 1.3em; }
.answer-msg strong { color: var(--text); font-family: var(--font-jp); }
.answer-msg.good { color: var(--good); }
.answer-msg.bad { color: var(--bad); }

.session-actions { display: flex; gap: 8px; margin-top: 10px; }
.session-actions .btn { flex: 1; }

.info-panel {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 16px;
  max-height: 52dvh;
  overflow-y: auto;
}
.info-panel h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 14px 0 4px; }
.info-panel h3:first-child { margin-top: 0; }
.info-panel p { margin: 0 0 4px; }

.summary-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: center; }
.summary-stats .n { font-size: 1.6rem; font-weight: 700; }

/* ------------------------------------------------------------------- detail */

.detail-hero { text-align: center; padding: 18px 0 6px; }
.detail-chars { font-family: var(--font-jp); font-size: clamp(3rem, 18vw, 4.5rem); line-height: 1.1; }
.detail-meanings { font-size: 1.15rem; font-weight: 600; }
.detail-readings { font-family: var(--font-jp); color: var(--text-2); font-size: 1.05rem; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .9rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.card-state {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
}
.card-state .state-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border-left: 4px solid var(--tile, var(--stage-lesson));
}

/* -------------------------------------------------------------------- misc */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: .9rem;
  text-align: center;
}
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }

.modal-host {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(4, 7, 12, .6);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-host[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: min(94vw, 420px);
  box-shadow: var(--shadow);
}
.modal h2 { margin-top: 0; }
.modal .btn-row { margin-top: 16px; }

.search-bar { position: relative; margin-bottom: 12px; }
/* Full-bleed scroller: chips stay inset, but the swipe area reaches the
   screen edges and the overflow never widens the page. */
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 0 16px 4px;
  margin: 0 -16px 12px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
/* Inside a card the row should not bleed past the card's own padding. */
.filter-row.inline { margin: 0; padding: 0 0 4px; }

.filter-chip {
  flex: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
}
.filter-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--text-3); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

.install-hint {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
  font-size: .88rem;
  margin-bottom: 12px;
}

@media (min-width: 620px) {
  .queue-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-state { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
