/* read. — calm, light-first, full-contrast body text, system fonts only */

:root {
  --bg: #fbf8f1;
  --card: #fffdf8;
  --ink: #1b1b1f;
  --soft: #4f5662;
  --line: #e4dfd3;
  --lead: #6b7380;
  --gold: #8a5d0b;
  --gold-soft: #f3e7c9;
  --warn: #8a2a12;
  --warn-bg: #fbe9e2;
  --shadow: 0 1px 2px rgba(40, 32, 12, .06), 0 10px 30px rgba(40, 32, 12, .07);
  --radius: 22px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131419;
    --card: #1b1d23;
    --ink: #f1efe9;
    --soft: #c3c6cd;
    --line: #2d3038;
    --lead: #9aa1ad;
    --gold: #e6bb57;
    --gold-soft: #3a3020;
    --warn: #ffb4a0;
    --warn-bg: #3a1f19;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  overflow-x: hidden;
}
b { font-weight: 700; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* slow ambient drift behind everything */
.drift { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.drift i {
  position: absolute;
  width: 46vmax; height: 46vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .5;
  animation: drift 38s ease-in-out infinite alternate;
}
.drift i:nth-child(1) { left: -12vmax; top: -10vmax; background: radial-gradient(circle, #f4e3b8, transparent 65%); }
.drift i:nth-child(2) { right: -16vmax; top: 18vh; background: radial-gradient(circle, #dfe3ea, transparent 65%); animation-duration: 46s; animation-delay: -12s; }
.drift i:nth-child(3) { left: 20vw; bottom: -24vmax; background: radial-gradient(circle, #efe6d6, transparent 65%); animation-duration: 54s; animation-delay: -25s; }
@media (prefers-color-scheme: dark) {
  .drift i { opacity: .22; }
  .drift i:nth-child(1) { background: radial-gradient(circle, #6b5320, transparent 65%); }
  .drift i:nth-child(2) { background: radial-gradient(circle, #3b4252, transparent 65%); }
  .drift i:nth-child(3) { background: radial-gradient(circle, #4a3d28, transparent 65%); }
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(4vmax, 3vmax, 0) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .drift i { animation: none; }
  .card { transition: none !important; }
}

/* header */
.top { max-width: 760px; margin: 0 auto; padding: 40px 20px 8px; }
.home {
  font: 600 12px/1 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--lead);
  text-decoration: none;
}
.home:hover { color: var(--gold); }
.top h1 {
  margin: 18px 0 6px;
  font: 400 clamp(56px, 11vw, 92px)/.95 var(--serif);
  letter-spacing: -.02em;
}
.top h1 b { font-weight: 700; }
.top h1 .dot { color: var(--gold); }
.lede { margin: 0; font-size: 19px; color: var(--soft); }
.lede b { color: var(--ink); }

/* cards */
main { max-width: 760px; margin: 0 auto; padding: 20px 20px 24px; display: grid; gap: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px 24px;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1), box-shadow .5s;
}
.card:hover { transform: translateY(-2px); }
.label {
  margin: 0 0 14px;
  font: 600 12px/1.2 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--lead);
}

/* tabs */
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); margin-bottom: 16px; }
.tabs button {
  border: 0; background: none; color: var(--soft);
  font: 600 15px/1 var(--sans);
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* drop zone */
.drop {
  display: grid; place-items: center; gap: 4px;
  min-height: 150px; padding: 24px;
  border: 2px dashed var(--line);
  border-radius: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .3s, background .3s;
}
.drop strong { font-size: 20px; font-weight: 600; }
.drop span { color: var(--soft); }
.drop:hover, .drop.over { border-color: var(--gold); background: var(--gold-soft); }
.drop:focus-within { outline: 2px solid var(--gold); outline-offset: 3px; }

.fileinfo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.fi-main { display: grid; min-width: 0; }
.fi-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.fi-name { font-weight: 600; overflow-wrap: anywhere; }
.fi-meta { color: var(--soft); font-size: 15px; }

.msg { margin: 12px 0 0; padding: 12px 14px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.msg.bad { background: var(--warn-bg); border-color: transparent; color: var(--warn); }

.encoding { margin-top: 14px; }
.encoding p { margin: 0 0 8px; }
select, textarea {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
}
.enc-preview { margin: 10px 0 0; padding: 12px; max-height: 160px; overflow: auto; white-space: pre-wrap; background: var(--bg); border-radius: 12px; border: 1px solid var(--line); font: 14px/1.5 var(--mono); }

textarea { width: 100%; resize: vertical; min-height: 140px; line-height: 1.5; }
.preview {
  margin-top: 12px; padding: 14px 16px; min-height: 3em; max-height: 360px; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
  border-radius: 14px; background: var(--bg); border: 1px solid var(--line);
  font-size: 18px; line-height: 1.6;
}
.preview:empty::before { content: "Your converted text shows up here."; color: var(--soft); }

/* buttons */
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
button.primary, a.primary, button.ghost, a.ghost {
  font: 600 16px/1 var(--sans);
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
button.primary, a.primary { background: var(--ink); color: var(--bg); border: 1px solid var(--ink); }
button.primary:hover:not(:disabled), a.primary:hover { background: var(--gold); border-color: var(--gold); color: #fff; }
button.ghost, a.ghost { background: none; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover:not(:disabled), a.ghost:hover { border-color: var(--gold); color: var(--gold); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.big { width: 100%; justify-content: center; padding: 16px; font-size: 18px; }
.hint { color: var(--soft); font-size: 15px; }

/* style menu: one option per line, dotted leader, a short phrase */
.menu { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.menu button {
  width: 100%;
  display: flex; align-items: baseline; gap: 10px;
  padding: 12px 14px;
  border: 1px solid transparent; border-radius: 14px;
  background: none; color: var(--ink);
  font: 17px/1.3 var(--sans); text-align: left; cursor: pointer;
}
.menu button:hover { background: var(--bg); }
.menu button[aria-checked="true"] { background: var(--gold-soft); border-color: var(--gold); }
.menu .key { font: 600 12px/1 var(--mono); color: var(--lead); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.menu .nm { white-space: nowrap; }
.menu .dots { flex: 1; border-bottom: 2px dotted var(--line); transform: translateY(-4px); min-width: 20px; }
.menu .bl { color: var(--soft); white-space: nowrap; }

.tune { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 2px 4px; color: var(--soft); }
.tune > span:first-child { color: var(--ink); font-weight: 600; margin-right: 6px; }
.tune input { flex: 1; min-width: 140px; accent-color: var(--gold); }
.tune-ends { font-size: 14px; }
.tune output { min-width: 3.5em; text-align: right; font: 14px var(--mono); color: var(--soft); }

/* colors */
.colors { margin-top: 18px; display: grid; gap: 10px; }
.color-row { display: flex; align-items: center; gap: 12px; }
.c-name { min-width: 7.5em; font-weight: 600; }
.chip {
  font: 600 14px/1 var(--sans); padding: 8px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: none; color: var(--soft);
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: pointer; }
input[type="color"].off { opacity: .5; }
.warn { margin: 2px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.warn button { font: 600 14px/1 var(--sans); padding: 7px 12px; border-radius: 999px; border: 1px solid currentColor; background: none; color: inherit; cursor: pointer; }
.note { margin: 0; color: var(--soft); font-size: 15px; }

/* the live sample: always on a light "page", like a printed handout */
.sample { margin: 20px 0 0; padding: 18px 20px; border-radius: 16px; background: #ffffff; border: 1px solid var(--line); }
.sample .label { margin-bottom: 10px; color: #5b6470; }
.sample p { margin: 0; color: #1b1b1f; font: 21px/1.55 var(--sans); }
.sample p.pdf b { font-weight: 400; -webkit-text-stroke-color: currentColor; }

/* progress + result */
.progress { margin-top: 16px; display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: center; }
.pbar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width .3s; }
.pbar.busy i { width: 30% !important; animation: busy 1.4s ease-in-out infinite; }
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.status { margin: 0; color: var(--soft); }
.result { margin-top: 16px; }
.summary { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.summary li { padding-left: 1.2em; position: relative; }
.summary li::before { content: "·"; position: absolute; left: .3em; color: var(--gold); font-weight: 700; }
.summary li.head { padding: 0; font-weight: 600; font-size: 18px; }
.summary li.head::before { content: none; }
.summary li.skip { color: var(--soft); }

.about { padding: 8px 6px 0; color: var(--soft); }
.about p { margin: 0 0 10px; }
.about b { color: var(--ink); }

.foot { max-width: 760px; margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; color: var(--lead); font-size: 14px; }

/* speed reader (RSVP) overlay: the page stays faintly visible behind it */
html.rsvp-open { overflow: hidden; }
.rsvp {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.rsvp-card {
  width: min(900px, 100%);
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 16px 22px 20px;
}
.rsvp-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rsvp-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsvp-where { margin-left: auto; color: var(--soft); font-size: 15px; white-space: nowrap; }
.rsvp-x { border: 1px solid var(--line); background: none; color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 15px; flex: none; }
.rsvp-x:hover { border-color: var(--gold); color: var(--gold); }
.rsvp-stage { position: relative; margin: 22px 0 16px; padding: 26px 0; }
/* three columns: the focal letter's column is centered, so it never moves */
.rsvp-word {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline;
  font: 400 clamp(32px, 6.5vw, 58px)/1.2 var(--mono);
  color: var(--ink); white-space: pre;
}
.rsvp-word .pre { text-align: right; }
.rsvp-word .foc { min-width: 1ch; text-align: center; font-weight: 800; color: var(--gold); }
.rsvp-word .suf { text-align: left; }
.rsvp-word b { font-weight: 700; }
.rsvp-word .foc b { font-weight: 800; }
.rsvp-word.long { font-size: clamp(22px, 4.4vw, 42px); }
.tick { position: absolute; left: 50%; width: 2px; height: 16px; background: var(--gold); transform: translateX(-50%); border-radius: 2px; }
.tick.t { top: 0; }
.tick.b { bottom: 0; }
.rsvp-bar { height: 4px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.rsvp-bar i { display: block; height: 100%; width: 0; background: var(--gold); }
.rsvp-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 16px; }
.rsvp-play { min-width: 8.5em; justify-content: center; }
.rsvp-speed { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 220px; color: var(--soft); }
.rsvp-speed input { flex: 1; accent-color: var(--gold); }
.rsvp-wpm { min-width: 5.5em; text-align: right; font: 14px var(--mono); }
kbd { font: 600 11px/1 var(--mono); border: 1px solid currentColor; border-radius: 5px; padding: 2px 5px; margin-left: 8px; opacity: .75; }
.rsvp-help { margin: 12px 0 0; color: var(--soft); font-size: 14px; }
::highlight(rsvp) { background-color: var(--gold-soft); color: inherit; }

@media (max-width: 560px) {
  .rsvp-help { display: none; }
  .rsvp-card { padding: 14px 14px 16px; }
  .top { padding-top: 28px; }
  .card { padding: 18px 16px 20px; border-radius: 18px; }
  .menu .bl { white-space: normal; }
  .menu .dots { display: none; }
  .menu button { flex-wrap: wrap; }
  .c-name { min-width: 0; flex: 1; }
}
