:root {
  --ground: #f4f0ea;
  --ink: #1d1b24;
  --muted: rgba(29, 27, 36, 0.55);
  --line: rgba(29, 27, 36, 0.12);
  --focus: #e5484d;
  --card: rgba(255, 255, 255, 0.72);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(50% 40% at 50% 30%, rgba(255, 196, 170, 0.35), transparent 70%),
    radial-gradient(40% 35% at 80% 90%, rgba(185, 160, 255, 0.18), transparent 70%),
    var(--ground);
  color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.reader { width: min(720px, 100%); display: grid; gap: 14px; }

/* The word sits in a three-column grid, so the red letter is always in the exact center. */
.stage {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  height: 200px;
  padding: 0 28px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--line), 0 30px 60px -36px rgba(60, 40, 30, 0.45);
  cursor: pointer;
  user-select: none;
}

.guide { position: relative; }
.guide::before {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  height: 1px;
  background: var(--line);
}
.guide::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 2px;
  height: 14px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--focus);
  opacity: 0.55;
}
.guide:first-child::before { bottom: 18px; }
.guide:first-child::after { bottom: 4px; }
.guide:last-child::before { top: 18px; }
.guide:last-child::after { top: 4px; }

.word {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  margin: 0;
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
  white-space: pre;
}
.before { text-align: right; }
.focus { color: var(--focus); }

.bar { display: flex; align-items: center; gap: 10px; }

.play, .restart {
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.play { width: 46px; height: 46px; background: var(--ink); color: #fff; }
.play svg { width: 20px; height: 20px; fill: currentColor; }
.play .icon-pause, .reader.is-playing .play .icon-play { display: none; }
.reader.is-playing .play .icon-pause { display: block; }
.restart { width: 38px; height: 38px; background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.restart svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.play:focus-visible, .restart:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

input[type="range"] { accent-color: var(--ink); margin: 0; }
.seek { flex: 1; min-width: 60px; }
.left { flex: none; min-width: 64px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.speed { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.speed input { width: 110px; }
.speed output { min-width: 62px; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }

.paste { display: grid; gap: 6px; transition: opacity 0.3s; }
.reader.is-playing .paste { opacity: 0.45; }
.paste-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 0 4px; }
textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.keys { margin: 0; text-align: center; font-size: 12.5px; color: var(--muted); }

@media (max-width: 560px) {
  .stage { height: 160px; padding: 0 16px; }
  .bar { flex-wrap: wrap; }
  .speed { order: 5; width: 100%; justify-content: space-between; }
  .speed input { flex: 1; }
  .keys { display: none; }
}
