:root {
  --canvas: #010102;
  --surface-1: #0f1011;
  --surface-2: #141516;
  --surface-3: #18191a;
  --surface-4: #191a1b;
  --hairline: #23252a;
  --hairline-strong: #34343a;
  --ink: #f7f8f8;
  --ink-muted: #d0d6e0;
  --ink-subtle: #8a8f98;
  --ink-tertiary: #62666d;
  --primary: #5e6ad2;
  --primary-hover: #828fff;
  --success: #27a644;
  --warning: #b58b39;
  --danger: #c65f5f;
  --topbar-height: 56px;
  --sidebar-width: 216px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  font-family: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; }
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30; height: var(--topbar-height);
  display: grid; grid-template-columns: var(--sidebar-width) 1fr auto; align-items: center;
  border-bottom: 1px solid var(--hairline); background: rgba(1, 1, 2, .94); backdrop-filter: blur(16px);
}
.brand { height: 100%; display: flex; align-items: center; gap: 10px; padding: 0 20px; font-weight: 600; letter-spacing: -.3px; border-right: 1px solid var(--hairline); }
.brand-mark { width: 19px; height: 19px; position: relative; overflow: hidden; border-radius: 5px; background: var(--primary); transform: rotate(-10deg); }
.brand-mark::before, .brand-mark::after, .brand-mark i { content: ""; position: absolute; left: -2px; right: -2px; height: 2px; background: #fff; transform: rotate(-35deg); }
.brand-mark::before { top: 5px; } .brand-mark i { top: 9px; } .brand-mark::after { top: 13px; }
.brand:hover .brand-mark { transform: rotate(0deg) scale(1.04); }
.brand-mark { transition: transform .32s var(--ease-out); }
.topbar-context { display: flex; align-items: center; gap: 10px; padding-left: 24px; }
.context-label, .sync-label { color: var(--ink-tertiary); font-size: 12px; }
.device-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 5px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: default; }
.device-chip:hover { background: var(--surface-2); border-color: var(--hairline); }
.chevron { color: var(--ink-tertiary); margin-left: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; padding-right: 20px; }

.sidebar { position: fixed; z-index: 20; top: var(--topbar-height); bottom: 0; left: 0; width: var(--sidebar-width); display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--hairline); background: var(--canvas); padding: 18px 12px 16px; }
.nav-list { display: grid; gap: 4px; }
.nav-item { width: 100%; min-height: 40px; position: relative; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 8px; padding: 0 12px; background: transparent; color: var(--ink-subtle); text-align: left; cursor: pointer; transition: background .18s ease, color .18s ease, transform .18s var(--ease-out); }
.nav-item:hover { background: var(--surface-1); color: var(--ink-muted); }
.nav-item.is-active { background: var(--surface-2); color: var(--ink); }
.nav-item:active { transform: scale(.975); }
.nav-item::before { content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--primary-hover); opacity: 0; transform: scaleY(.25); transition: opacity .2s ease, transform .3s var(--ease-out); }
.nav-item.is-active::before { opacity: 1; transform: scaleY(1); }
.nav-glyph { width: 20px; color: var(--ink-tertiary); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 10px; }
.nav-item.is-active .nav-glyph { color: var(--primary-hover); }
.sidebar-footer { border-top: 1px solid var(--hairline); padding: 18px 8px 0; }
.connection-summary { display: grid; gap: 3px; margin-bottom: 10px; }
.connection-summary strong { font-weight: 500; font-size: 13px; }
.connection-summary > span:last-child { color: var(--ink-tertiary); font: 11px ui-monospace, "SFMono-Regular", Consolas, monospace; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--ink-subtle); font-size: 12px; cursor: pointer; }
.text-button:hover { color: var(--ink); }

.workspace { margin-left: var(--sidebar-width); padding: calc(var(--topbar-height) + 44px) 40px 56px; }
.page { display: none; max-width: 1440px; margin: 0 auto; }
.page.is-active { display: block; animation: page-enter .34s var(--ease-out) both; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 32px; }
.page-heading h1 { margin: 8px 0 8px; font-size: clamp(32px, 4vw, 48px); font-weight: 600; line-height: 1.08; letter-spacing: -1.7px; }
.page-heading p { margin: 0; color: var(--ink-subtle); font-size: 15px; }
.eyebrow { color: var(--ink-tertiary); font-size: 11px; font-weight: 500; letter-spacing: .65px; }
.heading-status { display: inline-flex; align-items: center; gap: 9px; color: var(--ink-muted); padding: 8px 12px; background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 8px; white-space: nowrap; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-tertiary); box-shadow: 0 0 0 3px rgba(98, 102, 109, .12); }
.is-online .status-dot, .status-dot.is-online { background: var(--success); box-shadow: 0 0 0 3px rgba(39, 166, 68, .12); }
.is-warning .status-dot, .status-dot.is-warning { background: var(--warning); box-shadow: 0 0 0 3px rgba(181, 139, 57, .12); }
.is-offline .status-dot, .status-dot.is-offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(198, 95, 95, .12); }

.panel { border: 1px solid var(--hairline); border-radius: 12px; background: var(--surface-1); overflow: hidden; transition: border-color .22s ease, background-color .22s ease; }
.panel:hover { border-color: var(--hairline-strong); }
.motion-card {
  --card-x: 50%;
  --card-y: 50%;
  --card-lift: 0px;
  --card-tilt-x: 0deg;
  --card-tilt-y: 0deg;
  position: relative;
  isolation: isolate;
  transform: perspective(1000px) translateY(var(--card-lift)) rotateX(var(--card-tilt-x)) rotateY(var(--card-tilt-y));
  transform-origin: center;
  will-change: transform;
  transition: transform .32s var(--ease-out), border-color .22s ease, box-shadow .28s ease, background-color .22s ease;
}
.motion-card::after {
  content: "";
  position: absolute;
  z-index: 6;
  inset: -1px;
  padding: 1px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(180px circle at var(--card-x) var(--card-y), rgba(130,143,255,.72), rgba(94,106,210,.18) 40%, transparent 72%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  transition: opacity .24s ease;
}
.motion-card:hover {
  --card-lift: -2px;
  border-color: rgba(130,143,255,.28);
  box-shadow: 0 16px 36px rgba(0,0,0,.22), 0 1px 0 rgba(255,255,255,.035);
}
.motion-card:hover::after { opacity: 1; }
.motion-card.is-settling { transition-duration: .48s; }
.video-panel.motion-card, .live-player-panel.motion-card { --card-lift: 0px; --card-tilt-x: 0deg; --card-tilt-y: 0deg; }
.panel-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; border-bottom: 1px solid var(--hairline); }
.panel-header.compact { min-height: 68px; }
.panel-header h2 { margin: 3px 0 0; font-size: 18px; font-weight: 500; letter-spacing: -.3px; }
.video-meta { display: flex; align-items: center; gap: 10px; color: var(--ink-tertiary); font-size: 12px; }
.receive-rate, .live-stat { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.receive-rate.is-good, .live-stat.is-good { color: #75d98c; }
.receive-rate.is-warning, .live-stat.is-warning { color: #d6b56f; }
.receive-rate.is-danger, .live-stat.is-danger { color: #e19494; }
.status-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-muted); font-size: 11px; }
.status-badge.is-live { background: rgba(39, 166, 68, .13); color: #75d98c; }
.status-badge.is-live::before { content: ""; width: 5px; height: 5px; margin-right: 6px; border-radius: 50%; background: currentColor; animation: live-blink 1.8s ease-in-out infinite; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .75fr); gap: 16px; }
.video-stage { position: relative; min-height: 430px; aspect-ratio: 16 / 9; background: #050506; overflow: hidden; }
.video-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #050506; opacity: 0; transition: opacity .25s ease; }
.video-stage.has-video iframe { opacity: 1; }
.video-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--ink-subtle); text-align: center; }
.video-empty strong { color: var(--ink-muted); font-weight: 500; }
.video-empty > span:last-child { font-size: 12px; }
.signal-rings { width: 48px; height: 34px; position: relative; display: block; margin-bottom: 8px; }
.signal-rings i { position: absolute; left: 50%; bottom: 0; border: 1px solid var(--ink-tertiary); border-bottom: 0; border-radius: 999px 999px 0 0; transform: translateX(-50%); animation: signal-breathe 2.2s ease-in-out infinite; }
.signal-rings i:nth-child(1) { width: 12px; height: 8px; } .signal-rings i:nth-child(2) { width: 28px; height: 20px; } .signal-rings i:nth-child(3) { width: 46px; height: 33px; }
.signal-rings i:nth-child(2) { animation-delay: .16s; }
.signal-rings i:nth-child(3) { animation-delay: .32s; }
.video-overlay { position: absolute; left: 0; right: 0; bottom: 0; min-height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: rgba(1, 1, 2, .72); border-top: 1px solid rgba(255,255,255,.07); color: var(--ink-muted); font-size: 12px; opacity: .72; transform: translateY(3px); transition: opacity .22s ease, transform .22s var(--ease-out); }
.video-stage:hover .video-overlay, .video-stage:focus-within .video-overlay { opacity: 1; transform: translateY(0); }
.icon-button { width: 32px; height: 32px; border: 1px solid var(--hairline-strong); border-radius: 8px; background: rgba(15,16,17,.8); cursor: pointer; }
.icon-button:hover { background: var(--surface-3); border-color: var(--ink-tertiary); }

.chain-panel { display: flex; flex-direction: column; }
.pipeline { list-style: none; margin: 0; padding: 10px 18px; flex: 1; }
.pipeline li { position: relative; min-height: 62px; display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 10px; }
.pipeline li:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 38px; bottom: -9px; width: 1px; background: var(--hairline-strong); }
.stage-marker { width: 11px; height: 11px; border: 2px solid var(--ink-tertiary); border-radius: 50%; background: var(--surface-1); z-index: 1; }
.pipeline li.is-ok .stage-marker { border-color: var(--success); background: var(--success); box-shadow: 0 0 0 4px rgba(39,166,68,.09); }
.pipeline li.is-active .stage-marker { border-color: var(--primary-hover); background: var(--primary); box-shadow: 0 0 0 4px rgba(94,106,210,.12); }
.pipeline li.is-active .stage-marker { animation: marker-pulse 1.9s ease-out infinite; }
.pipeline strong, .pipeline small { display: block; }
.pipeline strong { font-weight: 500; font-size: 13px; }
.pipeline small { margin-top: 2px; color: var(--ink-tertiary); font-size: 11px; }
.stage-state { color: var(--ink-tertiary); font-size: 11px; }
.pipeline li.is-ok .stage-state { color: #75d98c; }
.pipeline li.is-active .stage-state { color: var(--primary-hover); }
.chain-note { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 0 16px 16px; padding: 14px; border: 1px solid var(--hairline); border-radius: 8px; background: var(--canvas); }
.chain-note span { color: var(--ink-subtle); font-size: 12px; }
.chain-note strong { font-size: 12px; font-weight: 500; color: #75d98c; }
.chain-note small { grid-column: 1 / -1; color: var(--ink-tertiary); font-size: 11px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 16px 0; border: 1px solid var(--hairline); border-radius: 12px; background: var(--surface-1); overflow: hidden; }
.metric-card { min-height: 116px; display: flex; flex-direction: column; justify-content: center; padding: 18px 22px; transition: background-color .22s ease; }
.metric-card:hover { background: var(--surface-2); }
.metric-card:not(:last-child) { border-right: 1px solid var(--hairline); }
.metric-card > span { color: var(--ink-subtle); font-size: 12px; }
.metric-card strong { margin: 7px 0 2px; font-size: 26px; line-height: 1; font-weight: 500; letter-spacing: -1px; }
.metric-card small { color: var(--ink-tertiary); font-size: 11px; }
.bottom-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 16px; }
.activity-list { padding: 0 20px 10px; }
.activity-row { display: grid; grid-template-columns: 50px 10px 1fr; gap: 10px; align-items: start; padding: 16px 0; border-bottom: 1px solid var(--hairline); }
.activity-row:last-child { border-bottom: 0; }
.activity-time { color: var(--ink-tertiary); font-size: 11px; padding-top: 2px; }
.activity-dot { width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: var(--primary); }
.activity-row strong, .activity-row small { display: block; }
.activity-row strong { font-size: 13px; font-weight: 500; }
.activity-row small { margin-top: 2px; color: var(--ink-tertiary); font-size: 11px; }
.health-list { margin: 0; padding: 4px 20px 12px; }
.health-list > div { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 43px; border-bottom: 1px solid var(--hairline); }
.health-list > div:last-child { border-bottom: 0; }
.health-list dt { color: var(--ink-subtle); font-size: 12px; }
.health-list dd { margin: 0; max-width: 65%; overflow: hidden; color: var(--ink-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.button { min-height: 34px; padding: 7px 13px; border-radius: 8px; border: 1px solid transparent; font-weight: 500; font-size: 12px; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s var(--ease-out); }
.button:active:not(:disabled), .icon-button:active:not(:disabled) { transform: scale(.96); }
.button:disabled { opacity: .5; cursor: wait; }
.button-secondary { background: var(--surface-1); border-color: var(--hairline); }
.button-secondary:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.toast-region { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { min-width: 240px; max-width: 360px; padding: 11px 13px; border: 1px solid var(--hairline-strong); border-radius: 8px; background: var(--surface-3); color: var(--ink-muted); box-shadow: 0 10px 32px rgba(0,0,0,.28); font-size: 12px; animation: toast-enter .3s var(--ease-out) both; transition: opacity .2s ease, transform .2s ease; }
.toast.is-leaving { opacity: 0; transform: translateY(6px) scale(.98); }

.live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.live-player-panel { align-self: start; }
.live-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 520px; background: #050506; overflow: hidden; }
.live-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity .2s ease; }
.live-stage.has-video iframe { opacity: 1; }
.player-toolbar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 14px; border-top: 1px solid var(--hairline); }
.player-toolbar > div { display: flex; align-items: center; gap: 10px; }
.player-toolbar strong { font-weight: 500; }
.player-toolbar span:last-child { color: var(--ink-tertiary); font-size: 12px; }
.telemetry-panel { align-self: stretch; }
.telemetry-list { margin: 0; padding: 8px 18px 12px; }
.telemetry-list > div { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--hairline); }
.telemetry-list > div:last-child { border-bottom: 0; }
.telemetry-list dt { color: var(--ink-subtle); font-size: 12px; }
.telemetry-list dd { margin: 0; color: var(--ink-muted); font-size: 12px; text-align: right; }
.telemetry-note { margin: 8px 16px 16px; padding: 14px; border: 1px solid var(--hairline); border-radius: 8px; background: var(--canvas); }
.telemetry-note strong { font-size: 12px; font-weight: 500; }
.telemetry-note p { margin: 5px 0 0; color: var(--ink-tertiary); font-size: 11px; }

.settings-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 16px; }
.form-grid, .advanced-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 16px; padding: 22px; }
.field { display: grid; align-content: start; gap: 7px; color: var(--ink-muted); font-size: 12px; }
.field-wide { grid-column: 1 / -1; }
.field small { color: var(--ink-tertiary); font-size: 11px; }
.field input, .field select { width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid var(--hairline-strong); border-radius: 8px; outline: none; background: var(--surface-2); color: var(--ink); }
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(94,106,210,.13); }
.policy-panel { padding-bottom: 8px; }
.policy-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 18px; border-bottom: 1px solid var(--hairline); }
.policy-row strong, .policy-row small { display: block; }
.policy-row strong { font-size: 13px; font-weight: 500; }
.policy-row small { margin-top: 3px; color: var(--ink-tertiary); font-size: 11px; }
.toggle { width: 34px; height: 20px; flex: none; position: relative; border-radius: 999px; background: var(--surface-4); border: 1px solid var(--hairline-strong); }
.toggle i { position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-tertiary); }
.toggle.is-on { background: rgba(94,106,210,.24); border-color: rgba(130,143,255,.5); }
.toggle.is-on i { left: 17px; background: var(--primary-hover); }
.policy-summary { display: grid; gap: 3px; margin: 16px 18px 10px; padding: 14px; border-radius: 8px; background: var(--canvas); border: 1px solid var(--hairline); }
.policy-summary span { color: var(--ink-tertiary); font-size: 11px; }
.policy-summary strong { font-size: 12px; font-weight: 500; color: var(--ink-muted); }
.advanced-panel { margin-top: 16px; }
.advanced-panel summary { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 20px; cursor: pointer; list-style: none; }
.advanced-panel summary::-webkit-details-marker { display: none; }
.advanced-panel summary > span { display: grid; gap: 3px; }
.advanced-panel summary strong { font-size: 14px; font-weight: 500; }
.advanced-panel summary small { color: var(--ink-tertiary); font-size: 11px; }
.advanced-panel[open] summary { border-bottom: 1px solid var(--hairline); }
.form-actions { min-height: 72px; display: flex; align-items: center; justify-content: flex-end; gap: 20px; }
.form-actions > span { color: var(--ink-tertiary); font-size: 11px; }
.button-danger { background: rgba(198,95,95,.08); border-color: rgba(198,95,95,.35); color: #e19494; }
.button-danger:hover { background: rgba(198,95,95,.14); }

.diagnostic-metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; border: 1px solid var(--hairline); border-radius: 12px; background: var(--surface-1); overflow: hidden; }
.diagnostic-metrics .metric-card:not(:last-child) { border-right: 1px solid var(--hairline); }
.diagnostics-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 16px; margin-bottom: 16px; }
.service-list { padding: 4px 18px 10px; }
.service-list > div { min-height: 64px; display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--hairline); }
.service-list > div { transition: background-color .18s ease, padding .18s var(--ease-out); }
.service-list > div:hover { margin-inline: -8px; padding-inline: 8px; background: var(--surface-2); border-radius: 6px; }
.service-list > div:last-child { border-bottom: 0; }
.service-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-tertiary); }
.service-dot.is-online { background: var(--success); box-shadow: 0 0 0 3px rgba(39,166,68,.11); }
.service-dot.is-idle { background: var(--warning); box-shadow: 0 0 0 3px rgba(181,139,57,.1); }
.service-list strong, .service-list small { display: block; }
.service-list strong { font-size: 13px; font-weight: 500; }
.service-list small { margin-top: 2px; color: var(--ink-tertiary); font-size: 11px; }
.service-list > div > span:last-child { color: var(--ink-subtle); font-size: 11px; }
.log-panel { margin-bottom: 16px; }
.command-line { padding: 12px 18px; border-bottom: 1px solid var(--hairline); background: var(--canvas); color: var(--ink-tertiary); font: 11px/1.5 ui-monospace, "SFMono-Regular", Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-panel pre { min-height: 220px; max-height: 420px; overflow: auto; margin: 0; padding: 18px; background: #080809; color: var(--ink-subtle); font: 12px/1.65 ui-monospace, "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.maintenance-panel { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 22px 24px; border: 1px solid rgba(198,95,95,.22); border-radius: 12px; background: rgba(198,95,95,.035); }
.maintenance-panel { overflow: hidden; }
.maintenance-panel h2 { margin: 3px 0; font-size: 17px; font-weight: 500; }
.maintenance-panel p { margin: 0; color: var(--ink-tertiary); font-size: 11px; }
.maintenance-panel > div:last-child { display: flex; gap: 8px; }

.connection-dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--hairline-strong); border-radius: 12px; background: var(--surface-1); color: var(--ink); box-shadow: 0 28px 80px rgba(0,0,0,.56); }
.connection-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.connection-dialog[open] { animation: dialog-enter .28s var(--ease-out) both; }
.dialog-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--hairline); }
.dialog-header h2 { margin: 3px 0 0; font-size: 18px; font-weight: 500; }
.dialog-close { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-subtle); font-size: 20px; cursor: pointer; }
.dialog-close:hover { background: var(--surface-3); color: var(--ink); }
.dialog-body { display: grid; grid-template-columns: 1fr 140px; gap: 18px 14px; padding: 22px 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--hairline); }

.value-flash { animation: value-refresh .34s var(--ease-out); }
.activity-row:first-child { animation: row-enter .34s var(--ease-out) both; }
.device-chip .status-dot.is-online, .heading-status.is-online .status-dot, .player-toolbar .status-dot.is-online { animation: status-breathe 2.4s ease-in-out infinite; }

@keyframes page-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes value-refresh {
  0% { opacity: .45; transform: translateY(3px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes status-breathe {
  0%, 100% { box-shadow: 0 0 0 3px rgba(39,166,68,.10); }
  50% { box-shadow: 0 0 0 6px rgba(39,166,68,.02); }
}
@keyframes marker-pulse {
  0% { box-shadow: 0 0 0 0 rgba(94,106,210,.28); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(94,106,210,0); }
}
@keyframes signal-breathe {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}
@keyframes live-blink {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}
@keyframes toast-enter {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes row-enter {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1100px) {
  :root { --sidebar-width: 188px; }
  .workspace { padding-left: 28px; padding-right: 28px; }
  .overview-grid { grid-template-columns: 1fr; }
  .pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
  .pipeline li { min-height: 90px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; }
  .pipeline li:not(:last-child)::after { display: none; }
  .stage-state { margin-top: auto; }
  .live-layout, .settings-layout { grid-template-columns: 1fr; }
  .live-stage { min-height: 420px; }
}
@media (max-width: 820px) {
  :root { --sidebar-width: 72px; }
  .brand { justify-content: center; padding: 0; }
  .brand > span:last-child, .nav-item > span:last-child, .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-glyph { width: auto; }
  .topbar-context { padding-left: 16px; }
  .context-label, .sync-label { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric-card:nth-child(2) { border-right: 0; }
  .metric-card:nth-child(-n+2) { border-bottom: 1px solid var(--hairline); }
  .bottom-grid { grid-template-columns: 1fr; }
  .diagnostic-metrics { grid-template-columns: 1fr 1fr; }
  .diagnostic-metrics .metric-card:nth-child(2) { border-right: 0; }
  .diagnostic-metrics .metric-card:nth-child(-n+2) { border-bottom: 1px solid var(--hairline); }
  .diagnostics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  :root { --sidebar-width: 0px; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 12px; }
  .brand { border-right: 0; justify-content: flex-start; }
  .brand > span:last-child { display: inline; }
  .topbar-context { justify-self: end; padding: 0; }
  .device-chip { padding-inline: 6px; }
  .device-chip #deviceName, .chevron { display: none; }
  .topbar-actions { padding: 0; }
  #refreshAll { width: 34px; overflow: hidden; color: transparent; position: relative; padding: 0; }
  #refreshAll::after { content: "↻"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); font-size: 16px; }
  .sidebar { top: auto; width: 100%; height: 58px; right: 0; flex-direction: row; border-right: 0; border-top: 1px solid var(--hairline); padding: 8px 12px; }
  .nav-list { width: 100%; grid-template-columns: repeat(4, 1fr); }
  .nav-item { min-height: 40px; }
  .workspace { margin-left: 0; padding: 88px 16px 88px; }
  .page-heading { display: block; }
  .page-heading h1 { font-size: 34px; letter-spacing: -1.2px; }
  .heading-status { margin-top: 20px; }
  .panel-header { align-items: flex-start; }
  .video-meta { display: grid; justify-items: end; }
  .video-stage { min-height: 220px; }
  .pipeline { grid-template-columns: 1fr; }
  .pipeline li { min-height: 54px; display: grid; grid-template-columns: 18px 1fr auto; align-items: center; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 104px; padding: 16px; }
  .live-stage { min-height: 230px; }
  .player-toolbar, .maintenance-panel { align-items: flex-start; flex-direction: column; }
  .player-toolbar { padding: 12px; }
  .form-grid, .advanced-grid, .dialog-body { grid-template-columns: 1fr; }
  .form-actions { align-items: stretch; flex-direction: column; padding: 16px 0; }
  .form-actions .button { min-height: 42px; }
  .maintenance-panel > div:last-child { width: 100%; flex-direction: column; }
  .maintenance-panel .button { width: 100%; min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
