:root {
  --bg: #09090b;
  --panel: #111114;
  --panel2: #18181d;
  --ink: #d4d4d8;
  --ink-h: #fafafa;
  --ink2: #a1a1aa;
  --muted: #71717a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --specular: inset 0 1px 0 rgba(255, 255, 255, 0.07);

  --accent: #ff5232;
  --accent-soft: rgba(255, 82, 50, 0.12);
  --accent-border: rgba(255, 82, 50, 0.36);

  --cta-bg: #ffffff;
  --cta-ink: #09090b;
  --cta-hover: #e4e4e7;

  --green: #22c55e;
  --green-ink: #86efac;
  --amber: #f59e0b;
  --red: #ef4444;

  --serif: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.55 var(--sans); min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

/* Sidebar */
.sidebar {
  background: #0b0b0e; border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; justify-content: space-between;
  position: sticky; top: 0; height: 100vh; min-width: 0;
}
.sidebar > div { min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid var(--line); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--panel2); border: 1px solid var(--line-strong); box-shadow: var(--specular);
}
.brand-name { font-family: var(--serif); font-size: 15px; letter-spacing: -0.02em; color: var(--ink-h); font-weight: 800; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav-list { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--ink2); cursor: pointer; text-align: left; font-size: 13.5px; font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.nav-label { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.nav-icon { flex-shrink: 0; opacity: 0.78; }
.nav-item.active .nav-icon { opacity: 1; color: var(--accent); }
.nav-item:hover { color: var(--ink-h); background: rgba(255,255,255,0.04); }
.nav-item.active { background: var(--panel2); border-color: var(--line-strong); box-shadow: var(--specular); color: var(--ink-h); }
.nav-badge {
  font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: rgba(255,255,255,0.06); color: var(--ink-h);
}

.sidebar-footer { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.plan-pill {
  padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line);
  font-size: 12.5px; box-shadow: var(--specular);
}

/* Main area */
.main-col { display: flex; flex-direction: column; min-width: 0; }
.sandbox-banner {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 9px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink2);
}
.sandbox-banner[hidden] { display: none; }
.sandbox-banner strong { color: var(--ink-h); }
.lbl-short { display: none; }

.topbar {
  padding: 15px 24px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: rgba(9, 9, 11, 0.88); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20;
}
.page-title { font-family: var(--serif); font-size: 22px; color: var(--ink-h); font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; }
.content { padding: 24px; display: flex; flex-direction: column; gap: 20px; max-width: 1280px; width: 100%; }

/* Reusable Controls — Stark White Primary + Neutral Surface Secondary */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--panel2); box-shadow: var(--specular); color: var(--ink-h); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.btn:hover { background: #23232a; border-color: rgba(255,255,255,0.28); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--cta-bg); border-color: var(--cta-bg); color: var(--cta-ink);
  box-shadow: none; font-weight: 700;
}
.btn.primary:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn.good { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.36); color: var(--green-ink); box-shadow: none; }
.btn.danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #fca5a5; box-shadow: none; }
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--specular); }
.inner-panel { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 13px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-family: var(--serif); font-size: 15.5px; font-weight: 700; color: var(--ink-h); letter-spacing: -0.015em; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--specular); }
.kpi-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--mono); }
.kpi-val { font-family: var(--mono); font-size: 27px; font-weight: 700; color: var(--ink-h); margin-top: 6px; }
.kpi-sub { font-size: 12px; color: var(--ink2); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--ink2); font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink-h); font-size: 13.5px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }

/* Custom Range Slider — Eliminates default browser #0075ff blue */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: #27272a;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid #ffffff;
  cursor: pointer;
}

.status-pill {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 11px;
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); text-transform: uppercase;
}
.status-pill.published, .status-pill.connected, .status-pill.active, .status-pill.pass {
  background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.36); color: var(--green-ink);
}
.status-pill.queued, .status-pill.awaiting_approval, .status-pill.warn {
  background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.4); color: #fcd34d;
}
.status-pill.failed, .status-pill.dead_letter, .status-pill.collision, .status-pill.paused {
  background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #fca5a5;
}

.mono-accent { font-family: var(--mono); font-size: 11px; color: var(--accent); }

/* Safe-Zone Interactive Phone Stage */
.studio-split { display: grid; grid-template-columns: 332px 1fr; gap: 20px; align-items: start; }
.phone-stage {
  width: 310px; height: 550px; border-radius: 24px; border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #16161b 0%, #09090b 100%);
  position: relative; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,0.85), var(--specular);
}
.phone-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage-empty-placeholder {
  position: absolute;
  top: 15%;
  bottom: 27%;
  left: 7%;
  right: 20%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  color: var(--ink2);
  font-size: 12.5px;
  pointer-events: none;
}

.safe-overlay { position: absolute; inset: 0; pointer-events: none; }
.zone-top {
  position: absolute; top: 0; left: 0; right: 0; height: 13%;
  background: rgba(255, 82, 50, 0.08); border-bottom: 1px dashed rgba(255, 82, 50, 0.42);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px;
  font-family: var(--mono); font-size: 9.5px; color: #fda4af;
}
.zone-right {
  position: absolute; right: 0; top: 42%; bottom: 25%; width: 17%;
  background: rgba(255, 82, 50, 0.08); border-left: 1px dashed rgba(255, 82, 50, 0.42);
  display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl;
  font-family: var(--mono); font-size: 9px; color: #fda4af;
}
.zone-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; height: 25%;
  background: rgba(255, 82, 50, 0.08); border-top: 1px dashed rgba(255, 82, 50, 0.42);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 6px;
  font-family: var(--mono); font-size: 9.5px; color: #fda4af;
}
.zone-safe-band {
  position: absolute; top: 13%; bottom: 25%; left: 4%; right: 18%;
  border: 1px dashed rgba(34, 197, 94, 0.42); border-radius: 8px;
}
.caption-preview {
  position: absolute; left: 7%; right: 20%; text-align: center;
  padding: 6px 10px; border-radius: 8px; font-weight: 800; font-size: 14.5px; line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0,0,0,0.95); transition: top 0.12s ease;
}
.caption-preview.hormozi { color: #facc15; text-transform: uppercase; letter-spacing: 0.02em; }
.caption-preview.clean { color: #fff; font-weight: 600; background: rgba(9,9,11,0.72); border: 1px solid rgba(255,255,255,0.14); }
.caption-preview.editorial { color: #fafafa; font-family: var(--serif); font-size: 17px; font-weight: 700; }
.caption-preview.collision {
  color: #fecaca !important;
  background: rgba(127, 29, 29, 0.9) !important;
  border: 1.5px solid #ef4444;
  text-shadow: 0 2px 6px rgba(0,0,0,0.95);
}
.safe-overlay.hud-off { opacity: 0; }

/* HUD Mode Toggles & Presets */
.hud-mode-row { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; width: 100%; background: var(--bg); padding: 4px; border-radius: 9px; border: 1px solid var(--line); }
.hud-mode-btn {
  flex: 1;
  padding: 5px 8px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--ink2); font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.hud-mode-btn.active { background: var(--panel2); border-color: var(--line-strong); color: var(--ink-h); box-shadow: var(--specular); }

/* Getting Started Checklist */
.onboard-card {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--specular);
  border-radius: 14px;
  padding: 18px 20px;
}
.onboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.onboard-step {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 13px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
}
.onboard-step.done { border-color: rgba(34, 197, 94, 0.38); }

/* Visual Platform Toggle Chips */
.dest-chip-grid { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.dest-chip {
  padding: 6px 11px; border-radius: 7px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink2); font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.dest-chip.selected {
  background: var(--accent-soft); border-color: var(--accent-border); color: var(--ink-h); font-weight: 600;
}

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 120; background: rgba(4, 5, 8, 0.82);
  backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 16px; padding: 22px; box-shadow: 0 28px 70px rgba(0, 0, 0, 0.85), var(--specular);
}

/* Heatmap */
.heatmap { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; font-family: var(--mono); font-size: 10.5px; }
.hm-cell { padding: 8px 4px; border-radius: 6px; text-align: center; border: 1px solid var(--line); }

.table-box { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; }

.tabs-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-chip {
  padding: 6px 11px; border-radius: 7px; border: 1px solid var(--line);
  background: transparent; color: var(--ink2); font-size: 12.5px; cursor: pointer;
}
.tab-chip.active { background: var(--cta-bg); border-color: var(--cta-bg); color: var(--cta-ink); font-weight: 600; }

pre.code-box {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-family: var(--mono); font-size: 12px; color: var(--ink); overflow-x: auto; white-space: pre-wrap;
}

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 99;
  padding: 12px 18px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line-strong);
  color: var(--ink-h); font-size: 13.5px; box-shadow: 0 12px 30px rgba(0,0,0,0.6), var(--specular); display: none;
}
.toast.show { display: block; }

details.dev-accordion summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
details.dev-accordion summary::-webkit-details-marker { display: none; }
details.dev-accordion[open] summary { margin-bottom: 14px; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
  .sidebar { position: static; height: auto; min-width: 0; max-width: 100%; overflow: hidden; padding: 8px 12px; gap: 6px; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar > div { min-width: 0; max-width: 100%; }
  .brand { padding: 2px 0 6px; border-bottom: none; }
  .nav-list { flex-direction: row; width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 6px; margin-top: 6px; padding-bottom: 4px; scrollbar-width: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item { flex-shrink: 0; padding: 6px 11px; border-radius: 8px; font-size: 12.5px; background: var(--panel); border-color: var(--line); }
  .sidebar-footer { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 6px; padding-top: 6px; }
  .sidebar-footer .plan-pill { display: none; }
  .sidebar-footer .btn { flex: 1; width: auto !important; padding: 6px 8px; font-size: 11.5px; white-space: nowrap; }
  .sandbox-banner { display: none !important; }
  .content { padding: 14px; gap: 16px; }
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: nowrap; }
  .topbar > div:first-child { min-width: 0; flex: 1; overflow: hidden; }
  .page-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-actions { flex-wrap: nowrap !important; gap: 6px !important; flex-shrink: 0; }
  .lbl-full { display: none; }
  .lbl-short { display: inline; }
  .topbar-actions .btn.sm { padding: 6px 9px; font-size: 11.5px; white-space: nowrap; }
  .studio-split { grid-template-columns: minmax(0, 1fr); }
  .phone-stage { width: 100%; max-width: 310px; margin: 0 auto; }
}
