/* ---- IRL+ brand system ----
   lime #ccff02 (primary)  ·  cyan #02bccc  ·  red #e56767
   near-black glass surfaces, lime-tinted borders + glows, Syne/Inter/JetBrains Mono */

:root {
  --lime: #ccff02;
  --lime-glow: rgba(204, 255, 2, .40);
  --lime-dim: rgba(204, 255, 2, .15);
  --cyan: #02bccc;
  --red: #e56767;
  --amber: #f5c451;
  --line: rgba(255, 255, 255, .10);
  --line-soft: rgba(255, 255, 255, .06);
  --surface: rgba(20, 20, 32, .55);
  --surface-2: #14141f;
}

/* ambient IRL+ glow behind everything */
body {
  background:
    radial-gradient(1100px 560px at 82% -12%, rgba(204, 255, 2, .055), transparent 60%),
    radial-gradient(820px 460px at -5% 112%, rgba(2, 188, 204, .045), transparent 60%),
    #050508;
}

/* glass panels */
header, aside {
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}

/* Control / icon buttons */
.ctl {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .7rem; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: #e0e0e8;
  font-size: .82rem; cursor: pointer; transition: border-color .15s, color .15s, box-shadow .15s, background .15s;
}
.ctl:hover { border-color: var(--lime); color: var(--lime); }
.ctl-primary { background: var(--lime-dim); border-color: var(--lime); color: var(--lime); }
.ctl-primary:hover { box-shadow: 0 0 24px var(--lime-glow); }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .3rem .45rem; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line); color: #c3c3d4;
  cursor: pointer; transition: border-color .15s, color .15s, box-shadow .15s;
}
.iconbtn:hover { border-color: var(--lime); color: var(--lime); box-shadow: 0 0 16px var(--lime-dim); }
.iconbtn.active { border-color: var(--lime); color: var(--lime); background: var(--lime-dim); }
.iconbtn.danger:hover { border-color: var(--red); color: var(--red); box-shadow: 0 0 16px rgba(229, 103, 103, .25); }

.field {
  padding: .45rem .6rem; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: #e0e0e8; font-size: .85rem;
}
.field:focus { outline: none; border-color: var(--lime); box-shadow: 0 0 0 3px var(--lime-dim); }

/* Range sliders */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  height: 4px; background: rgba(204, 255, 2, .18); border-radius: 999px; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--lime); border: 2px solid #050508; cursor: pointer; box-shadow: 0 0 10px var(--lime-glow);
}
input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--lime); border: 2px solid #050508; cursor: pointer; box-shadow: 0 0 10px var(--lime-glow);
}

/* Audio mixer — vertical channel strips (OBS-style). The fader is a horizontal range
   rotated 90° so it renders identically across browsers (no slider-vertical quirks). */
.mixer { display: flex; gap: 10px; align-items: stretch; }
.mix-ch {
  display: flex; flex-direction: column; align-items: center; gap: 7px; width: 58px;
  padding: 9px 4px; border-radius: 10px;
  background: rgba(255, 255, 255, .025); border: 1px solid var(--line-soft);
}
.mix-master { background: var(--lime-dim); border-color: rgba(204, 255, 2, .28); }
.mix-master .mix-label, .mix-master .mix-pct { color: var(--lime); }
.mix-disabled { opacity: .4; }
.mix-label {
  font: 10px/1.1 'JetBrains Mono', ui-monospace, monospace; color: #c8c8d6; text-align: center;
  max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mix-pct { font: 10px/1 'JetBrains Mono', ui-monospace, monospace; color: var(--lime); height: 12px; }
.mix-note { font: 9px/1 'JetBrains Mono', ui-monospace, monospace; color: #6a6a7a; }
.mix-track {
  position: relative; width: 30px; height: 128px; overflow: hidden; cursor: pointer; touch-action: none;
  background: #07070d; border: 1px solid var(--line); border-radius: 7px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .7);
}
.mix-track:hover { border-color: rgba(204, 255, 2, .4); }
.mix-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 50%;
  background: linear-gradient(180deg, var(--lime), rgba(204, 255, 2, .25)); opacity: .5; pointer-events: none;
}
.mix-thumb {
  position: absolute; left: 50%; bottom: 50%; transform: translate(-50%, 50%);
  width: 26px; height: 9px; border-radius: 3px; background: var(--lime);
  border: 2px solid #050508; box-shadow: 0 0 10px var(--lime-glow); pointer-events: none;
}
.mix-mute {
  width: 30px; height: 26px; display: grid; place-items: center; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--line); color: #c3c3d4; cursor: pointer;
}
.mix-mute:hover { border-color: var(--lime); color: var(--lime); }
.mix-mute.on { border-color: var(--red); color: var(--red); background: rgba(229, 103, 103, .12); }

/* Audio bar panels (mixer + options) */
.aux-panel {
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px;
}
.ab-title { font: 10px/1 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .2em; color: #8a8f98; }
.aux-sep { border: none; border-top: 1px solid var(--line); margin: 0; }
.aux-field { display: flex; flex-direction: column; gap: 7px; }
.aux-field input[type=range] { margin: 4px 0 0; }
.aux-flabel { font: 10px/1 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .12em; color: #8a8f98; }
.aux-hint { font: 10px/1.3 'JetBrains Mono', ui-monospace, monospace; color: #6f6f80; margin-top: 2px; }
.aux-hint code { color: var(--lime); background: rgba(204, 255, 2, .08); padding: 0 3px; border-radius: 3px; }
.aux-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.aux-toggle-text { display: flex; flex-direction: column; gap: 4px; }
.aux-toggle-text b { font: 12px/1.1 Inter, system-ui, sans-serif; color: #e6e6ee; font-weight: 600; }
.aux-toggle-text small { font: 10px/1.2 'JetBrains Mono', ui-monospace, monospace; color: #8a8f98; }

/* Custom checkbox */
.vp-check {
  -webkit-appearance: none; appearance: none; flex-shrink: 0;
  width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface-2); cursor: pointer; display: inline-grid; place-content: center; transition: all .12s;
}
.vp-check:hover { border-color: var(--lime); }
.vp-check:checked { background: var(--lime-dim); border-color: var(--lime); box-shadow: 0 0 12px var(--lime-dim); }
.vp-check:checked::after {
  content: ''; width: 5px; height: 9px; margin-top: -2px;
  border: solid var(--lime); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* Add-source dropdown */
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 210px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 6px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .55); display: flex; flex-direction: column; gap: 2px;
}
.dd-item {
  display: flex; align-items: center; gap: 11px; text-align: left; width: 100%;
  padding: 8px 10px; border-radius: 8px; background: transparent; border: 1px solid transparent;
  color: #e0e0e8; cursor: pointer;
}
.dd-item:hover { background: var(--lime-dim); border-color: rgba(204, 255, 2, .25); color: var(--lime); }
.dd-item > [data-icon] { color: var(--lime); flex-shrink: 0; }
.dd-text { display: flex; flex-direction: column; gap: 1px; }
.dd-text b { font: 600 12px/1.1 Inter, system-ui, sans-serif; }
.dd-text small { font: 10px/1 'JetBrains Mono', ui-monospace, monospace; color: #8a8f98; }
.dd-item:hover .dd-text small { color: rgba(204, 255, 2, .7); }

/* Collapsible panels (fast slide) + edge handles */
#rail { transition: margin-left .18s ease; min-height: 0; }
#rail.collapsed { margin-left: -22rem; }
#audiobar { overflow-y: hidden; max-height: 60vh; transition: max-height .18s ease, padding-top .18s ease, padding-bottom .18s ease; }
#audiobar.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; }
.edge-handle {
  position: absolute; z-index: 45; display: grid; place-items: center; cursor: pointer; padding: 0;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--lime); box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
.edge-handle:hover { background: var(--lime-dim); box-shadow: 0 0 16px var(--lime-dim); }
.edge-handle .ico { display: grid; place-items: center; transition: transform .2s ease; }
#railHandle { left: 0; top: 50%; transform: translateY(-50%); width: 16px; height: 60px; border-radius: 0 9px 9px 0; }
#railHandle .ico { transform: rotate(90deg); }          /* ‹ collapse */
#railHandle.closed .ico { transform: rotate(-90deg); }  /* › expand */
.audio-handle-bar { height: 16px; display: grid; place-items: center; cursor: pointer; color: var(--lime); background: var(--surface-2); border-top: 1px solid var(--line); }
.audio-handle-bar:hover { background: var(--lime-dim); }
.audio-handle-bar .ico { display: grid; place-items: center; transition: transform .2s ease; }   /* ⌄ collapse */
.audio-handle-bar.closed .ico { transform: rotate(180deg); }                                       /* ⌃ expand */

/* Sidebar rail + debug panel (debug capped so it never runs off-screen) */
.vp-rail { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#debug { flex: 0 0 auto; }
#debug[open] #cfg { overflow: auto; max-height: 45vh; }
#cfg::-webkit-scrollbar { width: 12px; height: 12px; }
#cfg::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); border-radius: 999px; }
#cfg::-webkit-scrollbar-thumb { background: rgba(204, 255, 2, .32); border-radius: 999px; border: 3px solid #0a0a12; }
#cfg::-webkit-scrollbar-thumb:hover { background: rgba(204, 255, 2, .55); }

/* Themed tooltip (replaces native title) */
.tip {
  position: fixed; z-index: 1000; pointer-events: none; max-width: 280px; white-space: normal;
  background: rgba(10, 10, 16, .96); border: 1px solid rgba(204, 255, 2, .26); color: #e9ffb3;
  font: 11px/1.4 'JetBrains Mono', ui-monospace, monospace; padding: 6px 10px; border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6); backdrop-filter: blur(5px);
}
.tip.hidden { display: none; }

/* Source connect/disconnect toast (center-top) */
.src-toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%) translateY(-24px);
  z-index: 80; display: flex; align-items: center; gap: 10px; pointer-events: none;
  background: #07070d; border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px;
  font: 12px/1 Inter, system-ui, sans-serif; color: #e6e6ee;
  opacity: 0; transition: opacity .22s ease, transform .22s ease; box-shadow: 0 10px 34px rgba(0, 0, 0, .55);
}
.src-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.src-toast b { font-weight: 600; }
.src-toast [data-icon] { display: grid; place-items: center; }
.src-toast.ok { border-color: var(--lime); color: var(--lime); box-shadow: 0 10px 34px rgba(0, 0, 0, .55), 0 0 16px var(--lime-dim); }
.src-toast.ok b { color: #fff; }
.src-toast.bad { border-color: var(--red); color: var(--red); }
.src-toast.bad b { color: #fff; }

/* Crop faux source backdrop */
.faux-source { background: repeating-linear-gradient(45deg, #14141f 0 14px, #111119 14px 28px); }

/* In-monitor live crop overlay */
.crop-ov { position: absolute; inset: 0; z-index: 35; }
.crop-dim { position: absolute; background: rgba(229, 103, 103, .42); pointer-events: none; }
.crop-win { position: absolute; outline: 2px solid var(--lime); box-shadow: 0 0 0 1px #000; }
.crop-h { position: absolute; width: 14px; height: 14px; background: var(--lime); border: 2px solid #050508; border-radius: 3px; }
.crop-h-nw { left: -7px; top: -7px; cursor: nwse-resize; }
.crop-h-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.crop-h-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.crop-h-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.crop-h-n { left: 50%; top: -7px; transform: translateX(-50%); cursor: ns-resize; }
.crop-h-s { left: 50%; bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
.crop-h-w { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.crop-h-e { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

/* Source / preset cards */
.src-card {
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  padding: 16px 18px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.src-card:hover { border-color: rgba(204, 255, 2, .25); }
.src-card.selected { border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime-dim), 0 8px 30px rgba(0, 0, 0, .4), 0 0 26px rgba(204, 255, 2, .06); }
.src-card.dragging-float { position: fixed; z-index: 100; pointer-events: none; opacity: .96; border-color: var(--lime); box-shadow: 0 14px 36px rgba(0, 0, 0, .6); }
.src-placeholder { border: 2px dashed var(--lime); background: var(--lime-dim); border-radius: 12px; }
.grip { cursor: grab; touch-action: none; }
.grip:active { cursor: grabbing; }
.src-url {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10px; color: #aab;
  background: #0a0a12; border: 1px solid var(--line); border-radius: 8px;
  padding: .25rem .45rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Status dots */
.stdot { width: 8px; height: 8px; border-radius: 999px; background: #44445a; transition: background .2s, box-shadow .2s; }
.stdot.on  { background: var(--lime); box-shadow: 0 0 8px var(--lime-glow); }
.stdot.off { background: var(--red); }

.badge {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 9px; letter-spacing: .1em;
  text-transform: uppercase; padding: .08rem .4rem; border-radius: 6px;
  border: 1px solid var(--line); color: #9a9ab0;
}

/* Program monitor: lime ring + faint scanlines (on-brand CRT) */
#stage {
  box-shadow: 0 0 0 1px rgba(204, 255, 2, .10), 0 24px 70px rgba(0, 0, 0, .55), 0 0 60px rgba(204, 255, 2, .05);
}
#stage::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 25; opacity: .5;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0, 0, 0, .14) 3px);
}

/* Centered "video source" placeholder (shown when there's no real frame yet) */
.layer-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  gap: .45rem; pointer-events: none; color: #7b7b92;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px;
  padding: .5rem; overflow: hidden; text-align: center;
}
.layer-ph svg { width: 18px; height: 18px; opacity: .85; flex: none; }

/* On-canvas layer selection/move tab */
.layer-tab {
  position: absolute; top: 0; left: 0; z-index: 15;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10px; line-height: 1;
  padding: .25rem .45rem; background: rgba(5, 5, 8, .8); color: #c3c3d4;
  border: 1px solid var(--line); border-radius: 9px 0 9px 0;
  cursor: move; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.layer-tab.on { color: var(--lime); border-color: var(--lime); background: rgba(5, 5, 8, .92); box-shadow: 0 0 14px var(--lime-dim); }

/* "CROP" badge on a cropped layer in the program monitor */
.crop-badge {
  position: absolute; top: 0; right: 0; z-index: 16;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 9px; letter-spacing: .08em;
  padding: .12rem .35rem; border-radius: 0 0 0 7px;
  background: #e56767; color: #160606; font-weight: 700; white-space: nowrap;
}

/* Floating transform toolbar */
.fb-group {
  display: flex; align-items: center; gap: .1rem;
  background: rgba(13, 13, 22, .9); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 12px;
  padding: .2rem .3rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 0 18px rgba(204, 255, 2, .08);
}
.fb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .32rem; border-radius: 8px; color: #c3c3d4; cursor: pointer; transition: color .12s, background .12s;
}
.fb-btn:hover { color: var(--lime); background: var(--lime-dim); }
.fb-btn.active { color: var(--lime); background: var(--lime-dim); }
.fb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 .25rem; }
/* collapse toggles reflect state */
.iconbtn.active { color: var(--lime); border-color: var(--lime); background: var(--lime-dim); }
.fb-range { width: 72px; margin: 0 .25rem; }

/* Themed scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(204, 255, 2, .25) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(204, 255, 2, .18); border-radius: 999px; border: 2px solid #0d0d16; }
::-webkit-scrollbar-thumb:hover { background: rgba(204, 255, 2, .38); }

/* Layers/handles must claim touch gestures so dragging on the monitor doesn't scroll the page */
.layer, .layer-tab, .crop-h, .crop-win { touch-action: none; }

/* Mobile tab bar (shown only in the narrow layout) */
.mtabs { display: none; }
.mtab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 4px; background: var(--surface-2); border: 1px solid var(--line); border-bottom: none;
  color: #c3c3d4; font: 600 12.5px/1 Inter, system-ui, sans-serif; cursor: pointer;
}
.mtab:first-child { border-radius: 10px 0 0 0; }
.mtab:last-child { border-radius: 0 10px 0 0; }
.mtab [data-icon] { display: grid; place-items: center; }
.mtab.active { color: var(--lime); background: var(--lime-dim); border-color: var(--lime); }

/* ---------- Narrow / mobile layout: monitor on top, one panel below ---------- */
@media (max-width: 880px) {
  /* Natural document scroll — fixed 100vh layouts fight mobile address bars (header was being
     pushed off-screen). The page scrolls; the header stays pinned. */
  body { height: auto !important; overflow: visible !important; }
  header { position: sticky; top: 0; z-index: 50; height: auto; flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; }
  #previewQuality, #pgmspec, #presetStar, #presetDel, #debug { display: none !important; }
  #presetSel { max-width: 120px; }

  #workspace { flex-direction: column; height: auto !important; overflow: visible; }
  #main { order: -1; min-height: 0; overflow: visible; }
  #stagewrap { width: 100%; aspect-ratio: 16 / 9; max-height: 56vh; padding: 10px 10px 4px; }
  #stageHint, #railHandle, #audioHandleBar { display: none !important; }

  .mtabs { display: flex; padding: 0 10px; }

  /* Panels full-width; ignore the desktop collapse handles */
  #rail { width: 100%; margin-left: 0 !important; border-right: none; }
  #rail.collapsed { margin-left: 0 !important; }
  .vp-rail { overflow: visible; }
  #audiobar { max-height: none !important; overflow: visible; flex-direction: column; gap: 14px; padding: 14px 12px !important; }
  #audiobar.collapsed { max-height: none !important; }
  .aux-panel { min-width: 0 !important; }
  .mixer { flex-wrap: wrap; gap: 8px; }

  /* roomier tap targets */
  .iconbtn { padding: .5rem .6rem; }
  .ctl { padding: .55rem .8rem; }

  /* Tab → which panel is visible (rail is the Sources panel; audiobar holds Mixer + Audio) */
  #workspace[data-mtab="sources"] #audiobar { display: none; }
  #workspace[data-mtab="mixer"]  #rail,
  #workspace[data-mtab="output"] #rail { display: none; }
  #workspace[data-mtab="mixer"]  #audiobar .aux-panel:nth-child(2) { display: none; }  /* hide Audio options */
  #workspace[data-mtab="output"] #audiobar .aux-panel:nth-child(1) { display: none; }  /* hide Mixer */
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===================== IRL+ Relay panel layout ===================== */

/* Left nav rail */
.nav-rail { width: 208px; backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 9px 11px; border-radius: 10px; color: #b7b7c8; cursor: pointer;
  font: 500 13px/1 Inter, system-ui, sans-serif; position: relative;
  border: 1px solid transparent; transition: color .14s, background .14s, border-color .14s;
}
.nav-item [data-icon] { display: grid; place-items: center; color: currentColor; opacity: .85; }
.nav-item:hover { color: var(--lime); background: rgba(255,255,255,.03); }
.nav-item.active { color: var(--lime); background: var(--lime-dim); border-color: rgba(204,255,2,.22); }
.nav-item.active::before {
  content: ''; position: absolute; left: -2px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; background: var(--lime); border-radius: 999px; box-shadow: 0 0 8px var(--lime-glow);
}

/* Top status pills */
.stat-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.stat-pill [data-icon] { display: grid; place-items: center; }

/* KPI tiles (Stats view) */
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.kpi-label { font: 9px/1 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .18em; color: #8a8f98; margin-bottom: 8px; }
.kpi-val { font: 700 26px/1 Syne, system-ui, sans-serif; color: var(--lime); text-shadow: 0 0 16px rgba(204,255,2,.18); }
.kpi-unit { font: 400 11px/1 'JetBrains Mono', monospace; color: var(--muted); }

/* Section labels */
.section-label { font: 10px/1 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .2em; color: #8a8f98; }

/* Settings panel cards */
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.panel-card dt { font: 9px/1 'JetBrains Mono', monospace; letter-spacing: .12em; color: #8a8f98; }
.panel-card dd { font: 12px/1.3 'JetBrains Mono', monospace; color: #d8d8e4; }
.panel-card dl > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Modal field label */
.flabel { display: block; font: 10px/1 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .1em; color: #8a8f98; margin-bottom: 5px; }

/* Endpoint row (combined, single copy) */
.ep-row { display: flex; align-items: center; gap: 8px; }
.ep-tag {
  font: 9px/1 'JetBrains Mono', monospace; letter-spacing: .04em; color: var(--lime);
  background: var(--lime-dim); border: 1px solid rgba(204,255,2,.2); border-radius: 6px;
  padding: 4px 7px; min-width: 50px; text-align: center; flex-shrink: 0; white-space: nowrap;
}

/* Endpoint group (Ingest / Playback / Monitor) */
.ep-group + .ep-group { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.ep-group-head {
  font: 9px/1 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .16em; color: #7f7f92;
  margin-bottom: 6px; display: flex; align-items: center; gap: 7px;
}
.ep-group-head::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Contained metric box for live stream cards */
.metric-box {
  display: grid; gap: 10px; margin-top: 12px;
  background: rgba(5,5,8,.5); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px;
}
.metric-box .metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 8px; }
.metric-box .metric-val { color: #eaeaf2; }
/* Each metric as its own tile */
.metric-tile {
  background: rgba(255,255,255,.03); border: 1px solid var(--line-soft); border-radius: 9px;
  padding: 8px 10px; text-align: center;
}
.metric-tile .metric-label { display: block; margin-bottom: 5px; }
.metric-tile .metric-val { font-size: 13px; }
@media (max-width: 640px){ .metric-box .metric-grid { grid-template-columns: repeat(3, 1fr); } }

/* Per-link bonding bars */
.link-row { display: flex; align-items: center; gap: 8px; }
.link-ip { font: 10px/1 'JetBrains Mono', monospace; color: #c3c3d4; width: 120px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-bar { flex: 1; height: 6px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.link-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--lime)); box-shadow: 0 0 8px var(--lime-dim); transition: width .5s ease; }
.link-kbps { font: 10px/1 'JetBrains Mono', monospace; color: var(--lime); width: 74px; text-align: right; flex-shrink: 0; }
.link-down .link-fill { background: var(--red); }
.link-down .link-ip { color: var(--red); }

/* Metric cell (live cards) */
.metric-label { font: 8px/1 'JetBrains Mono', monospace; letter-spacing: .1em; color: var(--muted); }
.metric-val { font: 12px/1 'JetBrains Mono', monospace; color: #e0e0e8; margin-top: 3px; }

/* Narrow: collapse nav labels to icons */
@media (max-width: 720px) {
  .nav-rail { width: 60px; }
  .nav-label { display: none; }
  .nav-item { justify-content: center; padding: 10px 0; }
}

/* ===================== Accordion key cards ===================== */
.acc { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; transition: border-color .15s; }
.acc.open { border-color: rgba(204,255,2,.28); box-shadow: 0 0 0 1px var(--lime-dim), 0 10px 34px rgba(0,0,0,.35); }
.acc-head { display: flex; align-items: center; gap: 9px; padding: 12px 15px; cursor: pointer; user-select: none; transition: background .12s; }
.acc-head:hover { background: rgba(255,255,255,.02); }
.acc-chev { display: grid; place-items: center; color: var(--muted); transition: transform .2s ease, color .15s; flex-shrink: 0; }
.acc.open .acc-chev { transform: rotate(90deg); color: var(--lime); }
.acc-body { padding: 4px 16px 18px; }
.detail-col { background: rgba(5,5,8,.4); border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 16px; }
.drow { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.drow:last-child { border-bottom: none; }
.dlabel { font: 10px/1.2 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .06em; color: #8a8f98; }
.dval { font: 11px/1.3 'JetBrains Mono', ui-monospace, monospace; color: #d8d8e4; text-align: right; }
.spark { width: 100%; }

/* Log rows */
.log-row { display: grid; grid-template-columns: 128px 62px 88px 1fr; gap: 10px; align-items: baseline;
  padding: 6px 10px; border-radius: 8px; font: 11px/1.4 'JetBrains Mono', ui-monospace, monospace; }
.log-row:hover { background: rgba(255,255,255,.025); }
.log-ts { color: #7f7f92; }
.log-lvl { font-size: 9px; letter-spacing: .08em; text-transform: uppercase; padding: 1px 5px; border-radius: 5px; text-align: center; }
.log-lvl.info { color: var(--cyan); background: rgba(2,188,204,.12); }
.log-lvl.warn { color: #e5c767; background: rgba(229,199,103,.12); }
.log-lvl.error { color: var(--red); background: rgba(229,103,103,.14); }
.log-cat { color: var(--lime); opacity: .85; }
.log-msg { color: #c8c8d6; }

/* Log filter chips */
.log-chips { display: flex; flex-wrap: wrap; gap: 12px; }
.lchip-grp { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.lchip-lbl { font: 8px/1 'JetBrains Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: #6f6f82; margin-right: 2px; }
.lchip { font: 9px/1 'JetBrains Mono', ui-monospace, monospace; padding: 4px 8px; border-radius: 6px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); transition: all .12s; }
.lchip:hover { border-color: rgba(204,255,2,.4); color: var(--lime); }
.lchip.on { background: var(--lime-dim); border-color: var(--lime); color: var(--lime); }

/* Log table */
.log-table-wrap { max-height: 66vh; overflow: auto; }
table.log-table { width: 100%; border-collapse: collapse; font: 11px/1.4 'JetBrains Mono', ui-monospace, monospace; }
table.log-table thead th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; color: #6f6f82;
  text-transform: uppercase; letter-spacing: .04em; font-size: 8.5px; padding: 8px 10px; background: #16161f;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
table.log-table thead th.sortable { cursor: pointer; user-select: none; }
table.log-table thead th.sortable:hover, table.log-table thead th.on { color: var(--lime); }
table.log-table td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: baseline; }
table.log-table tbody tr:hover td { background: rgba(255,255,255,.025); }
.log-table .lt-ts { color: #7f7f92; white-space: nowrap; }
.log-table .lt-cat { color: var(--lime); opacity: .85; white-space: nowrap; }
.log-table .lt-user { color: var(--cyan); opacity: .9; white-space: nowrap; }
.log-table .lt-msg { color: #c8c8d6; word-break: break-word; }

/* Resources card (Server Settings) */
.res-row { margin-bottom: 12px; }
.res-head { display: flex; justify-content: space-between; font: 11px/1.4 'Inter', sans-serif; color: #c8c8d4; margin-bottom: 5px; }
.res-bar { height: 7px; border-radius: 99px; background: rgba(255,255,255,.06); overflow: hidden; }
.res-fill { display: block; height: 100%; border-radius: 99px; transition: width .5s ease; }
.res-fill.h-good { background: linear-gradient(90deg, var(--cyan), var(--lime)); }
.res-fill.h-warn { background: linear-gradient(90deg, #c9a13a, var(--amber)); }
.res-fill.h-bad  { background: var(--red); }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.res-grid dt { font: 8px/1 'JetBrains Mono', monospace; letter-spacing: .08em; text-transform: uppercase; color: #6f6f82; margin-bottom: 4px; }
.res-grid dd { font: 12px/1 'JetBrains Mono', monospace; color: #e0e0e8; }

/* Idle stream rows (Stats view) */
.idle-row { display: flex; align-items: center; gap: 9px; padding: 8px 14px; border-radius: 10px;
  background: rgba(255,255,255,.02); border: 1px solid var(--line-soft); }
.idle-row:hover { border-color: var(--line); }

/* KPI tile icons + more accordion padding */
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi-top .kpi-label { margin-bottom: 0; }
.kpi-ic { color: var(--lime); opacity: .5; display: grid; place-items: center; }
.kpi-ic svg { width: 15px; height: 15px; }
.acc-body { padding: 12px 18px 20px !important; }
.acc.open .acc-head { border-bottom: 1px solid var(--line-soft); }

/* ===================== Video preview + usage pills ===================== */
.preview {
  position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden;
  background: #07070d; border: 1px solid var(--line); margin-bottom: 4px;
}
.preview-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.preview-ph { position: absolute; inset: 0; display: grid; place-items: center;
  font: 10px/1.4 'JetBrains Mono', ui-monospace, monospace; color: var(--muted); text-align: center; }
.preview-wait { color: var(--lime); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:1} }
.preview-btn {
  position: absolute; left: 8px; bottom: 8px; z-index: 2; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: 8px; cursor: pointer;
  background: rgba(5,5,8,.72); border: 1px solid var(--line); color: var(--lime); backdrop-filter: blur(4px);
}
.preview-btn:hover { border-color: var(--lime); box-shadow: 0 0 14px var(--lime-dim); }
.preview-cap { position: absolute; right: 8px; bottom: 8px; z-index: 2;
  font: 8px/1.2 'JetBrains Mono', monospace; color: rgba(255,255,255,.45); background: rgba(5,5,8,.5);
  padding: 2px 6px; border-radius: 5px; }

/* Usage window pills */
.usage-pills { display: inline-flex; gap: 3px; }
.upill {
  font: 9px/1 'JetBrains Mono', ui-monospace, monospace; padding: 3px 7px; border-radius: 6px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); transition: all .12s;
}
.upill:hover { border-color: rgba(204,255,2,.4); color: var(--lime); }
.upill.on { background: var(--lime-dim); border-color: var(--lime); color: var(--lime); }

/* Ingest bonded hint */
.ingest-hint { font: 9px/1.4 'JetBrains Mono', monospace; color: #7f7f92; margin: 6px 0 4px; padding-left: 2px; }

/* ---- Confirm modal ---- */
.modal-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; width: min(92vw, 400px); box-shadow: 0 24px 60px rgba(0,0,0,.6); }
.confirm-title { font: 700 15px/1.3 'Syne', sans-serif; color: #f0f0f5; margin-bottom: 8px; }
.confirm-body { font: 12px/1.6 'Inter', sans-serif; color: var(--muted); margin-bottom: 18px; }
.confirm-body b { color: #e6e6ee; font-weight: 600; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.ctl-danger { background: rgba(229,103,103,.14); border-color: rgba(229,103,103,.5); color: #f0a5a5; }
.ctl-danger:hover { background: rgba(229,103,103,.22); border-color: var(--red); color: #ffd5d5; box-shadow: 0 0 20px rgba(229,103,103,.25); }

/* ---- Empty-state CTA (Stream Keys) ---- */
.empty-cta { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; cursor: pointer;
  padding: 40px 24px; border: 1.5px dashed var(--line); border-radius: 16px; background: rgba(255,255,255,.015);
  transition: border-color .15s, background .15s; }
.empty-cta:hover { border-color: rgba(204,255,2,.45); background: rgba(204,255,2,.03); }
.empty-cta .empty-ic { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 4px;
  border-radius: 11px; background: var(--lime-dim); color: var(--lime); }
.empty-cta .empty-ic svg { width: 20px; height: 20px; }
.empty-cta .empty-t { font: 600 15px/1.2 'Syne', sans-serif; color: #eaeaf2; }
.empty-cta .empty-s { font: 11px/1.5 'Inter', sans-serif; color: var(--muted); max-width: 420px; text-align: center; }

/* ---- Health grading (link telemetry) ---- */
.h-good { color: var(--lime) !important; }
.h-warn { color: var(--amber) !important; }
.h-bad  { color: var(--red) !important; }
.h-muted{ color: var(--muted) !important; }
.metric-tile[title] { cursor: help; }
.link-fill.h-good { background: linear-gradient(90deg, var(--cyan), var(--lime)); }
.link-fill.h-warn { background: linear-gradient(90deg, #c9a13a, var(--amber)); box-shadow: 0 0 8px rgba(245,196,81,.25); }
.link-fill.h-bad  { background: var(--red); box-shadow: none; }
.hdot { width: 7px; height: 7px; border-radius: 999px; flex: 0 0 auto; }
.hdot.h-good { background: var(--lime); box-shadow: 0 0 6px var(--lime-glow); }
.hdot.h-warn { background: var(--amber); box-shadow: 0 0 6px rgba(245,196,81,.5); }
.hdot.h-bad  { background: var(--red); box-shadow: 0 0 6px rgba(229,103,103,.5); }

/* ---- Session history table ---- */
.sess-wrap { border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden; background: rgba(10,10,16,.35); }
table.sess { width: 100%; border-collapse: collapse; font: 10px/1.3 'JetBrains Mono', ui-monospace, monospace; }
table.sess th { text-align: left; font-weight: 600; color: #6f6f82; text-transform: uppercase; letter-spacing: .04em;
  font-size: 8.5px; padding: 6px 9px; background: rgba(255,255,255,.03); border-bottom: 1px solid var(--line-soft); }
table.sess td { padding: 6px 9px; color: #c8c8d4; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.sess tbody tr:last-child td, table.sess tr:last-child td { border-bottom: none; }
table.sess tbody tr:hover td { background: rgba(204,255,2,.04); }
.sess .ta-r { text-align: right; }
.sess-empty { font: 10px/1.4 'JetBrains Mono', monospace; color: #6f6f82; padding: 10px 2px; }
table.sess th.sortable { cursor: pointer; user-select: none; transition: color .12s; }
table.sess th.sortable:hover { color: var(--lime); }
table.sess th.on { color: var(--lime); }
.sess .sort-ar { margin-left: 3px; font-size: 8px; }
.sess-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 9px; background: rgba(255,255,255,.02); font: 9px/1 'JetBrains Mono', monospace; color: #7f7f92; }
.spage { font: 9px/1 'JetBrains Mono', monospace; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; cursor: pointer; transition: all .12s; }
.spage:hover:not(:disabled) { border-color: rgba(204,255,2,.4); color: var(--lime); }
.spage:disabled { opacity: .35; cursor: default; }
