:root {
  --panel: #18181b;
  --line: #2b2b30;
  --fg: #f4f2ee;
  --muted: #9b9ba4;
  --accent: #ffb000;
  --font-ui: "DM Sans", system-ui, sans-serif;
  --font-read: "Noto Sans Telugu", "Nirmala UI", "Gautami", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: #000; color: var(--fg); font: 15px var(--font-ui); }

#app { display: flex; flex-direction: column; height: 100%; background: var(--bg-c, #000); }

.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 10px 14px; background: #000; border-bottom: 1px solid var(--line);
  transition: opacity .25s;
}
.ptitle { flex: 1 0 100%; min-width: 0; user-select: none; }
.ptitle strong { display: block; font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: 500 14px var(--font-ui); color: var(--fg); background: transparent;
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; min-height: 38px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 700; min-width: 92px; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ctl { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.ctl input[type=range] { width: 110px; accent-color: var(--accent); }
.ctl output { color: var(--fg); min-width: 2.4ch; font-variant-numeric: tabular-nums; }
.ctl select { background: #0f0f11; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; font: inherit; }
.sw { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.sw input { accent-color: var(--accent); width: 16px; height: 16px; }
.status { color: var(--accent); font-size: 13px; min-width: 9ch; }

.times { margin-left: auto; display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.times strong { color: var(--fg); font-size: 16px; font-variant-numeric: tabular-nums; }

.progress { height: 4px; background: var(--line); transition: opacity .25s; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: grab; }
.stage.grabbing { cursor: grabbing; }

.scroller { position: absolute; top: 0; left: 0; width: 100%; will-change: transform; }
.text {
  width: min(92%, 1000px); margin: 0 auto;
  font-family: var(--font-read); font-weight: 600; line-height: 1.65;
  white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--fg-c, #fff); user-select: none;
}
.text.mirror { transform: scaleX(-1); }

/* straight line mode: one long line, no wrapping */
.m-horizontal .scroller { width: max-content; }
.m-horizontal .text { width: max-content; margin: 0; white-space: pre; overflow-wrap: normal; }

/* right to left: each word is an isolated unit so word order flows from the right edge */
.w { display: inline-block; unicode-bidi: plaintext; }

.count {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 clamp(96px, 24vw, 260px) var(--font-ui); color: var(--accent);
  background: rgba(0, 0, 0, 0.55); pointer-events: none;
}

/* while playing, controls fade away until the pointer moves */
#app.idle .bar, #app.idle .progress { opacity: 0; pointer-events: none; }
#app.idle .stage { cursor: none; }

@media (max-width: 560px) {
  .times { margin-left: 0; }
  .ctl input[type=range] { width: 90px; }
}
@media (prefers-reduced-motion: reduce) { .bar, .progress { transition: none; } }
