:root {
  --bg: #121417;
  --bg-2: #181b1f;
  --surface: #1e2227;
  --surface-2: #262b31;
  --line: #2e343b;
  --text: #eef0f2;
  --muted: #9aa3ad;
  --accent: #f2c418;
  --accent-ink: #1b1600;
  --radius: 12px;
  --panel-w: 400px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h3 { margin: 0; }

/* Top bar ---------------------------------------------------------------- */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font: 700 18px 'Space Grotesk', sans-serif;
}
.brand-text { font: 700 18px 'Space Grotesk', sans-serif; letter-spacing: 0.01em; }
.brand-text em { font-style: normal; font-weight: 500; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: #46505a; }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }

/* Layout ------------------------------------------------------------------ */
.layout {
  height: calc(100% - 64px);
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
}

.viewer {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, #3a4049 0%, #22262c 55%, #15171a 100%);
}
.viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.viewer-title { position: absolute; top: 24px; left: 28px; pointer-events: none; }
.eyebrow { font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.viewer-title h1 { font: 700 clamp(26px, 3.4vw, 44px)/1.05 'Space Grotesk', sans-serif; margin: 6px 0 6px; }
.meta { color: var(--muted); font-size: 14px; }
.hint-drag { position: absolute; top: 28px; right: 24px; font-size: 12px; color: var(--muted); pointer-events: none; }

.views {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: rgba(20, 22, 25, 0.72); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px;
  max-width: calc(100% - 32px); overflow-x: auto;
}
.chip { background: transparent; border: 0; padding: 7px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip.on { color: var(--accent-ink); background: var(--accent); }
.divider { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }

.loader {
  position: absolute; inset: 0; display: none; place-items: center; z-index: 2;
  background: radial-gradient(ellipse at 50% 40%, #3a4049 0%, #22262c 55%, #15171a 100%);
}
.loader.show { display: grid; }
.loader-card { width: min(320px, calc(100% - 48px)); text-align: center; }
.loader-eyebrow { font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.loader-title { font: 700 22px 'Space Grotesk', sans-serif; margin: 8px 0 18px; }
.loader-track { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.loader-bar { height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width 0.2s ease-out; }
.loader.indeterminate .loader-bar { width: 35% !important; animation: loader-slide 1.2s ease-in-out infinite; }
@keyframes loader-slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.loader-text { margin-top: 12px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .loader.indeterminate .loader-bar { animation: none; width: 100% !important; opacity: 0.5; } }
.credit { position: absolute; left: 28px; bottom: 30px; font-size: 11px; color: var(--muted); max-width: 30%; }
.credit a, .credits a { color: inherit; }
.credits { margin: 0; padding-left: 18px; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* Panel ------------------------------------------------------------------- */
.panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-2); border-left: 1px solid var(--line);
}
.tabs { display: flex; justify-content: space-between; overflow-x: auto; border-bottom: 1px solid var(--line); padding: 0 12px; scrollbar-width: none; }
.tab {
  background: none; border: 0; padding: 14px 4px 12px; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 6px; align-items: baseline;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-num { font-size: 10px; display: none; opacity: 0.6; font-variant-numeric: tabular-nums; }

.panel-body { flex: 1; overflow-y: auto; padding: 8px 20px 24px; }
.panel-foot { display: flex; justify-content: space-between; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }

.group { padding: 18px 0 6px; }
.group h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600;
  margin-bottom: 12px; display: flex; justify-content: space-between;
}
.h-note { text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 500; }
.hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }

/* Generation cards */
.gen-list { display: grid; gap: 10px; }
.gen-card {
  text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; transition: border-color 0.15s, background 0.15s;
}
.gen-card:hover { border-color: #46505a; }
.gen-card.selected { border-color: var(--accent); background: linear-gradient(180deg, rgba(242, 196, 24, 0.08), transparent 70%), var(--surface); }
.gen-top { display: flex; justify-content: space-between; align-items: baseline; }
.gen-short { font: 700 18px 'Space Grotesk', sans-serif; }
.gen-years { font-size: 12px; color: var(--muted); }
.gen-code { font-size: 13px; color: var(--accent); margin-top: 2px; font-weight: 500; }
.gen-blurb { font-size: 13px; color: var(--muted); margin: 8px 0 10px; line-height: 1.45; }

/* Segmented options */
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.seg-wrap { grid-template-columns: repeat(2, 1fr); }
.seg-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  transition: border-color 0.15s, background 0.15s;
}
.seg-btn:hover { border-color: #46505a; }
.seg-btn.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.seg-label { font-size: 14px; font-weight: 500; }
.seg-desc { font-size: 12px; color: var(--muted); }
.seg-btn:not(.selected) 
/* Swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  position: relative; width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  background: var(--c);
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.25), inset 0 4px 8px rgba(255, 255, 255, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: transform 0.12s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--accent); }
.swatch.metal { background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.45), transparent 45%), var(--c); }
.swatch.custom {
  background: conic-gradient(from 90deg, #f44, #fd4, #4f8, #4df, #84f, #f4c, #f44);
  display: grid; place-items: center; cursor: pointer;
}
.swatch.custom::after { content: ''; width: 18px; height: 18px; border-radius: 50%; background: var(--c); border: 2px solid #fff; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* Toggles */
.toggles { display: grid; gap: 8px; }
.toggle-row {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.toggle-row:hover { border-color: #46505a; }
.toggle-row.on { border-color: rgba(242, 196, 24, 0.6); }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; }
.switch { width: 34px; height: 20px; border-radius: 999px; background: #3a4048; position: relative; transition: background 0.15s; }
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
}
.toggle-row.on .switch { background: var(--accent); }
.toggle-row.on .switch::after { transform: translateX(14px); background: var(--accent-ink); }
.toggle-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Summary */
.sum-hero { display: flex; gap: 14px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 14px; }
.sum-dot { width: 44px; height: 44px; border-radius: 50%; background: var(--c); flex: none; box-shadow: inset 0 -6px 12px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.15); }
.sum-title { font-weight: 600; margin-bottom: 3px; }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.lines li span:first-child { color: var(--muted); }
.lines li span:last-child { text-align: right; }
.sum-actions { display: grid; gap: 8px; padding-top: 18px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Responsive ---------------------------------------------------------------- */
@media (max-width: 900px) {
  body { overflow-x: hidden; overflow-y: auto; }
  .layout { display: flex; flex-direction: column; height: auto; }
  .layout > * { min-width: 0; width: 100%; }
  .tabs { justify-content: flex-start; gap: 14px; }
  .viewer { height: 56vh; min-height: 340px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .panel-body { overflow: visible; padding: 4px 16px 20px; }
  .panel-foot { padding: 12px 16px; position: sticky; bottom: 0; background: var(--bg-2); }
  .topbar { padding: 0 16px; }
  .brand-text em, #btn-reset, .hint-drag { display: none; }
  .viewer-title { top: 16px; left: 16px; }
  .credit { display: none; }
  .views { bottom: 14px; }
}
@media (max-width: 520px) {
  #btn-random { display: none; }
    }
