/* ==========================================================================
   Kinetic · base + app shell
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-feature-settings: var(--feat);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.006em;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- top bar ---------------- */
.top {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 64px; padding: 0 22px;
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { position: relative; width: 26px; height: 26px; flex: none; }
.logo i { position: absolute; display: block; border-radius: calc(4px * var(--rk)); background: var(--ink); }
.logo i:nth-child(1) { background: var(--acc); }
.wordmark { font-weight: 650; font-size: 16.5px; letter-spacing: -0.025em; }
.tagline { font-size: 12.5px; color: var(--mut); padding-left: 11px; border-left: 1px solid var(--line); white-space: nowrap; }

.actions { justify-self: end; display: flex; gap: 4px; align-items: center; }
.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: calc(11px * var(--rk));
  display: grid; place-items: center; color: var(--ink2);
  transition: background .2s, color .2s, transform .2s var(--ease-spring);
}
.icon-btn:hover { background: var(--tray); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn > span { grid-area: 1 / 1; display: grid; place-items: center; transition: opacity .25s, transform .4s var(--ease-spring); }
.icon-btn .off { opacity: 0; transform: scale(.5) rotate(-60deg); }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.btn-primary {
  height: 36px; padding: 0 15px 0 12px; border-radius: calc(11px * var(--rk));
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 6px 16px color-mix(in oklab, var(--ink) 18%, transparent);
  transition: transform .25s var(--ease-spring), box-shadow .25s;
  margin-left: 6px;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: scale(.96); }
.btn-primary svg { color: var(--acc3); }

/* shell segmented control (pill animated by app.js springs) */
.seg {
  position: relative; display: inline-flex; padding: 3px; gap: 0;
  border-radius: calc(12px * var(--rk)); background: var(--tray);
}
.seg > button {
  position: relative; z-index: 1; height: 30px; padding: 0 15px; border-radius: calc(9px * var(--rk));
  font-size: 13px; font-weight: 560; color: var(--mut); white-space: nowrap;
  transition: color .25s;
}
.seg > button[aria-selected="true"], .seg > button[aria-pressed="true"] { color: var(--ink); }
.seg > button:not(:disabled):hover { color: var(--ink); }
.seg > button:disabled { opacity: .55; }
.seg > button .soon { font-size: 9.5px; font-weight: 600; letter-spacing: .02em; color: var(--mut); margin-left: 5px; vertical-align: 1px; text-transform: uppercase; }
.seg-pill {
  position: absolute; z-index: 0; top: 3px; left: 0; height: 30px; width: 10px;
  border-radius: calc(9px * var(--rk)); background: var(--card);
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 3px 10px rgba(0,0,0,.05), var(--hair);
}
.seg.small > button { height: 28px; padding: 0 13px; font-size: 12.5px; }
.seg.small .seg-pill { height: 28px; }
.seg.full { display: flex; }
.seg.full > button { flex: 1; padding: 0 6px; }

/* ---------------- scene bar ---------------- */
.scenebar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 2px 24px 0; min-height: 44px;
}
.hint { margin: 0; font-size: 12.5px; color: var(--mut); display: flex; align-items: center; gap: 8px; }
.hint .live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 22%, transparent); animation: livepulse 2.4s ease-in-out infinite; }
@keyframes livepulse { 50% { box-shadow: 0 0 0 6px color-mix(in oklab, var(--ok) 0%, transparent); } }
.kbd { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--tray); color: var(--ink2); }

/* ---------------- stage ---------------- */
main#stageHost { display: flex; justify-content: center; padding: 10px 24px 28px; }
.stage-wrap { position: relative; flex: none; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.card {
  position: absolute; overflow: hidden;
  border-radius: var(--r-tray);
  background: var(--s0); color: var(--fg);
  transition: translate .45s var(--ease-out), box-shadow .45s var(--ease-out);
  isolation: isolate;
}
.card.tone-card { box-shadow: var(--sh-card); }
.card.tone-ink { box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 10px 26px rgba(10,10,20,.12); }
:root[data-mode="dark"] .card.tone-tray { box-shadow: var(--hair); }
.card:hover { translate: 0 -2px; box-shadow: var(--sh-hover); }
.card-in { position: absolute; inset: 0; }

/* flow layout for narrow screens */
.stage.flow { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; transform: none !important; }
.stage.flow .card { position: relative; left: auto !important; top: auto !important; flex: none; }

/* ---------------- customize panel ---------------- */
.panel {
  position: fixed; z-index: 60; top: 72px; right: 14px; bottom: 14px; width: 344px;
  display: flex; flex-direction: column;
  background: color-mix(in oklab, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  border-radius: calc(22px * var(--rk));
  box-shadow: var(--sh-pop), 0 0 0 1px var(--line);
  transform: translateX(calc(100% + 30px)) scale(.98);
  opacity: 0; visibility: hidden;
  transition: transform .55s cubic-bezier(.2,.9,.1,1), opacity .3s, visibility 0s .55s;
}
.panel.open { transform: none; opacity: 1; visibility: visible; transition: transform .55s cubic-bezier(.2,.9,.1,1), opacity .25s, visibility 0s; }
.panel-head { display: flex; align-items: center; padding: 16px 16px 6px 20px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.02em; }
.panel-head .icon-btn { margin-left: auto; width: 32px; height: 32px; }
.panel-body { flex: 1; overflow: auto; padding: 4px 20px 16px; scrollbar-width: thin; }
.panel-foot { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.p-sec { padding: 14px 0 4px; }
.p-sec + .p-sec { border-top: 1px solid var(--line); }
.p-lbl { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 600; color: var(--mut); letter-spacing: .01em; margin-bottom: 10px; text-transform: uppercase; }
.p-lbl small { text-transform: none; font-weight: 500; letter-spacing: 0; color: var(--mut); font-family: var(--font-mono); }

.swatches { display: grid; grid-template-columns: repeat(9, 1fr); gap: 7px; }
.sw {
  position: relative; aspect-ratio: 1; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  transition: transform .3s var(--ease-spring);
}
.sw:hover { transform: scale(1.1); }
.sw::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; box-shadow: 0 0 0 2px var(--ink); opacity: 0; transform: scale(.8); transition: opacity .25s, transform .35s var(--ease-spring); }
.sw[aria-pressed="true"]::after { opacity: 1; transform: none; }
.sw.custom { background: conic-gradient(from 0deg, #ff4d4d, #ffb84d, #f5ff4d, #4dff88, #4dd2ff, #6b4dff, #ff4dd8, #ff4d4d); }
.sw.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }

.fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.font-opt {
  position: relative; text-align: left; padding: 11px 12px 10px; border-radius: calc(13px * var(--rk));
  background: var(--raise); box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .25s, background .25s, transform .25s var(--ease-spring);
}
.font-opt:hover { transform: translateY(-1px); }
.font-opt[aria-pressed="true"] { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--acc), 0 4px 14px color-mix(in oklab, var(--acc) 14%, transparent); }
.font-opt .fa { display: flex; align-items: baseline; justify-content: space-between; }
.font-opt .fa b { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.font-opt .fa i { font-style: normal; font-size: 15px; color: var(--mut); font-variant-numeric: tabular-nums; }
.font-opt .fn { display: block; margin-top: 7px; font-size: 11.5px; color: var(--mut); font-family: var(--font-ui); }

.p-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 10px; font-size: 13px; }
.p-row span { color: var(--ink2); }
.switch { position: relative; width: 40px; height: 24px; border-radius: 12px; background: var(--track); transition: background .3s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .45s var(--ease-spring); }
.switch[aria-checked="true"] { background: var(--acc); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }

.btn-soft {
  flex: 1; height: 36px; border-radius: calc(11px * var(--rk)); display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--tray); font-size: 12.5px; font-weight: 600; color: var(--ink);
  transition: transform .25s var(--ease-spring), background .2s;
}
.btn-soft:hover { background: color-mix(in oklab, var(--tray) 80%, var(--ink) 6%); }
.btn-soft:active { transform: scale(.96); }
.btn-soft.accent { background: var(--acc); color: var(--acc-ink); }

.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 80; transform: translate(-50%, 20px); opacity: 0;
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 550;
  box-shadow: var(--sh-pop); pointer-events: none;
  transition: transform .45s var(--ease-spring), opacity .25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* view transitions: circular reveal for light/dark */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }

@media (max-width: 1100px) { .tagline { display: none; } }
@media (max-width: 760px) {
  .top { grid-template-columns: auto 1fr auto; gap: 8px; padding: 0 12px; }
  .top .modes { justify-self: center; }
  .modes > button { padding: 0 11px; font-size: 12.5px; }
  .seg > button .count, .wordmark, .tagline, #btnPlay, #btnReplay, #btnFilm, .top .sep { display: none; }
  .btn-primary .lbl { display: none; }
  .btn-primary { padding: 0 11px; }
  .scenebar { padding: 4px 14px 0; flex-wrap: wrap; }
  .hint { display: none; }
  main#stageHost { padding: 10px 14px 24px; }
  .panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 78vh; transform: translateY(calc(100% + 20px)); }
  .scenes { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .scenes::-webkit-scrollbar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { transition: none; }
  .hint .live { animation: none; }
}

/* ---------------- views: showcase / library ---------------- */
.sb-show, .sb-lib { display: flex; align-items: center; gap: 16px; width: 100%; }
.sb-show { justify-content: space-between; }
body[data-view="showcase"] .sb-lib, body[data-view="showcase"] #library { display: none; }
body[data-view="library"] .sb-show, body[data-view="library"] #stageHost { display: none; }
body[data-view="library"] .scenebar {
  position: sticky; top: 64px; z-index: 45; padding-top: 6px; padding-bottom: 10px;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px);
}
.view-in { animation: viewIn .55s var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.seg > button .count { font-size: 10.5px; font-weight: 600; margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: color-mix(in oklab, var(--ink) 7%, transparent); color: var(--mut); font-variant-numeric: tabular-nums; }

.lib-search {
  flex: none; display: flex; align-items: center; gap: 8px; width: 260px; height: 36px; padding: 0 8px 0 12px;
  border-radius: calc(12px * var(--rk)); background: var(--tray); color: var(--mut); cursor: text;
  transition: box-shadow .2s, background .2s;
}
.lib-search:focus-within { background: var(--card); box-shadow: 0 0 0 1.5px var(--acc), 0 0 0 5px color-mix(in oklab, var(--acc) 15%, transparent); }
.lib-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 13px; color: var(--ink); padding: 0; }
.lib-search input::placeholder { color: var(--mut); }
.lib-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.lib-search kbd { font: 600 11px var(--font-ui); padding: 2px 7px; border-radius: 6px; background: color-mix(in oklab, var(--ink) 7%, transparent); color: var(--mut); }
.lib-cats { overflow-x: auto; max-width: calc(100% - 276px); scrollbar-width: none; }
.lib-cats::-webkit-scrollbar { display: none; }
.lib-cats > button i { font-style: normal; font-size: 10.5px; margin-left: 5px; opacity: .6; font-variant-numeric: tabular-nums; }

.lib { position: relative; max-width: 1480px; margin: 0 auto; padding: 14px 24px 48px; }
.lib-grid { position: relative; }
.tile {
  position: absolute; left: 0; top: 0; border-radius: calc(24px * var(--rk)); overflow: hidden;
  background: var(--card); box-shadow: var(--sh-card), 0 0 0 1px var(--line);
  transform-origin: 50% 30%;
}
.tile-stage {
  position: relative;
  background-color: var(--bg);
  background-image: radial-gradient(circle, color-mix(in oklab, var(--ink) 9%, transparent) 1px, transparent 1.3px);
  background-size: 14px 14px; background-position: 7px 7px;
}
.tile-stage .card { position: absolute; }
.tile-meta { display: flex; align-items: flex-start; gap: 10px; height: 64px; padding: 12px 16px 0; }
.tile-tx { flex: 1; min-width: 0; }
.tile-tx b { display: block; font-size: 13.5px; font-weight: 620; letter-spacing: -0.015em; }
.tile-tx span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; font-size: 11.5px; line-height: 1.35; color: var(--mut); }
.tile-cat { flex: none; margin-top: 1px; font-size: 10.5px; font-weight: 650; padding: 3px 8px; border-radius: 7px; background: var(--tint); color: var(--acc); }
:root[data-mode="dark"] .tile-cat { color: var(--acc3); }
.lib-empty { display: none; flex-direction: column; align-items: center; gap: 14px; padding: 80px 0; color: var(--mut); font-size: 14px; }
.lib-empty.show { display: flex; }
.lib-empty b { color: var(--ink); font-weight: 600; }
.lib-empty .btn-soft { flex: none; padding: 0 16px; }

@media (max-width: 760px) {
  body[data-view="library"] .scenebar { top: 64px; }
  .sb-lib { flex-direction: column; align-items: stretch; gap: 8px; }
  .lib-search { width: 100%; }
  .lib-cats { max-width: 100%; }
  .lib { padding: 10px 14px 40px; }
}

/* ---------------- tile open button ---------------- */
.tile-open {
  position: absolute; right: 10px; top: 10px; z-index: 3; width: 30px; height: 30px; border-radius: 10px;
  display: grid; place-items: center; color: var(--ink2);
  background: color-mix(in oklab, var(--card) 85%, transparent); box-shadow: 0 0 0 1px var(--line), 0 2px 8px rgba(0,0,0,.06);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; transform: scale(.85); transition: opacity .2s, transform .3s var(--ease-spring);
}
.tile:hover .tile-open, .tile-open:focus-visible { opacity: 1; transform: none; }
.tile-open:hover { color: var(--acc); }
.tile-meta { cursor: pointer; }
.tile-meta:hover .tile-tx b { color: var(--acc); }
@media (hover: none) { .tile-open { opacity: 1; transform: none; } }

/* ---------------- focus view ---------------- */
.focus { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 28px; visibility: hidden; transition: visibility 0s .45s; }
.focus.open { visibility: visible; transition: none; }
.focus-bg { position: absolute; inset: 0; background: color-mix(in oklab, var(--bg) 55%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); opacity: 0; transition: opacity .35s; }
.focus.open .focus-bg { opacity: 1; }
.focus-panel {
  position: relative; display: grid; grid-template-columns: 1fr 320px; width: min(1180px, 100%); height: min(720px, 100%);
  border-radius: calc(28px * var(--rk)); overflow: hidden; background: var(--card); box-shadow: var(--sh-pop), 0 0 0 1px var(--line);
  opacity: 0; transform: translateY(18px) scale(.97); transition: opacity .3s, transform .55s cubic-bezier(.2,.9,.1,1);
}
.focus.open .focus-panel { opacity: 1; transform: none; }
.focus-stage {
  position: relative; overflow: hidden; background-color: var(--bg);
  background-image: radial-gradient(circle, color-mix(in oklab, var(--ink) 10%, transparent) 1px, transparent 1.3px); background-size: 18px 18px;
}
.focus-card { position: absolute; left: 50%; top: 50%; transform-origin: 50% 50%; }
.focus-card .card { position: absolute; left: 0; top: 0; width: 100%; height: 100%; animation: fpop .6s var(--ease-spring) both; }
.focus-card .card:hover { translate: none; }
@keyframes fpop { from { opacity: 0; transform: translateX(calc(var(--dir, 0) * 40px)) scale(.92); } to { opacity: 1; transform: none; } }
.focus-nav {
  position: absolute; top: 50%; width: 40px; height: 40px; margin-top: -20px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink2); background: var(--card); box-shadow: var(--sh-card), 0 0 0 1px var(--line); transition: transform .3s var(--ease-spring), color .2s;
}
.focus-nav.prev { left: 18px; } .focus-nav.next { right: 18px; }
.focus-nav:hover { color: var(--acc); transform: scale(1.08); }
.focus-count { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.focus-side { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px 16px; border-left: 1px solid var(--line); overflow: auto; }
.fs-top { display: flex; align-items: center; justify-content: space-between; }
.fs-top .icon-btn { width: 32px; height: 32px; }
.focus-side h2 { margin: 10px 0 0; font-size: 21px; font-weight: 650; letter-spacing: -0.025em; }
.focus-side > p { margin: 4px 0 6px; font-size: 13px; line-height: 1.45; color: var(--mut); }
.fs-sec { padding: 12px 0 6px; border-top: 1px solid var(--line); }
.fs-sec .p-lbl { margin-bottom: 9px; }
.fs-replay { width: 100%; margin-top: 10px; }
.fcs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fc { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: calc(12px * var(--rk)); background: var(--raise); }
.fc svg { overflow: visible; margin-bottom: 4px; }
.fc-ax { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; fill: none; }
.fc-ln { stroke: var(--acc); stroke-width: 2; fill: none; stroke-linecap: round; }
.fc b { font-size: 12px; font-weight: 620; }
.fc span { font-size: 10.5px; color: var(--mut); }
.fs-foot { margin-top: auto; padding-top: 12px; display: flex; align-items: center; gap: 4px; }
@media (max-width: 860px) {
  .focus { padding: 0; }
  .focus-panel { grid-template-columns: 1fr; grid-template-rows: 55% 45%; width: 100%; height: 100%; border-radius: 0; }
  .focus-side { border-left: 0; border-top: 1px solid var(--line); }
}

/* ---------------- panel: film section ---------------- */
.p-note { margin: -2px 0 10px; font-size: 12px; line-height: 1.45; color: var(--mut); }
.p-note code { font-family: var(--font-mono); font-size: 11px; padding: 1px 4px; border-radius: 4px; background: var(--tray); color: var(--ink2); }
.p-btns { display: flex; gap: 8px; }

/* ---------------- film mode ---------------- */
body.film { overflow: hidden; }
body.film .top, body.film .scenebar, body.film .panel, body.film .toast, body.film .focus, body.film #library { display: none !important; }
body.film main#stageHost { position: fixed; inset: 0; padding: 0; display: block; }
body.film .card { transition: none; }
body.film .stage { pointer-events: none; } /* recording: no hover lifts, autoplay never yields */
body.film .kp-spin, body.film .lg-spin { animation: none; transform: rotate(calc(var(--kt, 0) * 420deg)); }

/* ---------------- stage host (format-aware, spring-fitted) ---------------- */
main#stageHost { display: block; }
.stage-wrap { position: relative; width: 100%; }
.sb-remix { flex: none; height: 32px; padding: 0 12px; }
.sb-show .hint { margin-left: auto; }

/* ---------------- create view ---------------- */
body:not([data-view="create"]) #create, body:not([data-view="create"]) .sb-create { display: none; }
body[data-view="create"] .sb-show, body[data-view="create"] .sb-lib, body[data-view="create"] #stageHost, body[data-view="create"] #library { display: none; }
.sb-create { display: flex; align-items: center; gap: 12px; width: 100%; flex-wrap: wrap; }
.cr-start select {
  height: 32px; padding: 0 30px 0 12px; border: 0; border-radius: calc(10px * var(--rk)); background: var(--tray); color: var(--ink);
  font: 560 12.5px var(--font-ui); cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--mut) 50%), linear-gradient(135deg, var(--mut) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; background-size: 5px 5px; background-repeat: no-repeat;
}
.cr-acts { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.cr-acts .btn-soft { flex: none; height: 32px; padding: 0 12px; }
.create { display: grid; grid-template-columns: minmax(0, 1fr) 296px; gap: 18px; align-items: start; padding: 8px 24px 24px; }
.cr-main { min-width: 0; }
.cr-stagehost { position: relative; }
.cr-side {
  position: sticky; top: 124px; max-height: calc(100vh - 140px); display: flex; flex-direction: column;
  border-radius: calc(22px * var(--rk)); background: var(--card); box-shadow: var(--sh-card), 0 0 0 1px var(--line); overflow: hidden;
}
.cr-side-h { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 16px 8px; font-size: 14px; letter-spacing: -0.015em; }
.cr-side-h b { font-weight: 650; }
.cr-search { width: auto; margin: 0 12px 6px; height: 34px; }
.cr-list { flex: 1; overflow: auto; padding: 0 8px 8px; scrollbar-width: thin; }
.cr-cat-h { padding: 12px 8px 4px; font-size: 10.5px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; color: var(--mut); }
.cr-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px; border-radius: calc(10px * var(--rk)); text-align: left; font-size: 12.5px; transition: background .15s; }
.cr-item:hover { background: var(--tray); }
.cr-item b { flex: 1; min-width: 0; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-sz { flex: none; width: 58px; padding: 2px 0; border-radius: 5px; background: var(--tray); color: var(--mut); text-align: center; font: 600 9.5px var(--font-mono); }
.cr-item:hover .cr-sz { background: var(--card); }
.cr-add { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--tint); color: var(--acc); transition: transform .3s var(--ease-spring); }
.cr-item:hover .cr-add { transform: scale(1.12); }
.cr-item.on .cr-add { background: var(--acc); color: var(--acc-ink); }
.cr-item.on b { color: var(--mut); }
.cr-none { padding: 24px 8px; font-size: 12.5px; color: var(--mut); text-align: center; }
.cr-tip { margin: 0; padding: 10px 16px 14px; border-top: 1px solid var(--line); line-height: 1.45; }
:root[data-mode="dark"] .cr-add { color: var(--acc3); }

/* edit chrome on the builder stage */
.ed { display: none; }
.stage.editing .ed {
  display: block; position: absolute; inset: 0; z-index: 30; cursor: grab; border-radius: inherit; touch-action: none;
  box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .2s, background .2s;
}
.stage.editing .ed:hover { box-shadow: inset 0 0 0 2px var(--acc); background: color-mix(in oklab, var(--acc) 6%, transparent); }
.ed-name {
  position: absolute; left: 8px; bottom: 8px; padding: 3px 8px; border-radius: 7px; white-space: nowrap;
  background: color-mix(in oklab, var(--ink) 86%, transparent); color: var(--bg); font: 600 10.5px var(--font-ui);
  opacity: 0; transform: translateY(3px); transition: opacity .2s, transform .25s var(--ease-out); pointer-events: none;
}
.ed-btns { position: absolute; right: 7px; top: 7px; display: flex; gap: 5px; opacity: 0; transform: translateY(-3px); transition: opacity .2s, transform .25s var(--ease-out); }
.ed:hover .ed-name, .ed:hover .ed-btns, .card.dragging .ed-name, .card.dragging .ed-btns { opacity: 1; transform: none; }
.ed-btns button { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.18), 0 0 0 1px var(--line); cursor: pointer; }
.ed-btns button:hover { color: var(--acc); }
.ed-x:hover { color: var(--bad) !important; }
.ed-tone i { width: 11px; height: 11px; border-radius: 50%; background: var(--tray); box-shadow: inset 0 0 0 1.5px var(--ink2); }
.ed-tone i[data-t="card"] { background: var(--card); }
.ed-tone i[data-t="ink"] { background: var(--dk); box-shadow: none; }
.stage .card.dragging { z-index: 60 !important; box-shadow: var(--sh-pop); translate: 0 -3px; transition: box-shadow .25s; }
.card.dragging .ed { cursor: grabbing; }
.card.flash { animation: crFlash 1.1s var(--ease-out); }
@keyframes crFlash { 0%, 100% { outline: 2px solid transparent; outline-offset: 6px; } 25% { outline: 3px solid var(--acc); outline-offset: 3px; } }
.cr-guides { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity .3s; }
.stage.editing .cr-guides { opacity: 1; }
.cr-col { position: absolute; border-radius: var(--r-tray); box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--ink) 9%, transparent); display: grid; place-items: center; text-align: center; font-size: 12px; line-height: 1.5; color: var(--mut); }
.cr-col.empty { box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--acc) 35%, transparent); background: color-mix(in oklab, var(--acc) 4%, transparent); }
.cr-col.tight { box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--bad) 45%, transparent); }
.cr-meter { position: absolute; top: 5px; text-align: center; font: 650 10px var(--font-ui); letter-spacing: .01em; color: var(--mut); }
.cr-meter.room, .cr-meter.empty { color: var(--acc); }
.cr-meter.tight { color: var(--bad); }
@media (max-width: 1060px) {
  .create { grid-template-columns: 1fr; }
  .cr-side { position: relative; top: 0; max-height: 420px; }
}

/* ---------------- embed mode ---------------- */
body.embed { overflow: hidden; }
body.embed > *:not(.embed-host):not(script) { display: none !important; }
html.embed-clear, html.embed-clear body { background: transparent !important; }
.embed-host { position: fixed; inset: 0; }
.embed-box { position: absolute; left: 50%; top: 50%; transform-origin: 50% 50%; }
.embed-box .card { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.embed-box .card:hover { translate: none; }
.fs-embed-note { margin: 8px 0 0; }
@media (max-width: 760px) {
  .modes > button[data-v="create"], .sb-remix { display: none; }
}

/* ---------------- interaction hints ---------------- */
.k-hint {
  position: fixed; left: 0; top: 0; z-index: 85; display: flex; align-items: center; gap: 8px;
  padding: 7px 13px 7px 9px; border-radius: 12px; white-space: nowrap; pointer-events: none;
  background: var(--ink); color: var(--bg); font: 600 12.5px var(--font-ui); letter-spacing: -0.01em;
  box-shadow: var(--sh-pop); opacity: 0; scale: .9; transform-origin: 50% 100%;
  transition: opacity .22s, scale .4s var(--ease-spring);
}
.k-hint.below { transform-origin: 50% 0; }
.k-hint.show { opacity: 1; scale: 1; }
.k-hint::after { content: ''; position: absolute; left: var(--ax, 50%); bottom: -4px; width: 10px; height: 10px; margin-left: -5px; border-radius: 2px; background: inherit; transform: rotate(45deg); }
.k-hint.below::after { bottom: auto; top: -4px; }
.k-hint .hg { color: var(--acc3); }
.k-hint.auto { padding-right: 15px; }
.k-hint-ring {
  position: fixed; left: 0; top: 0; z-index: 84; pointer-events: none; border-radius: calc(12px * var(--rk));
  box-shadow: 0 0 0 2px var(--acc), 0 0 0 7px color-mix(in oklab, var(--acc) 20%, transparent);
  opacity: 0; transition: opacity .25s;
}
.k-hint-ring.show { opacity: 1; animation: hintPulse 1.5s ease-in-out infinite; }
@keyframes hintPulse { 50% { box-shadow: 0 0 0 2px var(--acc), 0 0 0 12px color-mix(in oklab, var(--acc) 0%, transparent); } }

/* gesture glyphs (chip + focus view) */
.hg { position: relative; flex: none; width: 18px; height: 18px; display: inline-grid; place-items: center; }
.hg i, .hg b { grid-area: 1 / 1; display: block; }
.hg i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.hg b { position: absolute; inset: 1px; border-radius: 50%; border: 1.5px solid currentColor; opacity: 0; }
.hg-tap b { animation: hgRing 1.4s var(--ease-out) infinite; }
.hg-drag-x i { animation: hgX 1.6s ease-in-out infinite; }
.hg-drag-y i { animation: hgY 1.6s ease-in-out infinite; }
.hg-drag i { animation: hgXY 1.8s ease-in-out infinite; }
.hg-drag-x b, .hg-drag-y b, .hg-drag b { inset: auto; width: 14px; height: 2px; border: 0; border-radius: 1px; background: currentColor; opacity: .28; }
.hg-drag-y b { width: 2px; height: 14px; }
.hg-drag b { width: 2px; height: 14px; transform: rotate(45deg); }
.hg-type i { width: 2px; height: 12px; border-radius: 1px; animation: hgBlink 1s steps(1) infinite; }
.hg-type b { inset: auto; bottom: 2px; width: 14px; height: 1.5px; border: 0; border-radius: 1px; background: currentColor; opacity: .35; }
.hg-keys i { width: 14px; height: 10px; border-radius: 3px; background: none; border: 1.5px solid currentColor; }
.hg-keys b { inset: auto; width: 6px; height: 1.5px; border: 0; border-radius: 1px; background: currentColor; opacity: 1; animation: hgKey 1.2s ease-in-out infinite; }
.hg-hover i { width: 0; height: 0; border-radius: 0; background: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 10px solid currentColor; transform: rotate(-30deg); animation: hgHover 1.8s ease-in-out infinite; }
.hg-scroll i { width: 8px; height: 13px; border-radius: 4px; background: none; border: 1.5px solid currentColor; }
.hg-scroll b { inset: auto; width: 2px; height: 3px; border: 0; border-radius: 1px; background: currentColor; opacity: 1; animation: hgWheel 1.3s ease-in-out infinite; }
.hg-drop i { animation: hgDrop 1.5s var(--ease-out) infinite; }
.hg-drop b { inset: auto; bottom: 1px; width: 14px; height: 2px; border: 0; border-radius: 1px; background: currentColor; opacity: .4; }
@keyframes hgRing { 0% { transform: scale(.35); opacity: .9; } 100% { transform: scale(1.15); opacity: 0; } }
@keyframes hgX { 0%, 100% { transform: translateX(-5px); } 50% { transform: translateX(5px); } }
@keyframes hgY { 0%, 100% { transform: translateY(5px); } 50% { transform: translateY(-5px); } }
@keyframes hgXY { 0%, 100% { transform: translate(-4px, 4px); } 50% { transform: translate(4px, -4px); } }
@keyframes hgBlink { 50% { opacity: 0; } }
@keyframes hgKey { 50% { transform: translateY(1px); opacity: .4; } }
@keyframes hgHover { 0%, 100% { transform: translate(-3px, 2px) rotate(-30deg); } 50% { transform: translate(3px, -2px) rotate(-30deg); } }
@keyframes hgWheel { 0% { transform: translateY(-3px); opacity: 1; } 100% { transform: translateY(3px); opacity: 0; } }
@keyframes hgDrop { 0% { transform: translateY(-6px); opacity: 0; } 40% { opacity: 1; } 100% { transform: translateY(3px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hg i, .hg b, .k-hint-ring.show { animation: none !important; } }

/* focus view: how to play */
.fs-play { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.fs-play li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; line-height: 1.35; color: var(--ink2); }
.fs-play .hg { width: 28px; height: 28px; border-radius: calc(9px * var(--rk)); background: var(--tint); color: var(--acc); }
:root[data-mode="dark"] .fs-play .hg { color: var(--acc3); }
.fs-play b { font-weight: 650; color: var(--ink); margin-right: 6px; }

/* ---------------- panel: make it yours ---------------- */
.p-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.p-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 11px; font-weight: 600; color: var(--mut); }
.p-field.wide, .p-fields > .p-field:last-child { grid-column: 1 / -1; }
.p-field input {
  width: 100%; height: 34px; padding: 0 10px; border: 0; outline: none; border-radius: calc(10px * var(--rk));
  background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); font: 500 13px var(--font-ui); color: var(--ink);
  transition: box-shadow .2s;
}
.p-field input:focus { box-shadow: inset 0 0 0 1.5px var(--acc), 0 0 0 4px color-mix(in oklab, var(--acc) 14%, transparent); }
.p-field input::placeholder { color: var(--mut2); }
.p-link { font: 600 11px var(--font-ui); color: var(--acc); text-transform: none; letter-spacing: 0; padding: 2px 5px; margin-left: 4px; border-radius: 5px; }
.p-link:hover { background: var(--tint); }
:root[data-mode="dark"] .p-link { color: var(--acc3); }

/* builder palette: toggle + auto-filled markers */
.cr-item .cr-add span { display: grid; place-items: center; }
.cr-item.on .off-i { display: none; }
.cr-item.on:hover .on-i { display: none; }
.cr-item.on:hover .off-i { display: grid; }
.cr-item.on:hover .cr-add { background: color-mix(in oklab, var(--bad) 14%, var(--card)); color: var(--bad); }
.cr-item.on:hover b { color: var(--ink); }
.cr-tag { flex: none; font: 650 9px var(--font-ui); font-style: normal; letter-spacing: .03em; text-transform: uppercase; padding: 2px 5px; border-radius: 5px; color: var(--acc); background: var(--tint); }
:root[data-mode="dark"] .cr-tag { color: var(--acc3); }
.stage .card.peek { outline: 3px solid var(--acc); outline-offset: 3px; }
#crFill { gap: 6px; }
#crFill svg { color: var(--acc); }
