/* PoolGod Broadcast Commentator Studio v2 */

body { overflow: hidden; }

/* ─── Header ─── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 50;
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-mark {
  color: var(--accent);
  display: inline-flex;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--fg-strong);
  white-space: nowrap;
}
.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-ink);
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  white-space: nowrap;
}
@media (max-width: 1580px) {
  .brand-tag,
  .scene-bar .kicker { display: none; }
  .app-header .seg-i { padding: 4px 8px; font-size: 11px; }
  .app-header .btn-sm { padding: 5px 9px; font-size: 11px; }
  .app-header .status-pill strong { max-width: 82px; }
  .app-header .icon-btn { width: 30px; height: 30px; }
}

.scene-bar {
  display: flex; align-items: center; gap: 8px;
  margin-left: 6px;
  flex-shrink: 0;
}
.kicker {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  font-weight: 600;
  white-space: nowrap;
}

.seg {
  display: inline-flex;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.seg-i {
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  white-space: nowrap;
}
.seg-i:hover { color: var(--fg); }
.seg-i.is-active { background: var(--bg-card); color: var(--fg); box-shadow: var(--sh-1); }
.seg-sm .seg-i { padding: 4px 10px; font-size: 11px; }

.header-utils { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
}
.status-pill strong {
  display: inline-block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.status-pill .sep { color: var(--fg-faint); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-faint); flex-shrink: 0; }
.dot.is-online { background: var(--good); box-shadow: 0 0 0 3px oklch(0.62 0.13 155 / 0.2); }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  border: 1px solid transparent;
  transition: all .15s;
}
.icon-btn:hover { color: var(--fg); background: var(--bg-sunken); border-color: var(--border-soft); }
.icon-btn .material-symbols-outlined { font-size: 20px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-weight: 500; font-size: 13px;
  transition: all .15s;
  white-space: nowrap;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: var(--accent); color: white; box-shadow: var(--sh-1); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--sh-2); }
.btn-outline { border-color: var(--border-hi); color: var(--fg); background: var(--bg-card); }
.btn-outline:hover { border-color: var(--fg-muted); background: var(--bg-sunken); }
.btn-ghost { color: var(--fg-muted); background: transparent; }
.btn-ghost:hover { color: var(--fg); background: var(--bg-sunken); }
.btn-ghost.is-active { color: var(--fg); background: var(--bg-sunken); }

/* ─── Main split layout ─── */
.app-main {
  height: calc(100vh - var(--header-h));
  display: grid;
  grid-template-columns: 380px 1fr;
  overflow: hidden;
}

/* ─── Control surface ─── */
.control-surface {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: var(--s-5);
  display: flex; flex-direction: column;
  gap: var(--s-5);
}
.cs-section { display: flex; flex-direction: column; gap: var(--s-3); }
.cs-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-3);
}
.cs-head .kicker { margin-bottom: 2px; }
.cs-title { font-size: 16px; font-weight: 600; color: var(--fg-strong); }
.cs-head-actions { display: flex; gap: 4px; }
.cs-hint { font-size: 12px; color: var(--fg-muted); line-height: 1.5; margin-bottom: 4px; }

/* Player row */
.player-row { display: flex; gap: var(--s-2); }
.player-tab {
  flex: 1;
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg-muted);
  font-weight: 500;
  transition: all .15s;
}
.player-tab:hover { border-color: var(--border-hi); color: var(--fg); }
.player-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--fg);
  box-shadow: var(--sh-1);
}
.player-tab .p-meta { margin-left: auto; color: var(--fg-faint); font-size: 11px; }
.player-tab.is-active .p-meta { color: var(--accent-ink); }
.p-name { flex: 1; }

/* Last shot block */
.last-shot {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-4);
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
}
.ls-grade {
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r);
  font-family: var(--font-display);
  font-size: 34px; font-weight: 700;
  letter-spacing: -0.04em;
  border: 1px solid var(--border);
}
.ls-grade[data-grade="A"] { background: var(--grade-a-bg); color: var(--grade-a); border-color: color-mix(in srgb, var(--grade-a) 35%, transparent); }
.ls-grade[data-grade="B"] { background: var(--grade-b-bg); color: var(--grade-b); border-color: color-mix(in srgb, var(--grade-b) 35%, transparent); }
.ls-grade[data-grade="C"] { background: var(--grade-c-bg); color: var(--grade-c); border-color: color-mix(in srgb, var(--grade-c) 35%, transparent); }
.ls-grade[data-grade="D"] { background: var(--grade-d-bg); color: var(--grade-d); border-color: color-mix(in srgb, var(--grade-d) 35%, transparent); }
.ls-grade[data-grade="F"] { background: var(--grade-f-bg); color: var(--grade-f); border-color: color-mix(in srgb, var(--grade-f) 35%, transparent); }
.ls-info { display: flex; flex-direction: column; justify-content: center; }
.ls-num { font-family: var(--font-mono); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg-strong); line-height: 1; }
.ls-meta { display: flex; gap: 6px; align-items: baseline; font-size: 12px; color: var(--fg-muted); margin-top: 6px; }
.sep { color: var(--fg-faint); }

/* Widget list */
.widget-list { display: flex; flex-direction: column; gap: 6px; }
.widget-item {
  display: grid;
  grid-template-columns: 24px auto 1fr auto auto;
  gap: var(--s-3);
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: all .15s;
  cursor: grab;
}
.widget-item:hover { border-color: var(--border-hi); box-shadow: var(--sh-1); }
.widget-item.is-on { border-color: var(--accent-line); background: var(--accent-soft); }
.widget-item .grip {
  color: var(--fg-faint);
  display: inline-flex;
}
.widget-item .grip .material-symbols-outlined { font-size: 18px; }
.wi-icon {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs);
  background: var(--bg-sunken);
  color: var(--fg-muted);
}
.widget-item.is-on .wi-icon { background: var(--bg-card); color: var(--accent); }
.wi-icon .material-symbols-outlined { font-size: 16px; }
.wi-name { font-size: 13px; font-weight: 500; }
.wi-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  padding: 2px 6px;
  background: var(--bg-sunken);
  border-radius: var(--r-xs);
}
.widget-item.is-on .wi-val { background: var(--bg-card); color: var(--fg); }

/* Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.sw-track {
  position: absolute; inset: 0;
  background: var(--border-hi);
  border-radius: 999px;
  transition: background .2s;
  cursor: pointer;
}
.sw-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--sh-1);
  transition: left .2s;
}
.switch input:checked + .sw-track { background: var(--accent); }
.switch input:checked + .sw-track .sw-thumb { left: 18px; }

/* Control rows */
.control-rows { display: flex; flex-direction: column; gap: var(--s-3); }
.ctl-row { display: flex; gap: var(--s-3); align-items: flex-start; }
.ctl-label { font-size: 13px; font-weight: 500; }
.ctl-sub { font-size: 11px; color: var(--fg-muted); margin-top: 2px; }
.slider-row { padding-left: 48px; }
.slider-row input[type=range] {
  width: 100%;
  accent-color: var(--accent);
}
.slider-ticks {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px; color: var(--fg-faint);
  margin-top: 2px;
}

/* URL block */
.url-block {
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: var(--s-3) var(--s-4);
}
.url-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-dim); font-weight: 600; margin-bottom: 6px; }
.url-row { display: flex; gap: var(--s-2); align-items: center; }
.url-code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 6px 10px;
  color: var(--fg);
  white-space: nowrap;
  overflow-x: auto;
}
.url-hint { font-size: 11px; color: var(--fg-muted); margin-top: 8px; line-height: 1.5; }

/* ─── Scene pane ─── */
.scene-pane {
  background: var(--bg-sunken);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.scene-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px var(--s-5);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.scene-meta { display: flex; align-items: baseline; gap: var(--s-3); }
.scene-name { font-size: 13px; font-weight: 600; color: var(--fg-strong); }
.scene-tools { display: flex; gap: 6px; align-items: center; }

.scene-frame {
  flex: 1;
  position: relative;
  margin: var(--s-5);
  background: linear-gradient(135deg, #11202c 0%, #0a1620 50%, #122632 100%);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-3), inset 0 0 0 1px rgba(255,255,255,0.04);
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - var(--header-h) - 120px);
  align-self: center;
  width: min(100%, calc((100vh - var(--header-h) - 120px) * 16/9));
  flex-shrink: 0;
}

.scene-bg { position: absolute; inset: 0; }
.bg-table {
  position: absolute;
  inset: 12% 18% 28% 18%;
  background: radial-gradient(ellipse at center, oklch(0.32 0.06 155) 0%, oklch(0.22 0.05 155) 60%, oklch(0.14 0.03 155) 100%);
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.65;
}
.bg-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.5) 100%);
}
.bg-watermark {
  position: absolute;
  top: 16px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(255,255,255,0.18);
  text-transform: uppercase;
}

.safe-area {
  position: absolute;
  inset: 5%;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 6px;
  pointer-events: none;
}

.scene-grid {
  position: absolute; inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: calc(100% / 16) calc(100% / 9);
  display: none;
}
.scene-grid.is-on { display: block; }

.widget-stage { position: absolute; inset: 0; }

.lt-helper[hidden] { display: none !important; }
.lt-helper {
  position: absolute;
  bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
}
.lt-helper .kicker { color: rgba(255,255,255,0.5); }

.scene-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px var(--s-5) 12px;
  font-size: 11px;
  color: var(--fg-muted);
}
.legend-inline { display: flex; gap: var(--s-4); }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.scene-coords { color: var(--fg-faint); }

/* ─── Stream widgets (rendered inside the OBS frame) ─── */
.widget-stage {
  --sw-accent: #3b6cf5;
  --sw-bg: 15, 23, 42;
  --sw-fg: #ffffff;
  --sw-opacity: 0.92;
}
.sw {
  position: absolute;
  background: linear-gradient(160deg, rgba(var(--sw-bg), var(--sw-opacity)), rgba(var(--sw-bg), calc(var(--sw-opacity) * 0.88)));
  border: 1px solid rgba(255,255,255,0.11);
  border-top: 2px solid var(--sw-accent);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--sw-fg);
  font-family: var(--font-sans);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.52), inset 0 1px 0 rgba(255,255,255,0.06);
  cursor: grab;
  user-select: none;
  transition: box-shadow .18s, border-color .18s;
  min-width: 144px;
}
.sw:hover { border-color: rgba(255,255,255,0.18); }
.sw.is-dragging {
  cursor: grabbing;
  box-shadow: 0 0 0 2px var(--sw-accent), 0 12px 36px rgba(0,0,0,0.5);
  z-index: 10;
}
.sw.is-selected {
  border-color: var(--sw-accent);
  box-shadow: 0 0 0 1px var(--sw-accent), 0 8px 28px rgba(0,0,0,0.4);
  outline: 1px dashed rgba(255,255,255,0.4);
  outline-offset: 4px;
}
.sw.is-flash { animation: swFlash 0.6s ease; }
@keyframes swFlash {
  0%   { border-color: var(--sw-accent); box-shadow: 0 0 0 3px var(--sw-accent), 0 8px 28px rgba(0,0,0,0.4); }
  100% { border-color: rgba(255,255,255,0.08); box-shadow: 0 8px 28px rgba(0,0,0,0.4); }
}
.sw-icon-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.sw-icon {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  background: rgba(255,255,255,0.06);
}
.sw-icon .material-symbols-outlined { font-size: 14px; color: rgba(255,255,255,0.85); }
.sw-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
}
.sw-value {
  display: flex; align-items: baseline; gap: 4px;
}
.sw-value .num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: white;
  line-height: 1;
}
.sw-value .unit {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
}

/* Grade widget special styling */
.sw[data-metric="grade"] .sw-value .num { font-size: 36px; }
.sw[data-metric="grade"][data-grade="A"] .sw-value .num { color: oklch(0.78 0.18 155); }
.sw[data-metric="grade"][data-grade="B"] .sw-value .num { color: oklch(0.78 0.14 165); }
.sw[data-metric="grade"][data-grade="C"] .sw-value .num { color: oklch(0.82 0.16 75); }
.sw[data-metric="grade"][data-grade="D"] .sw-value .num { color: oklch(0.78 0.16 45); }
.sw[data-metric="grade"][data-grade="F"] .sw-value .num { color: oklch(0.72 0.18 25); }

/* Bar widgets (straightness/smoothness) */
.sw[data-style="bar"] {
  min-width: 200px;
}
.sw .sw-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.sw .sw-bar-fill {
  height: 100%;
  background: var(--sw-accent);
  border-radius: 2px;
  transition: width .5s cubic-bezier(0.4,0,0.2,1);
}

/* Pin badge */
.sw .pin {
  position: absolute;
  top: -6px; right: -6px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--sw-accent);
  display: none;
  align-items: center; justify-content: center;
}
.sw.is-pinned .pin { display: inline-flex; }
.sw.is-pinned .pin .material-symbols-outlined { font-size: 10px; color: white; }

/* Scene = lower-third overrides */
.scene-frame.is-lt .sw {
  bottom: 5% !important;
  top: auto !important;
}

/* ═══════ clickable status pill, hotkey inline ═══════ */
.status-pill.is-clickable {
  cursor: pointer;
  background: transparent;
  font: inherit;
  transition: border-color .15s, background .15s;
}
.status-pill.is-clickable:hover { border-color: var(--fg-muted); background: var(--bg-sunken); }
.status-pill.is-clickable.is-disconnected .dot { background: var(--bad); box-shadow: 0 0 0 3px oklch(0.65 0.20 25 / 0.2); }
.status-pill.is-clickable.is-disconnected { border-color: oklch(0.85 0.10 25 / 0.6); }

.kbd-inline {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  margin-left: 6px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 3px;
  font-size: 10px;
  color: rgba(255,255,255,0.95);
  font-weight: 600;
}
.btn-outline .kbd-inline {
  background: var(--bg-sunken);
  border-color: var(--border);
  color: var(--fg-muted);
}

/* ═══════ Theme picker ═══════ */
.theme-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.tp {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.tp:hover { border-color: var(--border-hi); }
.tp.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tp-swatch {
  width: 22px; height: 22px;
  border-radius: 5px;
  background:
    linear-gradient(135deg, var(--tp-a) 0 50%, var(--tp-bg) 50% 100%);
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
  position: relative;
}
.tp-swatch::after {
  content: ""; position: absolute;
  bottom: 2px; right: 2px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--tp-fg);
  border: 1px solid rgba(0,0,0,0.15);
}
.tp-name { font-size: 12px; font-weight: 500; color: var(--fg); }

.theme-tuners {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-soft);
}
.tuner-row {
  display: grid;
  grid-template-columns: 56px 32px 1fr;
  align-items: center;
  gap: 8px;
}
.tuner-row.tuner-slider {
  grid-template-columns: 56px 1fr 36px;
}
.tuner-label { font-size: 11px; color: var(--fg-muted); font-weight: 500; }
.color-input {
  width: 32px; height: 26px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  padding: 2px;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border-radius: 3px; border: none; }
.hex-input {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  font-size: 11px;
  color: var(--fg);
  width: 100%;
}
.hex-input:focus { outline: none; border-color: var(--accent); }
.tuner-row input[type=range] { width: 100%; accent-color: var(--accent); }
.tuner-row.tuner-slider .mono { font-size: 11px; color: var(--fg-muted); text-align: right; }

.contrast-row {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--fg-muted);
}
.contrast-row.is-warn { border-color: oklch(0.85 0.12 80 / 0.6); }
.contrast-row.is-warn .material-symbols-outlined { color: var(--warn) !important; }
.contrast-row.is-bad { border-color: oklch(0.85 0.12 25 / 0.6); }
.contrast-row.is-bad .material-symbols-outlined { color: var(--bad) !important; }

/* ═══════ Presets ═══════ */
.preset-list {
  display: flex; flex-direction: column; gap: 6px;
  min-height: 24px;
}
.preset-empty {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-faint);
  background: var(--bg-sunken);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
}
.preset {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color .15s;
}
.preset:hover { border-color: var(--border-hi); }
.pkbd {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-muted);
}
.pname {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  border: 1px solid transparent;
  padding: 2px 6px;
  border-radius: 4px;
  background: transparent;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.pname:focus { border-color: var(--accent); background: var(--bg-sunken); }
.pmeta {
  font-size: 10px;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--fg-faint);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.pbtn:hover { color: var(--fg); background: var(--bg-sunken); border-color: var(--border); }
.pbtn .material-symbols-outlined { font-size: 14px; }
.pbtn-recall { color: var(--accent); }
.pbtn-recall:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* ═══════ Connection mini grid in URL block ═══════ */
.conn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 10px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.conn-item { background: var(--bg-card); padding: 6px 10px; }
.conn-k {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--fg-faint); font-weight: 600;
}
.conn-v { font-size: 12px; color: var(--fg); margin-top: 2px; }
.conn-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.conn-tag.is-live { background: oklch(0.92 0.10 155 / 0.6); color: var(--good); }

/* ═══════ Hotkeys modal ═══════ */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 35, 0.55);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fadein .15s ease-out;
}
.modal[hidden] { display: none; }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.modal-card {
  width: min(620px, 92vw);
  max-height: 86vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(0.96); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-title { font-size: 18px; font-weight: 600; color: var(--fg-strong); margin-top: 2px; }
.hk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 32px;
  padding: 20px;
  overflow-y: auto;
}
.hk-section { display: flex; flex-direction: column; gap: 6px; }
.hk-h {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  font-weight: 600;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
}
.hk { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--fg); }
.hk-k {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 22px;
  padding: 0 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-muted);
  flex-shrink: 0;
}

/* ═══════ Relay popover ═══════ */
.popover {
  position: fixed;
  top: 60px;
  right: 20px;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 10px);
  box-shadow: var(--sh-3);
  z-index: 90;
  animation: pop .15s ease-out;
}
.popover[hidden] { display: none; }
.pop-arrow {
  position: absolute;
  top: -6px; right: 60px;
  width: 12px; height: 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  transform: rotate(45deg);
}
.pop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.pop-title { font-size: 14px; font-weight: 600; color: var(--fg-strong); }
.pop-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  background: oklch(0.96 0.04 155);
  border: 1px solid oklch(0.85 0.10 155 / 0.5);
  border-radius: 99px;
  font-size: 11px;
  color: var(--good);
  font-weight: 500;
}
.pop-pill.is-disconnected {
  background: oklch(0.96 0.04 25);
  border-color: oklch(0.85 0.10 25 / 0.5);
  color: var(--bad);
}
.pop-pill.is-disconnected .dot { background: var(--bad); box-shadow: 0 0 0 3px oklch(0.65 0.20 25 / 0.2); }
.pop-grid {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px;
}
.pop-field { display: flex; flex-direction: column; gap: 4px; }
.pop-k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  font-weight: 600;
}
.pop-arrow { /* already declared above */ }
.text-input {
  height: 30px;
  padding: 0 10px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  font-size: 12px;
  color: var(--fg);
  width: 100%;
  font-family: var(--font-mono);
}
.text-input:focus { outline: none; border-color: var(--accent); background: var(--bg-card); }
.pop-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.pop-stat { background: var(--bg-card); padding: 8px 10px; }
.ps-k {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--fg-faint); font-weight: 600;
}
.ps-v { font-size: 13px; color: var(--fg-strong); margin-top: 2px; font-weight: 500; }
.pop-actions {
  display: flex; flex-direction: column; gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}
.pop-btns { display: flex; gap: 6px; justify-content: flex-end; }
.check-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
}
.check-row input[type=checkbox] {
  width: 14px; height: 14px;
  accent-color: var(--accent);
}

/* ═══════ Grade distribution (future widget) ═══════ */
.grade-dist { display: flex; flex-direction: column; gap: 4px; }
.gd-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.gd-letter { font-family: var(--font-mono); font-weight: 700; width: 14px; text-align: center; }
.gd-bar { flex: 1; height: 6px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.gd-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.gd-pct { font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); width: 32px; text-align: right; }

/* ═══════ Comparison rows (future widget) ═══════ */
.cmp-row { display: flex; gap: 8px; align-items: center; font-size: 12px; border-bottom: 1px solid var(--border-soft); padding: 6px 0; }
.cmp-row:last-child { border-bottom: none; }
.cmp-cell { flex: 1; }
.cmp-name { color: var(--fg-muted); font-size: 11px; margin-bottom: 2px; }
.cmp-val { font-family: var(--font-mono); font-weight: 600; color: var(--fg-strong); }
.cmp-delta { font-size: 11px; font-family: var(--font-mono); }
.cmp-delta.is-pos { color: var(--good); }
.cmp-delta.is-neg { color: var(--bad); }

/* ═══════ Scene pane extras ═══════ */
.scene-pane { position: relative; }
