/* StreamHub MoJoPro Dashboard — control room theme (2026-10 refresh)
   Class names and IDs are shared with app.js; restyle freely, rename nothing. */

:root {
  color-scheme: dark;

  --bg: #0a0d12;
  --surface: #11161e;
  --surface-2: #161c26;
  --surface-3: #1d2531;
  --surface-hover: #242e3c;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);

  --text: #e8edf4;
  --text-2: #b6c0cd;
  --muted: #7d8999;

  --accent: #00a3e0;
  --accent-text: #4cc6f4;
  --accent-soft: rgba(0, 163, 224, 0.14);
  --accent-ring: rgba(0, 163, 224, 0.45);
  --primary: #0a78b5;
  --primary-hover: #0b87cb;

  --live: #ff3d4f;
  --live-strong: #d9363e;
  --live-soft: rgba(255, 61, 79, 0.14);
  --amber: #f5b340;
  --amber-soft: rgba(245, 179, 64, 0.13);
  --green: #2ed38a;
  --green-hover: #4ee09f;
  --green-soft: rgba(46, 211, 138, 0.13);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --thumb: 22px; /* native range thumb width; the drawn thumb tracks it exactly */
}

/* ---------- Base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

html {
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: relative;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 50% -260px, rgba(0, 163, 224, 0.16), transparent 70%),
    var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 55%);
  mask-image: linear-gradient(180deg, #000, transparent 55%);
}

h1, h2, h3, h4, p { margin: 0; }

p:empty { display: none; }

input,
select,
button { font: inherit; color: inherit; }

button { cursor: pointer; touch-action: manipulation; }

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover { color: #8adaf8; text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 20px 88px;
}

/* ---------- Form fields ---------- */

.field-group { margin-bottom: 16px; }

.field-group label,
.selector-label-row label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder { color: #566273; }

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239aa6b5' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  cursor: pointer;
}

select:disabled { cursor: not-allowed; opacity: 0.6; }

input[type="text"]:hover,
input[type="password"]:hover,
select:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.22); }

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.secret-row input { flex: 1; min-width: 0; }

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { background: var(--surface-hover); border-color: rgba(255, 255, 255, 0.2); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); border-color: transparent; }

.btn-success {
  border-color: transparent;
  background: var(--green);
  color: #03170d;
}

.btn-success:hover { background: var(--green-hover); border-color: transparent; }

.btn-danger {
  border-color: transparent;
  background: var(--live-strong);
  color: #fff;
}

.btn-danger:hover { background: #e5444b; border-color: transparent; }

.btn-inline {
  min-height: 42px;
  padding: 0 14px;
  white-space: nowrap;
  font-size: 13px;
}

/* Transport icons, drawn in CSS so the labels app.js writes stay untouched */
.btn-live-toggle::before,
.btn-mojopro-record-toggle::before,
.btn-streamhub-record-toggle::before {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
}

.btn-live-toggle.btn-success::before {
  width: 10px;
  height: 10px;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(3, 23, 13, 0.25);
}

.btn-live-toggle.btn-danger::before,
.btn-mojopro-record-toggle.btn-danger::before,
.btn-streamhub-record-toggle.btn-danger::before {
  border-radius: 2px;
  background: currentColor;
}

/* ---------- Status text ---------- */

.status-line,
.status-inline {
  min-height: 20px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-2);
}

.status-line:empty { margin-top: 0; }
.status-line.ok,
.status-inline.ok { color: var(--green); }
.status-line.error,
.status-inline.error { color: #ff7782; }

/* ---------- Surfaces ---------- */

.panel,
.input-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px rgba(0, 0, 0, 0.28);
}

.panel-kicker,
.card-kicker,
.confirm-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-text);
}

/* ---------- Connection screen ---------- */

.connection-panel {
  max-width: 440px;
  margin: 10vh auto 32px;
  padding: 32px;
}

.connection-head {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.connection-panel .brand-logo {
  display: block;
  height: 26px;
  margin-bottom: 20px;
}

.connection-panel h1 {
  font-size: 22px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.panel-copy {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.ip-port-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
}

.connection-panel .actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  margin-top: 24px;
}

.btn:disabled {
  cursor: progress;
  opacity: 0.75;
}

/* ---------- Dashboard header ---------- */

.dashboard {
  display: grid;
  gap: 16px;
}

.dashboard-header {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px 12px 20px;
  border-color: var(--border-strong);
  background: rgba(17, 22, 30, 0.82);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.header-logo {
  display: block;
  height: 22px;
  flex: 0 0 auto;
}

.header-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid var(--border-strong);
}

.header-copy h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.header-subtitle {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.header-actions .btn { min-height: 36px; padding: 6px 14px; font-size: 13px; }

/* ---------- Empty state ---------- */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 56px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(17, 22, 30, 0.6);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.empty-state::before {
  content: "";
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16.72 11.06A10.94 10.94 0 0 1 19 12.55'/%3E%3Cpath d='M5 12.55a10.94 10.94 0 0 1 5.17-2.39'/%3E%3Cpath d='M10.71 5.05A16 16 0 0 1 22.58 9'/%3E%3Cpath d='M1.42 9a15.91 15.91 0 0 1 4.7-2.88'/%3E%3Cpath d='M8.53 16.11a6 6 0 0 1 6.95 0'/%3E%3Cline x1='12' y1='20' x2='12.01' y2='20'/%3E%3Cline x1='1' y1='1' x2='23' y2='23'/%3E%3C/svg%3E") center / contain no-repeat;
}

.empty-state::after {
  content: "Waiting for a connected MoJoPro. This view updates automatically.";
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Input cards ---------- */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
  gap: 16px;
  align-items: start;
}

.cards-grid:has(> .input-card:only-child) {
  grid-template-columns: minmax(0, 720px);
  justify-content: center;
}

.input-card {
  position: relative;
  container: card / inline-size;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* On-air tally: the card itself turns red while its input is live */
.input-card:has(.badge-live:not([hidden])) {
  border-color: rgba(255, 61, 79, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 61, 79, 0.22), 0 12px 40px rgba(255, 61, 79, 0.08), 0 12px 32px rgba(0, 0, 0, 0.28);
}

.input-card:has(.badge-live:not([hidden]))::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  right: 24px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--live);
  box-shadow: 0 0 12px rgba(255, 61, 79, 0.7);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card-top > div:first-child { min-width: 0; }

.input-name {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.input-device {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.preview-badges-row {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.input-state,
.preview-badges-row::before {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1;
}

.input-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-live {
  background: var(--live);
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 61, 79, 0.45);
}

.badge-live::before { animation: tally-pulse 1.6s ease-in-out infinite; }

.badge-preview {
  border-color: rgba(245, 179, 64, 0.4);
  background: var(--amber-soft);
  color: var(--amber);
}

/* Neither LIVE nor PREVIEW: the input is still connected (only connected inputs get a card) */
.preview-badges-row:not(:has(.input-state:not([hidden])))::before {
  content: "CONNECTED";
  border-color: rgba(46, 211, 138, 0.35);
  background: var(--green-soft);
  color: var(--green);
}

/* Input briefly missing from StreamHub's list: keep the card in place, dimmed, until it returns */
.input-card.is-reconnecting { border-color: rgba(245, 179, 64, 0.35); box-shadow: none; }
.input-card.is-reconnecting::before { display: none; }
.input-card.is-reconnecting > :not(.card-top) { opacity: 0.45; transition: opacity 0.2s ease; }
.input-card.is-reconnecting .input-state,
.input-card.is-reconnecting .preview-badges-row::before { display: none; }

.input-card.is-reconnecting .preview-badges-row::after {
  content: "RECONNECTING";
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 11px;
  border: 1px solid rgba(245, 179, 64, 0.4);
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  animation: tally-pulse 1.6s ease-in-out infinite;
}

@keyframes tally-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Preview + audio meter */

.preview-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: stretch;
}

.thumbnail-wrap {
  position: relative;
  display: flex;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #05070a;
}

.thumbnail {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumbnail-fallback {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.018) 0 10px, transparent 10px 20px),
    #070a0e;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.thumbnail-fallback::before {
  content: "";
  width: 28px;
  height: 28px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8999' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 16v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10'/%3E%3Cline x1='1' y1='1' x2='23' y2='23'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.8;
}

/* Channel strip: dB scale | level meter | gain fader, all on the same 0 to -50 axis */

.audio-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 8px 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.audio-meter-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 72px;
  width: 100%;
}

.audio-scale {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* top/bottom 4px puts the track ends level with the centres of the "0" and "-50" labels */
.audio-meter-track {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 22px;
  width: 10px;
  container-type: size;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #06080b;
}

/* LED segments */
.audio-meter-track::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(6, 8, 11, 0.9) 3px 4px);
}

.audio-meter-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  /* Gradient is sized to the whole track so colours stay pinned to dB levels */
  background: linear-gradient(0deg, #2ed38a 0%, #2ed38a 58%, #f5b340 78%, #ff3d4f 94%);
  background-size: 100% 100cqh;
  background-position: bottom;
  transition: height 0.12s ease;
}

.audio-meter-peak {
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 0;
  height: 2px;
  border-radius: 1px;
  background: #fff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
  transition: bottom 0.12s ease;
}

/* Gain fader (vertical .glass-range; dragging is handled in app.js) */
.glass-range.is-vertical {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 36px;
  right: 0;
  height: auto;
  cursor: ns-resize;
  touch-action: none; /* a drag on the fader moves the fader, not the page */
}

.glass-range.is-vertical .slider-shell { inset: 4px 0; }

.glass-range.is-vertical .slider-shell::before,
.glass-range.is-vertical .slider-fill {
  top: auto;
  right: auto;
  left: 50%;
  width: 4px;
  transform: translateX(-50%);
}

.glass-range.is-vertical .slider-shell::before { top: 0; bottom: 0; height: auto; }

.glass-range.is-vertical .slider-fill {
  bottom: 0;
  height: calc(var(--progress) * 100%);
  background: linear-gradient(0deg, #0a78b5, var(--accent));
}

.glass-range.is-vertical .slider-lens {
  top: calc((1 - var(--progress)) * 100%);
  left: 50%;
  width: 28px;
  height: 14px;
  border-radius: 4px;
  transform: translate(-50%, -50%);
}

/* fader-cap groove */
.glass-range.is-vertical .slider-lens::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 5px;
  right: 5px;
  height: 2px;
  border-radius: 1px;
  background: rgba(10, 30, 45, 0.45);
  transform: translateY(-50%);
}

.audio-gain-readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  padding: 0 2px;
  line-height: 1;
}

.audio-gain-readout span {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.audio-gain-value {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

/* Telemetry */

.compact-stats.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
}

.stat-chip {
  display: grid;
  gap: 4px;
  align-content: start;
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface-2);
}

.stat-chip span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-chip strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.telemetry-location a::after { content: " \2197"; }

/* Transport actions */

.actions,
.header-actions,
.action-row { display: flex; gap: 10px; }

.action-row.triple-actions {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.action-row .btn {
  min-height: 46px;
  padding: 8px 12px;
  font-size: 13px;
}

/* Camera section */

.card-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.control-row.settings-camera-selector {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.selector-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.selector-label-row label { margin: 0; }

.camera-selector-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
}

.selector-shell select {
  height: 40px;
  background-color: var(--bg);
}

/* Camera settings */

.settings-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.settings-list > .exposure-card,
.settings-list > .setting-card:has(.preset-buttons) {
  grid-column: 1 / -1;
}

.setting-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px 14px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.exposure-card { padding-bottom: 12px; }

.setting-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.setting-head > div { min-width: 0; }

.setting-head h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.setting-head p {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.setting-readout {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.setting-head { margin-bottom: 10px; }

/* Pin controls to the bottom so sliders line up across side-by-side cards */
.setting-controls {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.setting-card.is-unavailable { opacity: 0.5; }

.mode-chip:disabled,
.preset-chip:disabled {
  cursor: not-allowed;
  background: transparent;
  color: var(--muted);
}

.setting-card:has(.glass-range.is-disabled) .setting-readout {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

/* Segmented mode / preset controls */

.mode-buttons,
.preset-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  justify-self: start;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.mode-chip,
.preset-chip {
  min-height: 30px;
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mode-chip:hover,
.preset-chip:hover {
  background: var(--surface-3);
  color: var(--text);
}

.mode-chip.active,
.preset-chip.active {
  border-color: rgba(0, 163, 224, 0.45);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.mode-chip:active,
.preset-chip:active { transform: translateY(1px); }

/* Sliders: app.js renders .glass-range > .slider-shell > (.slider-fill, .slider-lens) + an invisible native range on top */

.glass-range {
  --progress: 0;
  --pos: calc(var(--thumb) / 2 + var(--progress) * (100% - var(--thumb)));
  position: relative;
  display: block;
  height: 32px;
  margin: 0;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.glass-range.is-disabled { cursor: not-allowed; }

.glass-range > input[type="range"] {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.glass-range > input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb);
  height: 28px;
}

.glass-range > input[type="range"]::-moz-range-thumb {
  width: var(--thumb);
  height: 28px;
  border: 0;
}

.glass-range .slider-shell {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glass-range .slider-shell::before,
.glass-range .slider-fill {
  position: absolute;
  top: 50%;
  left: 0;
  height: 6px;
  border-radius: 999px;
  transform: translateY(-50%);
}

.glass-range .slider-shell::before {
  content: "";
  right: 0;
  background: rgba(255, 255, 255, 0.09);
}

.glass-range .slider-fill {
  width: var(--pos);
  background: linear-gradient(90deg, #0a78b5, var(--accent));
}

.glass-range .slider-lens {
  position: absolute;
  top: 50%;
  left: var(--pos);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f4f8fc;
  box-shadow: 0 0 0 4px rgba(0, 163, 224, 0.22), 0 2px 6px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  transition: box-shadow 0.15s ease;
}

.glass-range:hover .slider-lens,
.glass-range:has(input:focus-visible) .slider-lens {
  box-shadow: 0 0 0 6px rgba(0, 163, 224, 0.3), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.glass-range.is-dragging .slider-lens {
  box-shadow: 0 0 0 8px rgba(0, 163, 224, 0.32), 0 2px 8px rgba(0, 0, 0, 0.55);
}

.glass-range.is-disabled { opacity: 0.38; }

.glass-range.is-disabled .slider-fill { background: rgba(255, 255, 255, 0.3); }

.glass-range.is-disabled .slider-lens {
  background: #9aa6b5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.setting-meta {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Activity button + drawer (position/size are pinned inline by app.js) ---------- */

.notification-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 81;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 8px 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(29, 37, 49, 0.88);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.notification-fab:hover { background: rgba(36, 46, 60, 0.95); border-color: rgba(255, 255, 255, 0.22); }

.notification-count {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.notification-fab.has-events .notification-count {
  background: var(--accent);
  color: #02121b;
}

.notification-center {
  position: fixed;
  right: 20px;
  top: 96px;
  bottom: 20px;
  z-index: 80;
  width: 360px;
  max-width: calc(100vw - 40px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(17, 22, 30, 0.94);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overscroll-behavior: contain;
}

.notification-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 22, 30, 0.97);
}

.section-heading h3 { font-size: 15px; font-weight: 650; }
.section-heading p { margin-top: 2px; font-size: 12px; color: var(--muted); }

.notification-actions .btn { min-height: 32px; padding: 4px 12px; font-size: 12px; }

.notification-list {
  display: grid;
  padding: 6px 8px 76px; /* clears the Activity button that sits over the drawer */
}

.notification-item {
  display: grid;
  gap: 3px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}

.notification-item:last-child { border-bottom: 0; }

.notification-item strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.notification-item span {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.notification-item.empty {
  padding: 32px 12px;
  border: 0;
  color: var(--muted);
  text-align: center;
}

/* ---------- Confirm dialog ---------- */

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 0.15s ease-out;
}

.confirm-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: dialog-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.confirm-kicker { margin-bottom: 8px; }

.confirm-dialog h3 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.confirm-message {
  margin-top: 8px;
  color: var(--text-2);
  line-height: 1.55;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.confirm-actions .btn { min-width: 112px; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ---------- Footer ---------- */

.dashboard-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
  padding: 8px 4px 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer-version { font-family: var(--mono); color: var(--accent-text); font-weight: 600; }
.footer-credit { color: var(--text-2); }
.footer-sep { color: #3a4452; }

/* ---------- Responsive ---------- */

/* Touch screens: bigger targets everywhere */
@media (pointer: coarse) {
  :root { --thumb: 30px; }

  .glass-range { height: 44px; }
  .glass-range .slider-shell::before,
  .glass-range .slider-fill { height: 8px; }
  .glass-range .slider-lens { width: 26px; height: 26px; }

  .mode-chip,
  .preset-chip { min-height: 38px; padding: 8px 14px; }

  .btn { min-height: 46px; }
  .header-actions .btn { min-height: 40px; }
}

@container card (max-width: 480px) {
  .settings-list { grid-template-columns: minmax(0, 1fr); }

  .action-row.triple-actions { grid-template-columns: 1fr 1fr; }
  .action-row.triple-actions .btn-live-toggle { grid-column: 1 / -1; }

  .compact-stats.telemetry-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .page { padding: 10px 12px 84px; }

  /* 16px stops iOS Safari from zooming the page when a field is focused */
  input[type="text"],
  input[type="password"],
  select { font-size: 16px; }

  .connection-panel {
    margin-top: 6vh;
    padding: 24px 20px;
  }

  .dashboard-header {
    top: 8px;
    padding: 10px 10px 10px 14px;
  }

  .header-brand { gap: 12px; }
  .header-logo { height: 18px; }
  .header-copy { padding-left: 12px; }
  .header-copy h2 { font-size: 14px; }
  .header-subtitle { font-size: 11px; }

  .input-card { padding: 14px; gap: 12px; }
  .input-name { font-size: 16px; }

  /* Give the gain fader a usable throw on phones; the picture letterboxes inside the taller box */
  .preview-panel { gap: 8px; min-height: 176px; }
  .preview-panel .thumbnail-wrap { aspect-ratio: auto; height: 100%; }

  .notification-fab { right: 12px; bottom: 12px; }
}

@media (max-width: 420px) {
  .header-logo { display: none; }
  .header-copy { padding-left: 0; border-left: 0; }
  .connection-panel .actions { grid-template-columns: 1fr 1fr; }
  .ip-port-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Accounts, saved StreamHubs (v1.2) ---------- */

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-danger { color: #ff7782; }
.btn-block { width: 100%; }

/* Connect screen head: logo + user menu on one row */
.connection-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.connection-head-row .brand-logo { margin-bottom: 0 !important; }
.user-menu { position: relative; }
.user-menu summary {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu summary::after { content: ''; width: 6px; height: 6px; margin-top: -3px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); flex: 0 0 auto; }
.user-menu summary:hover { border-color: rgba(255, 255, 255, 0.22); }
.user-menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  display: grid;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.user-menu-pop a,
.user-menu-pop button {
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.user-menu-pop a:hover,
.user-menu-pop button:hover { background: var(--surface-hover); text-decoration: none; color: var(--text); }

/* Saved StreamHubs list */
.hub-search { width: 100%; height: 40px; margin-bottom: 10px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg); color: var(--text); }
.hub-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.saved-hub-list {
  display: grid;
  gap: 6px;
  max-height: 452px; /* ~8 rows, then the list scrolls inside the panel */
  overflow-y: auto;
  margin-bottom: 12px;
  overscroll-behavior: contain;
}
.saved-hub {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.saved-hub:hover { border-color: rgba(255, 255, 255, 0.22); background: var(--surface-2); }
.saved-hub.is-busy { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.saved-hub-main {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.saved-hub-main:focus-visible, .saved-hub-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }
.saved-hub-name { display: block; font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-hub-addr { display: block; margin-top: 2px; font-family: var(--mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-hub.is-busy .saved-hub-addr::after { content: ' · connecting…'; font-family: var(--font); color: var(--accent-text); }
.saved-hub-edit {
  display: grid;
  place-items: center;
  width: 46px;
  border: 0;
  border-left: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.saved-hub-edit:hover { color: var(--text); }
.saved-hubs-empty { font-size: 13px; color: var(--muted); padding: 6px 0; }

/* Add / edit form */
.editor-title { font-size: 15px; font-weight: 650; margin-bottom: 16px; }
.connection-panel .editor-actions { grid-template-columns: 1fr 2fr; }
.connection-panel .editor-actions.single { grid-template-columns: 1fr; }
.editor-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
.editor-links .link-btn[hidden] { display: none; }
.form-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }

.auth-panel .actions { grid-template-columns: 1fr !important; }
.auth-foot { margin-top: 18px; font-size: 13px; color: var(--muted); }

/* Account page */
.account-page { max-width: 880px; margin: 0 auto; display: grid; gap: 16px; padding-top: 24px; }
.account-section { padding: 24px; }
.account-section h2 { font-size: 17px; font-weight: 650; margin-bottom: 4px; }
.account-section > p { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.account-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-top img { height: 22px; }
.account-form { max-width: 380px; }
.account-form .btn { margin-top: 4px; }
.team-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.team-table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 8px 8px; border-bottom: 1px solid var(--border); }
.team-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.team-table tr:last-child td { border-bottom: 0; }
.team-table .muted { color: var(--muted); }
.team-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.team-actions .btn { min-height: 30px; padding: 3px 10px; font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.pill.admin { background: var(--accent-soft); color: var(--accent-text); }
.pill.off { background: var(--live-soft); color: #ff7782; }
.invite-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.invite-row select { width: auto; min-width: 150px; }
.link-box { display: flex; gap: 8px; margin-top: 12px; }
.link-box input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; }
.link-box[hidden] { display: none; }

@media (max-width: 720px) {
  .team-table thead { display: none; }
  .team-table, .team-table tbody, .team-table tr, .team-table td { display: block; width: 100%; }
  .team-table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .team-table td { border: 0; padding: 3px 0; }
  .team-actions { justify-content: flex-start; margin-top: 6px; }
}
a.btn, a.btn:hover { color: var(--text); text-decoration: none; }
.user-bar-links { display: flex; gap: 14px; }
.account-divider { margin: 24px 0; border: 0; border-top: 1px solid var(--border); }
input[type="email"], input[type="search"] { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg); color: var(--text); }
input[type="email"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.team-subtitle { margin: 22px 0 8px; font-size: 13px; font-weight: 650; color: var(--text-2); }
.team-subtitle:first-of-type { margin-top: 0; }
.invite-row { margin-top: 10px; }
.invite-row #invite-label { flex: 1 1 240px; width: auto; min-width: 0; }
@media (max-width: 720px) {
  .team-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
}
