/* Read — dark quiet focus. Not the Listen board, not the paper journal. */
:root {
  --void: #07080b;
  --raised: #101218;
  --line: #1c2129;
  --ink: #d5dde6;
  --mute: #7a8490;
  --dim: #4b5560;
  --orp: #8ee4c8;
  --hair: rgba(142, 228, 200, 0.28);
  --fill: #8ee4c8;
  --danger: #e8b4a0;
  --tap: 44px;
  --pad: 20px;
  --max: 420px;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--void);
  color: var(--ink);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}
html { min-height: 100%; }
body {
  font-family: var(--sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, .icon, .chip, .btn, .card, .well, .dock, .card-row, .page {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.skip {
  position: absolute;
  left: -999px;
  top: 8px;
}
.skip:focus {
  left: 12px;
  z-index: 20;
  background: var(--raised);
  color: var(--ink);
  padding: 8px 12px;
}
#app {
  max-width: var(--max);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 var(--pad) calc(28px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}
.top { padding: 18px 0 8px; }
.nav {
  display: flex;
  gap: 16px;
  align-items: baseline;
}
.nav a {
  color: var(--mute);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 650;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}
.nav a:hover, .nav a:focus { color: var(--orp); }
.view { padding-bottom: 24px; }
.hero { padding: 12px 0 22px; }
.mark {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--orp);
  font-weight: 700;
}
h1 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 560;
  letter-spacing: -0.035em;
}
.lede {
  margin: 0;
  color: var(--mute);
  font-size: 15.5px;
  max-width: 34em;
}
.shelf-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 10px;
}
.shelf-bar h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 650;
}
.shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.card-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}
.card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 16px 0;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
  min-height: 72px;
  border: 0;
}
.card:hover .card-title, .card:focus-visible .card-title { color: var(--orp); }
.card-title {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.card-src, .card-meta {
  margin: 0;
  font-size: 13px;
  color: var(--mute);
}
.card-meta { color: var(--dim); }
.card-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.icon-x {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 22px;
  border-radius: 10px;
}
.icon-x:hover { color: var(--danger); background: var(--raised); }
.resume {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orp);
  font-weight: 700;
}
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: var(--tap);
  padding: 0 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  background: var(--raised);
}
.btn.primary {
  background: var(--orp);
  color: #08110e;
}
.btn.ghost {
  background: transparent;
  color: var(--mute);
  padding-left: 0;
  padding-right: 10px;
}
.btn.ghost:hover { color: var(--ink); }
.btn.file { position: relative; overflow: hidden; cursor: pointer; }
.btn.file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 16px;
}
.sheet-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}
.import { display: grid; gap: 14px; }
.import label { display: grid; gap: 6px; }
.import label span {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 650;
}
.import em { font-style: normal; color: var(--mute); text-transform: none; letter-spacing: 0; font-weight: 500; }
input, textarea {
  width: 100%;
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
}
textarea { resize: vertical; min-height: 180px; line-height: 1.45; }
.hint, .status, .keys, .reduce-note {
  margin: 0;
  color: var(--mute);
  font-size: 13px;
}
.status { color: var(--orp); }
.status.err { color: var(--danger); }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

.player-view {
  min-height: calc(100dvh - 70px);
  display: flex;
  flex-direction: column;
}
.player-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
}
.now-title {
  margin: 0;
  font-size: 13px;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 220px;
  position: relative;
}
.well {
  position: relative;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0 18px;
  cursor: pointer;
}
.hair {
  position: absolute;
  left: 50%;
  top: 18px;
  bottom: 28px;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--hair) 18%, var(--hair) 82%, transparent);
  pointer-events: none;
}
.word {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  width: 100%;
  font-size: 42px;
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-ligatures: none;
  user-select: none;
}
.pre { text-align: right; color: var(--ink); padding-right: 0; }
.orp {
  color: var(--orp);
  font-weight: 650;
  min-width: 0.62em;
  text-align: center;
  padding: 0 1px;
}
.post { text-align: left; color: var(--ink); }
.chunk-rest {
  margin: 10px 0 0;
  color: var(--mute);
  font-size: 18px;
  text-align: center;
}
.page {
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  padding: 8px 0 18px;
  max-height: 52dvh;
  overflow: auto;
}
.page p { margin: 0 0 0.9em; }
.page .w {
  border-radius: 3px;
}
.page .w.cur {
  background: rgba(142, 228, 200, 0.18);
  color: var(--orp);
  box-shadow: 0 0 0 3px rgba(142, 228, 200, 0.18);
}

.dock {
  padding: 4px 0 8px;
  display: grid;
  gap: 12px;
}
.progress .bar {
  height: 3px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--fill);
}
.meta {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.transport, .speed, .toggles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.icon {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: var(--raised);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon.play {
  width: 64px;
  height: 64px;
  background: var(--orp);
  color: #08110e;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.icon.sm { font-size: 22px; }
.wpm {
  margin: 0;
  min-width: 96px;
  text-align: center;
  color: var(--mute);
  font-size: 13px;
}
.wpm strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.chip {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--mute);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.chip.on {
  border-color: var(--orp);
  color: var(--orp);
}
.keys { text-align: center; }
.keys[hidden] { display: none; }

/* Focus mode: chrome recedes while playing */
body.focus .top,
body.focus #player-chrome,
body.focus #player-dock {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}
body.focus #player-dock { transform: translateY(8px); }
.top, #player-chrome, #player-dock {
  transition: opacity 0.25s ease, transform 0.25s ease;
}
body.focus { cursor: none; }
body.focus .stage { cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  body.focus .top,
  body.focus #player-chrome,
  body.focus #player-dock,
  .top, #player-chrome, #player-dock {
    transition: none;
  }
  .word { font-size: 36px; }
}

@media (max-width: 390px) {
  :root { --pad: 16px; }
  h1 { font-size: 30px; }
  .word { font-size: 36px; }
}

/* Phone/tablet sideways: full-width well, compact dock, extra room for the word */
@media (orientation: landscape) and (hover: none) {
  :root { --pad: 16px; --max: none; }
  #app {
    max-width: none;
    min-height: 100dvh;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .top { padding: 4px 0 0; }
  .nav a { min-height: 36px; }
  .hero { padding: 4px 0 10px; }
  h1 { font-size: 26px; }
  .player-view { min-height: calc(100dvh - 40px); }
  .player-head { min-height: 36px; }
  .stage { min-height: 0; }
  .well {
    min-height: 0;
    padding: 4px 4vw 8px;
  }
  .hair { top: 0; bottom: 4px; }
  .word { font-size: clamp(72px, 12vw, 112px); }
  .page { max-height: 62dvh; }
  .dock {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 20px;
    padding: 0 0 2px;
  }
  .progress { flex: 1 1 100%; }
  .progress .meta { margin: 4px 0 0; }
  .transport, .speed, .toggles { gap: 8px; margin: 0; }
  .icon.play { width: 52px; height: 52px; font-size: 13px; }
  .wpm { min-width: 72px; }
  .wpm strong { font-size: 18px; }
}

@media (orientation: landscape) and (hover: none) and (max-height: 430px) {
  .word { font-size: clamp(64px, 10vw, 96px); }
  .icon.play { width: 48px; height: 48px; }
}

.pile-block {
  margin: 0 0 18px;
}
.pile-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
}
.pile-head h2 {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink, #e8fff4);
}
.pile-sub {
  margin: 0;
  color: var(--muted, #7a8f86);
  font-size: 13px;
}
.pile-block.quiet .pile-sub {
  font-style: italic;
}
.shelf.pile {
  margin-bottom: 4px;
}
.shelf.dusty .card-meta {
  opacity: 0.75;
}
.card .resume-line {
  display: block;
  margin-top: 4px;
  color: var(--mint, #7dffc2);
  font-size: 13px;
  font-weight: 600;
}
