/* صدى · Echo Type
 * المفهوم: مسرح مظلم يضيئه زمرّد متوهّج، يتحوّل إلى أحمر درامي في المقاطع الحماسية.
 * التخطيط: عمود المسرح (فيديو ← سطر الكتابة ← الشريط المرن ← الإحصاءات ← الليونة) + عمود جانبي للأسطر.
 */


*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }

body {
  /* الألوان */
  --acc: #2bffa0;
  --acc2: #12c98b;
  --deep: #04402a;
  --tint: #010805;
  --bg: #010302;
  --panel: color-mix(in srgb, var(--deep) 14%, rgba(4, 8, 6, 0.93));
  --panel-solid: #030b07;
  --stroke: color-mix(in srgb, var(--acc) 14%, transparent);
  --stroke-2: color-mix(in srgb, var(--acc) 34%, transparent);
  --glow: color-mix(in srgb, var(--acc) 55%, transparent);
  --text: #e6fff3;
  --muted: #8aac9d;
  --faint: #52705f;
  --ghost: rgba(205, 255, 232, 0.25);
  --on-acc: #01150c;
  --danger: #ff4d61;
  --amber: #ffc04d;
  --r: 18px;
  /* الخطوط */
  --ui: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;

  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  color-scheme: dark;
}
/* انتقال لوني خفيف: خصائص لون عادية على عناصر محددة فقط، لمرة واحدة عند تغيّر اللون */
.btn, .chip, .seg-switch button, .mode, .panel, .stage, .screen, .elastic, .stat,
.rate, .tl-time, .state-dot, .el-fill, .caret, .brand-mark, .ly, .swatch {
  transition-property: color, background-color, border-color, opacity, transform;
  transition-duration: 0.6s;
  transition-timing-function: ease;
}

/* ------------------------------------------------ الجو العام */
.aura { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; background: var(--tint); }
.aura i { position: absolute; border-radius: 50%; }
.aura i:nth-child(1) {
  width: 80vmax; height: 80vmax; left: -10vmax; top: -40vmax;
  background: radial-gradient(circle, rgba(4, 64, 42, 0.95) 0%, transparent 62%);
}
.aura i:nth-child(2) {
  width: 60vmax; height: 60vmax; right: -20vmax; bottom: -25vmax;
  background: radial-gradient(circle, rgba(43, 255, 160, 0.11) 0%, transparent 60%);
}
.aura i:nth-child(3) {
  width: 46vmax; height: 46vmax; left: 30vw; top: 30vh;
  background: radial-gradient(circle, rgba(18, 201, 139, 0.07) 0%, transparent 60%);
}
.aura { background: #010805; contain: strict; }
/* طبقتا لون ثابتتان تتبادلان الظهور بـ opacity فقط (تعمل على كرت الشاشة) */
.wash { position: absolute; inset: 0; opacity: 0; transition: opacity 1.1s ease; will-change: opacity; }
.wash.on { opacity: 1; }
.veil { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 35%, transparent 35%, rgba(0, 0, 0, 0.72) 100%); }
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.035; contain: strict;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ------------------------------------------------ عناصر أساسية */
button, input, select, textarea { font: inherit; color: inherit; }
kbd {
  font-family: var(--mono); font-size: 11.5px; line-height: 1; padding: 3px 6px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--stroke-2); border-bottom-width: 2px; color: var(--text);
  direction: ltr; display: inline-block;
}
code { font-family: var(--mono); font-size: 0.92em; color: var(--acc); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ltr { direction: ltr; text-align: left; }
[hidden] { display: none !important; }

.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--stroke-2); background: rgba(255, 255, 255, 0.025); color: var(--text);
  font-family: var(--ui); font-weight: 500; font-size: 14px; line-height: 1.2;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.25s, transform 0.08s, color 0.2s;
}
.btn:hover { border-color: var(--acc); box-shadow: 0 0 22px -8px var(--glow); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .chip:focus-visible, .fire:focus-visible, .play-orb:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.primary { background: var(--acc); color: var(--on-acc); border-color: transparent; font-weight: 700; box-shadow: 0 0 26px -8px var(--glow); }
.btn.primary:hover { box-shadow: 0 0 34px -6px var(--glow); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.icon { width: 38px; height: 38px; padding: 0; }
.btn.icon.xs { width: 28px; height: 28px; font-size: 11px; }
.btn.on { background: color-mix(in srgb, var(--acc) 18%, transparent); border-color: var(--acc); box-shadow: 0 0 20px -8px var(--glow); }
.btn.danger:hover { border-color: var(--danger); box-shadow: 0 0 20px -8px rgba(255, 77, 97, 0.7); color: #ffd9de; }
.btn kbd { margin-inline-start: 4px; }

.inp {
  width: 100%; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--stroke-2); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.inp:focus { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 16%, transparent); }
.inp::placeholder { color: var(--faint); }
.inp.bad { border-color: var(--danger); }
select.inp, .sel { width: auto; padding: 7px 30px 7px 12px; border-radius: 999px; cursor: pointer; background-color: rgba(255, 255, 255, 0.03); }
select option { background: var(--panel-solid); color: var(--text); }

/* ------------------------------------------------ الشريط العلوي */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding-block: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px), 3vw);
  padding-right: max(16px, env(safe-area-inset-right, 0px), 3vw);
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; color: var(--acc); filter: drop-shadow(0 0 10px var(--glow)); flex: none; }
.brand-name { font-weight: 700; font-size: 21px; display: flex; align-items: baseline; gap: 10px; line-height: 1.2; }
.brand-name .latin { font-family: var(--display); font-weight: 700; font-size: 12px; letter-spacing: 0.34em; color: var(--acc); text-shadow: 0 0 14px var(--glow); }
.brand-sub { font-size: 12.5px; color: var(--muted); }
.now { margin-inline: auto; text-align: center; min-width: 0; }
.now-label { font-size: 11px; color: var(--faint); letter-spacing: 0.04em; }
.now-title {
  font-family: var(--display), var(--ui); font-weight: 700; font-size: 18px; letter-spacing: 0.14em;
  color: var(--text); text-shadow: 0 0 22px var(--glow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw;
}
.top-actions { display: flex; gap: 10px; }

/* ------------------------------------------------ التخطيط */
.layout {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px;
  max-width: 1400px; margin: 0 auto;
  padding-block: 22px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px), 3vw);
  padding-right: max(16px, env(safe-area-inset-right, 0px), 3vw);
}
.stage-col, .side-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.side-col { position: sticky; top: 16px; align-self: start; }

/* ------------------------------------------------ الفيديو */
.screen {
  position: relative; aspect-ratio: 16 / 9; max-width: 100%; border-radius: var(--r); overflow: hidden; background: #000;
  border: 1px solid var(--stroke-2);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 34px 90px -36px var(--glow), inset 0 0 70px rgba(0, 0, 0, 0.6);
}
.screen::before {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 58%, color-mix(in srgb, var(--acc) 26%, transparent) 100%);
  will-change: opacity; transition: opacity 0.8s;
}
body[data-themed="1"] .screen::before { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.85; } }
.screen-host, .screen-host > *, .screen-host iframe, .screen-host video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
.screen-host video { object-fit: contain; }
.screen-shield { position: absolute; inset: 0; z-index: 2; cursor: text; }
.screen::after {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 3px),
    linear-gradient(to top, rgba(0, 0, 0, 0.62), transparent 30%);
}
.hud { position: absolute; z-index: 4; inset-inline: 14px; bottom: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 999px; font-size: 12.5px;
  background: rgba(0, 0, 0, 0.72); border: 1px solid var(--stroke-2);
}
.pill.src { margin-inline-start: auto; color: var(--muted); }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 10px var(--acc); flex: none; }
.hud[data-phase="grace"] .state-dot { background: var(--acc2); }
.hud[data-phase="decel"] .state-dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.hud[data-phase="waiting"] .state-dot, .hud[data-phase="ready"] .state-dot, .hud[data-phase="done"] .state-dot { background: #7c9a8c; box-shadow: none; animation: breathe 1.6s ease-in-out infinite; }
.hud[data-phase="ahead"] .state-dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: breathe 0.9s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.3; } }
.rate { font-family: var(--mono); font-weight: 600; font-size: 14px; color: var(--acc); font-variant-numeric: tabular-nums; min-width: 4.2ch; text-align: center; }
.loop-pill { color: var(--acc); }
.momentum { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, 0.06); }
.momentum > i {
  will-change: transform;
  display: block; height: 100%; width: 100%; transform-origin: right center; transform: scaleX(0);
  background: linear-gradient(to left, var(--acc), var(--acc2)); box-shadow: 0 0 12px var(--acc);
}
.momentum > i.slow { background: linear-gradient(to left, var(--amber), var(--acc2)); }

.overlay {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; text-align: center; padding: 20px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.86));
  transition: opacity 0.45s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.ov { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 520px; }
.ov-kicker { font-family: var(--display); font-size: 12px; letter-spacing: 0.36em; color: var(--acc); text-transform: uppercase; }
.ov-title { font-family: var(--display), var(--ui); font-weight: 700; font-size: clamp(24px, 4vw, 46px); line-height: 1.1; letter-spacing: 0.1em; text-shadow: 0 0 34px var(--glow); text-wrap: balance; }
.ov-title.sm { font-size: clamp(20px, 2.6vw, 28px); letter-spacing: 0.04em; }
.ov-sub { color: var(--muted); font-size: 14.5px; text-wrap: balance; }
.ov-meta { font-size: 12.5px; color: var(--faint); }
.ov-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.ov-stats { display: flex; gap: 26px; margin: 6px 0; }
.ov-stats b { display: block; font-family: var(--mono); font-size: 30px; font-weight: 600; color: var(--acc); text-shadow: 0 0 18px var(--glow); }
.ov-stats span { font-size: 12px; color: var(--muted); }
.play-orb {
  width: 86px; height: 86px; border-radius: 50%; border: 1px solid var(--acc); color: var(--acc); cursor: pointer;
  background: radial-gradient(circle, color-mix(in srgb, var(--acc) 26%, transparent), transparent 70%);
  display: grid; place-items: center; margin: 6px 0;
  box-shadow: 0 0 44px -8px var(--glow), inset 0 0 22px -6px var(--glow);
  transition: transform 0.2s; position: relative;
}
.play-orb::after {
  content: ''; position: absolute; inset: -14px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, transparent 52%, color-mix(in srgb, var(--acc) 30%, transparent) 62%, transparent 72%);
  will-change: opacity; animation: orb 2.6s ease-in-out infinite;
}
.play-orb:hover { transform: scale(1.06); }
@keyframes orb { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
.overlay.hidden .play-orb::after, .overlay.hidden .spinner { animation: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--stroke-2); border-top-color: var(--acc); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ مسرح الكتابة */
.stage {
  position: relative; overflow: hidden; cursor: text;
  border: 1px solid var(--stroke); border-radius: var(--r);
  background: linear-gradient(180deg, color-mix(in srgb, var(--deep) 26%, rgba(2, 5, 4, 0.9)), rgba(1, 4, 3, 0.94));
  padding: 20px clamp(16px, 3vw, 34px) 24px;
  transition: border-color 1.2s;
}
.stage::before {
  content: ''; position: absolute; inset-inline: 8%; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--acc), transparent); opacity: 0.75;
}
.stage-in { text-align: left; }
.l-prev, .l-next {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.6em;
}
.l-prev { color: color-mix(in srgb, var(--acc) 38%, #34483f); margin-bottom: 10px; }
.l-next { color: var(--faint); margin-top: 12px; }
.l-cur {
  position: relative; min-height: 3.8em;
  font-family: var(--mono); font-weight: 500; font-size: clamp(18px, 2.15vw, 28px); line-height: 1.85;
  color: var(--ghost);
}
.l-text { position: static; }
.l-cur .word { display: inline-block; white-space: nowrap; }
.ch { transition: color 0.12s, text-shadow 0.2s; border-radius: 3px; }
.ch.punct { color: rgba(205, 255, 232, 0.16); }
.ch.cur { color: rgba(230, 255, 242, 0.62); }
.ch.sp.cur { background: color-mix(in srgb, var(--acc) 12%, transparent); }
.stage { --heat: 0; }
.ch.done { color: color-mix(in srgb, var(--acc) 30%, #ffffff); text-shadow: 0 0 calc(6px + 12px * var(--heat)) var(--glow); }
.ch.auto { opacity: 0.5; }
.ch.err { color: var(--danger) !important; text-shadow: 0 0 14px rgba(255, 77, 97, 0.85); background: rgba(255, 77, 97, 0.14); }
.caret {
  position: absolute; left: 0; top: 0; width: 2px; height: 1.3em; border-radius: 2px; pointer-events: none; z-index: 2;
  background: var(--acc); box-shadow: 0 0 8px var(--acc), 0 0 calc(18px + 14px * var(--heat)) var(--glow);
  transition: transform 0.11s cubic-bezier(0.22, 0.9, 0.3, 1), height 0.2s, background-color 0.6s;
  will-change: transform;
}
.caret.snap { transition: none; }
.caret.idle { animation: blink 1.1s ease-in-out infinite; }
.caret.miss { animation: miss 0.3s ease; background: var(--danger); box-shadow: 0 0 12px var(--danger); }
@keyframes blink { 0%, 45% { opacity: 1; } 60%, 90% { opacity: 0.15; } 100% { opacity: 1; } }
@keyframes miss { 25% { translate: -3px 0; } 50% { translate: 3px 0; } 75% { translate: -2px 0; } }
.l-cur.sweep::after {
  content: ''; position: absolute; inset: -6px -20px; pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--acc) 28%, transparent), transparent);
  animation: sweep 0.65s ease-out forwards;
}
@keyframes sweep { from { transform: translateX(-100%); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
.type-input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; pointer-events: none; }
.stage-empty { display: none; color: var(--faint); text-align: center; padding: 18px 0; }
.stage.empty .stage-in { display: none; }
.stage.empty .stage-empty { display: block; }
.focus-veil {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(1, 4, 3, 0.66); color: var(--muted);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.stage.blurred .focus-veil { opacity: 1; pointer-events: auto; }

/* ------------------------------------------------ الشريط المرن */
.elastic { padding: 12px 18px 12px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--panel); }
.el-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.drift { font-variant-numeric: tabular-nums; color: var(--text); }
.el-track { position: relative; height: 28px; direction: ltr; margin: 4px 7px 0; }
.el-rail { position: absolute; left: 0; right: 0; top: 50%; height: 2px; translate: 0 -50%; background: rgba(255, 255, 255, 0.08); border-radius: 2px; }
.el-fill { position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: color-mix(in srgb, var(--acc) 35%, transparent); border-radius: 2px; transform-origin: left center; transform: scaleX(0); will-change: transform; transition: none; }
.el-band { position: absolute; left: 0; width: 100%; top: 50%; height: 4px; margin-top: -2px; border-radius: 4px; background: var(--acc); transform-origin: left center; transform: scaleX(0); will-change: transform; transition: background-color 0.3s; }
.el-band[data-s="warn"] { background: var(--amber); }
.el-band[data-s="far"] { background: var(--danger); }
.el-mark { position: absolute; left: -6px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; will-change: transform; }
.el-mark.you { background: var(--acc); box-shadow: 0 0 12px var(--acc); }
.el-mark.song { border: 2px solid var(--text); background: var(--bg); }
.el-legend { display: flex; gap: 18px; font-size: 12px; color: var(--faint); }
.el-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--faint); }
.elastic:not(.live) .el-band, .elastic:not(.live) .el-mark, .elastic:not(.live) .live-only { display: none; }
.elastic:not(.live) .el-fill { height: 3px; margin-top: -1.5px; background: var(--acc); }
.phase-label { color: var(--text); font-weight: 500; }
.el-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.lg.you { background: var(--acc); }
.lg.song { border: 2px solid var(--text); }

/* ------------------------------------------------ الإحصاءات والتحكم */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--stroke); border-radius: 14px; background: var(--panel); padding: 10px 14px; min-width: 0; }
.stat b { display: block; font-family: var(--mono); font-size: 23px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.loop-group { display: inline-flex; gap: 6px; align-items: center; }
#btnNext { margin-inline-start: auto; }
#btnPrev { order: 0; }

/* ------------------------------------------------ اللوحات */
.panel { border: 1px solid var(--stroke); border-radius: var(--r); background: var(--panel); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 13px 18px; border-bottom: 1px solid var(--stroke); }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
.panel-head h3 small, .mc-head h2 small { font-family: var(--display); font-size: 10px; font-weight: 700; letter-spacing: 0.3em; color: var(--acc); }
.presets { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--stroke-2); background: transparent; color: var(--muted); border-radius: 999px;
  padding: 4px 12px; font-size: 12.5px; cursor: pointer; transition: 0.2s;
}
.chip:hover { color: var(--text); border-color: var(--acc); }
.chip.on { color: var(--on-acc); background: var(--acc); border-color: transparent; font-weight: 600; }

.sliders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; padding: 16px 18px 6px; }
.sl label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; color: var(--muted); }
.sl label em, .tg em { font-style: normal; font-size: 10.5px; color: var(--faint); margin-inline-start: 6px; font-family: var(--mono); }
.sl output { font-family: var(--mono); color: var(--acc); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 2px 0 0; }
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(to right, var(--acc) var(--fill, 50%), rgba(255, 255, 255, 0.09) var(--fill, 50%));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--panel-solid); border: 2px solid var(--acc); box-shadow: 0 0 10px var(--glow);
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.09); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--acc); }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--panel-solid); border: 2px solid var(--acc); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--acc) 30%, transparent); }

.toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 28px; padding: 4px 18px 14px; }
.tg { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13.5px; cursor: pointer; padding: 8px 0; }
.tg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tg .sw { position: relative; flex: none; width: 38px; height: 22px; border-radius: 22px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--stroke-2); transition: 0.2s; }
.tg .sw::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: 0.2s; }
.tg input:checked + .sw { background: color-mix(in srgb, var(--acc) 24%, transparent); border-color: var(--acc); }
.tg input:checked + .sw::after { inset-inline-start: 18px; background: var(--acc); box-shadow: 0 0 10px var(--acc); }
.tg input:focus-visible + .sw { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ------------------------------------------------ قائمة الأسطر */
.lyrics { list-style: none; margin: 0; padding: 8px; max-height: min(58vh, 620px); overflow: auto; position: relative; scrollbar-width: thin; scrollbar-color: var(--stroke-2) transparent; }
.ly {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; transition: background 0.2s, border-color 0.2s;
}
.ly:hover { background: rgba(255, 255, 255, 0.03); }
.ly.active { background: color-mix(in srgb, var(--acc) 10%, transparent); border-color: var(--stroke-2); }
.ly-time { font-family: var(--mono); font-size: 11.5px; color: var(--faint); padding-top: 2px; direction: ltr; font-variant-numeric: tabular-nums; }
.ly-text {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--muted); direction: ltr; text-align: left;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ly.active .ly-text { color: var(--text); }
.ly-tools { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dots { display: flex; gap: 3px; align-items: center; direction: ltr; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); display: inline-block; }
.dots i.on { background: var(--acc); box-shadow: 0 0 6px var(--acc); }
.dots b { font-family: var(--mono); font-size: 10px; color: var(--acc); font-weight: 500; }
.fire { border: 0; background: transparent; color: var(--faint); cursor: pointer; padding: 2px; border-radius: 6px; line-height: 0; transition: color 0.2s, filter 0.2s; }
.fire:hover { color: #ff6b7d; }
.ly.hot .fire { color: #ff3b55; filter: drop-shadow(0 0 6px #ff3b55); }
.ly.hot .ly-time { color: #ff7a8a; }
.ly-empty { color: var(--faint); font-size: 13px; padding: 14px; }
.keylist { list-style: none; margin: 0; padding: 10px 18px 4px; display: grid; gap: 8px; font-size: 13px; }
.keylist li { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.keylist li span:last-child { color: var(--muted); }
.keys-note { margin: 4px 18px 14px; font-size: 12.5px; color: var(--faint); }

/* ------------------------------------------------ المكتبة */
.drawer {
  position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-start;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.drawer.open { opacity: 1; pointer-events: auto; }
.drawer-panel {
  width: min(460px, 100%); height: 100%; display: flex; flex-direction: column;
  background: var(--panel-solid); border-inline-end: 1px solid var(--stroke-2);
  transform: translateX(100%); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.drawer.open .drawer-panel { transform: none; }
.mc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--stroke); }
.mc-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.lib-list { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.lib-card { border: 1px solid var(--stroke); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: rgba(255, 255, 255, 0.015); }
.lib-card.current { border-color: var(--stroke-2); box-shadow: 0 0 24px -12px var(--glow); }
.lib-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.lib-meta { font-size: 12.5px; color: var(--muted); }
.lib-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: #ffd9de; }
.lib-empty { color: var(--muted); padding: 10px; }
.drawer-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--stroke); }

/* ------------------------------------------------ مُنشئ المقاطع */
.modal {
  position: fixed; inset: 0; z-index: 50; overflow: auto;
  background: rgba(0, 0, 0, 0.84);
  padding: max(20px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card { width: min(1180px, 100%); margin: 0 auto; background: var(--panel-solid); border: 1px solid var(--stroke-2); border-radius: 22px; box-shadow: 0 40px 120px -40px var(--glow); }
.mc-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr); gap: 26px; padding: 20px 22px; }
.col { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; margin-top: 4px; }
.step .num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: color-mix(in srgb, var(--acc) 16%, transparent); border: 1px solid var(--stroke-2); color: var(--acc); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.field label em { font-style: normal; color: var(--acc); font-size: 12px; margin-inline-start: 6px; }
.file-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
textarea.inp { min-height: 210px; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; resize: vertical; text-align: left; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hint { margin: 0; font-size: 12.5px; color: var(--faint); }
.status { margin: 0; font-size: 13px; min-height: 1.4em; color: var(--muted); }
.status.ok { color: var(--acc); }
.status.warn { color: var(--amber); }
.status.bad { color: var(--danger); }
.preview { position: relative; aspect-ratio: 16 / 9; max-width: 100%; border-radius: 14px; overflow: hidden; background: #000; border: 1px solid var(--stroke); }
.preview-host, .preview-host > *, .preview-host iframe, .preview-host video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.preview-shield { position: absolute; inset: 0; z-index: 2; }
.preview-msg { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; color: var(--faint); font-size: 13px; background: #000; text-align: center; padding: 12px; }
.transport { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.transport input[type=range] { flex: 1; min-width: 120px; }
.transport .mono { font-size: 12px; color: var(--muted); }
.syncbox { border: 1px solid var(--acc); border-radius: 14px; padding: 14px; background: color-mix(in srgb, var(--acc) 7%, transparent); display: flex; flex-direction: column; gap: 8px; box-shadow: 0 0 30px -14px var(--glow); }
.sync-label { font-size: 13px; color: var(--acc); }
.sync-text { font-family: var(--mono); font-size: 16px; line-height: 1.5; text-align: left; }
.sync-time { margin-inline-start: auto; font-size: 13px; color: var(--muted); }
#builder.syncing .sync-hint { display: none; }
.table-wrap { position: relative; max-height: 340px; overflow: auto; border: 1px solid var(--stroke); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--panel-solid); color: var(--muted); font-weight: 500; font-size: 12px; text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--stroke); }
.tbl td { padding: 4px; border-bottom: 1px solid color-mix(in srgb, var(--acc) 7%, transparent); vertical-align: middle; }
.tbl td.n { color: var(--faint); font-family: var(--mono); font-size: 11.5px; text-align: center; width: 28px; }
.tbl td.c { text-align: center; }
.tbl td.nowrap { white-space: nowrap; }
.tbl td.tx { min-width: 180px; }
.tbl input.t { width: 76px; font-family: var(--mono); font-size: 12px; direction: ltr; text-align: center; padding: 6px 4px; border-radius: 8px; }
.tbl input.x { font-family: var(--mono); font-size: 12px; direction: ltr; text-align: left; padding: 6px 8px; border-radius: 8px; }
.tbl input[type=checkbox] { accent-color: #ff3b55; width: 16px; height: 16px; cursor: pointer; }
.tbl tr.syncing td { background: color-mix(in srgb, var(--acc) 13%, transparent); }
.tbl-empty { padding: 22px; text-align: center; color: var(--faint); font-size: 13px; }
#builder.has-rows .tbl-empty { display: none; }
.mc-foot { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--stroke); }
.mc-foot .status { margin-inline-end: auto; }
body.modal-open { overflow: hidden; }

/* ------------------------------------------------ الإشعار */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); z-index: 60;
  translate: -50% 16px; opacity: 0; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
  background: var(--panel-solid); border: 1px solid var(--stroke-2); padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 10px 40px -10px var(--glow); transition: opacity 0.3s, translate 0.3s;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ------------------------------------------------ عرض الجملة حسب النمط */
.stage { --ghost-line: color-mix(in srgb, var(--text) 42%, transparent); }
/* أثناء الاستماع مع إظهار النص: كاريوكي */
.stage[data-view="reveal"] .ch:not(.done) { color: color-mix(in srgb, var(--text) 42%, transparent); }
.stage[data-view="reveal"] .ch.sung:not(.done) { color: var(--text); text-shadow: 0 0 14px var(--glow); }
.stage[data-view="reveal"] .caret { opacity: 0.35 !important; }
/* الشرطات: شرطة لكل حرف، والترقيم يبقى ظاهراً */
.stage[data-view="dashes"] .ch:not(.done):not(.sp):not(.punct) {
  color: transparent; text-shadow: none;
  background-image: linear-gradient(var(--ghost-line), var(--ghost-line));
  background-repeat: no-repeat; background-size: 66% 2px; background-position: 50% 86%;
}
.stage[data-view="dashes"] .ch.cur:not(.done):not(.sp):not(.punct) { background-image: linear-gradient(var(--acc), var(--acc)); }
.stage[data-view="dashes"] .ch.punct:not(.done) { color: color-mix(in srgb, var(--text) 45%, transparent); }
/* بدون مساعدة / مخفي أثناء الاستماع: لا يظهر إلا ما كتبته */
.stage[data-view="blank"] .ch:not(.done),
.stage[data-view="hidden"] .ch:not(.done) { display: none; }
.ch.hinted { color: var(--amber) !important; text-shadow: 0 0 10px rgba(255, 192, 77, 0.6) !important; }
.stage:not([data-view="ghost"]) .l-next { visibility: hidden; }

.listen-hint {
  position: absolute; inset-inline-end: clamp(16px, 3vw, 34px); bottom: 14px;
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--acc);
  opacity: 0; transform: translateY(4px); transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
.stage[data-phase="listen"] .listen-hint { opacity: 1; transform: none; }
.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 16px; }
.eq i { width: 3px; height: 100%; border-radius: 2px; background: var(--acc); box-shadow: 0 0 8px var(--glow); animation: eq 0.9s ease-in-out infinite; transform-origin: bottom; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.55s; }
.eq i:nth-child(4) { animation-delay: -0.15s; }
@keyframes eq { 0%, 100% { transform: scaleY(0.25); } 50% { transform: scaleY(1); } }
.stage:not([data-phase="listen"]) .eq i { animation: none; }
.blank-hint {
  position: absolute; inset-inline-start: clamp(16px, 3vw, 34px); top: 50%; translate: 0 -50%;
  color: var(--faint); font-size: 14px; pointer-events: none; opacity: 0; transition: opacity 0.25s;
  direction: rtl;
}
.stage[data-view="blank"].fresh .blank-hint { opacity: 1; }
.stage[data-view="blank"].fresh .blank-hint { inset-inline-start: auto; inset-inline-end: clamp(16px, 3vw, 34px); }

/* إخفاء الإجابات في القائمة والشريط ضمن أنماط الذاكرة */
body[data-mode="dashes"] .ly:not(.seen):not(:hover) .ly-text,
body[data-mode="blank"] .ly:not(.seen):not(:hover) .ly-text,
body[data-mode="dashes"] .tl-block.line:not(.sel):not(:hover) .lbl,
body[data-mode="blank"] .tl-block.line:not(.sel):not(:hover) .lbl { filter: blur(4px); opacity: 0.7; }
.ly-text, .tl-block .lbl { transition: filter 0.25s, opacity 0.25s; }

/* ------------------------------------------------ لوحة النمط */
.modes { display: grid; gap: 8px; padding: 12px; }
.mode {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name demo" "desc demo";
  gap: 2px 12px; align-items: center; text-align: start;
  padding: 11px 14px; border-radius: 14px; cursor: pointer; color: var(--text);
  border: 1px solid var(--stroke); background: rgba(255, 255, 255, 0.015);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s;
}
.mode:hover { border-color: var(--stroke-2); }
.mode.on { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 9%, transparent); box-shadow: 0 0 26px -12px var(--glow); }
.mode:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.mode-name { grid-area: name; font-weight: 600; font-size: 14px; }
.mode-name em { font-style: normal; font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-inline-start: 6px; }
.mode-desc { grid-area: desc; font-size: 12px; color: var(--muted); }
.mode-demo {
  grid-area: demo; font-family: var(--mono); font-size: 12.5px; white-space: nowrap;
  padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--stroke);
}
.mode-demo b { font-weight: 500; color: var(--acc); }
.mode-demo i { font-style: normal; color: color-mix(in srgb, var(--text) 30%, transparent); }
.mode-demo u { text-decoration: none; color: var(--muted); letter-spacing: 0.12em; }
.mode-demo s { display: inline-block; width: 2px; height: 1.05em; vertical-align: -0.15em; margin-inline-start: 4px; background: var(--acc); box-shadow: 0 0 6px var(--acc); }
.live-notice { margin: 0 12px 4px; padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--amber); color: var(--amber); font-size: 12.5px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
body.live-sync .modes .mode-desc::after { content: ' · أثناء التشغيل'; color: var(--amber); }
.toggles.single, .sliders.single { grid-template-columns: minmax(0, 1fr); }
.toggles.single { padding: 2px 16px 4px; }
.sliders.single { padding: 2px 16px 14px; }
.mode-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 6px 16px 10px; border-top: 1px solid var(--stroke); }
.rate-pick { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------ قائمة الجمل */
.cdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); border: 1px solid rgba(255, 255, 255, 0.2); }
.cdot.none { background: transparent; box-shadow: none; border-style: dashed; border-color: var(--faint); }

/* ------------------------------------------------ الإعدادات المتقدمة */
.adv > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px;
  padding: 13px 18px; font-size: 14px; color: var(--muted); border-radius: var(--r);
}
.adv > summary::-webkit-details-marker { display: none; }
.adv > summary::after { content: '▾'; margin-inline-start: auto; transition: transform 0.2s; }
.adv[open] > summary::after { transform: rotate(180deg); }
.adv > summary small { font-size: 12px; color: var(--faint); }
.adv > summary:hover { color: var(--text); }
.adv > summary:focus-visible { outline: 2px solid var(--acc); outline-offset: -2px; }
.adv[open] > summary { border-bottom: 1px solid var(--stroke); border-radius: var(--r) var(--r) 0 0; }
.adv-body { display: grid; gap: 4px; padding-bottom: 6px; }
.adv-group { padding: 12px 0 4px; }
.adv-group + .adv-group { border-top: 1px solid var(--stroke); }
.adv-title { padding: 0 18px; font-weight: 600; font-size: 14px; }
.adv-title em { font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--acc); margin-inline-start: 6px; }
.adv-note { margin: 4px 18px 6px; font-size: 12.5px; color: var(--faint); max-width: 70ch; }
.panel-sub { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 18px 0; font-size: 13px; color: var(--muted); }
.live-box { transition: opacity 0.25s; }
.live-box.off { opacity: 0.4; }

/* ------------------------------------------------ الشريط الزمني */
.tl-panel { overflow: hidden; }
.tl-head-row { gap: 12px; }
.tl-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-time { font-size: 13px; color: var(--acc); width: 8ch; text-align: center; contain: layout paint; display: inline-block; }
.tl-play { font-size: 12px; }
.zoom { display: inline-flex; gap: 4px; }
.tl-saved { font-size: 12px; color: var(--acc); opacity: 0; transition: opacity 0.3s; min-width: 4em; }
.tl-saved.on { opacity: 1; }
.seg-switch { display: inline-flex; border: 1px solid var(--stroke-2); border-radius: 999px; padding: 2px; gap: 2px; background: rgba(0, 0, 0, 0.25); }
.seg-switch button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px; transition: 0.2s;
}
.seg-switch button:hover { color: var(--text); }
.seg-switch button.on { background: var(--acc); color: var(--on-acc); font-weight: 600; }
.seg-switch button:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.seg-switch.big button { padding: 6px 14px; font-size: 13px; }

.tl-scroll {
  position: relative; overflow-x: auto; overflow-y: hidden; margin: 12px 14px 0;
  border: 1px solid var(--stroke); border-radius: 12px; background: rgba(0, 0, 0, 0.35);
  scrollbar-width: thin; scrollbar-color: var(--stroke-2) transparent;
}
.tl-inner { position: relative; height: 130px; min-width: 100%; }
.tl-ruler { position: absolute; left: 0; right: 0; top: 0; height: 26px; cursor: col-resize; border-bottom: 1px solid var(--stroke); touch-action: none; }
.tk { position: absolute; bottom: 0; width: 1px; height: 6px; background: rgba(255, 255, 255, 0.14); }
.tk.mj { height: 11px; background: rgba(255, 255, 255, 0.34); }
.tk b { position: absolute; bottom: 12px; left: 3px; font: 500 10.5px/1 var(--mono); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-lane {
  position: absolute; left: 0; right: 0; top: 52px; bottom: 0; touch-action: none; cursor: crosshair;
  background: repeating-linear-gradient(90deg, transparent 0 59px, rgba(255, 255, 255, 0.02) 59px 60px);
}
.tl-block {
  --c: var(--acc); /* يتبع لون الموقع ما لم يُثبَّت لون للمربع */
  position: absolute; top: 12px; bottom: 12px; min-width: 4px; cursor: grab;
  border-radius: 8px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 22%, rgba(8, 14, 12, 0.92));
  border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.2s, background 0.2s;
}
.tl-block.colored { background: color-mix(in srgb, var(--c) 30%, rgba(8, 10, 10, 0.92)); }
.tl-block.pass {
  --c: color-mix(in srgb, var(--acc) 45%, #8a8f9c);
  background:
    repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 20%, transparent) 0 6px, transparent 6px 12px),
    rgba(10, 12, 14, 0.85);
  border-style: dashed;
}
.tl-block.pass.colored { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 34%, transparent) 0 6px, transparent 6px 12px), rgba(10, 10, 12, 0.85); }
.tl-block:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 80%, transparent), 0 0 16px -4px var(--c); }
.tl-block.sel { box-shadow: 0 0 0 2px var(--c), 0 0 22px -4px var(--c); z-index: 2; }
.tl-block.live::after { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--c) 18%, transparent); pointer-events: none; }
.tl-block:active { cursor: grabbing; }
.tl-block::before {
  content: attr(data-n); position: absolute; top: 3px; inset-inline-start: 9px;
  font: 600 9.5px/1 var(--mono); color: color-mix(in srgb, var(--c) 85%, white); opacity: 0.85; direction: ltr;
}
.tl-block.pass::before { content: none; }
.lbl {
  position: absolute; left: 9px; right: 9px; bottom: 6px; top: 15px; display: flex; align-items: flex-end;
  font: 500 11.5px/1.25 var(--mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; direction: ltr;
}
.tl-block.pass .lbl { top: 6px; align-items: center; color: var(--muted); font-family: var(--ui); }
.lbl.empty { color: var(--faint); font-style: italic; }
.h { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; z-index: 1; }
.h::after { content: ''; position: absolute; top: 30%; bottom: 30%; left: 3px; width: 3px; border-radius: 2px; background: color-mix(in srgb, var(--c) 80%, white); opacity: 0; transition: opacity 0.15s; }
.tl-block:hover .h::after, .tl-block.sel .h::after { opacity: 0.9; }
.hs { left: 0; }
.he { right: 0; }
.tl-ghost { position: absolute; top: 12px; bottom: 12px; display: none; border-radius: 8px; border: 1px dashed var(--acc); background: color-mix(in srgb, var(--acc) 14%, transparent); pointer-events: none; }
.tl-ghost.on { display: block; }
.tl-ghost.pass { border-color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.tl-headline { position: absolute; top: 0; bottom: 0; left: 0; width: 0; pointer-events: none; z-index: 4; will-change: transform; contain: layout style; }
.tl-inner { contain: layout style; }
.tl-block { contain: layout style paint; }
.tl-headline i { position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--text); box-shadow: 0 0 10px var(--glow); }
.tl-headline i::before { content: ''; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: var(--text); }

.tl-insp { padding: 12px 16px 4px; }
.insp-empty { margin: 0; font-size: 13px; color: var(--faint); }
.insp-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px 22px; }
.insp-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.insp-times { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); }
.insp-times label { display: inline-flex; gap: 6px; align-items: center; }
.insp-times .inp.t { width: 84px; font-family: var(--mono); font-size: 12.5px; text-align: center; padding: 6px; }
.insp-times .dur { color: var(--faint); font-size: 12px; }
textarea.tl-text { min-height: 56px; height: 56px; resize: vertical; font-family: var(--mono); font-size: 13.5px; text-align: left; }
.insp-label { font-size: 12.5px; color: var(--muted); }
.insp-note { margin: 0; font-size: 12px; color: var(--faint); }
.insp-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.12); background: var(--c); box-shadow: 0 0 12px -2px var(--c);
  transition: transform 0.15s, border-color 0.15s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.on { border-color: var(--text); transform: scale(1.1); }
.swatch:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.swatch.none { background: conic-gradient(from 0deg, #2bffa0, #12c98b, #04402a, #2bffa0); box-shadow: none; }
.swatch.none::after { content: 'A'; position: absolute; inset: 0; display: grid; place-items: center; font: 700 11px var(--mono); color: #01150c; }
.swatch.custom { background: conic-gradient(#ff2e4d, #ffb020, #2bffa0, #22d3ee, #a45bff, #ff3dbe, #ff2e4d); box-shadow: none; overflow: hidden; }
.swatch.custom.on { background: var(--c); box-shadow: 0 0 12px -2px var(--c); }
.swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.tl-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 16px 12px; border-top: 1px solid var(--stroke); margin-top: 10px; font-size: 12px; color: var(--faint); }
.tl-tip kbd { font-size: 10.5px; padding: 2px 5px; }

/* ------------------------------------------------ الشاشات الصغيرة */
@media (max-width: 1080px) {
  .layout { display: flex; flex-direction: column; gap: 16px; }
  .stage-col, .side-col { display: contents; }
  .screen { order: 1; } .stage { order: 2; } .elastic { order: 3; } .controls { order: 4; }
  .modes-panel { order: 5; } .tl-panel { order: 6; } .stats { order: 7; } .lyrics-panel { order: 8; }
  .adv { order: 9; } .keys { order: 10; }
  .side-col { position: static; }
  .lyrics { max-height: 360px; }
}
@media (max-width: 900px) {
  .mc-body { grid-template-columns: minmax(0, 1fr); }
  .insp-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .topbar { gap: 12px; }
  .now { order: 3; flex-basis: 100%; text-align: start; }
  .now-title { max-width: 100%; }
  .top-actions { margin-inline-start: auto; }
  .brand-sub { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sliders, .toggles { grid-template-columns: minmax(0, 1fr); }
  .hud .pill.src, .hud .mode-pill { display: none; }
  .insp-grid { grid-template-columns: minmax(0, 1fr); }
  .tl-tip { display: none; }
  #btnNext { margin-inline-start: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------ نظام الألوان: الشريط والدبابيس */
.tl-colorbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px 0; font-size: 12.5px; color: var(--muted);
}
.cb-title { font-weight: 600; color: var(--text); margin-inline-end: 4px; }
.cb-status { font-size: 12px; color: var(--acc); }
.base-chip, .lib-base {
  position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 5px 12px 5px 10px; border-radius: 999px; border: 1px solid var(--stroke-2); font-size: 12.5px; color: var(--text);
}
.base-chip:hover, .lib-base:hover { border-color: var(--acc); }
.base-chip input, .lib-base input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.base-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c, #2bffa0); border: 1px solid rgba(255, 255, 255, 0.25); flex: none; }
.lib-base { align-self: flex-start; }
.btn.on[data-a="ambi"] { background: linear-gradient(90deg, #ff2e4d33, #ffb02033, #22d3ee33, #a45bff33); border-color: var(--acc); }
.btn.dim { opacity: 0.55; }

.tl-keys {
  position: absolute; left: 0; right: 0; top: 26px; height: 26px; cursor: copy; touch-action: none;
  border-bottom: 1px solid var(--stroke); background: rgba(0, 0, 0, 0.25);
}
.ck-spans { position: absolute; left: 0; right: 0; top: 9px; height: 8px; pointer-events: none; }
.ck-spans i { position: absolute; top: 0; bottom: 0; background: var(--c); opacity: 0.55; border-radius: 2px; }
.ck-pins { position: absolute; inset: 0; pointer-events: none; }
.ck-pin {
  position: absolute; left: 0; top: 0; width: 0; height: 100%; pointer-events: auto; cursor: ew-resize;
  will-change: transform;
}
.ck-pin::before { content: ''; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--c); opacity: 0.9; }
.ck-pin b {
  position: absolute; left: -7px; top: 5px; width: 14px; height: 14px; transform: rotate(45deg); border-radius: 3px;
  background: var(--c); border: 2px solid rgba(0, 0, 0, 0.55); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.ck-pin.base b { background: repeating-linear-gradient(45deg, var(--c) 0 3px, rgba(0, 0, 0, 0.6) 3px 6px); }
.ck-pin.auto b { border-style: dashed; }
.ck-pin:hover b { box-shadow: 0 0 0 2px var(--text); }
.ck-pin.sel b { box-shadow: 0 0 0 2px var(--text), 0 0 12px var(--c); }
.ck-pin.sel::before { width: 2px; opacity: 1; }
.insp-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.insp-title em { font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.auto-tag { font-weight: 400; font-size: 11px; color: var(--amber); border: 1px dashed var(--amber); border-radius: 999px; padding: 0 8px; }
.swatch.none::after { content: '↺'; font: 700 13px var(--ui); }

/* ------------------------------------------------ الاستضافة: وضع الزائر ودخول المحرر */
.mini-card { width: min(420px, 100%); margin-top: 12vh; }
.lm-body { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px 20px; }
.lm-body .btn { align-self: flex-start; }
#btnAdmin.on { border-color: var(--acc); color: var(--acc); }
body.readonly #btnAdd, body.readonly #btnEdit,
body.readonly .tl-colorbar, body.readonly .tl-tools [data-new], body.readonly .tl-tools .seg-switch,
body.readonly .tl-tools [data-a="add"], body.readonly .tl-tools [data-a="undo"],
body.readonly .tl-foot label, body.readonly .tl-tip,
body.readonly .lib-actions [data-a="edit"], body.readonly .lib-actions [data-a="del"], body.readonly .lib-base,
body.readonly .drawer-foot label,
body.readonly .overlay [data-act="edit"], body.readonly .overlay [data-act="lyrics"], body.readonly .overlay [data-act="timeline"] { display: none !important; }
body.readonly .tl-lane, body.readonly .tl-keys { cursor: pointer; }
body.readonly .tl-block { cursor: pointer; }
body.readonly .h { display: none; }
body.readonly .ck-pin { cursor: default; }

/* مربعات الجمل: تلقائي يتبع لون الموقع، والمثبّت عليه علامة صغيرة */
.tl-block { transition: background-color 0.6s, border-color 0.6s, box-shadow 0.2s; }
.tl-block.pinned::after { content: '📌'; position: absolute; top: 2px; right: 6px; font-size: 9px; opacity: 0.8; }
.tl-block.pinned.live::after { content: '📌'; background: none; inset: 2px 6px auto auto; }
.swatch.auto-sw { background: conic-gradient(from 0deg, var(--acc), var(--acc2), var(--deep), var(--acc)); }
.swatch.auto-sw::after { content: 'A'; font: 700 11px var(--mono); color: var(--on-acc); }
body:not(.hosted) .admin-only, body.readonly .admin-only { display: none !important; }

/* مشغّل يوتيوب: نجعل الإطار أطول من الصندوق ونقص الحافتين.
   الفيديو 16:9 يملأ العرض فيبقى كاملاً ومكانه هو، والذي يُقص هو أشرطة يوتيوب العلوية والسفلية فقط:
   العنوان، المشاركة، الشعار، «المزيد من الفيديوهات». */
.screen-host.yt-crop, .preview-host.yt-crop { overflow: hidden; }
.screen-host.yt-crop iframe, .preview-host.yt-crop iframe {
  inset: auto; left: 0; top: -90px; width: 100%; height: calc(100% + 180px); pointer-events: none;
}
