:root {
  --bg: #050508;
  --panel: rgba(14, 14, 20, 0.88);
  --border: rgba(255, 255, 255, 0.1);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #818cf8;
  --accent-2: #fbbf24;
  --ok: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --side-w: min(300px, 92vw);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app { position: relative; width: 100%; height: 100%; height: 100dvh; }
#c {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Boot */
.boot {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: #050508;
  transition: opacity 0.4s, visibility 0.4s;
}
.boot.done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-card { text-align: center; width: min(280px, 80vw); }
.boot-brand {
  font-weight: 800;
  letter-spacing: 0.22em;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  color: #e4e4e7;
}
.boot-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
}
#boot-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #fbbf24);
  transition: width 0.2s;
}
#boot-text { margin: 0.75rem 0 0; font-size: 0.8rem; color: var(--muted); }

/* Top */
.top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand-block { display: flex; align-items: baseline; gap: 0.45rem; }
.brand {
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 0.9rem;
}
.brand-sub {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.top-actions { display: flex; gap: 0.4rem; }

/* Sides */
.side {
  position: absolute;
  top: 3.5rem;
  bottom: 2.4rem;
  z-index: 5;
  width: var(--side-w);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  padding: 0.95rem 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.side.left { left: 0.75rem; }
.side.right { right: 0.75rem; }
.side h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}
.hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}
.hint strong { color: #e4e4e7; }

.config-list { display: flex; flex-direction: column; gap: 0.4rem; }
.cfg {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 0.65rem 0.7rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
}
.cfg:hover { border-color: rgba(129,140,248,0.45); }
.cfg.selected {
  border-color: var(--accent);
  background: rgba(99,102,241,0.16);
}
.cfg-title { display: block; font-weight: 700; font-size: 0.9rem; }
.cfg-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
}

.detail-empty {
  margin: auto 0;
  text-align: center;
  color: var(--muted);
}
.detail-empty h2 { color: var(--text); margin-bottom: 0.4rem; }
.detail-empty p { font-size: 0.85rem; line-height: 1.4; }

.d-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.bom {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.bom-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.3rem;
  text-align: center;
}
.bom-n {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent-2);
}
.bom-l {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.1rem;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.mode-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.mode-btn.selected {
  background: rgba(99,102,241,0.22);
  border-color: var(--accent);
}

.build-panel {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.65rem;
  border-radius: 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
}
.step-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}
.pill {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(251,191,36,0.15);
  color: var(--accent-2);
  text-transform: uppercase;
}
.pill.bridge {
  background: rgba(96,165,250,0.15);
  color: #93c5fd;
}
.step-help {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}
.step-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0.4rem;
}

.color-block { display: flex; flex-direction: column; gap: 0.4rem; }
.color-label { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}
.swatch {
  appearance: none;
  border: 2px solid transparent;
  border-radius: 8px;
  height: 32px;
  cursor: pointer;
  padding: 0;
}
.swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(129,140,248,0.5);
}
.swatch.black { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2); }

.toggles {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.toggles label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }

.legal-note {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.4;
  opacity: 0.9;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:hover { background: rgba(255,255,255,0.1); }
.btn.primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-color: transparent;
  color: #fff;
}
.btn.ghost {
  background: transparent;
}
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.status-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  pointer-events: none;
}
.status-bar .sep { opacity: 0.4; }
#status { color: #c7d2fe; font-weight: 600; }

@media (max-width: 900px) {
  .side.left {
    top: auto;
    bottom: 2.2rem;
    left: 0.4rem;
    right: 50%;
    width: auto;
    max-height: 34vh;
    margin-right: 0.2rem;
  }
  .side.right {
    top: auto;
    bottom: 2.2rem;
    right: 0.4rem;
    left: 50%;
    width: auto;
    max-height: 34vh;
    margin-left: 0.2rem;
  }
}

@media (max-width: 560px) {
  .side.left, .side.right {
    left: 0.4rem;
    right: 0.4rem;
    width: auto;
    margin: 0;
  }
  .side.left { bottom: calc(2.2rem + 36vh); max-height: 28vh; }
  .side.right { max-height: 34vh; }
}
