:root {
  --bg: #121212;
  --fg: #fff;
  --focus: #ff4757;
  --panel: #1a1a1a;
  --field: #222;
  --line: #444;
  --accent: #2ed573;
  --muted: #999;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  min-height: 100vh;
  margin: 0;
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.site-header,
.site-footer,
main { width: 100%; max-width: 720px; }
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 12px;
  border-bottom: 1px solid #262626;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border: 1px solid #2c2c2c;
  border-radius: 9px;
  background: #1e1e1e;
  font: 700 18px/1 var(--mono);
  letter-spacing: -1px;
}
.brand-mark b { color: var(--focus); }
.brand-title { font-size: 1.05rem; font-weight: 600; line-height: 1.15; }
.brand-title small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }
.domain { color: var(--muted); font-size: 13px; text-decoration: none; }
.domain:hover, .site-footer a:hover { color: var(--accent); }

main { display: flex; flex-direction: column; gap: 16px; }
.reader {
  width: 100%;
  height: clamp(80px, 18vw, 120px);
  padding: 0 8px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-top: 2px solid #333;
  border-bottom: 2px solid #333;
  font: clamp(22px, 6vw, 48px)/1 var(--mono);
  white-space: nowrap;
}
.word-left, .word-right { flex: 1 1 0; min-width: 0; overflow: visible; }
.word-left { text-align: right; }
.word-right { text-align: left; }
.word-focus { flex: 0 0 auto; color: var(--focus); font-weight: 700; }

.progress-row { display: flex; align-items: center; gap: 10px; }
.progress-row span { min-width: 3.2em; color: #aaa; font-size: 13px; font-variant-numeric: tabular-nums; }
.progress-row span:last-child { text-align: right; }
input[type="range"] { flex: 1; width: 100%; margin: 0; padding: 0; border: 0; background: transparent; accent-color: var(--accent); cursor: pointer; }

.speed-controls,
.player-buttons { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; }
.speed-controls { gap: 14px; }
.speed-controls label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.speed-controls #longMin { width: 58px; }
.speed-controls input, .speed-controls select { padding: 6px 8px; font-size: 14px; }
.player-buttons { gap: 12px; }
.player-buttons button { width: 140px; }

button, input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
}
button, input, select { padding: 10px; font-size: 16px; }
button { cursor: pointer; background: var(--accent); color: var(--bg); font-weight: 700; }
button.secondary { background: var(--field); color: var(--fg); }
button:hover:not(:disabled) { filter: brightness(1.08); }
button.secondary:hover:not(:disabled) { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { cursor: default; opacity: .5; }
textarea {
  width: 100%;
  min-height: 140px;
  padding: 10px;
  resize: vertical;
  font: 15px/1.45 var(--mono);
}

.text-toolbar { display: flex; align-items: center; gap: 6px; margin-top: -8px; }
button.icon { width: 44px; height: 44px; padding: 9px; display: inline-flex; align-items: center; justify-content: center; }
button.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#toolMessage { margin-left: 6px; color: #aaa; font-size: 13px; }

.estimate { width: auto; border-collapse: collapse; font-size: 13px; }
.estimate td { padding: 3px 14px 3px 0; color: var(--muted); white-space: nowrap; }
.estimate td:last-child { color: var(--fg); text-align: right; font-variant-numeric: tabular-nums; }
.estimate tr.highlight td:last-child { color: var(--accent); font-weight: 700; }

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid #2c2c2c;
  border-radius: 8px;
  background: var(--panel);
}
.settings-card h2 { margin: 0; color: #888; font-size: 13px; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; }
.settings-grid + h2 { padding-top: 14px; border-top: 1px solid #2c2c2c; }
.settings-grid { display: grid; gap: 10px 16px; }
.settings-grid.colors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-grid.size { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-grid label { min-width: 0; display: flex; flex-direction: column; gap: 4px; color: #aaa; font-size: 13px; }
.settings-grid input { width: 100%; min-width: 0; height: 40px; }
input[type="color"] { padding: 2px; }
.export-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 180px)); justify-content: center; gap: 12px; }
.export-grid > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.export-grid button { width: 100%; height: 44px; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.export-grid small { color: #999; font-size: 12px; text-align: center; }
#status { min-height: 1.2em; color: #aaa; font-size: 14px; }

.site-footer {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  border-top: 1px solid #262626;
  color: var(--muted);
  font-size: 12px;
}
.site-footer span:last-child { text-align: right; }
.version { color: #777; font: 11px var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 560px) {
  .domain { display: none; }
  .site-footer { flex-direction: column; align-items: center; text-align: center; }
  .site-footer span:last-child { text-align: center; }
}
@media (max-width: 480px) {
  body { padding-inline: 12px; }
  .speed-controls input, .speed-controls select { min-height: 44px; }
  .settings-grid.colors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .export-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-buttons button { flex: 1 1 0; width: auto; }
  .player-buttons button { min-height: 44px; }
  .brand-title { font-size: .98rem; }
}
