:root {
  --hub-bg: #0B0E14;
  --hub-surface: #131822;
  --hub-surface-2: #1A2130;
  --hub-border: #242D3F;
  --stage-bg: #171D28;
  --ink: #F1F5F9;
  --ink-muted: #94A3B8;
  --emerald: #10B981;
  --emerald-hover: #34D399;
  --emerald-ink: #042419;
  --sky: #38BDF8;
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

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

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--stage-bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

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

/* Header & Controls */
.hub-bar {
  background: var(--hub-bg);
  border-bottom: 1px solid var(--hub-border);
  z-index: 20;
  flex-shrink: 0;
}

.hub-top {
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hub-logo {
  display: block;
  flex-shrink: 0;
}

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

.hub-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hub-badge {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 700;
  padding: 2px 7px;
  background: var(--hub-surface-2);
  border: 1px solid var(--hub-border);
  border-radius: 3px;
  color: var(--sky);
}

.hub-sub {
  margin: 1px 0 0;
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.dash-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dash-tab {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 4px;
  border: 1px solid var(--hub-border);
  background: var(--hub-surface);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: border-color 130ms ease, color 130ms ease, background-color 130ms ease;
}

.dash-tab:hover {
  border-color: #475569;
  color: var(--ink);
}

.dash-tab.is-active {
  background: var(--hub-surface-2);
  border-color: var(--sky);
  color: var(--ink);
}

.hub-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.vp-group {
  display: inline-flex;
  border: 1px solid var(--hub-border);
  border-radius: 4px;
  background: var(--hub-surface);
  overflow: hidden;
}

.vp-btn {
  min-height: 34px;
  padding: 0 10px;
  border: none;
  border-right: 1px solid var(--hub-border);
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.vp-btn:last-child {
  border-right: none;
}

.vp-btn:hover {
  color: var(--ink);
  background: var(--hub-surface-2);
}

.vp-btn.is-active {
  background: rgba(56, 189, 248, 0.16);
  color: var(--sky);
}

.tool-btn {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 4px;
  border: 1px solid var(--hub-border);
  background: var(--hub-surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  white-space: nowrap;
}

.tool-btn:hover {
  border-color: #475569;
  background: var(--hub-surface-2);
}

.tool-btn.is-open {
  border-color: var(--sky);
  color: var(--sky);
}

.buy-cta {
  min-height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 4px;
  background: var(--emerald);
  color: var(--emerald-ink);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease;
}

.buy-cta:hover {
  background: var(--emerald-hover);
}

/* Inspector Drawer Bar */
.inspector-bar {
  background: var(--hub-surface);
  border-top: 1px solid var(--hub-border);
  padding: 9px 18px;
  display: grid;
  grid-template-columns: 1.05fr 1.65fr 0.95fr 1.15fr;
  gap: 12px;
  align-items: center;
}

.inspector-bar[hidden] {
  display: none;
}

.insp-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.insp-label {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.insp-val {
  font-size: 0.83rem;
  color: var(--ink);
}

.insp-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.77rem;
  color: var(--sky);
}

.insp-text {
  font-size: 0.79rem;
  color: var(--ink-muted);
}

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

.swatch-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  border: 1px solid var(--hub-border);
  background: var(--hub-bg);
  color: var(--ink);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.swatch-btn:hover {
  border-color: var(--sky);
}

/* Stage Well */
.stage-well {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
}

.stage-meta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-chips-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--ink-muted);
  background: var(--hub-bg);
  border: 1px solid var(--hub-border);
  padding: 3px 9px;
  border-radius: 3px;
}

.meta-toast {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--emerald);
  min-height: 18px;
}

.preview-shell {
  margin: 0 auto;
  width: 100%;
  flex: 1 1 auto;
  min-height: 620px;
  border: 1px solid var(--hub-border);
  border-radius: 6px;
  overflow: hidden;
  background: #0F172A;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.42);
  transition: max-width 220ms ease;
}

.preview-shell.is-desktop {
  max-width: 100%;
}

.preview-shell.is-tablet {
  max-width: 768px;
  border-width: 6px;
  border-color: #1E293B;
  border-radius: 12px;
}

.preview-shell.is-mobile {
  max-width: 390px;
  border-width: 8px;
  border-color: #1E293B;
  border-radius: 18px;
}

#dashboardFrame {
  width: 100%;
  height: 100%;
  min-height: 620px;
  border: none;
  display: block;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 13, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 60;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--hub-surface);
  border: 1px solid var(--hub-border);
  border-top: 3px solid var(--emerald);
  border-radius: 6px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--emerald);
  display: block;
}

.modal-head h2 {
  margin: 3px 0 0;
  font-size: 1.2rem;
  color: var(--ink);
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  border: 1px solid var(--hub-border);
  background: var(--hub-bg);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-lead {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.bundle-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--ink);
}

.modal-note {
  font-size: 0.78rem;
  color: var(--ink-muted);
  background: var(--hub-bg);
  border: 1px solid var(--hub-border);
  padding: 10px 12px;
  border-radius: 4px;
}

.modal-note code {
  font-family: var(--font-mono);
  color: var(--sky);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 1120px) {
  .inspector-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .hub-top {
    padding: 10px 12px;
  }
  .inspector-bar {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }
  .stage-well {
    padding: 10px 10px 16px;
  }
  .dash-tabs {
    width: 100%;
  }
  .dash-tab {
    flex: 1 1 auto;
    justify-content: center;
  }
  .preview-shell,
  #dashboardFrame {
    min-height: 540px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}
