:root {
  --nrkbeta-orange: #ff6a00;
  --autocam-bg: #1a120b;
  --nrk-beta-surface: #3a2f27;
  --nrk-beta-text: #f1f5f9;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-800: #27272a;
  --ok: #3ecf8e;
  --warn: #e6a23c;
  --err: #ef6b6b;
  --font: 'Inter', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --unit-8: 8px;
  --radius-sm: 0.5rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--autocam-bg);
  color: var(--nrk-beta-text);
  font: 14px/1.45 var(--font);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

::selection {
  background: var(--nrkbeta-orange);
  color: #fff;
}

.shell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--nrk-beta-surface);
  background: color-mix(in srgb, var(--autocam-bg) 95%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-block { display: flex; flex-direction: column; gap: 2px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-flag {
  display: block;
  height: 28px;
  width: auto;
  object-fit: contain;
}
.brand {
  font-weight: 900;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  font-style: italic;
  font-size: 20px;
  color: #fff;
}
.brand-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--zinc-500);
  border-left: 1px solid var(--zinc-800);
  padding-left: 10px;
}
.brand-sub { font-size: 12px; color: var(--zinc-500); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--nrk-beta-surface);
  background: color-mix(in srgb, var(--nrk-beta-surface) 30%, transparent);
  color: var(--zinc-400);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.pill[data-kind="ok"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--nrk-beta-surface)); }
.pill[data-kind="warn"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--nrk-beta-surface)); }
.pill[data-kind="err"] { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--nrk-beta-surface)); }

/* No camera deck/chrome until a Whepret client tunnels in. */
body:not(.has-clients) .shell-tabs .tab:not(.tab-admin) {
  display: none;
}
body:not(.has-clients) .shell-tabs:has(.tab-admin[hidden]) {
  display: none;
}

.shell-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px 0;
  border-bottom: 1px solid var(--nrk-beta-surface);
  overflow-x: auto;
  flex-shrink: 0;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--zinc-500);
  padding: 8px 12px 10px;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
}
.tab:hover { color: var(--nrkbeta-orange); }
.tab.active {
  color: #fff;
  border-bottom-color: var(--nrkbeta-orange);
}
.tab.tab-admin { margin-left: auto; }

.shell-main {
  flex: 1;
  padding: 12px 16px 16px;
  max-width: none;
  width: 100%;
  margin: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel { display: none; min-height: 0; }
.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.panel[hidden] {
  display: none !important;
}

.card.compact {
  padding: 8px 10px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.card.compact .card-title {
  margin: 0;
  font-size: 9px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow: auto;
}

.row.tight { gap: 4px; }

.deck {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 92px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(140px, 0.22fr) minmax(0, 1fr) minmax(160px, 0.24fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "lens video exposure";
  gap: 8px;
  align-items: stretch;
}

.deck-lens,
.deck-video,
.deck-exposure {
  align-self: stretch;
  height: 100%;
  min-height: 0;
  margin-top: 0 !important; /* override .card + .card stacking margin */
}

.deck-lens { grid-area: lens; }
.deck-video {
  grid-area: video;
  min-width: 0;
}
.deck-exposure { grid-area: exposure; }

.deck-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.deck-client {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.deck-client strong {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stream-status {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--zinc-500);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  min-height: 14px; /* match .card-title row so columns line up */
}
.client-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--nrk-beta-surface, rgba(255, 255, 255, 0.08));
}
.client-meta[hidden] { display: none !important; }
.meta-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 3px 7px;
  border: 1px solid var(--nrk-beta-surface);
  border-radius: 2px;
  background: color-mix(in srgb, var(--nrk-beta-surface) 22%, transparent);
}
.meta-chip-label {
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--zinc-500);
  font-weight: 700;
}
.meta-chip span,
.meta-chip-link {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--zinc-300);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.meta-chip-link:hover { color: var(--nrkbeta-orange); }

.audio-section {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--nrk-beta-surface, rgba(255, 255, 255, 0.08));
}
.audio-channels {
  gap: 6px;
}
.audio-channel select {
  width: 100%;
}

.ae-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
}
.ae-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--zinc-400);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  margin: 0;
}
.ae-status[data-warn="1"] {
  color: var(--warn);
}

.deck .field label {
  margin-bottom: 3px;
  font-size: 9px;
}
.deck .field input:not([type="range"]):not([type="checkbox"]),
.deck .field select {
  padding: 5px 7px;
  font-size: 12px;
}

.range-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.range-row input[type="range"] {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 0;
  height: 22px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
}
.range-row input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--nrk-beta-surface);
}
.range-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: #3b82f6;
  border: 0;
  box-shadow: none;
}
.range-row input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--nrk-beta-surface);
  border: 0;
}
.range-row input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3b82f6;
  border: 0;
}
.deck .btn.primary {
  padding: 6px 10px;
  font-size: 10px;
}
.deck .btn.ghost,
.deck .btn.small {
  padding: 4px 7px;
  font-size: 10px;
}

.live-toggle {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.live-toggle .btn {
  width: auto;
  min-width: 70%;
}
.routing-fields {
  margin-top: 10px;
  gap: 8px;
}

.deck .video-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
}

@media (max-width: 980px) {
  .deck {
    max-height: none;
    height: auto;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
      "video video"
      "lens exposure";
  }
  .deck .video-stage {
    aspect-ratio: auto;
    height: auto;
    max-height: 70vh;
  }
  .deck .video-stage video {
    max-height: 70vh;
  }
}

.console-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.55fr) minmax(240px, 0.85fr);
}
@media (max-width: 900px) {
  .console-layout { grid-template-columns: 1fr; }
}

.video-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: var(--radius-sm);
  border: 0;
  overflow: hidden;
  aspect-ratio: auto;
  min-height: 0;
}
.video-stage video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius-sm);
  border: 1px solid var(--nrk-beta-surface);
}

.eyebrow {
  display: inline-block;
  background: color-mix(in srgb, var(--nrkbeta-orange) 12%, transparent);
  color: var(--nrkbeta-orange);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.empty-state h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1.05;
}
.empty-state p {
  margin: 0;
  max-width: 36rem;
  color: var(--zinc-400);
  font-size: 16px;
  line-height: 1.6;
}

.btn {
  appearance: none;
  border: 1px solid var(--nrk-beta-surface);
  background: color-mix(in srgb, var(--nrk-beta-surface) 35%, transparent);
  color: var(--nrk-beta-text);
  border-radius: 2px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: color-mix(in srgb, var(--nrkbeta-orange) 40%, var(--nrk-beta-surface)); }
.btn.primary {
  background: var(--nrkbeta-orange);
  border-color: transparent;
  color: #fff;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost {
  background: transparent;
  color: var(--zinc-400);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.btn.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--err) 45%, var(--nrk-beta-surface));
  color: var(--err);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 5px 9px; font-size: 11px; }

.card {
  background: color-mix(in srgb, var(--nrk-beta-surface) 20%, transparent);
  border: 1px solid var(--nrk-beta-surface);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.card + .card { margin-top: 14px; }

.card-title {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--zinc-500);
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.section-rule {
  height: 1px;
  flex: 1;
  background: var(--nrk-beta-surface);
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--zinc-500);
  margin-bottom: 6px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  background: #0d0d0d;
  border: 1px solid var(--nrk-beta-surface);
  border-radius: var(--radius-sm);
  color: var(--nrk-beta-text);
  padding: 8px 10px;
  font: inherit;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hint { color: var(--zinc-500); font-size: 12px; }

.meta-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.meta-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--nrk-beta-surface);
  font-size: 13px;
}
.meta-list li span:first-child { color: var(--zinc-500); }
.meta-list li span:last-child { font-family: var(--mono); font-size: 12px; }

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.users-table th,
.users-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--nrk-beta-surface);
  vertical-align: middle;
}
.users-table th {
  color: var(--zinc-500);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}
.token-cell {
  font-family: var(--mono);
  font-size: 12px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--nrk-beta-surface);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.role-badge.admin { color: var(--nrkbeta-orange); border-color: color-mix(in srgb, var(--nrkbeta-orange) 40%, var(--nrk-beta-surface)); }
.role-badge.user { color: var(--ok); }
.role-badge.client { color: var(--warn); }

.range-row .val {
  font-family: var(--mono);
  min-width: 4ch;
  color: var(--zinc-400);
  font-size: 12px;
}

.client-hero {
  margin-bottom: 8px;
}
.client-hero h1 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}
.client-hero .meta {
  color: var(--zinc-500);
  font-family: var(--mono);
  font-size: 12px;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}
.toast {
  background: #0d0d0d;
  border: 1px solid var(--nrk-beta-surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.toast.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--nrk-beta-surface)); }
.toast.err { border-color: color-mix(in srgb, var(--err) 50%, var(--nrk-beta-surface)); }

/* Color wheels under the camera preview (compact Resolve-style trackballs) */
.color-under-video {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--nrk-beta-surface);
}
.cwheel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}
.cwheel-grid-compact .cwheel {
  padding: 6px;
  gap: 4px;
  background: color-mix(in srgb, var(--nrk-beta-surface) 28%, transparent);
  border: 1px solid var(--nrk-beta-surface);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}
.cwheel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}
.cwheel-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--zinc-400);
}
.cwheel-reset {
  background: transparent;
  border: 1px solid var(--nrk-beta-surface);
  color: var(--zinc-500);
  border-radius: 999px;
  width: 18px;
  height: 18px;
  line-height: 1;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cwheel-reset:hover {
  color: var(--nrkbeta-orange);
  border-color: var(--nrkbeta-orange);
}
.cwheel-disc {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 112px;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 55%),
    conic-gradient(from 90deg,
      hsl(0, 100%, 50%),
      hsl(30, 100%, 50%),
      hsl(60, 100%, 50%),
      hsl(90, 100%, 50%),
      hsl(120, 100%, 50%),
      hsl(150, 100%, 50%),
      hsl(180, 100%, 50%),
      hsl(210, 100%, 50%),
      hsl(240, 100%, 50%),
      hsl(270, 100%, 50%),
      hsl(300, 100%, 50%),
      hsl(330, 100%, 50%),
      hsl(360, 100%, 50%));
  box-shadow: 0 0 0 1px var(--nrk-beta-surface), inset 0 0 16px rgba(0, 0, 0, 0.35);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
.cwheel-disc.dragging { cursor: grabbing; }
.cwheel-puck {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #111;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.cwheel-luma {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cwheel-luma-range {
  flex: 1;
  width: 100%;
  margin: 0;
}
.cwheel-rgbl {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}
.cwheel-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
}
.cwheel-field label {
  font-size: 8px;
  color: var(--zinc-500);
  letter-spacing: 0.05em;
}
.cwheel-field input {
  width: 100%;
  min-width: 0;
  padding: 2px 2px;
  font-size: 9px;
  text-align: center;
  background: color-mix(in srgb, var(--autocam-bg) 70%, transparent);
  border: 1px solid var(--nrk-beta-surface);
  border-radius: 3px;
  color: var(--nrk-beta-text);
  font-family: var(--mono);
}
.cwheel-field input:focus {
  outline: none;
  border-color: var(--nrkbeta-orange);
}

@media (max-width: 1100px) {
  .cwheel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cwheel-disc { max-width: 128px; }
}

@media (max-width: 980px) {
  .deck .video-stage {
    max-height: 48vh;
  }
  .deck .video-stage video {
    max-height: 48vh;
  }
}
