/* Self-hosted fonts (SIL OFL) */
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/unbounded-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/unbounded-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 800; font-display: swap; src: url("fonts/unbounded-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/onest-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/onest-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/onest-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/onest-latin-700-normal.woff2") format("woff2"); }

/* Layout idea: tool-first library. Compact hero, then a dense grid of playable tone cards. */
:root {
  --ink: #0D2A30;
  --ink-soft: #3E5C61;
  --brass: #F2B42C;
  --brass-deep: #C98B0B;
  --wave: #1A9E92;
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --line: #DCE4E3;
  --chip: #E8EFEE;
  --on-brass: #0D2A30;
  --font-display: "Unbounded", "Avenir Next", system-ui, sans-serif;
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #EAF2F1;
    --ink-soft: #9DB7BA;
    --brass: #F2B42C;
    --brass-deep: #FFCB5C;
    --wave: #2EC4B6;
    --bg: #0A1F24;
    --surface: #10313A;
    --line: #1E4650;
    --chip: #163C45;
    --on-brass: #0D2A30;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #EAF2F1;
  --ink-soft: #9DB7BA;
  --brass: #F2B42C;
  --brass-deep: #FFCB5C;
  --wave: #2EC4B6;
  --bg: #0A1F24;
  --surface: #10313A;
  --line: #1E4650;
  --chip: #163C45;
  --on-brass: #0D2A30;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img, svg, canvas { max-width: 100%; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.03em; line-height: 1.12; text-wrap: balance; margin: 0; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--wave); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand svg { width: 34px; height: 34px; }
.brand span { font-family: var(--font-display); font-weight: 800; font-size: 23px; letter-spacing: -0.04em; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 500; font-size: 15px; color: var(--ink-soft); }
.nav a:hover { color: var(--ink); background: var(--chip); }
@media (max-width: 600px) { .site-header { position: static; } }
.nav a[aria-current="page"] { color: var(--ink); background: var(--chip); }

/* Hero */
.hero { padding: 48px 0 28px; display: grid; gap: 18px; }
.hero h1 { font-size: clamp(32px, 5.2vw, 54px); font-weight: 700; max-width: 18ch; }
.hero p.lede { font-size: 18px; color: var(--ink-soft); max-width: 60ch; }
.page-hero { padding: 40px 0 20px; display: grid; gap: 12px; }
.page-hero h1 { font-size: clamp(28px, 4.4vw, 44px); font-weight: 700; }
.page-hero p { color: var(--ink-soft); font-size: 18px; max-width: 62ch; }

.search { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search input {
  flex: 1 1 280px; min-height: 48px; padding: 0 16px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Tone grid */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 28px 0 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 26px; font-weight: 700; }
.section-head .count { color: var(--ink-soft); font-size: 15px; font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center;
}
.card.playing { border-color: var(--wave); box-shadow: 0 0 0 1px var(--wave); }
.play {
  grid-row: span 2; width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brass); color: var(--on-brass); display: grid; place-items: center;
}
.play:hover { background: var(--brass-deep); }
.play svg { width: 22px; height: 22px; }
.card h3 { font-size: 17px; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--ink-soft); font-size: 14px; font-variant-numeric: tabular-nums; }
.meta span:last-child { white-space: nowrap; }
.pill { background: var(--chip); color: var(--ink); padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.wave { grid-column: 1 / -1; height: 44px; width: 100%; display: block; margin-top: 6px; }
.card-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; font: inherit; font-weight: 600; font-size: 15px;
  cursor: pointer; text-decoration: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--ink-soft); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--on-brass); }
.btn.primary:hover { background: var(--brass-deep); border-color: var(--brass-deep); }
.btn.block { flex: 1; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Tools strip */
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 44px 0; }
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: grid; gap: 8px; text-decoration: none; }
.tool:hover { border-color: var(--wave); }
.tool h3 { font-size: 21px; }
.tool p { color: var(--ink-soft); }
.tool .go { color: var(--wave); font-weight: 600; }

/* Panels / forms */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 15px; }
.field .hint { color: var(--ink-soft); font-size: 14px; }
.field input[type="text"], .field select {
  min-height: 48px; padding: 0 14px; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px 20px; text-align: center;
  display: grid; gap: 10px; justify-items: center; background: var(--surface); cursor: pointer;
}
.drop.over { border-color: var(--wave); }
.drop strong { font-size: 18px; }
.drop span { color: var(--ink-soft); }

.editor { display: grid; gap: 14px; }
.wavebox { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; height: 140px; overflow: hidden; touch-action: none; }
.wavebox canvas { width: 100%; height: 100%; display: block; }
.sel { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--brass) 22%, transparent); border-left: 3px solid var(--brass); border-right: 3px solid var(--brass); cursor: grab; }
.handle { position: absolute; top: 0; bottom: 0; width: 22px; cursor: ew-resize; }
.handle.l { left: -12px; } .handle.r { right: -12px; }
.handle::after { content: ""; position: absolute; top: 50%; left: 50%; width: 8px; height: 36px; margin: -18px 0 0 -4px; border-radius: 4px; background: var(--brass); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--wave); pointer-events: none; display: none; }
.times { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: 14px; font-variant-numeric: tabular-nums; flex-wrap: wrap; gap: 8px; }
.times b { color: var(--ink); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--wave); }

.status { font-size: 15px; color: var(--ink-soft); min-height: 1.5em; }
.status.error { color: #C2410C; }
:root[data-theme="dark"] .status.error { color: #FB923C; }

/* Steps */
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; counter-reset: s; }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 18px 64px; position: relative; }
.steps li::before {
  content: counter(s); position: absolute; left: 18px; top: 16px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--brass); color: var(--on-brass); display: grid; place-items: center; font-weight: 700; font-family: var(--font-display);
}
.steps h3 { font-size: 19px; margin-bottom: 4px; }
.steps p { color: var(--ink-soft); }
.prose { max-width: 68ch; display: grid; gap: 14px; }
.prose h2 { font-size: 26px; margin-top: 18px; }
.prose p, .prose li { color: var(--ink-soft); }
.prose code { background: var(--chip); padding: 1px 6px; border-radius: 6px; color: var(--ink); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 500;
  max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.2); display: none;
}
.toast.show { display: block; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 56px; padding: 28px 0 40px; color: var(--ink-soft); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }

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