#app {
  --focus: #d93036;
  --guide: #cfcdc3;
  --on-accent: #ffffff;
}

@media (prefers-color-scheme: dark) {
  #app {
    --focus: #ef5b60;
    --guide: #3a403c;
    --on-accent: #0d0f0e;
  }
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* Buttons and inputs */

.btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

textarea {
  display: block;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--inset);
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hint {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Home */

.card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.card h2 {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.home-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 1rem;
  margin-top: 1.75rem;
}

@media (max-width: 760px) {
  .home-grid {
    grid-template-columns: 1fr;
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.status {
  min-height: 1.4em;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  margin: 0.25rem 0 0;
  color: var(--focus);
  font-size: 0.9rem;
  font-weight: 500;
}

.privacy {
  margin-top: 1.5rem;
}

/* Reader */

.reader-top {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.reader-title {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage {
  position: relative;
  height: 11rem;
  margin-top: 1.25rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.guide {
  position: absolute;
  right: 1.5rem;
  left: 1.5rem;
  height: 0;
  border-top: 1.5px solid var(--guide);
}

.guide.top {
  top: calc(50% - 3.25rem);
}

.guide.bottom {
  top: calc(50% + 3.25rem);
}

/* Ticks pointing at the focus letter's column (42% across the stage). */
.guide::after {
  content: "";
  position: absolute;
  left: calc((100% + 3rem) * 0.42 - 1.5rem);
  width: 1.5px;
  height: 0.75rem;
  background: var(--guide);
}

.guide.top::after {
  top: 0;
}

.guide.bottom::after {
  bottom: 0;
}

.word {
  position: absolute;
  top: 50%;
  left: 42%;
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  font-weight: 500;
  line-height: 1;
  white-space: pre;
  transform: translateY(-50%);
}

/* The focus letter sits on the anchor; the rest of the word hangs off either side. */
.word .focus {
  position: relative;
  display: inline-block;
  color: var(--focus);
  transform: translateX(-50%);
}

.word .pre,
.word .post {
  position: absolute;
  top: 0;
  color: var(--fg);
}

.word .pre {
  right: 100%;
}

.word .post {
  left: 100%;
}

.context {
  position: relative;
  height: 15rem;
  margin-top: 1rem;
  padding: 0 0.5rem;
  overflow-y: auto;
  line-height: 1.85;
}

.context p {
  max-width: 44rem;
  margin: 0 auto 1.1rem;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.context p.dim {
  color: var(--muted);
  opacity: 0.75;
}

.context .w {
  cursor: pointer;
}

.context .w:hover {
  color: var(--accent);
}

.context .w.cur {
  color: var(--focus);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.playing .context,
.playing .context-hint {
  visibility: hidden;
}

.context-hint {
  margin-top: 0.4rem;
  text-align: center;
}

.controls {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

#seek {
  display: block;
  width: 100%;
  margin: 0 0 1rem;
  accent-color: var(--focus);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

#play {
  min-width: 5.5rem;
}

.speed {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.75rem;
}

.speed .mono {
  min-width: 4.6rem;
  text-align: center;
  font-size: 0.9rem;
}

.progress {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.keys {
  margin-top: 1rem;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  border: 2px solid var(--focus);
  border-radius: 14px;
  margin: 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  font-size: 1.5rem;
  font-weight: 600;
  pointer-events: none;
}

@media (max-width: 520px) {
  .progress {
    width: 100%;
    margin-left: 0;
  }

  .speed {
    margin-left: 0;
  }
}
