/* Bitkin Character Lab — "mission control" cockpit. Dark, dense, desktop-first. */
:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, .04);
  --line: rgba(255, 255, 255, .09);
  --ink: #e6edf7;
  --muted: #8b97ad;
  --accent: #34c894;
  --accent-deep: #059669;
  --gold: #FBBF24;
  --radius: 14px;
  --radius-lg: 24px;
  --rounded: "Nunito", system-ui, sans-serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html { overflow-x: hidden; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  padding-bottom: 92px;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--rounded); font-weight: 800; margin: 0; color: var(--ink); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

.panel-label { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 700; }
.mini-label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 10px 0 6px; }

.state-card {
  max-width: 480px; margin: 64px auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 24px; text-align: center; color: var(--ink); font-family: var(--rounded);
}
.state-card.error { text-align: left; color: #fca5a5; }
.state-card.error pre { white-space: pre-wrap; font: 12px/1.5 var(--mono); color: var(--ink); }

.cockpit { max-width: 1400px; margin: 0 auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }

/* ── swatch strip ── */
.swatch-strip { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 16px; }
.species-name { font-family: var(--rounded); font-weight: 800; font-size: 1.15rem; color: var(--ink); white-space: nowrap; }
.dot-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dot-row.mini { gap: 6px; }
.ring-dot { display: flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer; padding: 2px 6px 2px 2px; border-radius: 999px; }
.ring-dot:hover { background: rgba(255, 255, 255, .06); }
.ring-dot .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--dot); display: block; border: 2px solid transparent; }
.ring-dot.is-selected .dot { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(52, 200, 148, .25); }
.ring-dot .dot-label { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ring-dot.is-selected .dot-label { color: var(--ink); }
.mini-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--dot); border: 1px solid var(--line); cursor: pointer; padding: 0; }
.mini-dot:hover { filter: brightness(1.15); }
.divider { width: 1px; align-self: stretch; background: var(--line); }
.spacer { flex: 1; }
.badge { font-size: 11px; letter-spacing: .08em; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.is-dirty { color: #1a2035; background: var(--gold); border-color: var(--gold); font-weight: 700; }

.banner-slim {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .35); color: var(--gold);
  border-radius: var(--radius); padding: 8px 16px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700;
}
.banner-slim button {
  border: 1px solid var(--gold); background: transparent; color: var(--gold); border-radius: 999px;
  padding: 4px 12px; font-weight: 700; cursor: pointer; text-transform: none; letter-spacing: normal; font-size: 12px;
}

/* ── three-column grid ── */
.grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 340px; gap: 12px; align-items: start; min-height: 640px; }

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-section + .panel-section { margin-top: 16px; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 12px; cursor: pointer; }
.chip:hover { background: rgba(255, 255, 255, .06); }
.chip.is-selected { background: var(--accent); color: #06281d; border-color: var(--accent); }

.anim-list { display: flex; flex-direction: column; gap: 4px; }
.anim-item { text-align: left; border: 1px solid transparent; background: transparent; color: var(--ink); border-radius: 8px; padding: 7px 10px; font-size: 13px; cursor: pointer; }
.anim-item:hover { background: rgba(255, 255, 255, .06); }
.anim-item.is-selected { background: rgba(52, 200, 148, .15); border-color: var(--accent); color: var(--accent); font-weight: 700; }

.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 6px 12px; font-weight: 600; cursor: pointer; font-size: 13px; }
.btn-ghost:hover { background: rgba(255, 255, 255, .06); }

.ctl-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; }
.ctl-row label { flex: 0 0 auto; min-width: 84px; color: var(--muted); font-size: 12px; }
.ctl-row input[type="range"] { flex: 1; }
.ctl-row .val { min-width: 44px; text-align: right; color: var(--ink); font-size: 12px; }
.ctl-row select, .ctl-row input[type="text"] {
  flex: 1; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 6px 8px; font: inherit;
}
.check-row { justify-content: flex-start; cursor: pointer; }
.check-row input { margin-right: 4px; }
.color-row input[type="color"] { width: 36px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; flex: 0 0 auto; }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; background: var(--line); border-radius: 2px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #06281d; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stage-col { display: flex; flex-direction: column; gap: 12px; }
.stage {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px;
  display: flex; align-items: center; justify-content: center; min-height: 420px; position: relative; overflow: hidden;
}
.stage::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(52, 200, 148, .08), transparent 60%);
}
.stage-figure { width: min(440px, 100%); position: relative; z-index: 1; }
.stage-figure svg { width: 100%; height: auto; display: block; }
.part-readout {
  position: absolute; top: 12px; left: 12px; z-index: 2; background: rgba(11, 16, 32, .85); color: var(--gold);
  font-weight: 700; font-size: 11px; letter-spacing: .04em; padding: 4px 10px; border-radius: 6px;
}

.filmstrip-panel { padding: 10px 14px; }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.film-tile { flex: 0 0 auto; width: 96px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; text-align: center; cursor: pointer; color: var(--ink); }
.film-tile:hover { background: rgba(255, 255, 255, .06); }
.film-tile.is-selected, .film-tile.is-worn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.film-figure svg { width: 100%; height: auto; display: block; }
.film-label { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 4px; }

.panel-right { display: flex; flex-direction: column; gap: 12px; }
.details-panel { padding: 0; overflow: hidden; }
.details-panel summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.details-panel summary::-webkit-details-marker { display: none; }
.details-panel summary::before { content: '▸ '; color: var(--muted); font-size: 10px; }
.details-panel[open] summary::before { content: '▾ '; }
.panel-body { padding: 0 14px 14px; }
.ctl-group + .ctl-group { margin-top: 14px; }
.ctl-group-details { margin-top: 8px; border-top: 1px solid var(--line); }
.ctl-group-details summary.mini-label { list-style: none; cursor: pointer; padding: 8px 0 6px; font-size: 10px; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.ctl-group-details summary.mini-label::-webkit-details-marker { display: none; }
.ctl-group-details summary.mini-label::after { content: ' ▸'; font-size: 9px; }
.ctl-group-details[open] summary.mini-label::after { content: ' ▾'; }
.ctl-group-details + .ctl-group-details { margin-top: 0; }

@keyframes flashHighlight { 0%, 100% { background: transparent; } 35% { background: rgba(52, 200, 148, .28); } }
.flash { animation: flashHighlight 900ms ease; }

.parts-legend { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; max-height: 280px; overflow-y: auto; }
.part-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.part-row:hover { background: rgba(255, 255, 255, .06); }
.part-swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.part-name { flex: 1; color: var(--ink); }
.part-group { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }

.bottom-bar {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: rgba(11, 16, 32, .92); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 10px 20px; z-index: 50; font-size: 11px;
}
.bottom-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bottom-actions button { border: none; border-radius: 999px; padding: 8px 16px; font-weight: 700; cursor: pointer; font-size: 13px; }
#btn-share, #btn-download { background: var(--accent); color: #06281d; }
#btn-reset { background: transparent; border: 1px solid var(--line); color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: #7f1d1d; color: #fee2e2; padding: 10px 18px; border-radius: 10px; font-size: .85rem; max-width: 90vw; z-index: 200; }
#share-fallback { position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%); width: min(420px, 90vw); padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); z-index: 200; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; min-height: 0; }
  .stage { min-height: 320px; padding: 16px; }
  .stage-figure { width: min(320px, 100%); }
}
