:root {
  --panel: rgba(14, 17, 24, 0.84);
  --panel-line: rgba(255, 255, 255, 0.08);
  --ink: #eef0f4;
  --ink-2: #a7adba;
  --ink-3: #6b7280;
  --accent: #ff9a3c;
  --accent-soft: rgba(255, 154, 60, 0.18);
  --radius: 14px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: #c3c7cc;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}
body.line { background: #f6f4ef; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- brand ---------- */
.brand {
  position: fixed; top: 20px; left: 20px; display: flex; gap: 12px; align-items: center;
  padding: 10px 16px 10px 10px; background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: var(--radius); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.mark { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: #1a1208; display: grid; place-items: center; }
.mark svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.kicker { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); font-weight: 500; }
.brand h1 { margin: 2px 0 0; font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: -0.01em; }

/* ---------- step card ---------- */
.card {
  position: fixed; top: 92px; left: 20px; width: 340px; padding: 18px 20px 20px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: opacity .3s ease, transform .3s ease;
}
.counter { font-family: var(--mono); font-size: 12px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; }
.counter b { color: var(--accent); font-weight: 500; font-size: 13px; }
.card h2 { margin: 8px 0 8px; font-family: var(--serif); font-weight: 500; font-size: 26px; line-height: 1.15; letter-spacing: -0.01em; }
.card p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; }
.card.swap { opacity: 0; transform: translateY(6px); }

/* ---------- bottom bar ---------- */
.bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  width: min(880px, calc(100% - 40px));
  display: flex; align-items: center; gap: 6px; padding: 8px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.icon { width: 40px; height: 40px; flex: none; border-radius: 11px; display: grid; place-items: center; color: var(--ink); transition: background .15s; }
.icon:hover { background: rgba(255,255,255,0.08); }
.icon:disabled { opacity: .3; cursor: default; background: none; }
.icon.play { background: var(--accent); color: #1a1208; }
.icon.play:hover { background: #ffad5e; }
.icon.play svg { fill: currentColor; stroke-width: 2.4; }
.icon.play .i-pause { fill: none; display: none; }
body.playing .icon.play .i-play { display: none; }
body.playing .icon.play .i-pause { display: block; }

.timeline { flex: 1; display: flex; gap: 4px; padding: 0 10px; height: 40px; align-items: center; min-width: 0; }
.seg {
  position: relative; flex: 1; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; color: var(--ink-3); background: rgba(255,255,255,0.05); overflow: hidden;
  transition: color .2s, background .2s;
}
.seg:hover { background: rgba(255,255,255,0.1); color: var(--ink); }
.seg .fill { position: absolute; inset: 0; width: 0%; background: var(--accent-soft); }
.seg span { position: relative; }
.seg.done { color: var(--ink-2); }
.seg.done .fill { width: 100%; background: rgba(255,255,255,0.07); }
.seg.cur { color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255,154,60,0.55); }
.seg .tip {
  position: fixed; pointer-events: none; opacity: 0;
}

.seg-toggle { display: flex; padding: 3px; background: rgba(255,255,255,0.06); border-radius: 11px; flex: none; }
.seg-toggle button { padding: 0 12px; height: 34px; border-radius: 8px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.seg-toggle button.on { background: var(--ink); color: #11141b; }

.hint {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: rgba(20, 24, 32, 0.55); letter-spacing: 0.02em; pointer-events: none;
  transition: opacity .6s;
}

/* ---------- keys popover ---------- */
.keys {
  position: fixed; right: 20px; bottom: 96px; width: 300px; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.keys h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.keys dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; align-items: center; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--ink-2); }
kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 5px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.12); }

/* ---------- cover ---------- */
.cover {
  position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center;
  padding: 0 24px 120px; pointer-events: none;
  background: linear-gradient(to top, rgba(14,17,24,0.78) 0%, rgba(14,17,24,0.35) 32%, rgba(14,17,24,0) 55%);
  transition: opacity .6s ease;
}
.cover-inner { text-align: center; pointer-events: auto; }
.cover h2 { margin: 10px 0 22px; font-family: var(--serif); font-weight: 500; font-size: clamp(32px, 5vw, 54px); line-height: 1.05; letter-spacing: -0.02em; }
.cover .kicker { color: rgba(255,255,255,0.7); }
.cta {
  display: inline-flex; align-items: center; gap: 10px; padding: 14px 22px; border-radius: 999px;
  background: var(--accent); color: #1a1208; font-weight: 600; font-size: 16px;
  box-shadow: 0 10px 30px rgba(255,154,60,0.35); transition: transform .15s, background .15s;
}
.cta:hover { transform: translateY(-1px); background: #ffad5e; }
.cta svg { stroke-width: 2.4; }
body.covered .card, body.covered .bar, body.covered .hint { opacity: 0; pointer-events: none; }
body:not(.covered) .cover { opacity: 0; }
body:not(.covered) .cover-inner { pointer-events: none; }
.card, .bar, .hint { transition: opacity .5s ease; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .brand { top: 12px; left: 12px; right: 12px; padding: 8px 12px 8px 8px; }
  .brand h1 { font-size: 19px; }
  .mark { width: 32px; height: 32px; }
  .card {
    top: auto; bottom: 128px; left: 12px; right: 12px; width: auto; padding: 14px 16px 16px;
  }
  .card h2 { font-size: 21px; margin: 6px 0; }
  .card p { font-size: 14px; }
  .bar { bottom: 12px; width: calc(100% - 24px); flex-wrap: wrap; gap: 4px; padding: 8px; }
  .timeline { order: -1; flex-basis: 100%; padding: 0 2px 4px; height: 30px; }
  .seg { height: 22px; font-size: 10px; }
  .seg-toggle { margin-left: auto; }
  #help { display: none; }
  .hint { display: none; }
  .cover { padding-bottom: 80px; }
}

#sound .i-off { display: none; }
body.muted #sound .i-on { display: none; }
body.muted #sound .i-off { display: block; }
.legend { margin: 0 0 12px; font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.legend .dash { display: inline-block; width: 26px; height: 3px; background: repeating-linear-gradient(90deg, #ff8a2a 0 7px, transparent 7px 11px); }
.legend .dash.dot { background: repeating-linear-gradient(90deg, #ff8a2a 0 8px, transparent 8px 11px, #ff8a2a 11px 13px, transparent 13px 16px); }

.pill { height: 40px; flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border-radius: 11px; font-size: 13px; font-weight: 500; color: var(--ink); background: rgba(255,255,255,0.06); transition: background .15s; }
.pill:hover { background: rgba(255,255,255,0.12); }
.pill svg { width: 17px; height: 17px; }

/* video export: no controls, no transitions (frames are rendered one at a time) */
body.record .bar, body.record .hint, body.record .keys { display: none !important; }
body.record *, body.record *::before, body.record *::after { transition: none !important; }

/* follow on X (top right) */
.social {
  position: fixed; top: 20px; right: 20px; height: 58px; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 18px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 500; transition: background .15s, transform .15s;
}
.social:hover { background: rgba(30, 34, 44, 0.92); transform: translateY(-1px); }
.social b { font-size: 20px; font-weight: 600; line-height: 1; }
body.record .social { display: none; }
@media (max-width: 720px) {
  .brand { right: auto; }
  .social { top: 12px; right: 12px; height: 50px; padding: 0 14px; font-size: 14px; }
}
@media (max-width: 720px) {
  .pill { padding: 0 11px; }
  .pill span { display: none; } /* icon only on phones so the bar stays on two rows */
}

/* ---------- model switcher (title dropdown) ---------- */
a.mark { text-decoration: none; transition: transform .15s; }
a.mark:hover { transform: scale(1.05); }
.model-switch { display: inline-flex; align-items: center; gap: 6px; padding: 0; margin-top: 2px; color: var(--ink); }
.model-switch h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: -0.01em; }
.model-switch svg { width: 18px; height: 18px; color: var(--ink-2); transition: transform .2s; }
.model-switch[aria-expanded="true"] svg { transform: rotate(180deg); }
.model-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 280px; padding: 6px;
  background: rgba(14, 17, 24, 0.94); border: 1px solid var(--panel-line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 16px 40px rgba(0,0,0,0.25);
  display: flex; flex-direction: column; gap: 2px; z-index: 20;
}
.model-menu[hidden] { display: none; }
.model-menu a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.model-menu a:hover { background: rgba(255,255,255,0.07); }
.model-menu a.on { background: var(--accent-soft); }
.model-menu a.on b { color: var(--accent); }
.model-menu a b { font-weight: 600; font-size: 14px; }
.model-menu a span { font-size: 12px; color: var(--ink-2); }
.model-menu a.all { flex-direction: row; align-items: center; justify-content: space-between; border-top: 1px solid var(--panel-line); border-radius: 0 0 10px 10px; margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.model-menu a.all svg { width: 16px; height: 16px; }
.brand { z-index: 10; }
body.record .model-switch svg { display: none; }

/* ---------- gallery page ---------- */
body.gallery-page { overflow: auto; touch-action: auto; background: radial-gradient(ellipse at 50% 0%, #d6d9dd 0%, #c3c7cc 60%, #b9bdc3 100%); min-height: 100%; }
html:has(body.gallery-page) { overflow: auto; height: auto; }
.gallery { max-width: 1080px; margin: 0 auto; padding: 120px 24px 64px; }
.gallery-head { color: #14171f; margin-bottom: 32px; max-width: 640px; }
.gallery-head h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(32px, 5vw, 52px); line-height: 1.05; letter-spacing: -0.02em; margin: 0 0 12px; }
.gallery-head p { margin: 0; font-size: 16px; line-height: 1.55; color: #3b414d; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.model-card {
  display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--panel-line); box-shadow: 0 12px 32px rgba(20, 24, 32, 0.18);
  transition: transform .2s ease, box-shadow .2s ease;
}
.model-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(20, 24, 32, 0.26); }
.model-card .thumb { aspect-ratio: 4 / 3; background: radial-gradient(ellipse at 50% 40%, #e2e4e7 0%, #c9cdd2 75%); }
.model-card canvas { width: 100%; height: 100%; display: block; }
.model-card .info { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; }
.model-card h3 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 24px; letter-spacing: -0.01em; }
.model-card p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.chips span { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); padding: 4px 8px; border-radius: 6px; background: rgba(255,255,255,0.07); }
.model-card .go { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 14px; }
.model-card .go svg { width: 16px; height: 16px; stroke-width: 2.4; transition: transform .2s; }
.model-card:hover .go svg { transform: translateX(3px); }
.gallery-page .brand, .gallery-page .social { position: fixed; }
@media (max-width: 720px) {
  .gallery { padding: 88px 16px 40px; }
  .model-switch h1 { font-size: 19px; }
  .model-menu { min-width: 0; width: calc(100vw - 24px); }
}
