@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: block;
}

:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #888);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #fff);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { padding: 10px 12px 90px; }
[hidden] { display: none !important; }

.msg { padding: 40px 20px; text-align: center; color: var(--hint); white-space: pre-line; }

/* ---------- video stage ---------- */
.stage-wrap { display: flex; justify-content: center; }
.stage { position: relative; background: #000; overflow: hidden; border-radius: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.logo { position: absolute; cursor: grab; outline: 1.5px dashed rgba(255, 255, 255, .7);
  outline-offset: 2px; touch-action: none; }
.logo.dragging, .sub.dragging { cursor: grabbing; }

.sub { position: absolute; left: 6%; right: 6%; text-align: center; cursor: ns-resize;
  touch-action: none; padding: 2px 0; }
.sub::before { content: ""; position: absolute; inset: -4px -2%; border: 1.5px dashed rgba(255, 255, 255, .55);
  border-radius: 6px; pointer-events: none; }
.sub span { font-family: "Vazirmatn", sans-serif; font-weight: 700; color: #fff; line-height: 1.25;
  white-space: pre-wrap; unicode-bidi: plaintext; }
.sub.placeholder span { opacity: .55; }
.sub.style-boxed span { background: rgba(0, 0, 0, .56); padding: 0 .22em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.sub span .hl { color: #ffff00; }

/* ---------- controls ---------- */
.player { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.player input { flex: 1; }
.time { color: var(--hint); font-variant-numeric: tabular-nums; min-width: 3em; text-align: right; }
button.icon { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg2); color: var(--text);
  font-size: 15px; }

section { background: var(--bg2); border-radius: 12px; padding: 10px 12px; margin-top: 12px; }
h3 { margin: 0 0 8px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.toggle { font-weight: 400; color: var(--hint); display: flex; align-items: center; gap: 6px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.seg button { border: 1px solid transparent; background: var(--bg); color: var(--text); border-radius: 18px;
  padding: 6px 12px; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.seg button:disabled { opacity: .4; }

.slider { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.slider input { flex: 1; accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); }

.hint { color: var(--hint); font-size: 13px; margin: 6px 0 0; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: 13px; }

.actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 10px 12px
  calc(10px + env(safe-area-inset-bottom)); background: var(--bg); box-shadow: 0 -1px 0 rgba(0, 0, 0, .08); }
.actions button { flex: 1; border: 0; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 600; }
.primary { background: var(--accent); color: var(--accent-text); }
.secondary { background: var(--bg2); color: var(--text); }
.actions button:disabled { opacity: .5; }
