:root {
  --bg-obsidian: #070b0a;
  --bg-surface: #0e1513;
  --bg-elevated: #141e1b;
  --bg-well: #050807;
  --border-hairline: #1f2e29;
  --border-strong: #2d423b;
  --text-primary: #ecf3f0;
  --text-muted: #8ea39b;
  --text-dim: #657b73;
  --mint: #2ee59d;
  --mint-soft: #a7f3d0;
  --mint-bg: rgba(46, 229, 157, 0.11);
  --mint-border: rgba(46, 229, 157, 0.36);
  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-obsidian);
  color: var(--text-primary);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hub-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  flex-shrink: 0;
  z-index: 20;
}

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

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

.brand-mark {
  display: block;
  flex-shrink: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

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

.brand-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.kit-pill,
.spec-pill {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
}

.kit-pill {
  background: var(--mint-bg);
  color: var(--mint);
  border: 1px solid var(--mint-border);
}

.spec-pill {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-hairline);
}

.brand-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.tpl-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}

.tpl-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.tpl-tab.is-active {
  background: var(--mint-bg);
  color: var(--mint-soft);
  border-color: var(--mint-border);
}

.tpl-tab:focus-visible,
.vp-btn:focus-visible,
.action-link:focus-visible,
.buy-btn:focus-visible,
.modal-close:focus-visible,
.modal-checkout-btn:focus-visible,
.modal-secondary-btn:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

.tpl-num {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--mint);
  background: rgba(46, 229, 157, 0.12);
  padding: 1px 5px;
  border-radius: 3px;
}

.hub-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.vp-switch {
  display: inline-flex;
  align-items: center;
  background: var(--bg-obsidian);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.vp-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.vp-btn:hover {
  color: var(--text-primary);
}

.vp-btn.is-active {
  background: var(--bg-elevated);
  color: var(--mint);
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.action-link:hover {
  border-color: var(--border-strong);
  color: var(--mint-soft);
}

.buy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  border: 0;
  border-radius: 6px;
  background: var(--mint);
  color: #041d14;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.buy-btn:hover {
  background: var(--mint-soft);
}

.hub-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px;
  border-top: 1px solid var(--border-hairline);
  background: #0a100e;
  font-size: 11.5px;
  flex-wrap: wrap;
}

.subbar-left,
.subbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex-wrap: wrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  flex-shrink: 0;
}

.subbar-title {
  font-weight: 600;
  color: var(--text-primary);
}

.subbar-path {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mint);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  padding: 1px 6px;
}

.subbar-meta {
  color: var(--text-muted);
}

.subbar-vp {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--mint-soft);
  background: var(--mint-bg);
  border: 1px solid var(--mint-border);
  border-radius: 4px;
  padding: 1px 6px;
}

.stage {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 12px 14px 14px;
  background: var(--bg-well);
  min-height: 0;
  overflow: auto;
}

.preview-shell {
  width: 100%;
  min-height: 540px;
  height: 100%;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  overflow: hidden;
  background: #080c0b;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.55);
  transition: width 180ms ease;
}

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

.preview-shell.is-tablet {
  width: 820px;
  max-width: 100%;
  border-color: var(--border-strong);
}

.preview-shell.is-mobile {
  width: 390px;
  max-width: 100%;
  border-color: var(--mint-border);
  border-radius: 18px;
}

#templateFrame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 540px;
  border: 0;
  background: #080c0b;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 6, 5, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

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

.modal-kicker {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--mint);
}

.modal-title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-close:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.modal-summary {
  margin: 12px 0 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.deliverables-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.deliverables-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
}

.deliverables-list li div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
}

.deliverables-list strong {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-primary);
}

.deliv-tag {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--mint);
  background: var(--mint-bg);
  border: 1px solid var(--mint-border);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.modal-notice {
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--bg-obsidian);
  border: 1px solid var(--border-hairline);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-notice code,
.deliverables-list code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mint-soft);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-checkout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 6px;
  background: var(--mint);
  color: #041d14;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.modal-checkout-btn:hover {
  background: var(--mint-soft);
}

.modal-secondary-btn {
  padding: 9px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 1440px) {
  .brand-sub,
  .spec-pill {
    display: none;
  }
}

@media (max-width: 1180px) {
  .subbar-meta {
    display: none;
  }
}

@media (max-width: 720px) {
  .hub-top {
    padding: 10px 12px;
    gap: 8px;
  }

  .hub-subbar {
    padding: 6px 12px;
  }

  .subbar-path {
    display: none;
  }

  .template-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .tpl-tab {
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 9px;
  }

  .hub-controls {
    width: 100%;
    justify-content: space-between;
  }

  .vp-switch {
    display: none;
  }

  .stage {
    padding: 8px;
  }

  .preview-shell {
    min-height: 460px;
  }
}
