@font-face { font-family: "ReelSubtitle"; src: url("/static/subtitle-font.ttf") format("truetype"); font-display: swap; }
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #777777);
  --card: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #d6453d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, "Segoe UI", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
main { padding: 8px 10px calc(96px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
#title { font-weight: 700; }
.muted { color: var(--hint); font-size: 13px; }
h3 { font-size: 15px; margin: 14px 0 6px; }
button { font: inherit; color: var(--text); background: var(--card); border: 0; border-radius: 9px; padding: 9px 11px; min-height: 40px; touch-action: manipulation; }
button:disabled { opacity: .45; }
button.primary { background: var(--accent); color: var(--accent-text); }
button.danger { background: var(--danger); color: #fff; }
button.big { font-size: 17px; font-weight: 700; flex: 1; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.check { display: block; font-size: 13px; color: var(--hint); }
.clock { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.message { margin: 16px; padding: 14px; border-radius: 10px; background: var(--card); white-space: pre-wrap; }
.message.error { border: 1px solid var(--danger); }

#stage { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-bottom: 4px; }
#frame { position: relative; width: 100%; background: #000; border-radius: 8px; overflow: hidden; }
#video { display: block; width: 100%; height: auto; max-height: 34vh; object-fit: contain; }
.shade { position: absolute; top: 0; bottom: 0; background: rgba(0, 0, 0, .62); pointer-events: none; }
#shade-left { left: 0; }
#shade-right { right: 0; }
#crop-box { position: absolute; top: 0; bottom: 0; border: 2px solid #fff; border-radius: 3px; touch-action: none; cursor: grab; }
#frame.fit .shade, #frame.fit #crop-box { display: none; }
#subtitle { position: absolute; bottom: 6%; left: 0; right: 0; text-align: center; color: #fff; font-family: "ReelSubtitle", sans-serif; font-weight: normal; font-size: 15px; text-shadow: 0 1px 3px #000, 0 0 2px #000; padding: 0 6px; pointer-events: none; white-space: pre-line; }
.waiting { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0, 0, 0, .7); }

#timeline { position: relative; height: 26px; margin-top: 6px; background: repeating-linear-gradient(45deg, #9993, #9993 4px, #9991 4px, #9991 8px); border-radius: 6px; overflow: hidden; direction: ltr; touch-action: none; }
#track .part { position: absolute; top: 0; bottom: 0; background: var(--accent); opacity: .75; }
#track .mark { position: absolute; top: 0; bottom: 0; background: var(--danger); opacity: .55; }
#playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); }

#tabs { display: flex; gap: 6px; margin: 8px 0; }
#tabs button { flex: 1; }
#tabs button.on { background: var(--accent); color: var(--accent-text); }

.cue { background: var(--card); border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.cue.now { outline: 2px solid var(--accent); }
.cue.gone { opacity: .5; }
.cue.gone .cue-text { text-decoration: line-through; }
.cue-head { display: flex; gap: 8px; align-items: baseline; }
.cue-time { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; background: none; padding: 4px 0; min-height: 0; }
.cue-text { flex: 1; unicode-bidi: plaintext; text-align: start; }
.cue-note { color: var(--danger); font-size: 12px; }
.cue textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--hint); border-radius: 8px; padding: 8px; margin-top: 6px; unicode-bidi: plaintext; resize: vertical; }
.cue .times { font-size: 13px; }
.cue .times button { padding: 6px 8px; min-height: 34px; }
.edge { background: var(--card); border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.gap { display: flex; justify-content: space-between; align-items: center; background: var(--card); border-radius: 10px; padding: 6px 10px; margin: 6px 0; }

footer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid #8884; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; z-index: 10; }
footer #dirty { flex-basis: 100%; }
.cue .row button, .edge button, .gap button { background: var(--bg); border: 1px solid #8885; }
.cue .row { margin: 8px 0 0; }
