/* read. — RSVP reader
   A warm, paper-like reading surface. One accent. One job. */

:root {
  --bg: #faf7f1;
  --surface: #fefdfb;
  --surface-2: #f3eee3;
  --ink: #1a1a1a;
  --ink-soft: #3a3733;
  --muted: #75716a;
  --muted-2: #a09a90;
  --border: #e8e2d4;
  --border-strong: #d8d0bd;
  --accent: #c9433a;
  --accent-soft: rgba(201, 67, 58, 0.12);
  --shadow: 0 1px 2px rgba(28, 22, 10, 0.04), 0 8px 24px rgba(28, 22, 10, 0.06);
  --shadow-lg: 0 12px 40px rgba(28, 22, 10, 0.18);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --duration: 140ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Cascadia Mono", monospace;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* The user-selected reader typeface. Defaults to sans. */
  --font-reader: var(--font-sans);
  --font-reader-weight: 500;
  /* Natural tracking. Negative tracking at large sizes makes glyphs collide. */
  --font-reader-tracking: 0;
  /* Reader text-size multiplier — adjustable via the topbar A−/A+ buttons. */
  --font-reader-scale: 1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0e0c;
    --surface: #181614;
    --surface-2: #211e1a;
    --ink: #f1ece2;
    --ink-soft: #d8d2c5;
    --muted: #8a857c;
    --muted-2: #5e5a52;
    --border: #2a2622;
    --border-strong: #38322c;
    --accent: #e85d50;
    --accent-soft: rgba(232, 93, 80, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 14px 50px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 4%, transparent), transparent 60%),
    radial-gradient(900px 400px at 50% 110%, color-mix(in srgb, var(--ink) 4%, transparent), transparent 60%);
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--ink); }

/* ───────── App layout ───────── */

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px;
  gap: 18px;
}

/* ───────── Topbar ───────── */

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
  user-select: none;
}
.brand__dot { color: var(--accent); }

.progress {
  position: relative;
  height: 4px;
  background: var(--border);
  border: 0;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  width: 100%;
  overflow: hidden;
  transition: height var(--duration) var(--ease);
}
.progress:hover, .progress:focus-visible { height: 6px; outline: none; }
.progress__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--ink);
  transition: width 80ms linear;
}

.topbar__meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.meta__sep { color: var(--muted-2); margin: 0 1px; }
.meta__bullet { color: var(--muted-2); }

/* ───────── Stage / Reader ───────── */

.stage {
  display: grid;
  place-items: center;
  position: relative;
  min-height: 0;
}

.reader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  width: 100%;
  max-width: 900px;
  padding: 24px 8px;
  user-select: none;
}

.reader__guide {
  width: 1px;
  height: 14px;
  background: var(--ink);
  opacity: 0.35;
}
@media (prefers-color-scheme: dark) {
  .reader__guide { opacity: 0.4; }
}

.word {
  display: grid;
  grid-template-columns: 1fr min-content 1fr;
  /* Real gap between segments — survives any font size. */
  column-gap: 0.06em;
  align-items: baseline;
  width: 100%;
  font-family: var(--font-reader);
  font-weight: var(--font-reader-weight);
  font-size: calc(clamp(36px, 7vw, 64px) * var(--font-reader-scale));
  letter-spacing: var(--font-reader-tracking);
  /* Slightly looser line-height to accommodate tall ascenders at 300%. */
  line-height: 1.15;
  color: var(--ink);
  /* Ascenders/descenders can clip on tight boxes at big sizes. */
  padding: 0.08em 0;
  transition: font-size 160ms var(--ease);
}

/* Allow the before/after segments to extend past their grid column when the
   word is too long for the viewport. The ORP stays dead-centered; the rest
   of the word just runs toward the screen edges. The body's overflow:hidden
   provides the outer clip. */
.word__before {
  text-align: right;
  white-space: nowrap;
  overflow: visible;
  min-width: 0;
}
.word__orp {
  text-align: center;
  color: var(--accent);
  white-space: nowrap;
}
.word__after {
  text-align: left;
  white-space: nowrap;
  overflow: visible;
  min-width: 0;
}

.reader__status {
  /* Fixed box keeps the word vertically pinned across play/pause/idle. */
  margin-top: 22px;
  min-height: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: opacity 200ms var(--ease);
}
.reader__status .hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.005em;
}
.reader__status .hint__sep {
  color: var(--muted-2);
  letter-spacing: 0;
}
.reader__status kbd {
  font-size: 10.5px;
  padding: 0 5px;
  height: 18px;
  min-width: 18px;
  border-bottom-width: 1.5px;
}
/* During play, fade the hint but keep the box's layout. */
.app.is-playing .reader__status { opacity: 0; }
.app.is-finished .reader__status { opacity: 0; }

/* ───────── Control panel (floats below the word when paused/idle) ───────── */

.panel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 22px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(28, 22, 10, 0.04), 0 6px 20px rgba(28, 22, 10, 0.06);
  transition: opacity 220ms var(--ease), transform 260ms var(--ease);
  /* Allow it to render over the status line on tight layouts. */
  position: relative;
  z-index: 1;
}
.app.is-playing .panel {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}
.app.is-finished .panel { display: none; }

.panel__sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}
.panel__group {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.panel__btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.panel__btn:hover { background: var(--surface-2); color: var(--ink); }
.panel__btn:active { transform: scale(0.96); }
.panel__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.panel__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.panel__btn--micro { width: 30px; height: 30px; }

.panel__primary {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: filter var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.panel__primary:hover { filter: brightness(1.1); }
.panel__primary:active { transform: scale(0.98); }
.panel__primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.typeface-glyph {
  font-family: var(--font-reader);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1;
  display: inline-block;
  transform: translateY(-0.5px);
}

/* Typeface popover */
.popover-anchor {
  position: relative;
  display: inline-flex;
}
.popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  min-width: 168px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(28, 22, 10, 0.06), 0 12px 32px rgba(28, 22, 10, 0.14);
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: rise 160ms var(--ease);
}
.popover[hidden] { display: none; }
.popover__option {
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.popover__option:hover { background: var(--surface-2); }
.popover__option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.popover__sample {
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-align: center;
}
.popover__label {
  color: var(--ink-soft);
}
.popover__option.is-current {
  background: var(--surface-2);
}
.popover__option.is-current .popover__label {
  color: var(--ink);
  font-weight: 500;
}
.popover__option.is-current::after {
  content: '';
  /* tiny accent dot at the right */
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: auto;
  grid-column: 2;
  justify-self: end;
  align-self: center;
}

.popover__divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

.popover__section {
  padding: 4px 10px 8px;
}
.popover__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.popover__section-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.popover__reset {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.popover__reset:hover { background: var(--surface-2); color: var(--ink); }

/* Generic slider (shared with wpm__slider styling) */
.slider {
  --fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background:
    linear-gradient(to right,
      var(--ink) 0%, var(--ink) var(--fill),
      var(--border) var(--fill), var(--border) 100%);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-runnable-track { height: 3px; background: transparent; }
.slider::-moz-range-track { height: 3px; background: transparent; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
  box-shadow: 0 0 0 2px var(--surface), 0 1px 2px rgba(0,0,0,0.18);
  cursor: grab;
  transition: transform 120ms var(--ease);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.12); }
.slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.05); }
.slider::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
  box-shadow: 0 0 0 2px var(--surface), 0 1px 2px rgba(0,0,0,0.18);
  cursor: grab;
}
.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--accent-soft);
}
.slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--accent-soft);
}
.size-glyph {
  font-family: var(--font-reader);
  font-weight: 500;
  line-height: 1;
  display: inline-block;
  color: currentColor;
}
.size-glyph--small { font-size: 11px; transform: translateY(0.5px); }
.size-glyph--large { font-size: 16px; transform: translateY(-0.5px); }

/* ───────── Done / completed state ───────── */

.done {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  max-width: 520px;
  text-align: center;
  animation: rise 220ms var(--ease);
}
.done[hidden] { display: none; }

.done__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 6px;
}
.done__title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.done__stats {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.done__stats b {
  color: var(--ink);
  font-weight: 600;
}
.done__sep { color: var(--muted-2); }
.done__actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

/* ───────── Controls ───────── */

.controls {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 8px 0 6px;
}

.controls__row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ctrl {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.ctrl:hover { background: var(--surface-2); color: var(--ink); }
.ctrl:active { transform: scale(0.96); }
.ctrl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctrl:disabled { opacity: 0.4; cursor: not-allowed; }

.ctrl--play {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  margin: 0 6px;
}
.ctrl--play:hover { background: var(--ink); color: var(--bg); filter: brightness(1.08); }
.ctrl--play .ctrl__pause-icon { display: none; }
.app.is-playing .ctrl--play .ctrl__play-icon { display: none; }
.app.is-playing .ctrl--play .ctrl__pause-icon { display: inline; }

.ctrl--ghost {
  color: var(--muted);
}

/* WPM slider */

.wpm {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-width: 260px;
  max-width: 440px;
  width: 100%;
  justify-self: end;
}
.wpm__label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.wpm__value {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-soft);
  min-width: 70px;
  text-align: right;
}
.wpm__unit { color: var(--muted); }

/* Filled track via gradient — JS keeps --fill in sync with the value. */
.wpm__slider {
  --fill: 30%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background:
    linear-gradient(to right,
      var(--ink) 0%,
      var(--ink) var(--fill),
      var(--border) var(--fill),
      var(--border) 100%);
  outline: none;
  cursor: pointer;
}
.wpm__slider::-webkit-slider-runnable-track {
  height: 3px;
  background: transparent;
}
.wpm__slider::-moz-range-track {
  height: 3px;
  background: transparent;
}
.wpm__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
  /* halo so the thumb reads as raised against the track */
  box-shadow: 0 0 0 2px var(--bg), 0 1px 2px rgba(0,0,0,0.18);
  cursor: grab;
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease);
}
.wpm__slider::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}
.wpm__slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.05);
}
.wpm__slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
  box-shadow: 0 0 0 2px var(--bg), 0 1px 2px rgba(0,0,0,0.18);
  cursor: grab;
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease);
}
.wpm__slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent-soft);
}
.wpm__slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent-soft);
}

/* ───────── Sheet (modal) ───────── */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}
.sheet[hidden] { display: none; }

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 180ms var(--ease);
}

.sheet__panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: min(720px, 90vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise 200ms var(--ease);
}
.sheet--small .sheet__panel { width: min(440px, 100%); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.sheet__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.sheet__tabs {
  display: flex;
  gap: 4px;
  padding: 12px 18px 0;
}
.tab {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.is-active { background: var(--ink); color: var(--bg); }

.sheet__body { padding: 14px 18px; overflow-y: auto; flex: 1; }

.tab-panel[hidden] { display: none; }

#pasteArea {
  width: 100%;
  min-height: 220px;
  max-height: 50vh;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
#pasteArea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 8%, transparent);
}

.sheet__hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 36px 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease), color var(--duration) var(--ease);
  text-align: center;
}
.dropzone:hover, .dropzone.is-hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--surface-2);
}
.dropzone__icon { color: var(--ink-soft); margin-bottom: 4px; }
.dropzone__title { font-size: 14px; color: var(--ink); }
.dropzone__hint { font-size: 12px; }

.urlrow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
#urlInput {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  font-size: 14px;
}
#urlInput:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 8%, transparent);
}

.sheet__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.985); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary {
  background: var(--ink);
  color: var(--bg);
}
.btn--primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn--secondary {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--border);
}
.btn--secondary:hover:not(:disabled) { border-color: var(--border-strong); }
.btn--ghost { color: var(--muted); }
.btn--ghost:hover { color: var(--ink); background: var(--surface-2); }

/* ───────── Keyboard shortcuts list ───────── */

.kbds {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  column-gap: 18px;
  row-gap: 10px;
  margin: 4px 0;
}
.kbds dt { display: flex; gap: 4px; flex-wrap: wrap; }
.kbds dd { margin: 0; color: var(--ink-soft); font-size: 14px; align-self: center; }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
}

/* Callout (used in the shortcuts sheet for the URL-path tip) */
.callout {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
}
.callout__label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
}
.callout__text {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.callout__text code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--ink);
  white-space: nowrap;
}

/* ───────── Toast ───────── */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  box-shadow: var(--shadow);
  animation: rise 180ms var(--ease);
}
.toast[hidden] { display: none; }

/* ───────── Responsive ───────── */

@media (max-width: 640px) {
  .app { padding: 14px 14px 12px; gap: 12px; }
  .topbar { gap: 12px; }
  .topbar__meta { font-size: 11px; }
  .controls { grid-template-columns: 1fr; gap: 12px; padding-top: 4px; }
  .controls__row { justify-self: center; }
  .wpm { min-width: 0; width: 100%; max-width: 100%; justify-self: center; }
  .ctrl { width: 42px; height: 42px; }
  .ctrl--play { width: 52px; height: 52px; }
  .word { font-size: clamp(32px, 9vw, 48px); }
  .sheet { padding: 12px; }
  .reader__status { font-size: 11.5px; gap: 6px; }
  .reader__status kbd { font-size: 10px; }
  .panel__primary span { display: none; }
  .panel__primary { padding: 0 11px; }
  .done__actions { flex-direction: column; }
  .done__actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
