/* ============================================================
   ChartFlow — Sadapanna theme, dark studio edition
   Headings/body: Poppins · Accent: Caveat · Wordmark: Madimi One
   (same font stack + component language as app/inkflow, dark palette)
   ============================================================ */

@font-face {
  font-family: "Madimi One";
  src: url("/assets/fonts/madimi-one-latin.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/assets/fonts/poppins-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/assets/fonts/poppins-600.woff2") format("woff2");
  font-weight: 600 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("/assets/fonts/caveat-600.woff2") format("woff2");
  font-weight: 600 700; font-style: normal; font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:          #0b0d13;
  --surface:     #141824;
  --surface-2:   #1b2030;
  --surface-3:   #232a3d;
  --ink:         #eef0f7;
  --ink-soft:    #9aa2ba;
  --ink-faint:   #6a7290;
  --purple:      #7c5cff;
  --purple-deep: #6543f0;
  --purple-soft: #241f47;
  --yellow:      #ffc736;
  --yellow-soft: #3a2f10;
  --green:       #35d39a;
  --red:         #ff6b6b;
  --line:        #262d40;
  --line-soft:   #1d2333;
  --radius:      18px;
  --radius-sm:   12px;
  --radius-pill: 999px;
  --sans: "Poppins", -apple-system, "Segoe UI", Roboto, sans-serif;
  --hand: "Caveat", "Comic Sans MS", cursive;
  --brand: "Madimi One", "Poppins", sans-serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, .38);
  font-size: 15px;
  color-scheme: dark;
}

body {
  background:
    radial-gradient(1100px 620px at 78% -12%, rgba(124, 92, 255, .16), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--purple); color: #fff; }
a { color: var(--purple); }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   top bar
   ============================================================ */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 20px;
  background: rgba(15, 18, 28, .86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 60;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; transition: transform .18s ease; }
.brand:hover { transform: translateY(-1px); }
.brand-icon { height: 32px; width: auto; display: block; }
.brand-word {
  font-family: var(--brand); font-size: 1.25rem; line-height: 1;
  text-transform: uppercase; letter-spacing: .01em; color: var(--ink);
}
.app-tag { display: flex; align-items: center; gap: 10px; }
.app-tag-pill {
  padding: 6px 15px; border-radius: var(--radius-pill);
  background: var(--purple-soft); color: #c3b4ff;
  font-weight: 600; font-size: 12.5px;
  border: 1px solid rgba(124, 92, 255, .35);
}
.app-tag-sub { font-family: var(--hand); font-size: 16px; color: var(--ink-soft); line-height: 1.1; display: none; }
@media (min-width: 720px) { .app-tag-sub { display: inline; } }

.topbar-project { margin-left: auto; min-width: 0; }
#project-name {
  width: 22ch; max-width: 40vw;
  background: transparent; border: 2px solid transparent;
  color: var(--ink); font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  padding: 8px 12px; border-radius: var(--radius-sm);
  text-overflow: ellipsis; outline: none;
  transition: background .15s, border-color .15s;
}
#project-name:hover { background: var(--surface-2); }
#project-name:focus { background: var(--surface-2); border-color: var(--purple); }
.topbar-actions { display: flex; gap: 8px; flex: none; }

/* ============================================================
   buttons
   ============================================================ */
.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  padding: 9px 17px;
  border-radius: var(--radius-pill);
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:hover { border-color: var(--purple); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--purple); border-color: var(--purple); color: #fff;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .32);
}
.btn.primary:hover { background: var(--purple-deep); border-color: var(--purple-deep); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { padding: 8px 13px; font-size: 15px; line-height: 1; }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: rgba(255, 107, 107, .1); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.linklike {
  background: none; border: none; color: var(--purple);
  cursor: pointer; font: inherit; text-decoration: underline; padding: 0;
}

/* ============================================================
   layout
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  padding: 18px 20px 40px;
  max-width: 1560px;
  margin: 0 auto;
  align-items: start;
}
.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.6px;
  color: #b9a7ff; margin-bottom: 12px; font-weight: 600;
}
.card h3 {
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  margin: 16px 0 8px;
}
.card h3:first-child { margin-top: 0; }
.divider { height: 1px; background: var(--line); margin: 14px -16px; }

/* ============================================================
   step tabs
   ============================================================ */
.tabs {
  display: flex; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 4px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto; min-width: max-content;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: none; border: none; color: var(--ink-soft);
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  padding: 9px 6px; border-radius: var(--radius-pill);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.active { background: var(--purple); color: #fff; }
.tab-n {
  display: inline-grid; place-items: center;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-soft);
  font-size: 10px; font-weight: 700; flex: none;
}
.tab.active .tab-n { background: rgba(255, 255, 255, .22); color: #fff; }
.tab.done .tab-n { background: var(--green); color: #06210f; }

.step { animation: stepIn .18s ease; }
@keyframes stepIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============================================================
   fields
   ============================================================ */
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > label,
.label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink);
}
.field output, .val {
  color: #c3b4ff; font-weight: 700; font-size: 12px;
  margin-left: auto; font-variant-numeric: tabular-nums;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 2px solid transparent;
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: var(--sans); font-size: 13.5px;
  outline: none;
  transition: border-color .15s, background .15s;
}
select {
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
                    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.5; font-size: 13px; }
input:focus, textarea:focus, select:focus { border-color: var(--purple); background: var(--surface-3); }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }

input[type="color"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 36px; border: none; padding: 0;
  border-radius: var(--radius-sm); background: none; cursor: pointer; overflow: hidden;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 2px solid rgba(255,255,255,.14); border-radius: var(--radius-sm); }
input[type="color"]::-moz-color-swatch { border: 2px solid rgba(255,255,255,.14); border-radius: var(--radius-sm); }

input[type="checkbox"] { accent-color: var(--purple); width: 15px; height: 15px; cursor: pointer; }

/* ---------- range ---------- */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; background: transparent; cursor: pointer; height: 20px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: var(--radius-pill); background: var(--surface-3);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; margin-top: -5px;
  border-radius: 50%; background: var(--purple);
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5);
  transition: transform .12s;
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-track { height: 5px; border-radius: var(--radius-pill); background: var(--surface-3); }
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--purple); border: 2px solid #fff;
}
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid #c3b4ff; outline-offset: 2px; }

.hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 5px; line-height: 1.55; }
.warn {
  font-size: 12px; color: #ffd479; margin-top: 6px;
  background: var(--yellow-soft); border: 1px solid rgba(255,199,54,.28);
  border-radius: 9px; padding: 7px 10px; line-height: 1.5;
}
.err {
  font-size: 12px; color: #ffb3b3; margin-top: 6px;
  background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.3);
  border-radius: 9px; padding: 7px 10px; line-height: 1.5;
}

/* ---------- segmented control ---------- */
.seg {
  display: flex; background: var(--surface-2);
  border-radius: var(--radius-pill); padding: 3px; gap: 3px;
}
.seg-btn {
  flex: 1 1 0; background: none; border: none; color: var(--ink-soft);
  padding: 7px 6px; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: var(--sans); border-radius: var(--radius-pill); text-align: center;
  transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--purple); color: #fff; }

details.adv { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 6px; }
details.adv summary {
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: #b9a7ff;
  padding: 6px 0; list-style: none; user-select: none;
}
details.adv summary::before { content: "▸ "; }
details.adv[open] summary::before { content: "▾ "; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv > *:not(summary) { margin-top: 8px; }

/* ============================================================
   chart type gallery
   ============================================================ */
.type-gallery {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.type-card {
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 12px 6px 10px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--ink-soft);
  font-family: var(--sans); font-size: 11.5px; font-weight: 600;
  transition: border-color .15s, background .15s, transform .12s, color .15s;
  text-align: center;
}
.type-card:hover { border-color: var(--surface-3); color: var(--ink); transform: translateY(-2px); }
.type-card.active { border-color: var(--purple); background: var(--purple-soft); color: #fff; }
.type-card .type-icon { font-size: 22px; line-height: 1; }
.type-card svg { width: 100%; height: 34px; }
@media (max-width: 420px) { .type-gallery { grid-template-columns: repeat(2, 1fr); } }

/* ---------- palette swatches ---------- */
.palette-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.palette-card {
  background: var(--surface-2); border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: 8px; cursor: pointer; transition: border-color .15s, background .15s;
}
.palette-card:hover { border-color: var(--surface-3); }
.palette-card.active { border-color: var(--purple); background: var(--purple-soft); }
.palette-swatches { display: flex; gap: 3px; height: 16px; }
.palette-swatches i { flex: 1; border-radius: 3px; display: block; }
.palette-name {
  display: block; margin-top: 6px; font-size: 11px; font-weight: 600;
  color: var(--ink-soft); text-align: left;
}
.palette-card.active .palette-name { color: #fff; }

/* ============================================================
   data table (generic — data.js builds into these classes)
   ============================================================ */
.cf-table-wrap {
  overflow: auto; max-height: 46vh;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
table.cf-table {
  border-collapse: separate; border-spacing: 0;
  width: 100%; font-size: 12.5px;
}
table.cf-table th, table.cf-table td {
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  padding: 0; text-align: left; vertical-align: middle;
}
table.cf-table th:last-child, table.cf-table td:last-child { border-right: none; }
table.cf-table tr:last-child td { border-bottom: none; }
table.cf-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-3);
  color: var(--ink-soft);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .9px;
  padding: 0;
}
table.cf-table thead th input,
table.cf-table td input {
  width: 100%; background: transparent; border: 2px solid transparent;
  color: var(--ink); font-family: var(--sans); font-size: 12.5px;
  padding: 8px 9px; border-radius: 0; outline: none;
}
table.cf-table thead th input {
  color: var(--ink-soft); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .9px;
}
table.cf-table td input:focus, table.cf-table thead th input:focus {
  border-color: var(--purple); background: var(--surface-3);
}
table.cf-table td.num input, table.cf-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.cf-table td.rowhead { background: var(--surface); color: var(--ink-soft); }
table.cf-table tbody tr:hover td { background: rgba(124, 92, 255, .06); }
table.cf-table td.invalid input { color: var(--red); background: rgba(255,107,107,.09); }
table.cf-table th.cf-th-tools, table.cf-table td.cf-td-tools { width: 30px; text-align: center; }
.cf-cell-btn {
  background: none; border: none; color: var(--ink-faint);
  cursor: pointer; font-size: 13px; line-height: 1; padding: 6px 4px;
  transition: color .15s;
}
.cf-cell-btn:hover { color: var(--red); }
.table-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.dropzone {
  margin-top: 10px;
  border: 2px dashed var(--surface-3);
  border-radius: 14px; padding: 14px; text-align: center;
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.55;
  transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--purple); background: var(--purple-soft); }

/* ============================================================
   preview column
   ============================================================ */
.preview-area { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 981px) { .preview-area { position: sticky; top: 78px; } }

.stage-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stage {
  width: 100%;
  height: min(60vh, 46vw);
  min-height: 220px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  overflow: hidden;
}
.stage.checker {
  background-image:
    linear-gradient(45deg, #ffffff10 25%, transparent 25%, transparent 75%, #ffffff10 75%),
    linear-gradient(45deg, #ffffff10 25%, transparent 25%, transparent 75%, #ffffff10 75%);
  background-color: #0a0c11;
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
}
#preview {
  display: block;
  max-width: 100%; max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
}

/* ---------- transport ---------- */
.player {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 14px;
}
.player .scrub { flex: 1 1 180px; min-width: 140px; }
.time {
  font-size: 12px; color: var(--ink-soft);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.loop-label, .speed-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-soft); white-space: nowrap; cursor: pointer;
}
.file-info { font-size: 12px; color: var(--ink-faint); padding: 0 4px; }

/* ---------- export progress ---------- */
.progress {
  height: 9px; border-radius: var(--radius-pill);
  background: var(--surface-2); overflow: hidden; margin-top: 10px; display: none;
}
.progress.active { display: block; }
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--purple), var(--yellow));
  border-radius: var(--radius-pill);
  transition: width .15s;
}
.export-status { font-size: 12px; color: var(--ink-soft); margin-top: 6px; min-height: 16px; }
.export-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.export-row select { flex: 1; min-width: 140px; }

/* ---------- saved project list ---------- */
.proj-list { display: flex; flex-direction: column; gap: 6px; }
.proj-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.proj-item .proj-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-item .proj-date { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.empty-note { font-size: 12.5px; color: var(--ink-faint); padding: 10px 2px; }

/* ============================================================
   generic modal
   ============================================================ */
.cf-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.cf-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 7, 12, .72);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.cf-modal-box {
  position: relative;
  width: min(560px, 100%);
  max-height: min(80vh, 720px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  animation: modalIn .16s ease;
}
.cf-modal-box.wide { width: min(860px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.cf-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.cf-modal-head h3 { font-size: 14.5px; font-weight: 600; flex: 1; }
.cf-modal-head .btn.icon { margin-left: auto; }
.cf-modal-body { padding: 16px; overflow: auto; flex: 1; font-size: 13.5px; line-height: 1.6; }
.cf-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.cf-modal-foot:empty { display: none; }

/* ---------- toast ---------- */
.cf-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 10px 18px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 300;
  animation: modalIn .16s ease;
}

/* ============================================================
   app.js-built components
   ============================================================ */

/* type gallery thumbnails */
.type-card { padding: 8px 8px 10px; }
.type-thumb {
  width: 100%; height: auto; aspect-ratio: 16 / 9;
  display: block; border-radius: 8px;
  background: #10131c;
}
.type-name { display: block; line-height: 1.3; }
.type-name .type-icon { font-size: 13px; }

/* chips (samples, theme presets) */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.chip-label { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft);
  padding: 6px 12px; border-radius: var(--radius-pill);
  font-family: var(--sans); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--purple); color: var(--ink); }
.theme-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.theme-chip { background: var(--purple-soft); border-color: rgba(124,92,255,.35); color: #c3b4ff; }
.theme-chip:hover { color: #fff; }

/* series color overrides */
.series-overrides { display: flex; flex-direction: column; gap: 6px; }
.series-row { display: flex; align-items: center; gap: 10px; }
.series-row .series-color { width: 40px; height: 26px; flex: none; }
.series-row .series-name {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* background editors */
.bg-editor { margin-top: 10px; }
.stops-box { display: flex; flex-direction: column; gap: 8px; }
.stop-row { display: flex; align-items: center; gap: 10px; }
.stop-row input[type="color"] { width: 44px; height: 30px; flex: none; }
.stop-row input[type="range"] { flex: 1; }

/* easing gallery */
.ease-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ease-card {
  background: var(--surface-2); border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 6px; cursor: pointer; display: flex; flex-direction: column; gap: 5px; align-items: center;
  transition: border-color .15s, background .15s;
}
.ease-card:hover { border-color: var(--surface-3); }
.ease-card.active { border-color: var(--purple); background: var(--purple-soft); }
.ease-canvas { width: 100%; height: auto; display: block; }
.ease-name { font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.ease-card.active .ease-name { color: #fff; }

/* bezier editor */
.bezier-wrap { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.bezier-canvas {
  width: 100%; max-width: 300px; height: auto; display: block;
  background: var(--surface-2); border-radius: var(--radius-sm);
  touch-action: none; cursor: crosshair;
}
.bezier-readout {
  font-size: 12px; color: #c3b4ff; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* export format cards */
.fmt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.fmt-card {
  background: var(--surface-2); border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: 11px 12px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 3px;
  transition: border-color .15s, background .15s;
}
.fmt-card:hover { border-color: var(--surface-3); }
.fmt-card.active { border-color: var(--purple); background: var(--purple-soft); }
.fmt-name { font-size: 14px; font-weight: 700; color: var(--ink); font-family: var(--sans); }
.fmt-sub { font-size: 11px; color: var(--ink-soft); }
.fmt-card.active .fmt-sub { color: #c3b4ff; }
.export-btn { width: 100%; margin-top: 10px; padding: 12px; font-size: 14px; }

/* safe-area overlay (preview only) */
.stage { position: relative; }
.safe-overlay {
  position: absolute; pointer-events: none; z-index: 5;
}

/* file-input-in-a-button */
.file-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
.file-btn input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%;
}

/* data-step extras from data.js (cf-*) */
.cf-actions { display: flex; gap: 8px; margin-top: 10px; }
.cf-btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  padding: 7px 13px; border-radius: var(--radius-pill);
  font-family: var(--sans); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cf-btn:hover { border-color: var(--purple); }
.cf-btn-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.cf-btn-ghost { background: transparent; }
.cf-btn-add, .cf-btn-del {
  border: none; background: none; color: var(--ink-faint);
  padding: 6px 8px; font-size: 14px; line-height: 1; cursor: pointer;
  border-radius: 6px; transition: color .15s, background .15s;
}
.cf-btn-add:hover { color: var(--green); background: rgba(53,211,154,.1); }
.cf-btn-del:hover { color: var(--red); background: rgba(255,107,107,.1); }
table.cf-table th { position: relative; }
table.cf-table .cf-del-col { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
table.cf-table thead th { white-space: nowrap; }
.cf-th-text { padding: 8px 9px; display: inline-block; }
.cf-form { display: flex; flex-direction: column; gap: 10px; }
.cf-field { display: flex; flex-direction: column; gap: 5px; }
.cf-field-label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.cf-field-hint { font-size: 11px; color: var(--ink-faint); }
.cf-import { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.cf-import-summary {
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: #b9a7ff;
  padding: 4px 0; list-style: none; user-select: none;
}
.cf-import-summary::-webkit-details-marker { display: none; }
.cf-import-summary::before { content: "▸ "; }
.cf-import[open] .cf-import-summary::before { content: "▾ "; }
.cf-import-body { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.cf-import-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cf-file-label { position: relative; overflow: hidden; }
.cf-file-label input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cf-import-status { font-size: 12px; }
.cf-import-status.cf-ok { color: var(--green); }
.cf-import-status.cf-error { color: var(--red); }
.cf-warn {
  font-size: 12px; color: #ffd479; margin-top: 8px;
  background: var(--yellow-soft); border: 1px solid rgba(255,199,54,.28);
  border-radius: 9px; padding: 7px 10px; line-height: 1.5;
}

/* ============================================================
   content band (SEO copy added in a later phase)
   ============================================================ */
.intro { max-width: 1560px; margin: 0 auto; padding: 24px 20px 0; text-align: center; }
.intro h1 {
  font-family: var(--brand); font-weight: 400;
  font-size: clamp(24px, 4.2vw, 38px); line-height: 1.15; color: var(--ink);
}
.intro h1 .hl { font-family: var(--hand); font-weight: 700; color: #b9a7ff; font-size: 1.12em; }
.intro p { max-width: 660px; margin: 12px auto 0; color: var(--ink-soft); font-size: 15px; line-height: 1.65; }

.about-app { border-top: 1px solid var(--line); background: var(--surface); margin-top: 30px; }
.about-inner { max-width: 820px; margin: 0 auto; padding: 40px 20px 48px; }
.about-app h2 { font-family: var(--brand); font-weight: 400; font-size: 23px; margin: 32px 0 12px; }
.about-inner > h2:first-child { margin-top: 0; }
.about-app h3 { font-size: 15.5px; font-weight: 600; color: #b9a7ff; margin-bottom: 6px; }
.about-app p { color: var(--ink-soft); line-height: 1.7; font-size: 14.5px; }

.steps { list-style: none; counter-reset: step; display: grid; gap: 12px; }
.steps li {
  position: relative; padding-left: 40px;
  color: var(--ink-soft); line-height: 1.6; font-size: 14.5px;
}
.steps li strong { color: var(--ink); font-weight: 600; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--purple); color: #fff;
  border-radius: 50%; font-size: 13px; font-weight: 600;
}

.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.feature {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; background: var(--surface-2);
}

.faq-list { display: grid; gap: 10px; }
.faq-item {
  border: 1px solid var(--line); border-radius: 14px;
  padding: 4px 16px; background: var(--surface-2);
  transition: border-color .18s ease, background .18s ease;
}
.faq-item[open] { border-color: var(--purple); background: var(--surface-3); }
.faq-item summary {
  cursor: pointer; font-weight: 600; color: var(--ink);
  padding: 12px 0; list-style: none;
  position: relative; padding-right: 26px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; position: absolute; right: 2px; top: 10px;
  font-size: 20px; line-height: 1; color: var(--purple);
}
.faq-item[open] summary::after { content: "–"; }
.faq-item p { padding: 0 0 14px; }

.app-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 30px; }
.app-footer-inner {
  max-width: 820px; margin: 0 auto; padding: 20px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; color: var(--ink-soft); font-size: 13.5px;
}
.app-footer nav { display: flex; gap: 18px; }

/* ============================================================
   mobile — declared last so it wins the cascade
   ============================================================ */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 14px 14px 32px; }

  /* dissolve the preview wrapper so the stage can dock for the whole scroll */
  .preview-area { display: contents; }
  .stage-wrap { order: -3; }
  .player { order: -2; }
  .file-info { order: 3; }

  .stage-wrap {
    position: sticky; top: 60px; z-index: 40;
    padding: 8px; border-radius: 14px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .55);
  }
  .stage { height: 30vh; min-height: 130px; }

  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .topbar-project { margin-left: auto; }
  #project-name { width: 16ch; }
  .tab { font-size: 12px; padding: 8px 7px; }
}

@media (max-width: 560px) {
  .topbar-project { order: 3; width: 100%; margin-left: 0; }
  #project-name { width: 100%; max-width: none; background: var(--surface-2); }
  .row2, .row3 { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
  .tab-n { display: none; }
}
