/* Components and views. Colors, type and spacing come from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1200px 520px at 85% -10%, var(--bg-glow), transparent 70%),
    radial-gradient(900px 480px at -10% 10%, var(--bg-glow), transparent 65%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.92em; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
p { margin: 0; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.page { width: min(100%, var(--page-max)); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--ink-3); }
.small { font-size: var(--text-sm); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ───────── Top bar ─────────
 * Scrolling down hides the bar (body.nav-hidden); scrolling up brings it back.
 * Everything sticky below it uses --header-offset so it slides up together. */
:root { --header-offset: var(--topbar-h); }
body.nav-hidden { --header-offset: 0px; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  transition: transform 320ms var(--ease), box-shadow 320ms var(--ease), background 320ms var(--ease);
  height: var(--topbar-h);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
body.nav-hidden .topbar { transform: translateY(-100%); }
body.scrolled .topbar { box-shadow: 0 10px 24px -18px rgb(30 24 14 / 0.35); }
.topbar .page { height: 100%; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 650; letter-spacing: 0.01em; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); display: grid; place-items: center; box-shadow: var(--shadow-1); }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-size: var(--text-sm); font-weight: 550;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--ink-inverse); }
.nav a svg { width: 16px; height: 16px; }
.nav .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent-2); color: #fff; font-size: 11px; display: inline-grid; place-items: center; font-weight: 700; }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--ink-2);
  display: inline-grid; place-items: center; cursor: pointer; text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.banner { background: var(--warning-soft); color: var(--warning); border-bottom: 1px solid color-mix(in srgb, var(--warning) 25%, transparent); font-size: var(--text-sm); }
.banner .page { display: flex; gap: 10px; align-items: center; padding-top: 8px; padding-bottom: 8px; }
.banner svg { width: 16px; height: 16px; flex: none; }

/* ───────── Buttons, chips, badges ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: var(--text-sm); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-1);
  transition: transform 120ms var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { border-color: var(--ink-3); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--ink); color: var(--ink-inverse); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); color: var(--ink-inverse); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; border-radius: 9px; font-size: var(--text-xs); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: var(--text-sm); cursor: pointer; white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--ink-inverse); }
.chip .n { font-size: 11px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: color-mix(in srgb, var(--c, var(--ink-3)) 14%, transparent);
  color: color-mix(in srgb, var(--c, var(--ink-3)) 85%, var(--ink));
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink-3)); }
.badge.plain::before { display: none; }
.badge.outline { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2); }
.status-captured { --c: var(--status-captured); }
.status-draft { --c: var(--status-draft); }
.status-reproduced { --c: var(--status-reproduced); }
.status-reusable { --c: var(--status-reusable); }
.data-original { --c: var(--data-original); }
.data-digitized { --c: var(--data-digitized); }
.data-synthetic { --c: var(--data-synthetic); }
.data-unknown { --c: var(--data-unknown); }

.id-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line); font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2);
}
.id-pill button { border: 0; background: transparent; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; color: var(--ink-3); display: grid; place-items: center; }
.id-pill button:hover { background: var(--surface-3); color: var(--ink); }
.id-pill svg { width: 14px; height: 14px; }

/* ───────── Hero ───────── */
.hero { padding: clamp(24px, 4.5vw, 48px) 0 14px; }
.hero-eyebrow svg { width: 15px; height: 15px; }
.hero-eyebrow { display: inline-flex; gap: 8px; align-items: center; font-size: var(--text-xs); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 650; }
.hero h1 { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 560; letter-spacing: -0.015em; margin-top: 10px; }
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 480; }
.hero p.lead { margin-top: 12px; max-width: 62ch; color: var(--ink-2); font-size: 1.02rem; }
.ribbon { margin-top: 26px; height: 10px; border-radius: 999px; display: flex; overflow: hidden; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.05); }
.ribbon span { flex: 1; transform-origin: left; animation: ribbon-in 900ms var(--ease) both; }
@keyframes ribbon-in { from { transform: scaleX(0); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.stat {
  display: flex; align-items: baseline; gap: 10px; padding: 10px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; transition: all var(--dur) var(--ease); text-align: left;
}
.stat:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.stat[aria-pressed="true"] { border-color: var(--c, var(--ink)); box-shadow: 0 0 0 1px var(--c, var(--ink)); }
.stat b { font-family: var(--font-display); font-size: 1.6rem; font-weight: 560; font-variant-numeric: tabular-nums; color: var(--c, var(--ink)); }
.stat span { font-size: var(--text-sm); color: var(--ink-2); }

/* ───────── Toolbar ───────── */
.toolbar {
  position: sticky; top: var(--header-offset); z-index: 30; margin: 0; padding: 10px 0;
  transition: top 320ms var(--ease), padding 240ms var(--ease);
}
/* Once stuck, the bar becomes a compact full-width strip. */
.toolbar::before {
  content: ""; position: absolute; inset: 0 calc(50% - 50vw); z-index: -1; opacity: 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: saturate(1.3) blur(14px); -webkit-backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px -20px rgb(30 24 14 / 0.4);
  transition: opacity 240ms var(--ease);
}
.toolbar.is-stuck { padding: 8px 0; }
.toolbar.is-stuck::before { opacity: 1; }
.toolbar.is-stuck .search input, .toolbar.is-stuck .select { height: 36px; }
.toolbar.is-stuck .search > svg { top: 9px; }
.toolbar.is-stuck .search kbd { top: 7px; }
.toolbar.is-stuck .select { background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px; }
.toolbar.is-stuck .segmented button { height: 28px; }
.toolbar-main { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-toggle { display: none; }
.toolbar.is-stuck .filter-toggle { display: inline-flex; height: 36px; }
.filter-toggle .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; display: inline-grid; place-items: center; }
.stuck-summary { display: none; font-size: var(--text-sm); color: var(--ink-3); margin-left: auto; white-space: nowrap; }
.toolbar.is-stuck .stuck-summary { display: inline; }
.filter-popover {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); padding: 14px 16px; border-radius: var(--radius); display: none;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3); animation: rise 220ms var(--ease) both;
}
.toolbar.is-stuck.filters-open .filter-popover { display: block; }
.filter-popover .filters { margin-top: 0; }
.search {
  position: relative; flex: 1 1 280px; max-width: 460px;
}
.search input {
  width: 100%; height: 42px; padding: 0 44px 0 40px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface); box-shadow: var(--shadow-1); outline: none; transition: border-color var(--dur), box-shadow var(--dur);
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.search > svg { position: absolute; left: 13px; top: 12px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search kbd { position: absolute; right: 10px; top: 10px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-3); font-size: 12px; }
.select {
  height: 42px; padding: 0 34px 0 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat;
}
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented button { border: 0; background: transparent; height: 34px; width: 38px; border-radius: 9px; cursor: pointer; color: var(--ink-3); display: grid; place-items: center; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.segmented svg { width: 17px; height: 17px; }
.filters { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.filter-row { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-label { font-size: 12px; color: var(--ink-3); width: 44px; flex: none; font-weight: 600; }
.result-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 16px 0 14px; color: var(--ink-3); font-size: var(--text-sm); }
.linklike { border: 0; background: none; padding: 0; color: var(--accent-ink); cursor: pointer; font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ───────── Cards ───────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: clamp(16px, 2vw, 24px); padding-bottom: 64px; }
.card {
  position: relative; display: flex; flex-direction: column; border-radius: var(--radius-lg); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-1); overflow: hidden; text-decoration: none; color: inherit;
  transition: transform 300ms var(--ease), box-shadow 300ms var(--ease), border-color 300ms var(--ease);
}
.grid.animate .card { animation: rise 520ms var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-3); border-color: var(--line-strong); color: inherit; }
.card-media { position: relative; aspect-ratio: 16 / 10.5; background: var(--figure-bg); border-bottom: 1px solid var(--line); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: contain; padding: 42px 14px 14px; transition: transform 600ms var(--ease); }
.card:hover .card-media img { transform: scale(1.035); }
.card-media .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa0a6; font-size: var(--text-sm); background: repeating-linear-gradient(-45deg, #f7f7f5 0 10px, #f0f0ec 10px 20px); }
.card-flags { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; justify-content: space-between; pointer-events: none; }
.card-flags .badge { background: color-mix(in srgb, #fff 88%, var(--c, #888)); color: #1b2528; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.card-flags .badge.outline { background: rgb(255 255 255 / 0.92); border-color: #ddd; color: #4a4a4a; }
.card-body { padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-id { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.card-title { font-size: 1rem; font-weight: 650; line-height: 1.4; color: var(--ink); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.card-link:focus-visible { outline: none; }
.card:has(.card-link:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
.card-flags, .card-actions { z-index: 2; }
.card-why { color: var(--ink-2); font-size: var(--text-sm); min-height: 3.2em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; overflow: hidden; margin-top: auto; padding-top: 8px; white-space: nowrap; mask-image: linear-gradient(90deg, #000 85%, transparent); }
.card-meta .tag { font-size: 12px; color: var(--ink-3); }
.card-meta .tag::before { content: "#"; opacity: 0.6; }
.card-actions { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; opacity: 0; transform: translateY(6px); transition: all var(--dur) var(--ease); }
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; transform: none; }
.card-actions .icon-btn { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1); width: 32px; height: 32px; }
.palette-strip { display: flex; height: 8px; transition: height 300ms var(--ease); }
.card:hover .palette-strip { height: 14px; }
.palette-strip span { flex: 1; }
.validation-flag { --c: var(--danger); }

/* List view */
.grid.list { grid-template-columns: 1fr; gap: 10px; }
.grid.list .card { flex-direction: row; border-radius: var(--radius); }
.grid.list .card-media { width: 180px; flex: none; aspect-ratio: auto; border-bottom: 0; border-right: 1px solid var(--line); }
.grid.list .card-media img { padding: 8px; }
.grid.list .card-flags { display: none; }
.grid.list .card-body { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 16px; }
.grid.list .card-body > .card-head { flex: 1 1 260px; }
.grid.list .card-why { flex: 2 1 300px; -webkit-line-clamp: 2; min-height: 0; }
.grid.list .card-meta { margin-top: 0; padding-top: 0; }
.grid.list .palette-strip { width: 10px; height: auto; flex-direction: column; }
.grid.list .card:hover .palette-strip { height: auto; width: 14px; }
.grid.list .card-actions { display: none; }

/* Empty / notices */
.empty {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); padding: clamp(22px, 4vw, 40px); background: color-mix(in srgb, var(--surface) 60%, transparent);
  display: grid; gap: 14px; grid-template-columns: auto 1fr; align-items: start; margin-bottom: 28px;
}
.empty .art { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty .art svg { width: 30px; height: 30px; }
.empty h3 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 560; }
.empty ol { margin: 6px 0 0; padding-left: 1.2em; color: var(--ink-2); }
.notice { border-radius: var(--radius); padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--line); font-size: var(--text-sm); color: var(--ink-2); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.notice.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--warning); }
.notice ul { margin: 6px 0 0; padding-left: 1.2em; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 560; }

/* ───────── Detail ───────── */
.crumbs { display: flex; gap: 8px; align-items: center; padding: 22px 0 10px; font-size: var(--text-sm); color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.crumbs a:hover { color: var(--ink); }
.crumbs svg { width: 16px; height: 16px; }
.detail { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: clamp(20px, 3vw, 36px); align-items: start; }
.stage { position: sticky; top: calc(var(--header-offset) + 16px); transition: top 320ms var(--ease); }
.stage-frame {
  position: relative; border-radius: var(--radius-lg); background: var(--figure-bg); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  overflow: hidden; cursor: zoom-in; display: grid; place-items: center; min-height: 260px;
}
.stage-frame img, .stage-frame .svg-host { width: 100%; height: auto; padding: clamp(10px, 2vw, 22px); animation: fade 350ms var(--ease); }
.stage-frame .svg-host svg { width: 100%; height: auto; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.stage-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.stage-caption { margin-top: 10px; font-size: var(--text-xs); color: var(--ink-3); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(16px, 2vw, 22px); box-shadow: var(--shadow-1); }
.panel + .panel { margin-top: 16px; }
.panel h3 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.panel h3 svg { width: 15px; height: 15px; }
.detail-title { font-family: var(--font-display); font-size: clamp(1.5rem, 2.6vw, 2.05rem); font-weight: 560; letter-spacing: -0.01em; margin: 12px 0 10px; }
.quote { position: relative; margin-top: 14px; padding: 12px 14px 12px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 4px 12px 12px 4px; color: var(--ink); font-size: 0.95rem; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.swatch {
  display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left;
  transition: all var(--dur) var(--ease);
}
.swatch:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.swatch i { width: 32px; height: 32px; border-radius: 9px; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); }
.swatch span { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.swatch b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch code { font-size: 11.5px; color: var(--ink-3); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: var(--text-sm); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.list-clean { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.list-clean li { position: relative; padding-left: 18px; font-size: var(--text-sm); color: var(--ink-2); }
.list-clean li::before { content: ""; position: absolute; left: 3px; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--accent)); }
.list-clean.warn li { --c: var(--accent-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); color: var(--ink-3); font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
tr:last-child td { border-bottom: 0; }
td code { color: var(--accent-ink); }
.check { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 0; border-top: 1px dashed var(--line); font-size: var(--text-sm); color: var(--ink-2); }
.check:first-child { border-top: 0; padding-top: 0; }
.files { display: grid; gap: 6px; }
.file-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); border: 1px solid transparent; font-size: var(--text-sm); }
.file-link:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.file-link code { color: var(--ink-3); font-size: 12px; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.file-link svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
details.fold { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
details.fold summary { cursor: pointer; color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; }
pre.code {
  margin: 10px 0 0; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.55; overflow: auto; max-height: 420px; white-space: pre;
}
.sections { margin-top: 28px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; padding-bottom: 64px; }
.sections .panel + .panel { margin-top: 0; }
.sections .panel.wide { grid-column: 1 / -1; }

/* ───────── Lightbox ───────── */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgb(10 14 15 / 0.82); backdrop-filter: blur(6px); display: grid; grid-template-rows: auto 1fr; animation: fade 200ms var(--ease); }
.lightbox-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; color: #e9eeec; font-size: var(--text-sm); }
.lightbox-bar .icon-btn { color: #e9eeec; }
.lightbox-bar .icon-btn:hover { background: rgb(255 255 255 / 0.1); }
.lightbox-body { overflow: auto; display: grid; place-items: center; padding: 0 16px 24px; }
.lightbox-body img { background: #fff; border-radius: 12px; max-width: none; cursor: zoom-out; }
.lightbox-body img.fit { max-width: 100%; max-height: calc(100vh - 90px); cursor: zoom-in; }

/* ───────── Toast ───────── */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: inline-flex; gap: 8px; align-items: center; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--ink-inverse); box-shadow: var(--shadow-3); font-size: var(--text-sm); animation: toast-in 260ms var(--ease) both; }
.toast svg { width: 16px; height: 16px; color: var(--accent-soft); }
.toast.out { animation: toast-out 220ms var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ───────── Studio (recolor / compose) ───────── */
.studio { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: clamp(18px, 3vw, 32px); align-items: start; padding-bottom: 64px; }
.studio-head { display: flex; gap: 12px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin: 6px 0 18px; }
.page > .studio-head:first-child { padding-top: 26px; }
.studio-head h1 { font-family: var(--font-display); font-size: clamp(1.5rem, 2.8vw, 2.1rem); font-weight: 560; }
.studio-head p { color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.canvas { position: sticky; top: calc(var(--header-offset) + 16px); transition: top 320ms var(--ease); border-radius: var(--radius-lg); background: var(--figure-bg); border: 1px solid var(--line); box-shadow: var(--shadow-2); padding: clamp(10px, 2vw, 22px); overflow: hidden; }
.canvas .svg-host svg { width: 100%; height: auto; transition: filter 300ms var(--ease); }
.canvas-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.role { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); }
.role:first-child { border-top: 0; }
.role input[type="color"] { width: 40px; height: 40px; border: 0; padding: 0; border-radius: 10px; background: none; cursor: pointer; }
.role input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.role input[type="color"]::-webkit-color-swatch { border: 1px solid rgb(0 0 0 / 0.12); border-radius: 10px; }
.role input[type="color"]::-moz-color-swatch { border: 1px solid rgb(0 0 0 / 0.12); border-radius: 10px; }
.role-name { display: flex; flex-direction: column; min-width: 0; }
.role-name b { font-size: var(--text-sm); }
.role-name small { color: var(--ink-3); font-size: 11.5px; }
.role input.hex { width: 92px; height: 32px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); padding: 0 8px; font-family: var(--font-mono); font-size: 12.5px; }
.role.changed .role-name b::after { content: " · 已修改"; color: var(--accent-2); font-weight: 600; font-size: 11.5px; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.preset { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px; cursor: pointer; text-align: left; transition: all var(--dur) var(--ease); }
.preset:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.preset .bar { display: flex; height: 16px; border-radius: 6px; overflow: hidden; }
.preset .bar span { flex: 1; }
.preset b { display: block; margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.field { display: grid; gap: 6px; font-size: var(--text-sm); }
.field > span { color: var(--ink-3); font-size: 12px; font-weight: 650; }
.field input[type="number"], .field input[type="text"], .field select { height: 36px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); padding: 0 10px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tray { display: grid; gap: 8px; }
.tray-item { display: grid; grid-template-columns: auto 56px 1fr auto; gap: 10px; align-items: center; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.tray-item.dragging { opacity: 0.4; }
.tray-item.over { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.tray-item img { width: 56px; height: 40px; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--line); }
.tray-item .grip { cursor: grab; color: var(--ink-3); display: grid; place-items: center; width: 22px; }
.tray-item .grip svg { width: 16px; height: 16px; }
.tray-item .label { font-family: var(--font-mono); font-weight: 700; color: var(--accent-2); margin-right: 6px; }
.tray-item .name { min-width: 0; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.pick { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 6px; cursor: pointer; text-align: left; font-size: 12px; transition: all var(--dur) var(--ease); }
.pick:hover { border-color: var(--line-strong); }
.pick[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent); }
.pick img { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #fff; border-radius: 8px; }
.pick span { display: block; margin-top: 4px; font-family: var(--font-mono); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── Guide ───────── */
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; counter-reset: step; }
.flow-step { position: relative; padding: 18px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.flow-step::before { counter-increment: step; content: counter(step, decimal-leading-zero); font-family: var(--font-display); font-size: 1.8rem; color: var(--c, var(--accent)); font-weight: 500; }
.flow-step h3 { margin-top: 6px; font-size: 1rem; }
.flow-step p { margin-top: 6px; color: var(--ink-2); font-size: var(--text-sm); }
.cmd { display: flex; gap: 8px; align-items: center; padding: 8px 8px 8px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-family: var(--font-mono); font-size: 12.5px; }
.cmd code { flex: 1; overflow-x: auto; white-space: nowrap; }
.cmd + .cmd { margin-top: 8px; }

/* ───────── Footer ───────── */
.footer { border-top: 1px solid var(--line); padding: 22px 0 36px; color: var(--ink-3); font-size: var(--text-sm); }
.footer .page { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }

.loading { display: grid; place-items: center; min-height: 50vh; color: var(--ink-3); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── Back to top ───────── */
.to-top {
  position: fixed; right: clamp(16px, 3vw, 28px); bottom: clamp(16px, 3vw, 28px); z-index: 35; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); cursor: pointer;
  display: grid; place-items: center; opacity: 0; transform: translateY(12px) scale(0.9); pointer-events: none; transition: all 260ms var(--ease);
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--ink-3); }
.to-top svg { width: 18px; height: 18px; }

/* ───────── Responsive ───────── */
@media (max-width: 980px) {
  .detail, .studio { grid-template-columns: 1fr; }
  .stage, .canvas { position: static; }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  :root { --topbar-h: 56px; }
  .brand-name { display: none; }
  .nav { margin-left: 0; }
  .nav a { padding: 7px 10px; }
  .nav a .label-long { display: none; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar.is-stuck .search { flex: 1 1 0; min-width: 0; }
  .toolbar.is-stuck .select, .toolbar.is-stuck .segmented, .toolbar.is-stuck .stuck-summary { display: none; }
  .filter-popover { max-height: 60vh; overflow: auto; }
  .search kbd { display: none; }
  .grid { grid-template-columns: 1fr; }
  .grid.list .card { flex-direction: column; }
  .grid.list .card-media { width: 100%; aspect-ratio: 16 / 9; border-right: 0; border-bottom: 1px solid var(--line); }
  .grid.list .palette-strip { width: auto; height: 8px; flex-direction: row; }
  .card-actions { opacity: 1; transform: none; }
  .empty { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
@media print {
  .topbar, .toolbar, .footer, .card-actions, .banner { display: none !important; }
  body { background: #fff; }
}
