:root {
  --bg: #020509;
  --bg-soft: #050b11;
  --panel: rgba(5, 12, 18, 0.84);
  --panel-strong: #071019;
  --line: #133246;
  --cyan: #40c9ff;
  --cyan-soft: #1e7ba3;
  --green: #41ef86;
  --green-dark: #167541;
  --red: #ff5470;
  --amber: #ffc45d;
  --text: #f5f7fa;
  --muted: #7f8999;
  --nav-h: 92px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 24px;
  --font: "Arlon", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
body { margin: 0; background: radial-gradient(circle at 50% 12%, rgba(22, 78, 110, .18), transparent 34%), var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; letter-spacing: .01em; }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.app-shell { width: min(100%, 820px); margin: 0 auto; min-height: 100vh; padding: 0 20px calc(var(--nav-h) + var(--safe-bottom) + 40px); }
.app-header { min-height: 138px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid rgba(64, 201, 255, .24); padding: 20px 4px 18px; }
.brand-wrap { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand-mark { width: 100px; height: 76px; display: flex; flex-direction: column; justify-content: center; align-items: center; line-height: .8; flex: 0 0 auto; }
.brand-i9 { font-family: Georgia, serif; font-size: 48px; font-weight: 800; letter-spacing: -6px; background: linear-gradient(180deg, #ffffff 0%, #42cfff 38%, #1d4f9e 64%, #d1a455 96%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.brand-space { margin-top: 10px; font-size: 10px; letter-spacing: 7px; color: #c9a15d; }
.brand-copy { min-width: 0; }
.brand-copy strong { font-size: clamp(22px, 5vw, 32px); font-weight: 300; display: block; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eyebrow { display: block; color: var(--cyan); font-size: 13px; letter-spacing: .22em; text-transform: uppercase; }
.status-pill { border: 1.5px solid var(--green); color: var(--green); background: rgba(4, 16, 11, .7); border-radius: 999px; padding: 14px 18px; letter-spacing: .08em; white-space: nowrap; display: inline-flex; align-items: center; gap: 11px; box-shadow: inset 0 0 18px rgba(65, 239, 134, .08); }
.status-pill--offline { border-color: var(--red); color: var(--red); }
.status-dot { width: 11px; height: 11px; border-radius: 50%; background: currentColor; box-shadow: 0 0 12px currentColor; }
.program-card { min-height: 190px; margin: 28px 0 34px; padding: 42px 36px; border: 1.5px solid var(--green-dark); border-radius: 30px; background: radial-gradient(circle at 100% 0, rgba(64,201,255,.06), transparent 30%), rgba(5, 12, 18, .64); display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; position: relative; overflow: hidden; }
.program-card::after { content: ""; position: absolute; right: -66px; top: -77px; width: 180px; height: 180px; border: 1px solid rgba(64,201,255,.18); border-radius: 50%; }
.program-card h1 { font-size: clamp(36px, 8vw, 58px); font-weight: 200; margin: 16px 0 0; line-height: 1; }
.lab-badge { border: 1px solid var(--green); color: var(--green); border-radius: 12px; padding: 14px 16px; letter-spacing: .12em; z-index: 1; }
.page { display: none; animation: fadeIn .22s ease; }
.page--active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-heading h2 { font-size: 34px; font-weight: 200; margin: 10px 0 0; }
.icon-button { width: 66px; height: 66px; border-radius: 50%; border: 1.5px solid var(--cyan); color: var(--cyan); background: transparent; font-size: 30px; cursor: pointer; }
.icon-button:active { transform: scale(.96); }
.scene-grid, .commercial-grid, .preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.scene-card { min-height: 158px; padding: 28px 24px; border: 1.5px solid var(--cyan); border-radius: 25px; background: linear-gradient(150deg, rgba(8,17,26,.72), rgba(1,4,8,.92)); text-align: left; display: flex; flex-direction: column; justify-content: space-between; color: var(--text); cursor: pointer; }
.scene-card strong { font-size: 25px; font-weight: 300; line-height: 1.25; }
.scene-card span { color: var(--cyan); letter-spacing: .12em; font-size: 13px; }
.scene-card--active { border-color: var(--green-dark); box-shadow: inset 0 0 18px rgba(65,239,134,.03); }
.scene-card--active strong { color: rgba(245,247,250,.38); }
.scene-card--active span { color: var(--green-dark); }
.camera-list, .audio-list, .system-status { display: grid; gap: 14px; }
.camera-card, .audio-card, .system-row { border: 1px solid rgba(64,201,255,.48); background: var(--panel); border-radius: 21px; padding: 20px; }
.camera-card { display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 14px; }
.camera-preview { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, rgba(64,201,255,.18), rgba(65,239,134,.07)); border: 1px solid rgba(64,201,255,.24); }
.camera-meta strong, .audio-head strong { display: block; font-weight: 400; }
.camera-meta small, .audio-head small { color: var(--muted); display: block; margin-top: 5px; }
.badge { padding: 7px 10px; border-radius: 999px; font-size: 11px; letter-spacing: .1em; border: 1px solid currentColor; }
.badge--online { color: var(--green); }
.badge--waiting { color: var(--amber); }
.badge--offline { color: var(--muted); }
.action-panel, .health-card, .log-panel { margin-top: 20px; border: 1px solid rgba(64,201,255,.28); background: linear-gradient(150deg, rgba(7,16,25,.82), rgba(2,5,9,.88)); border-radius: 24px; padding: 24px; }
.action-panel h3, .health-card h3 { font-size: 22px; font-weight: 400; margin: 0 0 9px; }
.action-panel p { color: var(--muted); margin: 0 0 20px; line-height: 1.55; }
.primary-button, .secondary-button, .danger-button { min-height: 52px; border-radius: 15px; padding: 13px 18px; letter-spacing: .08em; cursor: pointer; }
.primary-button { width: 100%; border: 1.5px solid var(--green); color: #031008; background: var(--green); font-weight: 700; }
.secondary-button { width: 100%; border: 1.5px solid var(--cyan); color: var(--cyan); background: transparent; }
.danger-button { width: 100%; border: 1.5px solid var(--red); color: var(--red); background: transparent; }
.audio-card { padding: 20px 18px; }
.audio-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.mute-button { border: 1px solid var(--cyan); color: var(--cyan); background: transparent; border-radius: 12px; padding: 9px 13px; }
.mute-button--active { border-color: var(--red); color: var(--red); }
.fader-wrap { display: grid; grid-template-columns: 1fr 54px; align-items: center; gap: 14px; }
.fader { width: 100%; accent-color: var(--cyan); }
.vu-meter { height: 8px; border-radius: 99px; background: rgba(127,137,153,.2); margin-top: 12px; overflow: hidden; }
.vu-meter span { display: block; width: 62%; height: 100%; background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); transform-origin: left center; animation: vu 1.3s ease-in-out infinite alternate; }
@keyframes vu { from { transform: scaleX(.45); } to { transform: scaleX(.95); } }
.switch-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; cursor: pointer; position: relative; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { width: 52px; height: 30px; border-radius: 99px; background: #1a2430; position: relative; transition: .2s; }
.switch-ui::after { content: ""; width: 24px; height: 24px; background: white; border-radius: 50%; position: absolute; left: 3px; top: 3px; transition: .2s; }
.switch-row input:checked + .switch-ui { background: var(--green-dark); }
.switch-row input:checked + .switch-ui::after { transform: translateX(22px); }
.countdown { border: 1px solid var(--cyan); color: var(--cyan); border-radius: 14px; padding: 10px 13px; font-variant-numeric: tabular-nums; }
.commercial-card, .preset-card { min-height: 145px; border: 1.5px solid var(--cyan); border-radius: 23px; background: var(--panel); color: var(--text); padding: 22px; display: flex; flex-direction: column; text-align: left; justify-content: space-between; cursor: pointer; }
.commercial-card strong { color: var(--cyan); font-size: 34px; font-weight: 300; }
.commercial-card span { color: var(--muted); }
.commercial-card--stop { border-color: var(--red); }
.commercial-card--stop strong { color: var(--red); }
.preset-card span { font-size: 26px; }
.preset-card strong { font-size: 21px; font-weight: 400; margin-top: 18px; }
.preset-card small { color: var(--muted); margin-top: 8px; line-height: 1.35; }
.preset-card--active { border-color: var(--green); box-shadow: 0 0 18px rgba(65,239,134,.08); }
.health-score-wrap { display: flex; align-items: center; gap: 18px; }
.health-score { width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--cyan); color: var(--cyan); font-size: 26px; }
.health-score-wrap strong { display: block; margin-top: 7px; font-weight: 400; }
.health-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.health-bar { background: rgba(127,137,153,.1); border-radius: 12px; padding: 12px 8px; text-align: center; }
.health-bar span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.health-bar strong { font-size: 14px; font-weight: 400; }
.teleprompter-panel textarea { width: 100%; resize: vertical; background: #02070c; border: 1px solid rgba(64,201,255,.35); border-radius: 15px; color: var(--text); padding: 15px; margin: 12px 0 16px; }
.system-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.system-row span { color: var(--muted); }
.system-row strong { font-weight: 400; }
.system-state { display: inline-flex; align-items: center; gap: 8px; color: var(--green); }
.system-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.system-state--warn { color: var(--amber); }
.system-state--off { color: var(--red); }
.two-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.log-title { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; letter-spacing: .12em; }
.log-title button { color: var(--cyan); background: transparent; border: 0; }
.log-list { margin-top: 14px; max-height: 230px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: #aab3c1; }
.log-item { padding: 8px 0; border-bottom: 1px solid rgba(127,137,153,.12); }
.log-item time { color: var(--cyan); margin-right: 8px; }
.app-footer { display: flex; justify-content: space-between; gap: 20px; color: #626b78; font-size: 12px; letter-spacing: .08em; padding: 30px 0 14px; }
.bottom-nav { position: fixed; z-index: 20; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 820px); min-height: calc(var(--nav-h) + var(--safe-bottom)); padding: 9px 10px calc(8px + var(--safe-bottom)); background: rgba(2,5,9,.96); border-top: 1px solid rgba(64,201,255,.18); display: grid; grid-template-columns: repeat(6, 1fr); backdrop-filter: blur(18px); }
.nav-item { color: #7b8595; background: transparent; border: 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; cursor: pointer; }
.nav-item span { font-size: 25px; line-height: 1; }
.nav-item small { font-size: 11px; white-space: nowrap; }
.nav-item--active { color: var(--cyan); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 18px); transform: translate(-50%, 20px); opacity: 0; width: min(calc(100% - 36px), 520px); padding: 14px 18px; border-radius: 15px; background: #0d1720; border: 1px solid var(--cyan); color: var(--text); pointer-events: none; transition: .22s; }
.toast--show { opacity: 1; transform: translate(-50%, 0); }
.preloader { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: #000; transition: opacity .5s, visibility .5s; }
.preloader--hidden { opacity: 0; visibility: hidden; }
.preloader-frame { width: min(84vw, 380px); min-height: 440px; border: 1.5px solid var(--green); border-radius: 36px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; box-shadow: inset 0 0 50px rgba(64,201,255,.05), 0 0 26px rgba(65,239,134,.05); text-align: center; }
.brand-mark--large { transform: scale(1.45); margin-bottom: 38px; }
.preloader-frame p { font-size: 20px; margin: 10px 0 26px; }
.preloader-frame small { margin-top: 24px; color: var(--green); letter-spacing: .1em; }
.loader-ring { width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(64,201,255,.2); border-top-color: var(--cyan); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal { width: min(calc(100% - 32px), 520px); border: 1px solid var(--cyan); border-radius: 24px; background: #071019; color: var(--text); padding: 0; }
.modal::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(5px); }
.modal form { padding: 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-weight: 400; }
.modal-head button { border: 0; background: transparent; color: var(--text); font-size: 30px; }
.modal label { display: grid; gap: 8px; margin-top: 20px; color: var(--muted); }
.modal input, .modal select { width: 100%; min-height: 50px; border: 1px solid rgba(64,201,255,.35); background: #02070c; color: var(--text); border-radius: 13px; padding: 0 13px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
@media (max-width: 620px) {
  .app-shell { padding-inline: 16px; }
  .app-header { min-height: 122px; }
  .brand-mark { width: 75px; transform: scale(.9); transform-origin: left center; }
  .brand-wrap { gap: 8px; }
  .brand-copy .eyebrow { font-size: 10px; letter-spacing: .18em; }
  .brand-copy strong { font-size: 20px; }
  .status-pill { padding: 12px 13px; font-size: 12px; }
  .program-card { padding: 34px 26px; min-height: 172px; }
  .scene-grid { gap: 12px; }
  .scene-card { min-height: 142px; padding: 23px 18px; border-radius: 22px; }
  .scene-card strong { font-size: 21px; }
  .scene-card span { font-size: 11px; }
}
@media (max-width: 390px) {
  .status-pill span:last-child { display: none; }
  .status-pill { width: 48px; height: 48px; justify-content: center; padding: 0; }
  .commercial-grid, .preset-grid { grid-template-columns: 1fr; }
  .health-bars { grid-template-columns: repeat(2, 1fr); }
  .nav-item small { font-size: 9px; }
}


.heading-actions { display: flex; align-items: center; gap: 10px; }
.heading-actions .icon-button { flex: 0 0 auto; }
.source-summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -6px 0 18px; padding: 13px 16px; border: 1px solid rgba(64,201,255,.24); border-radius: 15px; background: rgba(5,12,18,.64); }
.source-summary strong { color: var(--green); font-weight: 400; letter-spacing: .08em; font-size: 12px; }
.source-summary span { color: var(--muted); font-size: 12px; text-align: right; }
.source-list { display: grid; gap: 12px; }
.source-card { border: 1px solid rgba(64,201,255,.42); background: var(--panel); border-radius: 19px; overflow: hidden; margin-left: calc(var(--source-depth, 0) * 12px); }
.source-card--hidden { border-color: rgba(127,137,153,.25); opacity: .78; }
.source-row { min-height: 78px; display: grid; grid-template-columns: 30px 42px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 13px 14px; }
.source-expand { width: 30px; height: 30px; border: 0; color: var(--cyan); background: transparent; font-size: 27px; line-height: 1; transform: rotate(0deg); transition: transform .18s; }
.source-expand--open { transform: rotate(90deg); }
.source-expand--placeholder { display: block; }
.source-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; border: 1px solid rgba(64,201,255,.22); color: var(--cyan); background: rgba(64,201,255,.07); font-size: 19px; }
.source-meta { min-width: 0; }
.source-meta strong { display: block; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-meta small { display: block; color: var(--muted); margin-top: 5px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.source-state, .source-mini-button { min-height: 34px; border-radius: 10px; padding: 7px 9px; border: 1px solid currentColor; background: transparent; font-size: 10px; letter-spacing: .07em; cursor: pointer; }
.source-state { color: var(--green); }
.source-state--off { color: var(--muted); }
.source-state--warn { color: var(--amber); }
.source-state--error { color: var(--red); }
.source-mini-button { color: var(--cyan); }
.source-mini-button--danger { color: var(--red); }
.source-audio-controls { display: grid; grid-template-columns: auto minmax(0,1fr) 48px; gap: 10px; align-items: center; padding: 0 14px 14px 96px; }
.source-volume { width: 100%; accent-color: var(--cyan); }
.source-audio-controls output { color: var(--muted); font-size: 12px; text-align: right; }
.source-children { display: grid; gap: 9px; padding: 0 10px 10px; border-top: 1px solid rgba(64,201,255,.10); }
.source-children .source-card { margin-top: 9px; background: rgba(2,7,12,.74); }
.source-empty { min-height: 150px; border: 1px dashed rgba(64,201,255,.32); border-radius: 20px; display: grid; place-content: center; gap: 8px; text-align: center; padding: 28px; }
.source-empty strong { font-weight: 400; font-size: 20px; }
.source-empty span { color: var(--muted); line-height: 1.5; }
.source-rule { margin-top: 18px; padding: 17px; border-radius: 17px; background: rgba(64,201,255,.06); border: 1px solid rgba(64,201,255,.18); }
.source-rule strong { display: block; color: var(--cyan); font-weight: 400; margin-bottom: 7px; }
.source-rule span { color: var(--muted); font-size: 13px; line-height: 1.5; }
@media (max-width: 620px) {
  .heading-actions .icon-button { width: 54px; height: 54px; font-size: 24px; }
  .source-row { grid-template-columns: 25px 38px minmax(0,1fr); }
  .source-actions { grid-column: 2 / -1; justify-content: flex-start; padding-left: 48px; }
  .source-audio-controls { padding-left: 62px; }
  .source-card { margin-left: calc(var(--source-depth, 0) * 7px); }
}
