:root {
  --bg: #0c0b11;
  --panel: rgba(29, 26, 39, .88);
  --panel-2: rgba(20, 18, 28, .92);
  --ink: #f7f2ff;
  --muted: #a9a3b7;
  --line: rgba(255,255,255,.10);
  --line-strong: rgba(255,255,255,.18);
  --pink: #ff5f9e;
  --peach: #ff9f7f;
  --cyan: #69e8ff;
  --mint: #73f3ca;
  --violet: #b89cff;
  --warning: #ffd36c;
  --shadow: 0 24px 70px rgba(0,0,0,.42);
  --radius: 22px;
  --radius-sm: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255,95,158,.16), transparent 26rem),
    radial-gradient(circle at 86% 18%, rgba(105,232,255,.12), transparent 30rem),
    linear-gradient(145deg, #0d0b13 0%, #12101a 48%, #0a0910 100%);
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.scanlines {
  pointer-events: none; position: fixed; inset: 0; z-index: 50; opacity: .18;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(255,255,255,.022) 4px);
  mix-blend-mode: soft-light;
}

.app-shell { width: min(1720px, 100%); margin: 0 auto; padding: 18px clamp(14px, 2vw, 30px) 20px; }
.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand strong { display: block; letter-spacing: .12em; font-size: clamp(.92rem, 1.5vw, 1.08rem); }
.brand small { color: var(--muted); letter-spacing: .13em; font-size: .66rem; }
.brand-mark { width: 43px; height: 43px; border: 1px solid var(--line-strong); border-radius: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 7px; background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.02)); box-shadow: inset 0 0 18px rgba(255,255,255,.04), 0 0 28px rgba(255,95,158,.10); }
.brand-mark i { display: block; border-radius: 3px; }
.brand-mark i:nth-child(1) { background: var(--pink); }
.brand-mark i:nth-child(2) { background: var(--cyan); }
.brand-mark i:nth-child(3) { background: var(--violet); }
.brand-mark i:nth-child(4) { background: var(--mint); }
.top-actions { display: flex; align-items: center; gap: 9px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; font-size: .68rem; letter-spacing: .09em; font-weight: 800; }
.pill.good { color: var(--mint); background: rgba(115,243,202,.08); }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.045); cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.09); }

.workspace { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.panel { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); }
.library-panel { min-height: calc(100dvh - 130px); padding: 18px; display: flex; flex-direction: column; overflow: hidden; }
.panel-heading, .player-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0 0 5px; color: var(--cyan); letter-spacing: .13em; font-size: .66rem; font-weight: 900; }
h1,h2 { margin: 0; font-size: 1.08rem; line-height: 1.25; }
.counter { min-width: 33px; height: 33px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); font-weight: 800; }

.source-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 12px; }
.btn { min-height: 42px; border: 1px solid var(--line-strong); border-radius: 12px; background: rgba(255,255,255,.055); cursor: pointer; font-weight: 800; font-size: .82rem; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.10); }
.btn.primary { color: #17121d; border-color: transparent; background: linear-gradient(135deg, var(--pink), var(--peach)); box-shadow: 0 8px 28px rgba(255,95,158,.18); }
.btn.ghost { color: var(--muted); }
.source-note { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 13px; padding: 11px; background: rgba(0,0,0,.14); }
.status-dot { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 5px; border-radius: 999px; background: var(--mint); box-shadow: 0 0 11px rgba(115,243,202,.75); }
.source-note strong, .source-note small { display: block; }
.source-note strong { font-size: .79rem; }
.source-note small { margin-top: 2px; color: var(--muted); font-size: .68rem; line-height: 1.4; }
.filters { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 7px; margin: 14px 0 10px; }
.filters label span, .stack-label span { display: block; margin: 0 0 5px; color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .06em; }
.filters select, .filters input, .stack-label input, .speed-select { width: 100%; min-height: 36px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: #17141f; padding: 0 9px; }
.mini-btn { min-height: 36px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.045); cursor: pointer; color: var(--muted); font-size: .73rem; font-weight: 800; }

.session-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 3px; }
.session-list::-webkit-scrollbar { width: 6px; }
.session-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 999px; }
.session-item { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 11px 10px; margin: 0 0 7px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.028); cursor: pointer; text-align: left; transition: .15s ease; }
.session-item:hover { background: rgba(255,255,255,.065); }
.session-item.active { border-color: rgba(255,95,158,.55); background: linear-gradient(90deg, rgba(255,95,158,.12), rgba(105,232,255,.05)); }
.session-date { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--cyan); font-size: .63rem; line-height: 1.08; text-align: center; font-weight: 900; text-transform: uppercase; }
.session-meta strong { display: block; font-size: .83rem; }
.session-meta small { display: block; margin-top: 2px; color: var(--muted); font-size: .66rem; }
.cam-count { color: var(--mint); font-size: .65rem; font-weight: 900; }

.player-panel { min-width: 0; padding: 18px; display: flex; flex-direction: column; }
.player-head { margin-bottom: 14px; }
.sync-readout { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; color: var(--muted); font-size: .64rem; letter-spacing: .07em; font-weight: 900; }
.sync-readout .status-dot { margin: 0; width: 7px; height: 7px; flex-basis: 7px; }
.screen-wrap { min-height: 0; }
.video-stage { position: relative; width: 100%; aspect-ratio: 16/9; max-height: 65dvh; background: #030307; border: 1px solid rgba(255,255,255,.12); border-radius: 18px; overflow: hidden; box-shadow: inset 0 0 80px rgba(0,0,0,.75), 0 18px 45px rgba(0,0,0,.28); }
.video-stage::before { content: ""; pointer-events: none; position: absolute; inset: 0; z-index: 4; box-shadow: inset 0 0 70px rgba(0,0,0,.35); }
.camera-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #030307; opacity: 0; z-index: 0; pointer-events: none; }
.camera-video.active { opacity: 1; z-index: 1; }
.screen-overlay { position: absolute; left: 13px; right: 13px; top: 12px; z-index: 6; display: none; justify-content: space-between; pointer-events: none; color: rgba(255,255,255,.85); font: 800 .69rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; text-shadow: 0 1px 4px rgba(0,0,0,.9); }
.video-stage:not(.empty) .screen-overlay { display: flex; }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); font-size: 1rem; }
.empty-state span { max-width: 32rem; margin-top: 5px; font-size: .78rem; line-height: 1.45; }
.empty-state.compact { position: static; min-height: 160px; border: 1px dashed var(--line); border-radius: 14px; margin-top: 5px; }
.empty-icon { font-size: 2rem; color: var(--pink); margin-bottom: 8px; transform: rotate(-5deg); }
.camera-selector { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; margin-top: 9px; }
.cam-btn { min-height: 40px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.035); color: var(--muted); cursor: pointer; font-weight: 800; font-size: .75rem; }
.cam-btn span { margin-right: 5px; color: var(--violet); }
.cam-btn.active { color: var(--ink); border-color: rgba(105,232,255,.45); background: rgba(105,232,255,.08); }
.cam-btn:disabled { opacity: .38; cursor: not-allowed; }

.transport { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: rgba(0,0,0,.12); }
.transport-row { display: flex; align-items: center; gap: 8px; }
.round-btn, .play-btn { border: 1px solid var(--line); background: rgba(255,255,255,.045); cursor: pointer; font-weight: 900; }
.round-btn { width: 38px; height: 38px; border-radius: 999px; color: var(--muted); font-size: .69rem; }
.play-btn { width: 43px; height: 43px; border-radius: 999px; color: #160f1b; background: linear-gradient(135deg, var(--cyan), var(--mint)); border-color: transparent; box-shadow: 0 0 24px rgba(105,232,255,.15); }
.time-readout { min-width: 104px; color: var(--muted); font: 700 .72rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.spacer { flex: 1; }
.speed-select { width: 72px; min-height: 36px; }
.seek { width: 100%; margin: 9px 0 0; accent-color: var(--pink); }

.camera-grid { display: none; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 12px; }
.camera-card { display: flex; align-items: center; gap: 9px; min-width: 0; min-height: 58px; padding: 9px; text-align: left; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); cursor: pointer; }
.camera-card:hover { background: rgba(255,255,255,.06); }
.camera-card.active { border-color: rgba(255,95,158,.43); background: rgba(255,95,158,.07); }
.camera-card.missing { opacity: .38; cursor: not-allowed; }
.cam-icon { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 31px; border: 1px solid var(--line); border-radius: 9px; color: var(--violet); background: rgba(255,255,255,.035); }
.camera-card strong, .camera-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera-card strong { font-size: .74rem; }
.camera-card small { margin-top: 2px; color: var(--muted); font-size: .61rem; }
.footer { display: flex; justify-content: space-between; gap: 16px; padding: 13px 4px 0; color: #777182; font-size: .62rem; }

.settings-dialog { width: min(560px, calc(100% - 24px)); padding: 0; border: 0; background: transparent; color: var(--ink); }
.settings-dialog::backdrop { background: rgba(5,4,8,.72); backdrop-filter: blur(8px); }
.dialog-card { border: 1px solid var(--line-strong); border-radius: 20px; background: #17141f; padding: 19px; box-shadow: var(--shadow); }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.dialog-copy { color: var(--muted); font-size: .78rem; line-height: 1.5; }
.stack-label { display: block; margin-top: 10px; }
.stack-label input { min-height: 43px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.dialog-actions .btn { padding: 0 16px; }
.test-result { min-height: 22px; margin-top: 10px; color: var(--muted); font-size: .72rem; }
.test-result.good { color: var(--mint); }
.test-result.bad { color: var(--warning); }
.dialog-tip { border: 1px solid var(--line); border-radius: 12px; padding: 10px; color: var(--muted); background: rgba(0,0,0,.16); font-size: .7rem; line-height: 1.45; }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 100; max-width: min(520px, calc(100vw - 24px)); padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: #201b29; color: var(--ink); box-shadow: var(--shadow); font-size: .76rem; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Medium-height desktop: keep the full player on one screen */
@media (min-width: 901px) and (max-height: 920px) {
  .app-shell { padding-bottom: 8px; }
  .footer { display: none; }
}

/* Short desktops and Fold/tablet landscape */
@media (min-width: 700px) and (max-height: 700px) {
  .app-shell { padding-top: 8px; }
  .topbar { min-height: 48px; margin-bottom: 8px; }
  .brand-mark { width: 37px; height: 37px; }
  .workspace { grid-template-columns: 280px minmax(0,1fr); gap: 10px; }
  .library-panel, .player-panel { padding: 12px; border-radius: 17px; }
  .library-panel { min-height: calc(100dvh - 82px); }
  .source-actions { margin: 10px 0 8px; }
  .btn { min-height: 35px; }
  .source-note { padding: 8px; }
  .filters { margin: 9px 0 7px; }
  .session-item { padding: 7px 8px; margin-bottom: 5px; }
  .session-date { width: 36px; height: 36px; }
  .player-head { margin-bottom: 8px; }
  .video-stage { max-height: min(57dvh, calc(100dvh - 290px)); }
  .cam-btn { min-height: 32px; }
  .transport { margin-top: 7px; padding: 7px 9px; }
  .round-btn { width: 32px; height: 32px; }
  .play-btn { width: 36px; height: 36px; }
  .camera-grid { margin-top: 7px; }
  .camera-card { min-height: 44px; padding: 6px 8px; }
  .cam-icon { width: 26px; height: 26px; flex-basis: 26px; }
  .footer { display: none; }
}

/* Tablets / Fold portrait */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .library-panel { min-height: auto; max-height: none; }
  .session-list { max-height: 260px; }
  .video-stage { max-height: none; }
  .player-panel { min-height: auto; }
}

/* Phones */
@media (max-width: 620px) {
  .app-shell { padding: 10px 9px max(12px, env(safe-area-inset-bottom)); }
  .topbar { min-height: 54px; margin-bottom: 9px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand small { display: none; }
  .pill { display: none; }
  .workspace { gap: 9px; }
  .panel { border-radius: 17px; }
  .library-panel, .player-panel { padding: 12px; }
  .source-actions { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .mini-btn { grid-column: 1 / -1; }
  .session-list { max-height: 210px; }
  .player-head { align-items: center; }
  .sync-readout { padding: 6px 8px; font-size: .58rem; }
  .video-stage { border-radius: 13px; }
  .camera-selector { gap: 4px; }
  .cam-btn { min-height: 36px; padding: 0 3px; font-size: .66rem; }
  .transport-row { flex-wrap: wrap; }
  .spacer { display: none; }
  .time-readout { order: 4; flex: 1 0 100%; }
  .camera-grid { grid-template-columns: 1fr 1fr; }
  .footer { flex-direction: column; gap: 3px; }
}

/* Very narrow Fold cover / small phones */
@media (max-width: 380px) {
  .source-actions { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .filters .mini-btn { grid-column: auto; }
  .camera-card { min-height: 52px; }
  .cam-icon { display: none; }
}

/* Dedicated ultra-wide / infotainment mode — isolated from normal screens */
@media (min-width: 900px) and (min-aspect-ratio: 2/1) {
  .app-shell { width: 100%; max-width: none; padding: 8px 14px; }
  .topbar { min-height: 44px; margin-bottom: 7px; }
  .brand-mark { width: 35px; height: 35px; border-radius: 10px; }
  .workspace { grid-template-columns: minmax(245px, 18vw) minmax(0,1fr); gap: 9px; }
  .library-panel, .player-panel { padding: 10px 12px; border-radius: 16px; }
  .library-panel { min-height: calc(100dvh - 66px); }
  .source-actions { grid-template-columns: 1fr 1fr; margin: 7px 0; gap: 5px; }
  .btn { min-height: 31px; font-size: .7rem; }
  .source-note { padding: 6px 8px; }
  .filters { margin: 7px 0 5px; }
  .filters select, .filters input, .mini-btn { min-height: 30px; }
  .session-item { padding: 5px 7px; margin-bottom: 4px; }
  .session-date { width: 32px; height: 32px; }
  .player-head { margin-bottom: 6px; }
  .screen-wrap { display: grid; grid-template-columns: minmax(0,1fr) 82px; gap: 7px; }
  .video-stage { max-height: calc(100dvh - 220px); }
  .camera-selector { grid-template-columns: 1fr; margin: 0; gap: 5px; }
  .cam-btn { min-height: 0; height: auto; }
  .transport { margin-top: 6px; padding: 6px 8px; }
  .round-btn { width: 31px; height: 31px; }
  .play-btn { width: 35px; height: 35px; }
  .camera-grid { grid-template-columns: repeat(4,1fr); margin-top: 6px; gap: 5px; }
  .camera-card { min-height: 38px; padding: 5px 7px; }
  .cam-icon { width: 24px; height: 24px; flex-basis: 24px; }
  .footer { display: none; }
}
/* v0.2.5 private-account controls */
.top-actions{display:flex;align-items:center;gap:10px}.logout-form{margin:0;display:flex}.account-link{text-decoration:none;display:grid;place-items:center;color:#76e8df;font-size:13px}.logout-form .icon-btn{color:#f3b1c4}
@media(max-width:520px){.top-actions{gap:6px}.top-actions .icon-btn{width:42px;height:42px}.top-actions .pill{display:none}}
