:root {
  --bg-root: #070e0c;
  --bg-bar: rgba(11, 21, 18, 0.94);
  --border-subtle: rgba(148, 184, 168, 0.16);
  --text-primary: #edf4f0;
  --text-secondary: #8ea69b;
  --accent-gold: #e2b049;
  --accent-emerald: #18b26b;
  --focus-ring: #38bdf8;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.hub-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 46px minmax(0, 1fr);
  width: 100%;
  max-width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

/* Single Compact Top Bar */
.hub-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 30;
  min-width: 0;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hub-logo {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #4b2714 0%, #4b2714 68%, #e2b049 68%, #e2b049 100%);
  border: 1px solid rgba(226, 176, 73, 0.6);
  font-size: 14px;
}

.hub-brand-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

/* Horizontal 1-Tap Demo Selector Tabs */
.demo-tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
  min-width: 0;
  flex: 1;
  justify-content: center;
}

.demo-tabs::-webkit-scrollbar {
  display: none;
}

.demo-tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.demo-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.demo-tab.active {
  background: rgba(226, 176, 73, 0.18);
  border-color: var(--accent-gold);
  color: #fde68a;
}

.demo-tab-code {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.75;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Right Action Icons */
.stage-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.btn-action {
  appearance: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-action:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Full-Bleed 3D Stage */
.hub-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #050a08;
}

.stage-viewport {
  position: relative;
  width: 100%;
  height: 100%;
}

#demo-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #070e0c;
}

/* Spec Sheet Modal (<dialog closedby="any">) */
dialog.spec-modal {
  width: min(440px, calc(100vw - 24px));
  background: rgba(11, 21, 18, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid var(--accent-gold);
  border-radius: 14px;
  padding: 16px 18px;
  color: var(--text-primary);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

dialog.spec-modal::backdrop {
  background: rgba(3, 8, 6, 0.6);
  backdrop-filter: blur(3px);
}

.spec-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.stage-code {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(226, 176, 73, 0.18);
  border: 1px solid rgba(226, 176, 73, 0.45);
  color: #fde68a;
  font-size: 10.5px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-bottom: 4px;
}

.spec-modal-header h2 {
  margin: 0;
  font-size: 15px;
  color: #fde68a;
}

.spec-subtitle {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: #6ee7b7;
}

.btn-icon {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  border-radius: 7px;
  padding: 4px 9px;
  cursor: pointer;
}

.spec-dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.spec-row {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.spec-row dt {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.spec-row dd {
  margin: 0;
  font-size: 12px;
  color: var(--text-primary);
}

.spec-modal-footer {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.btn-standalone {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 600;
}

@media (max-width: 680px) {
  .hub-topbar {
    padding: 0 6px;
    gap: 4px;
  }
  .hub-brand,
  #btn-fullscreen {
    display: none;
  }
  .demo-tabs {
    justify-content: flex-start;
    gap: 4px;
  }
  .demo-tab {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
  }
  .btn-action {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
}
