@font-face { font-family: "Atkinson"; src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url(fonts/barlow-condensed-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url(fonts/barlow-condensed-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --chalk: #F3F5F2;      /* page */
  --sheet: #FFFFFF;      /* raised surfaces */
  --ink: #18232B;
  --ink-2: #4E5D64;
  --rule: #CBD3CE;
  --lane: #0E7C66;       /* actions, in-range */
  --lane-ink: #FFFFFF;
  --split: #FFD84D;      /* target tempo band */
  --split-soft: #FFF0B3;
  --out: #B3261E;        /* exclusions */
  --radius-s: 6px;
  --radius-l: 14px;
  --step: 4px;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --text: "Atkinson", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --chalk: #121A20; --sheet: #1A252C; --ink: #E6ECE8; --ink-2: #9AAAA6; --rule: #2E3D45;
    --lane: #3FC1A1; --lane-ink: #0B1A15; --split: #E8C33A; --split-soft: #4A4220; --out: #FF8A80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--chalk); color: var(--ink); font: 16px/1.5 var(--text); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--lane); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.error { color: var(--out); min-height: 1.5em; margin: 0; }
a { color: var(--lane); }

/* ---------- buttons ---------- */
.btn { display: inline-block; text-decoration: none; text-align: center; border: 1.5px solid var(--ink); background: transparent; border-radius: 999px; padding: 8px 18px; cursor: pointer; font-weight: 700; }
.btn.primary { background: var(--lane); border-color: var(--lane); color: var(--lane-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 12px; font-size: 14px; }
.iconbtn { border: 0; background: none; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; border-radius: 50%; }
.iconbtn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.chip { border: 1px solid var(--rule); background: var(--sheet); border-radius: 999px; padding: 4px 12px; font-size: 14px; cursor: pointer; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.warn { border-color: var(--out); color: var(--out); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; }
.login-card label { display: grid; gap: 4px; font-weight: 700; }
input[type=text], input[type=password], input[type=number], input:not([type]), select {
  border: 1.5px solid var(--rule); border-radius: var(--radius-s); background: var(--sheet); padding: 8px 10px; width: 100%; min-height: 44px;
}
.wordmark { font-size: 32px; letter-spacing: .02em; }

/* ---------- top & tabs ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; position: sticky; top: 0; background: var(--chalk); z-index: 5; }
.top .wordmark { font-size: 28px; margin-right: auto; }
.recipes { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 12px; scrollbar-width: none; }
.recipes button { flex: none; border: 1.5px solid var(--rule); background: var(--sheet); border-radius: 999px; padding: 6px 16px; cursor: pointer; font-family: var(--display); font-size: 18px; font-weight: 500; }
.recipes button[aria-current=true] { background: var(--ink); color: var(--chalk); border-color: var(--ink); }
.recipes .add { border-style: dashed; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 0 16px 96px; }
.editor, .results { min-width: 0; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(380px, 460px) minmax(0, 1fr); align-items: start; }
  .editor { position: sticky; top: 72px; max-height: calc(100dvh - 160px); overflow: auto; padding-right: 8px; }
}

/* ---------- editor ---------- */
.editor { display: grid; gap: 4px; }
.name-input { font-family: var(--display); font-size: 28px; font-weight: 700; border: 0 !important; border-bottom: 1.5px solid var(--rule) !important; border-radius: 0 !important; background: transparent !important; padding: 4px 0 !important; }
.desc-input { border: 0 !important; background: transparent !important; padding: 2px 0 !important; color: var(--ink-2); min-height: 36px !important; }
details.group { border-top: 1.5px solid var(--rule); }
details.group > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; padding: 12px 0; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary h3 { font-size: 22px; }
details.group > summary .gist { color: var(--ink-2); font-size: 14px; margin-left: auto; text-align: right; }
details.group[open] > summary .gist { visibility: hidden; }
.group-body { display: grid; gap: 14px; padding: 0 0 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field { display: grid; gap: 4px; }
.field > span { font-weight: 700; font-size: 14px; }
.hint { font-size: 14px; color: var(--ink-2); margin: 0; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1.5px solid var(--rule); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; font-size: 14px; min-height: 36px; }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--chalk); }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--lane); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* the tempo strip: the one loud element */
.tempo { display: grid; gap: 8px; }
.tempo .strip { margin-bottom: 22px; }
.tempo-readout { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tempo-readout .big { font-family: var(--display); font-size: 64px; font-weight: 700; line-height: .9; font-variant-numeric: tabular-nums; }
.tempo-readout .big small { font-size: 20px; font-weight: 500; margin-left: 4px; }
.strip { position: relative; height: 96px; border-bottom: 2px solid var(--ink); touch-action: none; cursor: crosshair; }
.strip svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.strip .bar { fill: var(--ink-2); opacity: .55; }
.strip .bar.hit { fill: var(--ink); opacity: 1; }
.strip .band { fill: var(--split); }
.strip .band.octave { fill: var(--split-soft); }
.strip .axis-l { position: absolute; bottom: -20px; transform: translateX(-50%); font: 500 13px var(--display); color: var(--ink-2); pointer-events: none; }
.strip .tgt { stroke: var(--ink); stroke-width: 2; }
.targets { display: flex; gap: 6px; flex-wrap: wrap; }
.tchip { display: inline-flex; align-items: center; gap: 4px; background: var(--split); color: #18232B; border-radius: 999px; padding: 2px 4px 2px 12px; font-family: var(--display); font-size: 20px; font-weight: 700; }
.tchip button { border: 0; background: transparent; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; color: inherit; }

/* tag pickers */
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 2px; border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 14px; border: 1.5px solid var(--ink); }
.tag.out { border-color: var(--out); color: var(--out); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.tag button { border: 0; background: none; cursor: pointer; width: 26px; height: 26px; color: inherit; }
.tag-input { position: relative; }
.tag-input ul { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--sheet); border: 1.5px solid var(--rule); border-radius: var(--radius-s); max-height: 240px; overflow: auto; }
.tag-input li { padding: 8px 10px; cursor: pointer; display: flex; justify-content: space-between; border-radius: 4px; }
.tag-input li[aria-selected=true], .tag-input li:hover { background: var(--chalk); }
.related { font-size: 14px; color: var(--ink-2); }
.related button { border: 0; background: none; color: var(--lane); cursor: pointer; padding: 2px 4px; text-decoration: underline; font-size: 14px; }

/* ---------- results ---------- */
.summary { display: grid; gap: 6px; padding: 4px 0 12px; }
.summary .headline { font-family: var(--display); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.why-head { font-size: 14px; }
.why { font-size: 14px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.why strong { color: var(--ink); }
.why button { border: 0; background: none; padding: 0; color: var(--lane); text-decoration: underline; cursor: pointer; font-size: 14px; }
.tabs { display: flex; gap: 2px; border-bottom: 1.5px solid var(--rule); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1.5px; white-space: nowrap; font-weight: 700; color: var(--ink-2); }
.tabs button[aria-selected=true] { color: var(--ink); border-color: var(--ink); }
.tab-body { padding-top: 8px; }
.tracks { list-style: none; margin: 0; padding: 0; }
.track { display: grid; grid-template-columns: 56px 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.track .bpm { font-family: var(--display); font-size: 26px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; line-height: 1; }
.track .bpm small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.track .bpm.none { color: var(--ink-2); font-size: 18px; }
.track .meta { min-width: 0; }
.track .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .sub { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .note { font-size: 13px; color: var(--ink-2); }
.track .note .bad { color: var(--out); }
.track .acts { display: flex; gap: 4px; }
.track .acts button { border: 1.5px solid var(--rule); background: var(--sheet); border-radius: 999px; min-width: 40px; height: 36px; padding: 0 10px; cursor: pointer; font-size: 14px; }
.track .acts button.keep { border-color: var(--lane); color: var(--lane); font-weight: 700; }
.track .acts button.drop:hover { border-color: var(--out); color: var(--out); }
.badge { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 4px; background: var(--split-soft); color: var(--ink); margin-left: 6px; vertical-align: 2px; }
.empty { padding: 24px 0; color: var(--ink-2); }
.progress { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; margin: 8px 0; }
.progress i { display: block; height: 100%; background: var(--lane); width: 0; transition: width .3s; }

/* ---------- footer actions ---------- */
.actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--chalk); border-top: 1.5px solid var(--rule); z-index: 6; }
.actions #dirty { margin-right: auto; font-size: 14px; }

/* ---------- settings sheet ---------- */
.sheet { border: 0; padding: 0; width: min(560px, 100%); max-height: 100dvh; background: var(--sheet); color: var(--ink); border-radius: var(--radius-l); }
.sheet::backdrop { background: rgb(0 0 0 / .4); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1.5px solid var(--rule); position: sticky; top: 0; background: var(--sheet); }
.sheet-head h2 { font-size: 26px; }
#settingsBody { padding: 8px 16px 24px; display: grid; gap: 20px; }
#settingsBody h3 { font-size: 20px; margin-bottom: 6px; }
.cov { width: 100%; border-collapse: collapse; font-size: 14px; }
.cov td { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.cov td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; width: 90px; display: inline-block; vertical-align: middle; margin-left: 8px; }
.meter i { display: block; height: 100%; background: var(--lane); }
.pls { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow: auto; }
.pls li { padding: 6px 0; border-bottom: 1px solid var(--rule); }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--chalk); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; pointer-events: auto; }
.toast a { color: var(--split); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
