@font-face { font-family: Roboto; font-weight: 400; font-display: swap; src: url(/fonts/roboto-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: Roboto; font-weight: 500; font-display: swap; src: url(/fonts/roboto-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }

:root {
  /* M3 dark, tonal spot, seed #2d5fa8 (tools/tokens.mjs) */
  --md-primary: #aac7ff;
  --md-on-primary: #0b305f;
  --md-primary-container: #284777;
  --md-on-primary-container: #d7e3ff;
  --md-secondary: #bec6dc;
  --md-on-secondary: #283141;
  --md-secondary-container: #3e4759;
  --md-on-secondary-container: #dae2f9;
  --md-error: #ffb4ab;
  --md-on-error: #690005;
  --md-error-container: #93000a;
  --md-on-error-container: #ffdad6;
  --md-surface: #111318;
  --md-on-surface: #e2e2e9;
  --md-on-surface-variant: #c4c6d0;
  --md-surface-container-low: #191c20;
  --md-surface-container: #1e2025;
  --md-surface-container-high: #282a2f;
  --md-surface-container-highest: #33353a;
  --md-outline: #8e9099;
  --md-outline-variant: #44474e;
  --md-inverse-surface: #e2e2e9;
  --md-inverse-on-surface: #2e3036;
  --md-inverse-primary: #415f91;
  --live: #ff5449;

  --font: Roboto, "Noto Sans Hebrew", "Segoe UI", "Arial Hebrew", system-ui, sans-serif;
  --shadow-2: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px 2px rgba(0,0,0,.15);
  --ease: cubic-bezier(.2,0,0,1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--md-on-surface); overflow: hidden; }
body { font: 400 14px/20px var(--font); -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

#stage { position: fixed; inset: 0; background: #000; user-select: none; -webkit-user-select: none; }
#v { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#stage.idle, #stage.idle * { cursor: none !important; }

/* ---------- icons ---------- */
.ic { width: 24px; height: 24px; fill: currentColor; flex: none; display: block; }
.ic-15 { position: relative; display: block; width: 24px; height: 24px; }
.ic-15 b { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 2px; font: 500 8px/1 Roboto, var(--font); letter-spacing: -.2px; }
.ic-15.fwd .ic { transform: scaleX(-1); }

/* ---------- icon buttons (M3 standard / tonal) ---------- */
.ib { position: relative; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: var(--md-on-surface); flex: none; outline: none; }
.ib::before, .btn::before, .chip::before, .mi::before { content: ""; position: absolute; inset: 4px; border-radius: inherit; background: currentColor; opacity: 0; transition: opacity .15s; pointer-events: none; }
.ib::before { inset: 4px; }
.ib:hover::before, .btn:hover::before, .chip:hover::before, .mi:hover::before { opacity: .08; }
.ib:active::before, .btn:active::before, .chip:active::before, .mi:active::before { opacity: .12; }
.ib:focus-visible, .btn:focus-visible, .chip:focus-visible, .mi:focus-visible, .seek:focus-visible { outline: 3px solid var(--md-secondary); outline-offset: -1px; }
.ib:disabled { opacity: .38; cursor: default; }
.ib:disabled::before { display: none; }
.ib.tonal { background: var(--md-primary-container); color: var(--md-on-primary-container); width: 56px; height: 48px; border-radius: 16px; }
.ib.tonal::before { inset: 0; }
.ib.small { width: 40px; height: 40px; }

/* ---------- text buttons ---------- */
.btn { position: relative; height: 40px; padding: 0 16px; border-radius: 20px; display: inline-flex; align-items: center; gap: 8px; font: 500 14px/20px var(--font); white-space: nowrap; outline: none; }
.btn::before { inset: 0; }
.btn.text { color: var(--md-primary); padding: 0 12px; }
.btn.tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn.filled { background: var(--md-primary); color: var(--md-on-primary); }
.btn .ic { width: 18px; height: 18px; }
.btn:disabled { opacity: .38; cursor: default; }

/* ---------- top bar ---------- */
#top { position: absolute; inset: 0 0 auto 0; display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 48px;
  background: linear-gradient(rgba(0,0,0,.6), transparent); transition: opacity .25s var(--ease); pointer-events: none; }
#top > * { pointer-events: auto; }
#title { display: flex; align-items: center; gap: 12px; min-width: 0; }
#title .badge { min-width: 44px; height: 32px; padding: 0 8px; border-radius: 8px; background: var(--md-primary-container); color: var(--md-on-primary-container);
  display: grid; place-items: center; font: 500 16px/24px Roboto, var(--font); }
#title .name { font: 400 22px/28px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#title .sub { color: var(--md-on-surface-variant); font-size: 14px; }
#top .spacer { flex: 1; }

/* ---------- bottom controls ---------- */
#bottom { position: absolute; inset: auto 0 0 0; padding: 56px 12px 8px; background: linear-gradient(transparent, rgba(0,0,0,.55) 35%, rgba(0,0,0,.8));
  transition: opacity .25s var(--ease), transform .25s var(--ease); }
#stage.idle #top, #stage.idle #bottom { opacity: 0; pointer-events: none; }
#stage.idle #top > *, #stage.idle #bottom * { pointer-events: none; }
#stage.idle #bottom { transform: translateY(8px); }

.seekwrap { direction: ltr; padding: 0 12px; }
.seek { position: relative; height: 40px; touch-action: none; cursor: pointer; outline: none; border-radius: 8px; }
.seek .trk { position: absolute; top: 14px; height: 12px; border-radius: 6px; }
.seek .inactive { left: 0; right: 0; background: var(--md-secondary-container); }
.seek .buf { left: 0; background: color-mix(in srgb, var(--md-secondary) 35%, var(--md-secondary-container)); border-radius: 6px; }
.seek .active { left: 0; background: var(--md-primary); border-radius: 6px 2px 2px 6px; }
.seek .handle { position: absolute; top: 2px; width: 4px; height: 36px; margin-left: -2px; border-radius: 2px; background: var(--md-primary);
  box-shadow: 0 0 0 4px #000a; transition: height .1s, top .1s; }
.seek:active .handle { width: 2px; margin-left: -1px; }
.seek.live .handle { background: var(--live); }
.seek .stop { position: absolute; top: 18px; right: 4px; width: 4px; height: 4px; border-radius: 2px; background: var(--md-primary); }
.seek .hover { position: absolute; bottom: 44px; transform: translateX(-50%); padding: 4px 8px; border-radius: 4px; background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface); font: 500 12px/16px Roboto, var(--font); white-space: nowrap; pointer-events: none; }
.seek.off { cursor: default; }
.seek.off .active, .seek.off .handle { background: var(--md-outline); }
.scale { display: flex; justify-content: space-between; color: var(--md-on-surface-variant); font: 400 12px/16px Roboto, var(--font); padding: 0 2px; height: 16px; }

.ctrl { display: flex; align-items: center; gap: 2px; min-height: 56px; }
.ctrl .grow { flex: 1; min-width: 8px; }
.vol { display: flex; align-items: center; }
.vol .seek { width: 96px; height: 40px; margin-inline-start: 4px; }
.vol .seek .trk { top: 16px; height: 8px; border-radius: 4px; }
.vol .seek .handle { top: 6px; height: 28px; }
.clock { display: flex; align-items: center; gap: 10px; margin-inline-start: 8px; white-space: nowrap; }
.clock .t { font: 500 16px/24px Roboto, var(--font); }
.clock .lag { color: var(--md-on-surface-variant); }
.livechip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--md-outline-variant);
  font: 500 14px/20px var(--font); color: var(--md-on-surface); }
.livechip i { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
.ratebtn { min-width: 48px; font: 500 14px/20px Roboto, var(--font); }

/* channel chips */
.chans { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 8px 12px 4px; scroll-padding: 0 48px; }
.chans::-webkit-scrollbar { display: none; }
.chans .sep { flex: none; align-self: center; color: var(--md-on-surface-variant); font: 500 12px/16px var(--font); padding: 0 4px 0 8px; }
.chip { position: relative; flex: none; height: 40px; padding: 0 14px 0 12px; border-radius: 8px; border: 1px solid var(--md-outline-variant);
  display: inline-flex; align-items: center; gap: 8px; color: var(--md-on-surface-variant); white-space: nowrap; outline: none; }
.chip::before { inset: 0; border-radius: 7px; }
.chip b { font: 500 14px/20px Roboto, var(--font); color: var(--md-on-surface); min-width: 18px; text-align: center; }
.chip span { font: 500 14px/20px var(--font); }
.chip small { font-size: 12px; opacity: .8; }
.chip.on { background: var(--md-secondary-container); border-color: transparent; color: var(--md-on-secondary-container); }
.chip.on b { color: var(--md-on-secondary-container); }

/* ---------- centre states ---------- */
.center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.spinner { width: 48px; height: 48px; animation: rot 1.4s linear infinite; }
.spinner circle { fill: none; stroke: var(--md-primary); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 90 150; animation: dash 1.4s var(--ease) infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes dash { 0% { stroke-dasharray: 1 150; stroke-dashoffset: 0; } 50% { stroke-dasharray: 90 150; stroke-dashoffset: -35; } 100% { stroke-dasharray: 90 150; stroke-dashoffset: -124; } }
#err { pointer-events: auto; text-align: center; max-width: 360px; padding: 24px; border-radius: 28px; background: var(--md-surface-container-high); }
#err .ic { width: 32px; height: 32px; margin: 0 auto 12px; color: var(--md-error); }
#err p { margin: 0 0 16px; color: var(--md-on-surface-variant); }
#err strong { display: block; font: 400 18px/24px var(--font); margin-bottom: 4px; color: var(--md-on-surface); }
#radio { text-align: center; }
#radio .ic { width: 64px; height: 64px; margin: 0 auto 16px; color: var(--md-primary); }
#radio .rn { font: 400 36px/44px var(--font); }
#radio .rs { color: var(--md-on-surface-variant); margin-top: 4px; }

#numpad { position: absolute; top: 16px; inset-inline-end: 24px; font: 400 57px/64px Roboto, var(--font); color: #fff; text-shadow: 0 2px 12px #000; pointer-events: none; }

#unmute { position: absolute; left: 50%; bottom: 50%; transform: translate(-50%, 50%); height: 56px; padding: 0 20px 0 16px; border-radius: 16px;
  background: var(--md-primary-container); color: var(--md-on-primary-container); display: flex; align-items: center; gap: 12px; font: 500 16px/24px var(--font); box-shadow: var(--shadow-2); }

/* ---------- menus ---------- */
.menu { position: absolute; z-index: 20; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); max-height: calc(100% - 96px); overflow-y: auto; padding: 8px 0; border-radius: 8px;
  background: var(--md-surface-container); box-shadow: var(--shadow-2); transform-origin: bottom; animation: pop .15s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scaleY(.9); } }
.menu h3 { margin: 0; padding: 8px 16px 4px; font: 500 14px/20px var(--font); color: var(--md-on-surface-variant); }
.mi { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 16px 0 12px; text-align: start; outline: none; }
.mi::before { inset: 0; border-radius: 0; }
.mi .ic { color: var(--md-on-surface-variant); }
.mi .chk { visibility: hidden; color: var(--md-on-surface); }
.mi.sel .chk { visibility: visible; }
.mi .lbl { flex: 1; }
.mi .tail { color: var(--md-on-surface-variant); font-size: 12px; }
.mi .two { display: flex; flex-direction: column; padding: 8px 0; }
.mi .two small { color: var(--md-on-surface-variant); font-size: 12px; line-height: 16px; }
.menu hr { border: 0; border-top: 1px solid var(--md-outline-variant); margin: 8px 0; }

/* M3 switch */
.sw { position: relative; flex: none; width: 52px; height: 32px; border-radius: 16px; border: 2px solid var(--md-outline); background: var(--md-surface-container-highest); transition: background .2s, border-color .2s; }
.sw::after { content: ""; position: absolute; top: 6px; inset-inline-start: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--md-outline); transition: all .2s var(--ease); }
.on > .sw, .sw.on { background: var(--md-primary); border-color: var(--md-primary); }
.on > .sw::after, .sw.on::after { width: 24px; height: 24px; top: 2px; inset-inline-start: 22px; background: var(--md-on-primary); }

/* ---------- dialog ---------- */
#scrim { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.dlg { width: min(400px, 100%); padding: 24px; border-radius: 28px; background: var(--md-surface-container-high); box-shadow: var(--shadow-2); animation: pop .2s var(--ease); max-height: 100%; overflow-y: auto; }
.dlg h2 { margin: 0 0 16px; font: 400 24px/32px var(--font); display: flex; align-items: center; gap: 12px; }
.dlg h2 .ic { color: var(--md-secondary); }
.dlg p { margin: 0 0 16px; color: var(--md-on-surface-variant); }
.dlg .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.field { position: relative; margin: 8px 0 4px; }
.field input { width: 100%; height: 56px; padding: 0 16px; border-radius: 4px; border: 1px solid var(--md-outline); background: transparent; outline: none;
  font: 400 22px/28px Roboto, var(--font); letter-spacing: .5px; direction: ltr; text-align: center; }
.field input:focus { border: 2px solid var(--md-primary); padding: 0 15px; }
.field label { position: absolute; top: -8px; inset-inline-start: 12px; padding: 0 4px; background: var(--md-surface-container-high); font: 400 12px/16px var(--font); color: var(--md-on-surface-variant); }
.field input:focus + label { color: var(--md-primary); }
.field.bad input { border-color: var(--md-error); }
.field.bad label, .hint.bad { color: var(--md-error); }
.hint { min-height: 16px; font: 400 12px/16px var(--font); color: var(--md-on-surface-variant); padding: 4px 16px 0; }
.qchips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.qchips .chip { height: 32px; padding: 0 12px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; align-items: center; }
.keys kbd { justify-self: start; min-width: 32px; padding: 2px 8px; border-radius: 6px; background: var(--md-surface-container-highest); font: 500 13px/20px Roboto, var(--font); text-align: center; direction: ltr; }

/* ---------- snackbar ---------- */
#snack { position: absolute; z-index: 40; left: 50%; top: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); min-height: 48px; padding: 14px 16px; border-radius: 4px;
  background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); box-shadow: var(--shadow-2); animation: pop .15s var(--ease); }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  #top { padding: 8px 8px 40px; }
  #title .name { font-size: 18px; }
  #bottom { padding: 40px 4px 4px; }
  .seekwrap { padding: 0 8px; }
  .vol .seek, .hide-s { display: none; }
  .clock { margin-inline-start: 4px; gap: 6px; }
  .clock .t { font-size: 14px; }
  .ib { width: 44px; height: 44px; }
  .ib.tonal { width: 52px; height: 44px; }
  .chans { padding: 6px 8px 2px; }
}
@media (max-width: 600px) {
  /* two rows: transport + clock, then the secondary controls pushed to the end */
  .ctrl { flex-wrap: wrap; }
  .ctrl .grow { flex-basis: 100%; height: 0; }
  #goTime { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
