:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #e5484d;
  --accent-dim: #b33a3e;
  --focus: #4f8ef7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header { text-align: center; padding: 2rem 1rem 1rem; }
header h1 { margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
header h1 span { color: var(--accent); }
.tagline { color: var(--muted); margin: 0.4rem 0 0; font-size: 0.95rem; }

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem;
}

.input-panel { display: flex; flex-direction: column; gap: 0.75rem; }

#url-form { display: flex; gap: 0.5rem; }
#url-input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
}
#url-input:focus { outline: 2px solid var(--focus); outline-offset: -1px; }

button {
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { background: #1e222b; border-color: #3a4150; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  min-width: 3.5rem;
  font-size: 1.15rem;
}
button.primary:hover { background: var(--accent-dim); }
button:disabled { opacity: 0.5; cursor: default; }

#paste-panel summary { color: var(--muted); cursor: pointer; padding: 0.25rem 0; }
#text-input {
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
  resize: vertical;
}
#load-text-btn { padding: 0.5rem 1rem; }

.status { min-height: 1.2em; margin: 0; font-size: 0.9rem; color: var(--muted); }
.status.error { color: #ff7a7e; }

.hidden { display: none; }

.reader { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

.article-meta { text-align: center; }
.article-meta h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.article-meta p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; }

.rsvp-window {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.rsvp-window .guide {
  position: absolute;
  left: 50%;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: var(--border);
}
.word-row {
  display: flex;
  align-items: baseline;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: pre;
}
.word-row .part:first-child {
  width: 50vw;
  max-width: 350px;
  text-align: right;
  overflow: hidden;
}
.word-row .part:last-child {
  width: 50vw;
  max-width: 350px;
  text-align: left;
  overflow: hidden;
}
.pivot { color: var(--accent); }

.progress-wrap { display: flex; flex-direction: column; gap: 0.35rem; }
.progress-bar {
  height: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.1s linear;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
}

.controls { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.controls button { min-width: 3rem; }

.wpm-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  justify-content: center;
}
.wpm-row label { color: var(--muted); font-size: 0.9rem; }
.wpm-row input[type="range"] { flex: 1; max-width: 380px; accent-color: var(--accent); }
.wpm-row output {
  min-width: 3.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

footer { text-align: center; padding: 1rem; color: var(--muted); font-size: 0.8rem; }

@media (max-width: 600px) {
  .word-row { font-size: 1.9rem; }
  .rsvp-window { height: 140px; }
}
