/* Charts to Go 2.0 — layout and components. Motion rules: transform/opacity only,
   ease-out on entrances, exits ~25% faster, popovers grow from their trigger,
   hover only on devices that hover, reduced motion keeps fades and drops movement. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 15px/24px var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ic { flex: none; display: block; }

/* ── app frame ─────────────────────────────────────────── */
.app { display: grid; grid-template-rows: var(--appbar) 1fr; height: 100dvh; }
.appbar {
  display: flex; align-items: center; gap: var(--sp-8);
  padding: 0 var(--sp-16) 0 var(--sp-16);
  background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle);
  position: relative; z-index: 5;
}
/* Lockup, same proportions as Library > Marca > Lockup in Figma (mark 36, gap 4, type 28/36), scaled to 20 px type */
.brand { display: flex; align-items: center; gap: 3px; color: var(--text-primary); text-decoration: none; margin-right: auto; }
#logo { display: flex; flex: none; }
.brand .logo { width: 26px; height: 26px; display: block; overflow: visible; }
.wordmark { display: block; font: 400 20px/26px var(--font-serif); letter-spacing: -0.2px; white-space: nowrap; }
.appbar-actions { display: flex; align-items: center; gap: var(--sp-8); }

.workspace { display: grid; grid-template-columns: 1fr var(--inspector); min-height: 0; }
.stage { display: grid; grid-template-rows: 1fr auto; min-width: 0; min-height: 0; position: relative; }
.canvas {
  position: relative; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-16);
  padding: var(--sp-32);
}
.chart-card {
  background: var(--chart-bg); border: 1px solid var(--border-subtle); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); overflow: hidden; position: relative; flex: none;
}
.chart-card.transparent-preview { background-image: conic-gradient(var(--bg-sunken) 25%, transparent 0 50%, var(--bg-sunken) 0 75%, transparent 0); background-size: 16px 16px; }
#chartHost svg { display: block; }
#chartHost [data-edit] { cursor: text; }
.readout {
  display: inline-flex; align-items: baseline; gap: 8px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border-subtle); border-radius: var(--r-full); background: var(--bg-surface);
  font: 600 13px/20px var(--font-sans); color: var(--text-primary); align-items: center;
  transition: border-color var(--d-press) var(--ease-out), transform var(--d-press) var(--ease-out);
}
.readout .mono { font: 400 12px/16px var(--font-mono); color: var(--text-secondary); }
@media (hover: hover) { .readout:hover { border-color: var(--border-strong); } }
.readout:active { transform: scale(0.97); }

/* ── buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-8);
  height: var(--control); padding: 0 var(--sp-16); border-radius: var(--r-md);
  font: 600 14px/20px var(--font-sans); border: 1px solid transparent; background: none; white-space: nowrap;
  transition: background-color var(--d-press) var(--ease-out), border-color var(--d-press) var(--ease-out), transform var(--d-press) var(--ease-out);
}
.btn:active, .icon-btn:active, .tile:active, .pal-card:active, .opt:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--text-on-accent); }
.btn-secondary { border-color: var(--border-strong); color: var(--text-primary); background: var(--bg-surface); }
.btn-tertiary { color: var(--text-accent); padding: 0 var(--sp-12); }
.btn-tertiary.compact { height: 32px; padding: 0 var(--sp-8); }
@media (hover: hover) {
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-secondary:hover { background: var(--bg-hover); }
  .btn-tertiary:hover { background: var(--accent-subtle); }
  .icon-btn:hover { background: var(--bg-hover); }
}
.btn .chev { margin-right: -4px; color: var(--icon-secondary); }
.icon-btn {
  width: var(--control); height: var(--control); display: inline-grid; place-items: center;
  border: 0; border-radius: var(--r-md); background: none; color: var(--icon-primary);
  transition: background-color var(--d-press) var(--ease-out), transform var(--d-press) var(--ease-out);
}
.icon-btn.sm { width: 32px; height: 32px; }
.btn[aria-expanded="true"], .icon-btn[aria-expanded="true"] { background: var(--bg-hover); }
.btn-primary[aria-expanded="true"] { background: var(--accent-hover); }

/* ── inspector ─────────────────────────────────────────── */
.inspector {
  background: var(--bg-surface); border-left: 1px solid var(--border-subtle);
  display: grid; grid-template-rows: 48px 1fr; min-height: 0; position: relative; z-index: 2;
}
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border-subtle); position: relative; padding: 0 12px; }
.tab {
  border: 0; background: none; height: 48px; font: 400 15px/20px var(--font-sans); color: var(--text-secondary);
}
.tab[aria-selected="true"] { color: var(--text-primary); font-weight: 600; }
@media (hover: hover) { .tab:hover { color: var(--text-primary); } }
.tab-ink {
  position: absolute; bottom: -1px; left: 12px; height: 2px; background: var(--accent);
  width: calc((100% - 24px) / 3); transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform var(--d-dropdown) var(--ease-out);
}
.panel { overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-8) var(--sp-24) var(--sp-48); scrollbar-gutter: stable; }
.panel-section { padding: var(--sp-16) 0; border-bottom: 1px solid var(--border-subtle); }
.panel-section:last-child { border-bottom: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-height: 32px; }
.h-m { font: 600 17px/24px var(--font-sans); margin: 0; }
.h-s { font: 600 15px/20px var(--font-sans); margin: 0; }
.meta { font: 400 13px/20px var(--font-sans); color: var(--text-secondary); }
.body-s { font: 400 13px/20px var(--font-sans); color: var(--text-secondary); margin: 0; }

/* groups (accordion) */
.group { border-bottom: 1px solid var(--border-subtle); }
.group-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; height: 48px;
  border: 0; background: none; padding: 0; font: 600 15px/20px var(--font-sans); text-align: left;
}
.group-head .ic { color: var(--icon-secondary); transition: transform var(--d-dropdown) var(--ease-out); }
.group[data-open="false"] .group-head .ic { transform: rotate(-90deg); }
.group-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--d-dropdown) var(--ease-out); }
.group[data-open="true"] .group-body { grid-template-rows: 1fr; }
.group-inner { overflow: hidden; min-height: 0; }
.group-inner > .stack { padding-bottom: var(--sp-16); opacity: 0; transition: opacity 140ms var(--ease-out); }
.group[data-open="true"] .group-inner > .stack { opacity: 1; transition-delay: 60ms; }
.stack { display: grid; gap: var(--sp-4); }

/* rows */
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-12); min-height: 48px; }
.row > label, .row > .lbl { font: 400 13px/20px var(--font-sans); color: var(--text-primary); flex: 1; }
.field { display: grid; gap: var(--sp-8); padding: var(--sp-8) 0 var(--sp-8); }
.lbl, .field > label, .field > .lbl { font: 400 13px/20px var(--font-sans); color: var(--text-primary); }
.field .hint { font: 400 12px/16px var(--font-sans); color: var(--text-secondary); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-12); }

/* inputs */
.input, .select {
  height: var(--control); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--bg-surface); padding: 0 12px; font: 400 15px/20px var(--font-sans); width: 100%; min-width: 0;
}
.input:focus, .select:focus { outline: 2px solid var(--focus-ring); outline-offset: -1px; border-color: var(--focus-ring); }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='%23566870'%3E%3Cpath d='M16 22 6 12l1.4-1.4 8.6 8.6 8.6-8.6L26 12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
body.dark .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='%23ADB5BD'%3E%3Cpath d='M16 22 6 12l1.4-1.4 8.6 8.6 8.6-8.6L26 12z'/%3E%3C/svg%3E"); }
.input.short { width: 120px; flex: none; }
.select.short { width: auto; min-width: 120px; max-width: 200px; flex: none; }
/* design-system dropdown: trigger looks like the field, list is a menu */
.ds-select { display: flex; align-items: center; gap: 8px; height: var(--control); width: 100%; min-width: 0; padding: 0 10px 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--bg-surface); color: var(--text-primary);
  font: 400 15px/20px var(--font-sans); text-align: left; cursor: pointer; transition: border-color var(--d-press) var(--ease-out), background-color var(--d-press) var(--ease-out); }
.ds-select .v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-select .ic { flex: none; color: var(--icon-secondary); transition: transform var(--d-dropdown) var(--ease-out); }
.ds-select[aria-expanded="true"] { border-color: var(--focus-ring); }
.ds-select[aria-expanded="true"] .ic { transform: rotate(180deg); }
.ds-select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -1px; border-color: var(--focus-ring); }
@media (hover: hover) { .ds-select:not([aria-expanded="true"]):hover { border-color: var(--text-secondary); } }
.ds-select.short { width: auto; min-width: 120px; max-width: 200px; flex: none; }
.ds-select.mark-sel { width: auto; min-width: 96px; height: 32px; font-size: 13px; flex: none; }
.menu.listbox { max-height: min(320px, 60vh); overflow-y: auto; }
.menu.listbox .mi { min-height: 36px; }
.menu.listbox .mi span { flex: 1; }
.menu.listbox .mi .pick-check { color: var(--text-accent); opacity: 0; }
.menu.listbox .mi[aria-selected="true"] { font-weight: 600; }
.menu.listbox .mi[aria-selected="true"] .pick-check { opacity: 1; }
.unit { position: relative; flex: none; width: 96px; }
.unit .input { padding-right: 34px; font-family: var(--font-mono); font-size: 14px; }
.unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 400 12px/16px var(--font-mono); color: var(--text-secondary); pointer-events: none; }
.unit.wide { width: 100%; }
.slider-row { display: flex; align-items: center; gap: var(--sp-12); flex: none; }
input[type="range"] { width: 96px; accent-color: var(--accent); }

.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; inset: -10px -6px; opacity: 0; margin: 0; cursor: pointer; z-index: 1; width: auto; height: auto; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background-color var(--d-tooltip) var(--ease-out); }
.switch .thumb { position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform var(--d-tooltip) var(--ease-out); }
.switch input:checked ~ .track { background: var(--accent); }
.switch input:checked ~ .thumb { transform: translateX(16px); }
body.dark .switch .thumb { background: var(--bg-app); }
body.dark .switch input:not(:checked) ~ .thumb { background: #F1F3F5; }
.switch input:focus-visible ~ .track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; gap: 4px; background: var(--bg-sunken); border-radius: var(--r-md); }
body.dark .seg { background: #15181B; }
.seg button { height: 32px; border: 0; border-radius: var(--r-sm); background: none; font: 400 14px/20px var(--font-sans); color: var(--text-secondary); padding: 0 8px; transition: background-color var(--d-press) var(--ease-out), color var(--d-press) var(--ease-out); }
.seg button[aria-checked="true"] { background: var(--bg-raised); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 2px rgba(15,26,32,.12); border: 1px solid var(--border-subtle); }
@media (hover: hover) { .seg button:not([aria-checked="true"]):hover { color: var(--text-primary); } }

.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-8); }
.opt {
  display: grid; justify-items: center; gap: 6px; padding: 14px 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  background: var(--bg-surface); font: 400 13px/20px var(--font-sans); color: var(--text-primary);
  transition: border-color var(--d-press) var(--ease-out), background-color var(--d-press) var(--ease-out), transform var(--d-press) var(--ease-out);
}
.opt[aria-checked="true"] { border-color: var(--border-selected); background: var(--bg-selected); color: var(--text-accent); font-weight: 600; }
.opt svg { color: var(--icon-primary); }
.opt[aria-checked="true"] svg { color: var(--text-accent); }
@media (hover: hover) { .opt:not([aria-checked="true"]):hover { border-color: var(--border-strong); } }

/* size presets */
.presets { display: grid; gap: 2px; margin: 0 -8px; }
.preset { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 8px; border: 0; border-radius: var(--r-md); background: none; text-align: left; color: var(--text-primary); font: 400 14px/20px var(--font-sans); transition: background-color var(--d-press) var(--ease-out); }
.preset[aria-checked="true"] { background: var(--bg-selected); font-weight: 600; }
.preset .pr-check { color: var(--text-accent); opacity: 0; transition: opacity var(--d-press) var(--ease-out); }
.preset[aria-checked="true"] .pr-check { opacity: 1; }
@media (hover: hover) { .preset[aria-checked="false"]:hover { background: var(--bg-hover); } }
.pr-glyph { width: 20px; height: 16px; display: grid; place-items: center; flex: none; }
.pr-glyph span { border: 1.5px solid var(--icon-secondary); border-radius: 2px; }
.pr-glyph span.dashed { border-style: dashed; }
.pr-name { flex: 1; }
.pr-size { font: 400 12px/16px var(--font-mono); color: var(--text-secondary); }
.wh { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.wh .x { color: var(--text-secondary); font-size: 13px; }

/* chart type trigger */
.type-trigger {
  width: 100%; height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--bg-surface); font: 400 15px/20px var(--font-sans); text-align: left;
  transition: border-color var(--d-press) var(--ease-out);
}
.type-trigger .grow { flex: 1; }
.type-trigger[aria-expanded="true"] { border-color: var(--border-selected); outline: 1px solid var(--border-selected); }
@media (hover: hover) { .type-trigger:hover { border-color: var(--text-secondary); } }

/* notices */
.notice {
  display: grid; grid-template-columns: 20px 1fr; gap: 4px 12px; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--bg-sunken); margin: var(--sp-8) 0; animation: notice-in 220ms var(--ease-out);
}
body.dark .notice { background: var(--bg-raised); }
.notice .ic { color: var(--status-warning); margin-top: 2px; }
.notice.info .ic { color: var(--text-accent); }
.notice.info, body.dark .notice.info { background: var(--accent-subtle); }
.notice .n-title { font: 600 14px/20px var(--font-sans); }
.notice .n-body { grid-column: 2; font: 400 13px/20px var(--font-sans); color: var(--text-secondary); margin: 0; }
.notice .n-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 6px 0 0 -12px; }
.notice .n-field { grid-column: 2; margin-top: 8px; }
@keyframes notice-in { from { opacity: 0; transform: translateY(-4px); } }

/* series list */
.series-list { list-style: none; margin: 4px 0 0; padding: 0; }
.series-item { display: flex; align-items: center; gap: 12px; min-height: 52px; border-radius: var(--r-md); position: relative; }
.series-item .handle { color: var(--icon-secondary); cursor: grab; padding: 4px; margin-left: -4px; border: 0; background: none; }
.series-item .sw { width: 20px; height: 20px; border-radius: 4px; flex: none; }
.series-item .name { flex: 1; font: 400 14px/20px var(--font-sans); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-item.is-hidden .name { color: var(--text-secondary); text-decoration: line-through; }
.series-item.is-hidden .sw { opacity: .35; }
.series-item .tag { font: 400 12px/16px var(--font-sans); color: var(--text-secondary); }
.series-item.dragging { opacity: .5; }
.series-item.drop-before::before { content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.series-item .mark-sel { width: 112px; height: 32px; font-size: 13px; padding-left: 10px; }

/* palette cards */
.pal-list { display: grid; gap: var(--sp-8); margin-top: var(--sp-8); }
.pal-card {
  border: 1px solid var(--border-subtle); border-radius: var(--r-lg); background: var(--bg-surface); padding: 14px 16px 16px; text-align: left;
  display: grid; gap: 12px; width: 100%; position: relative;
  transition: border-color var(--d-press) var(--ease-out), background-color var(--d-press) var(--ease-out), transform var(--d-press) var(--ease-out);
}
.pal-card[aria-checked="true"] { border-color: var(--border-selected); background: var(--bg-selected); }
@media (hover: hover) { .pal-card:not([aria-checked="true"]):hover { border-color: var(--border-strong); } }
.pal-card .pal-top { display: flex; align-items: center; justify-content: space-between; min-height: 24px; font: 600 14px/20px var(--font-sans); }
.pal-card .pal-top .ic { color: var(--text-accent); }
.strip { display: flex; height: 24px; border-radius: 6px; overflow: hidden; }
.strip span { flex: 1; }
.pal-more { position: absolute; right: 8px; top: 8px; }

.color-rows { list-style: none; margin: 0; padding: 0; }
.color-row { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.color-row .sw-btn { width: 28px; height: 28px; border-radius: 6px; border: 0; flex: none; padding: 0; transition: transform var(--d-press) var(--ease-out); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.color-row .sw-btn:active { transform: scale(0.94); }
.color-row .name { flex: 1; font: 400 14px/20px var(--font-sans); }
.color-row .hex { font: 400 12px/16px var(--font-mono); color: var(--text-secondary); }
.checks { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: 2px 12px; }
.checks .ic.ok { color: var(--status-success); }
.checks .ic.warn { color: var(--status-warning); }
.checks b { font: 600 14px/20px var(--font-sans); }
.checks p { grid-column: 2; margin: 0; font: 400 13px/20px var(--font-sans); color: var(--text-secondary); }
.checks .fix-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px; margin-left: -12px; }

/* palette editor */
.editor-colors { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 8px; }
.editor-colors li { display: grid; grid-template-columns: 24px 40px 1fr 40px; gap: 8px; align-items: center; }
.editor-colors input[type="color"] { width: 40px; height: 40px; border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 3px; background: var(--bg-surface); cursor: pointer; }
.editor-colors .input { font-family: var(--font-mono); font-size: 14px; text-transform: uppercase; }
.editor-colors .input.bad { border-color: var(--status-error); }
.editor-foot { position: sticky; bottom: calc(-1 * var(--sp-48)); background: var(--bg-surface); display: flex; justify-content: flex-end; gap: 8px; padding: 16px 0 16px; border-top: 1px solid var(--border-subtle); margin-top: 16px; }

/* ── data drawer ───────────────────────────────────────── */
.drawer { background: var(--bg-surface); border-top: 1px solid var(--border-subtle); display: grid; grid-template-rows: var(--drawer-head) 0fr; transition: grid-template-rows 300ms var(--ease-drawer); min-height: 0; }
.drawer[data-open="true"] { grid-template-rows: var(--drawer-head) 1fr; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 0 12px 0 24px; height: var(--drawer-head); }
.drawer-head .title { font: 600 15px/20px var(--font-sans); }
.drawer-head .meta { margin-right: auto; }
.drawer-head .toggle .ic { transition: transform 300ms var(--ease-drawer); }
.drawer-head .toggle[aria-expanded="true"] { background: none; }
.drawer-body { overflow: hidden; min-height: 0; }
.drawer[data-open="true"] .drawer-body { overflow: auto; }
.drawer-inner { padding: 0 24px 24px; }
.stage[data-drawer="true"] { grid-template-rows: minmax(260px, 1fr) minmax(0, min(50vh, 420px)); }
.stage[data-drawer="true"] .drawer { grid-template-rows: var(--drawer-head) 1fr; }

.grid-wrap { overflow: auto; border: 1px solid var(--border-subtle); border-radius: var(--r-md); max-width: 100%; display: inline-block; }
table.sheet { border-collapse: separate; border-spacing: 0; font: 400 14px/20px var(--font-sans); }
.sheet th, .sheet td { border-right: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); padding: 0; height: 36px; background: var(--bg-surface); }
.sheet thead th { background: var(--bg-sunken); height: 40px; position: sticky; top: 0; z-index: 1; }
body.dark .sheet thead th { background: var(--bg-raised); }
.sheet .rn { width: 48px; min-width: 48px; text-align: center; color: var(--text-secondary); font: 400 12px/16px var(--font-mono); background: var(--bg-surface); position: sticky; left: 0; z-index: 1; }
.sheet thead .rn { z-index: 2; }
.sheet .cell { width: 148px; min-width: 96px; height: 100%; border: 0; background: transparent; padding: 0 12px; outline: none; }
.sheet td.num .cell { text-align: right; font-family: var(--font-mono); font-size: 13px; }
.sheet td:focus-within, .sheet th:focus-within { box-shadow: inset 0 0 0 2px var(--border-selected); background: var(--bg-selected); }
.sheet td.bad { box-shadow: inset 0 0 0 2px var(--status-error); }
.sheet td.bad .cell { color: var(--status-error); }
.sheet td.flash { animation: flash 1.2s var(--ease-out); }
@keyframes flash { 0%, 40% { background: color-mix(in srgb, var(--status-error) 18%, transparent); } }
.sheet .colhead { display: flex; align-items: center; gap: 8px; padding-right: 12px; }
.sheet .colhead .cell { font-weight: 600; padding-right: 0; flex: 1; text-align: left !important; font-family: var(--font-sans) !important; font-size: 14px !important; }
.sheet .colhead .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; margin-left: 12px; }
.sheet .colhead .sw + .cell { padding-left: 0; }
.sheet .kind { font: 400 12px/16px var(--font-mono); color: var(--text-secondary); }
.sheet .add-col { border-right: 0; background: var(--bg-surface) !important; }
.sheet .add-col .btn { height: 40px; }
.sheet tr.ghost .cell::placeholder { color: var(--text-secondary); opacity: .7; }

/* ── empty state ───────────────────────────────────────── */
.empty {
  display: grid; justify-items: center; align-content: center; gap: 16px; text-align: center; padding: 48px 32px; max-width: 100%;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-xl); background: transparent;
  transition: border-color var(--d-press) var(--ease-out), background-color var(--d-press) var(--ease-out);
}
.dropping .empty { border-color: var(--accent); background: var(--accent-subtle); }
.empty-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-subtle); color: var(--text-accent); }
.empty h2 { font: 400 28px/36px var(--font-serif); margin: 0; }
.empty p { margin: 0; color: var(--text-secondary); font-size: 15px; max-width: 480px; }
.empty .body-s { font-size: 13px; }
.empty .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.link { border: 0; background: none; padding: 0; color: var(--text-accent); text-decoration: underline; text-underline-offset: 3px; font: inherit; }
.starters { display: grid; gap: 8px; margin-top: 16px; }
.starter { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: var(--bg-surface); text-align: left; transition: border-color var(--d-press) var(--ease-out), transform var(--d-press) var(--ease-out); }
.starter:active { transform: scale(0.98); }
@media (hover: hover) { .starter:hover { border-color: var(--border-strong); } }
.starter .st-ic { width: 32px; height: 32px; border-radius: 6px; background: var(--bg-sunken); display: grid; place-items: center; color: var(--icon-primary); flex: none; }
.starter .st-txt { flex: 1; display: grid; }
.starter b { font: 600 14px/20px var(--font-sans); }
.starter .st-txt span { font: 400 12px/16px var(--font-sans); color: var(--text-secondary); }
.starter > .ic { color: var(--icon-secondary); }
.chip { height: 32px; padding: 0 12px; border: 1px solid var(--border-subtle); border-radius: var(--r-full); background: var(--bg-surface); font: 400 13px/20px var(--font-sans); transition: border-color var(--d-press) var(--ease-out), transform var(--d-press) var(--ease-out); }
.chip:active { transform: scale(0.97); }
@media (hover: hover) { .chip:hover { border-color: var(--border-strong); } }

/* ── popovers, menus ───────────────────────────────────── */
.pop {
  position: fixed; z-index: 40; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); transform-origin: var(--origin, top right);
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.pop[data-state="open"] { opacity: 1; transform: none; transition-duration: var(--d-dropdown); }
@starting-style { .pop[data-state="open"] { opacity: 0; transform: scale(0.97); } }
.pop[data-state="closing"] { opacity: 0; transform: scale(0.97); pointer-events: none; }
.menu { padding: 6px; min-width: 248px; }
.menu .mi { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; background: none; border-radius: var(--r-sm); font: 400 14px/20px var(--font-sans); text-align: left; color: var(--text-primary); }
.menu .mi .ic { color: var(--icon-secondary); }
.menu .mi kbd { margin-left: auto; font: 400 12px/16px var(--font-mono); color: var(--text-secondary); }
.menu .mi.danger, .menu .mi.danger .ic { color: var(--status-error); }
.menu .mi:focus-visible { outline: none; background: var(--bg-hover); }
@media (hover: hover) { .menu .mi:hover { background: var(--bg-hover); } }
.menu hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 6px -6px; }
.menu .menu-head { padding: 8px 10px 4px; font: 600 13px/20px var(--font-sans); color: var(--text-secondary); }
.menu .mi.static { cursor: default; min-height: 36px; }
.ic.flip-x { transform: scaleX(-1); }
@media (hover: hover) { .menu .mi.static:hover { background: none; } }

.type-pop { padding: 20px 24px 24px; width: 664px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 80px); overflow: auto; }
.type-pop h3 { font: 600 14px/20px var(--font-sans); color: var(--text-secondary); margin: 0 0 8px; }
.type-pop section + section { margin-top: 16px; }
.tiles { display: grid; grid-template-columns: repeat(6, 96px); gap: 8px; }
.tile {
  height: 80px; display: grid; justify-items: center; align-content: center; gap: 6px; padding: 8px 4px;
  border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: var(--bg-surface); font: 400 13px/18px var(--font-sans); text-align: center;
  transition: border-color var(--d-press) var(--ease-out), background-color var(--d-press) var(--ease-out), transform var(--d-press) var(--ease-out);
}
.tile svg { color: var(--icon-primary); }
.tile[aria-checked="true"] { border-color: var(--border-selected); background: var(--bg-selected); color: var(--text-accent); font-weight: 600; }
.tile[aria-checked="true"] svg { color: var(--text-accent); }
@media (hover: hover) { .tile:not([aria-checked="true"]):hover { border-color: var(--border-strong); } }

.export-pop { width: 400px; max-width: calc(100vw - 32px); }
.export-pop .ep-body { padding: 24px 24px 8px; display: grid; gap: 4px; }
.export-pop h3 { font: 600 17px/24px var(--font-sans); margin: 0; }
.export-pop .ep-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border-subtle); margin-top: 8px; }
.export-pop .size-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }

.color-pop { padding: 16px; width: 288px; display: grid; gap: 12px; }
.color-pop .cp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.color-pop .cp-pal { display: grid; gap: 8px; }
.color-pop .cp-pal .lbl { color: var(--text-secondary); }
.color-pop .cp-custom { min-height: 40px; }
.hex-field { position: relative; width: 148px; flex: none; }
.hex-field .input { padding-left: 36px; width: 100%; }
.hex-field .hex-sw { position: absolute; left: 10px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(15,26,32,.12); pointer-events: none; }
.color-pop .swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.color-pop .swatches button { aspect-ratio: 1; border: 0; border-radius: 6px; padding: 0; position: relative; transition: transform var(--d-press) var(--ease-out); }
.color-pop .swatches button:active { transform: scale(0.92); }
.color-pop .swatches button[aria-checked="true"]::after { content: ''; position: absolute; inset: -3px; border: 2px solid var(--border-selected); border-radius: 8px; }

/* ── modal ─────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: grid; place-items: center; padding: 24px; transition: opacity 200ms var(--ease-out); }
.scrim[data-state="open"] { opacity: 1; transition-duration: var(--d-modal); }
@starting-style { .scrim[data-state="open"] { opacity: 0; } }
.scrim[data-state="closing"] { opacity: 0; }
.modal { width: 1000px; max-width: 100%; max-height: calc(100dvh - 48px); background: var(--bg-surface); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; transition: transform 200ms var(--ease-out); }
.scrim[data-state="open"] .modal { transform: none; transition-duration: var(--d-modal); }
@starting-style { .scrim[data-state="open"] .modal { transform: translateY(8px) scale(0.99); } }
.scrim[data-state="closing"] .modal { transform: translateY(4px); }
.modal-head { padding: 28px 32px 8px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.modal-head h2 { font: 400 36px/44px var(--font-serif); letter-spacing: -0.5px; margin: 0; }
.modal-head p { grid-column: 1; margin: 0; color: var(--text-secondary); max-width: 600px; }
.modal-body { display: grid; grid-template-columns: 300px 1fr; gap: 32px; padding: 16px 32px 24px; min-height: 0; overflow: auto; }
.included h3 { margin: 8px 0 8px; }
.included dl { margin: 0; }
.included .inc { padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.included .inc:first-of-type { border-top: 0; }
.included dt { font: 600 14px/20px var(--font-sans); }
.included dd { margin: 2px 0 0; font: 400 13px/20px var(--font-sans); color: var(--text-secondary); }
.included .not { display: flex; gap: 8px; align-items: center; padding-top: 10px; border-top: 1px solid var(--border-subtle); font: 400 13px/20px var(--font-sans); color: var(--text-secondary); }
.code-col { display: grid; grid-template-rows: auto 1fr; gap: 12px; min-height: 0; }
.code { margin: 0; padding: 20px 20px; background: var(--bg-sunken); border-radius: var(--r-lg); font: 400 13px/20px var(--font-mono); white-space: pre-wrap; overflow: auto; max-height: 52vh; color: var(--text-primary); }
body.dark .code { background: #15181B; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 16px 32px; border-top: 1px solid var(--border-subtle); }
.modal-foot .meta { margin-right: auto; }

/* ── toast & tooltip ───────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; display: flex; align-items: center; gap: 16px;
  min-height: 48px; padding: 0 8px 0 16px; border-radius: var(--r-lg); background: var(--bg-inverse); color: var(--text-on-inverse);
  font: 400 14px/20px var(--font-sans); box-shadow: var(--shadow-pop);
  transform: translateX(-50%); transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.toast[data-state="open"] { opacity: 1; transform: translateX(-50%); transition-duration: 240ms; }
@starting-style { .toast[data-state="open"] { opacity: 0; transform: translate(-50%, 8px); } }
.toast[data-state="closing"] { opacity: 0; transform: translate(-50%, 4px); }
.toast > .ic { opacity: .8; margin-right: -4px; }
.toast .t-close { border: 0; background: none; color: inherit; opacity: .7; width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-sm); margin-left: -8px; }
@media (hover: hover) { .toast .t-close:hover { opacity: 1; } }
.toast .btn-tertiary { color: var(--text-on-inverse); height: 32px; font-weight: 600; }
@media (hover: hover) { .toast .btn-tertiary:hover { background: color-mix(in srgb, var(--text-on-inverse) 12%, transparent); } }

.tip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 10px 12px; font: 400 13px/20px var(--font-sans); min-width: 140px;
  opacity: 0; transition: opacity var(--d-tooltip) var(--ease-out);
}
.tip[data-show="true"] { opacity: 1; }
.tip .t-head { font-weight: 600; margin-bottom: 4px; }
.tip .t-row { display: flex; align-items: center; gap: 8px; }
.tip .t-row .sw { width: 8px; height: 8px; border-radius: 2px; }
.tip .t-row .v { margin-left: auto; padding-left: 16px; font: 400 12px/20px var(--font-mono); }
.hint-tip { position: fixed; z-index: 30; pointer-events: none; background: var(--bg-inverse); color: var(--text-on-inverse); border-radius: var(--r-sm); padding: 6px 10px; font: 400 12px/16px var(--font-sans); opacity: 0; transform: translateY(2px); transition: opacity var(--d-tooltip) var(--ease-out), transform var(--d-tooltip) var(--ease-out); }
.hint-tip[data-show="true"] { opacity: 1; transform: none; }
.hint-tip.wide { max-width: 280px; white-space: normal; }
.hint-tip:not(.wide) { white-space: nowrap; }
.drawer-head { cursor: pointer; }
.drawer-head .btn, .drawer-head .icon-btn { cursor: pointer; }
@media (hover: hover) { .drawer-head:hover { background: var(--bg-hover); } }
.how-link { margin-top: 4px; }
/* How it works: the player. Steps roll like the CP-14446 player (0.45 s, ease [0.45, 0, 0.1, 1]). */
.modal.how { width: min(736px, calc(100vw - 32px)); }
.modal.how .modal-head { padding: 24px 24px 12px 32px; align-items: center; }
.modal.how .modal-head h2 { font-size: 28px; line-height: 36px; letter-spacing: -0.3px; }
.how-body { padding: 0 32px 24px; display: grid; gap: 12px; min-height: 0; overflow: auto; }
.how-media { border-radius: var(--r-lg); overflow: hidden; background: var(--bg-sunken); box-shadow: inset 0 0 0 1px var(--border-subtle); }
.how-video { width: 100%; aspect-ratio: 16 / 9; display: block; cursor: pointer; }
.how-controls { display: flex; align-items: center; gap: 12px; height: 32px; margin-top: -2px; }
.how-play { color: var(--icon-secondary); margin-left: -6px; }
.how-track { position: relative; flex: 1; height: 32px; display: flex; align-items: center; }
.how-rail { position: relative; width: 100%; height: 4px; border-radius: var(--r-full); background: var(--bg-sunken); overflow: hidden; }
.how-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: var(--r-full); background: var(--accent); }
.how-ticks span { position: absolute; top: 50%; width: 2px; height: 8px; border-radius: 1px; transform: translate(-50%, -50%); background: var(--border-strong); pointer-events: none; }
.how-ticks span.past { background: var(--bg-surface); }
.how-scrub { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.how-track:has(.how-scrub:focus-visible) .how-rail { outline: 2px solid var(--focus-ring); outline-offset: 4px; }
.how-time { flex: none; font: 400 12px/16px var(--font-mono); color: var(--text-secondary); }
.how-sound { flex: none; color: var(--icon-secondary); margin-right: -4px; }
.how-replay { flex: none; margin-right: -12px; }
.how-step { position: relative; height: 48px; border-radius: var(--r-md); background: var(--accent-subtle); overflow: hidden; }
.how-line { position: absolute; inset: 0; display: flex; align-items: center; gap: 12px; padding: 0 16px; font: 500 14px/20px var(--font-sans); color: var(--text-primary);
  transition: transform 450ms cubic-bezier(0.45, 0, 0.1, 1), opacity 450ms cubic-bezier(0.45, 0, 0.1, 1); }
.how-line[data-enter] { transform: translateY(100%); opacity: 0; transition: none; }
.how-line[data-leave] { transform: translateY(-100%); opacity: 0; }
.how-n { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--r-full); background: var(--accent); color: var(--text-on-accent); font: 600 12px/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.how-foot { justify-content: space-between; padding: 16px 32px; }
.how-dots { display: flex; align-items: center; gap: 2px; }
.how-dot { display: grid; place-items: center; height: 32px; padding: 0 3px; border: 0; background: none; border-radius: var(--r-full); }
.how-dot span { display: block; width: 8px; height: 8px; border-radius: var(--r-full); background: var(--border-subtle); transition: width 250ms var(--ease-out), background-color 250ms var(--ease-out); }
.how-dot.done span { background: var(--border-strong); }
.how-dot[aria-current="step"] span { width: 20px; background: var(--accent); }
@media (hover: hover) { .how-dot:hover span { background: var(--border-strong); } .how-dot[aria-current="step"]:hover span { background: var(--accent-hover); } }
@media (max-width: 767px) {
  .modal.how .modal-head { padding: 20px 16px 8px 20px; }
  .modal.how .modal-head h2 { font-size: 24px; line-height: 32px; }
  .how-body { padding: 0 16px 16px; }
  .how-step { height: auto; min-height: 48px; }
  .how-line { position: relative; padding: 12px 16px; }
  .how-line[data-leave] { position: absolute; }
  .how-foot { padding: 12px 16px; }
  .how-replay { display: none; }
}
@media (prefers-reduced-motion: reduce) { .how-line { transition: opacity 200ms linear; transform: none !important; } }
.inline-edit { position: fixed; z-index: 35; border: 0; outline: 2px solid var(--focus-ring); border-radius: 4px; background: var(--chart-bg); color: var(--chart-title); padding: 0 4px; margin-left: -4px; animation: fade 120ms var(--ease-out); }
@keyframes fade { from { opacity: 0; } }

/* ── first-run choreography (once per load) ────────────── */
.intro .appbar, .intro .inspector, .intro .drawer, .intro .chart-card, .intro .readout { animation: rise 420ms var(--ease-out) backwards; }
.intro .appbar { animation-delay: 0ms; }
.intro .chart-card { animation-delay: 60ms; }
.intro .readout { animation-delay: 140ms; }
.intro .inspector { animation-delay: 100ms; animation-name: rise-side; }
.intro .drawer { animation-delay: 160ms; }
/* brand intro (first load of a session): see app/brand.js */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg-app); pointer-events: none; }
.splash-mark { width: 96px; height: 96px; display: block; overflow: visible; will-change: transform, opacity, filter; }
.splash-mark path { transition: none; }
.intro-hold .inspector, .intro-hold .drawer, .intro-hold .chart-card, .intro-hold .readout, .intro-hold .appbar-actions { opacity: 0; }
.intro.from-splash .appbar { animation: none; }
.intro.from-splash .appbar-actions { animation: fade 200ms var(--ease-out) backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes rise-side { from { opacity: 0; transform: translateX(8px); } }

/* ── mobile ────────────────────────────────────────────── */
.sheet-handle { display: none; }
.mobile-only { display: none !important; }
@media (max-width: 767px) {
  body { overflow: hidden; }
  .appbar { padding: 0 12px 0 16px; height: 64px; }
  .app { grid-template-rows: 64px 1fr; }
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex !important; }
  .workspace { grid-template-columns: 1fr; }
  .stage { grid-template-rows: 1fr; }
  .drawer { display: none; }
  .canvas { justify-content: flex-start; padding: 12px 16px; gap: 12px; height: calc(100dvh - 64px - var(--sheet-peek, 46dvh)); }
  .inspector {
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--sheet-h, 54dvh); border-left: 0;
    border-radius: 20px 20px 0 0; border-top: 1px solid var(--border-subtle); box-shadow: 0 -8px 32px rgba(15,26,32,.10);
    grid-template-rows: 20px 48px 1fr; transition: height 300ms var(--ease-drawer);
  }
  .inspector[data-expanded="true"] { --sheet-h: calc(100dvh - 72px); }
  .sheet-handle { display: grid; place-items: center; border: 0; background: none; height: 20px; padding: 0; }
  .sheet-handle::before { content: ''; width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); }
  .panel { padding: 4px 16px 32px; }
  .tabs { padding: 0 12px; }
  .type-pop { width: calc(100vw - 16px); padding: 16px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .modal-body { grid-template-columns: 1fr; padding: 16px 20px; }
  .modal-head { padding: 20px 20px 8px; }
  .modal-head h2 { font-size: 28px; line-height: 36px; }
  .modal-foot { padding: 12px 20px; flex-wrap: wrap; }
  .modal-foot .meta { flex-basis: 100%; }
  .fullsheet { position: fixed; inset: 0; z-index: 45; background: var(--bg-surface); display: grid; grid-template-rows: 56px auto 1fr; animation: rise 300ms var(--ease-drawer); }
  .fullsheet .fs-head { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border-subtle); }
  .fullsheet .fs-head .title { font: 600 17px/24px var(--font-sans); margin-right: auto; }
  .fullsheet .fs-body { overflow: auto; padding: 16px; }
  .intro .inspector { animation-name: rise; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-property: opacity, background-color, border-color, color !important; }
  .intro .appbar, .intro .inspector, .intro .drawer, .intro .chart-card, .intro .readout, .fullsheet { animation-name: fade !important; }
  .notice { animation-name: fade; }
  @starting-style { .pop[data-state="open"], .scrim[data-state="open"] .modal { transform: none; } }
}

/* Preview only: keep chart hairlines at 1 screen px when the canvas is zoomed out, as they are in a 1x export. */
#chartHost svg .c-axes line, #chartHost svg .c-axes polygon { vector-effect: non-scaling-stroke; }
