/* semicord — one stylesheet, light and dark. Phone first. */
:root {
  color-scheme: light dark;
  --bg: #f6f3ec;
  --panel: #fffdf8;
  --ink: #1d1b18;
  --muted: #5f5a52;
  --line: #d9d2c4;
  --accent: #b4540a;
  --accent-ink: #ffffff;
  --accent-soft: #f4d9bf;
  --ghost: #2d6a78;
  --white-key: #ffffff;
  --white-key-edge: #bdb5a6;
  --black-key: #22201c;
  --wood: #6b4a2f;
  --fret: #c8c0b0;
  --string: #e8e1d2;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --panel: #1d2026;
    --ink: #ece8e0;
    --muted: #a39d92;
    --line: #343841;
    --accent: #f0a04b;
    --accent-ink: #1a1308;
    --accent-soft: #4a3520;
    --ghost: #6cc3d5;
    --white-key: #e9e6df;
    --white-key-edge: #8d887e;
    --black-key: #0b0c0e;
    --wood: #3a2a1c;
    --fret: #8a8478;
    --string: #cfc8b8;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1rem; }

.top { display: flex; align-items: baseline; gap: .75rem; padding: .6rem 0 .2rem; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand b { color: var(--accent); }
.top h1 { font-size: .95rem; font-weight: 500; color: var(--muted); margin: 0; }

/* ── readout ── */
.readout {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .55rem .9rem .6rem; margin-top: .4rem; min-height: 11.2rem;
}
.name-row { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; min-height: 3.6rem; }
#chord-name { font-size: 3.1rem; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; color: var(--accent); word-break: break-word; }
#chord-name:empty::before { content: "—"; color: var(--line); }
#chord-long { font-size: 1rem; color: var(--ink); font-weight: 600; }
#hint { color: var(--muted); margin: .2rem 0 0; font-size: .92rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .1rem .8rem; margin: .35rem 0 0; font-size: .95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.alts { display: flex; flex-wrap: wrap; gap: .3rem; }
.alts span { border: 1px solid var(--line); border-radius: 999px; padding: 0 .5rem; font-weight: 600; font-size: .9rem; }

/* ── controls ── */
.controls { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; margin: .55rem 0; }
.controls button {
  font: inherit; font-weight: 700; border-radius: 8px; padding: .45rem .85rem; min-height: 40px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer;
}
.controls button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.controls button:disabled { opacity: .45; cursor: default; }
.controls label { display: inline-flex; gap: .35rem; align-items: center; color: var(--muted); font-size: .92rem; margin-left: auto; }
button:focus-visible { outline: 3px solid var(--ghost); outline-offset: 2px; }

/* ── piano: 2 octaves across a phone, the whole C3–C6 range on desktop ── */
.piano-scroll { overflow-x: auto; overscroll-behavior-x: contain; border-radius: var(--radius); border: 1px solid var(--line); background: var(--black-key); padding: 6px 0 0; }
#piano { --w: calc((100vw - 2rem - 2px) / 14); position: relative; height: 150px; width: calc(var(--w) * 22); }
@media (min-width: 900px) {
  #piano { --w: calc((min(100vw, 1120px) - 2rem - 2px) / 22); height: 180px; }
}
.key { position: absolute; top: 0; padding: 0; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; font: inherit; }
.key.white {
  width: var(--w); height: 100%; background: var(--white-key); border-right: 1px solid var(--white-key-edge);
  border-radius: 0 0 6px 6px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px;
  font-size: .7rem; color: #6b665d;
}
.key.black {
  width: calc(var(--w) * .62); height: 60%; background: var(--black-key); z-index: 2;
  border-radius: 0 0 5px 5px; box-shadow: inset 0 -4px 0 rgba(255,255,255,.08);
}
.key.on { background: var(--accent); color: var(--accent-ink); }
.key.black.on { background: var(--accent); box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); }
.key.echo:not(.on) { box-shadow: inset 0 -10px 0 var(--ghost); }
.key.bass::after { content: "bass"; position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-size: .6rem; font-weight: 700; }

/* ── fretboard: strings as rows, high e on top like tablature ── */
.guitar h2, .about h2 { font-size: 1.1rem; margin: 1.2rem 0 .3rem; }
.guitar p.small { margin: 0 0 .4rem; color: var(--muted); font-size: .9rem; }
.fb-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
#fretboard { display: grid; grid-template-columns: 3.1rem repeat(15, minmax(2.4rem, 1fr)); min-width: calc(3.1rem + 15 * 2.4rem); }
.fb-open {
  font: inherit; font-weight: 700; border: 0; border-right: 4px solid var(--fret); background: var(--panel); color: var(--muted);
  height: 2.3rem; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 0 .35rem; font-size: .85rem;
}
.fb-open .st { color: var(--muted); font-weight: 500; }
.fb-open.open .mark { color: var(--accent); }
.fb-cell {
  position: relative; border: 0; padding: 0; height: 2.3rem; cursor: pointer; background: var(--wood);
  border-right: 2px solid var(--fret); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.fb-cell::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px solid var(--string); opacity: .85; }
.fb-cell .dot {
  position: absolute; left: 50%; top: 50%; width: 1.55rem; height: 1.55rem; margin: -.775rem 0 0 -.775rem; border-radius: 50%;
  display: none; align-items: center; justify-content: center; font-size: .68rem; font-weight: 800;
}
.fb-cell.on .dot { display: flex; background: var(--accent); color: var(--accent-ink); }
.fb-cell.echo:not(.on) .dot { display: flex; border: 2px solid var(--ghost); color: var(--ghost); background: var(--panel); }
.fb-nums { display: contents; }
.fb-nums span { text-align: center; font-size: .72rem; color: var(--muted); padding: .1rem 0; }
.fb-nums span.inlay { color: var(--accent); font-weight: 800; }

/* ── text ── */
.about { max-width: 46rem; }
.about p, .about li { color: var(--ink); }
.about code { font-size: .92em; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 0 .25rem; }
.about table { border-collapse: collapse; font-size: .92rem; margin: .4rem 0 .8rem; }
.about th, .about td { border-bottom: 1px solid var(--line); padding: .25rem .6rem .25rem 0; text-align: left; vertical-align: top; }
footer { color: var(--muted); font-size: .85rem; padding: 1.5rem 0 2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── front page: link from the readout to the chord's own page ── */
.chord-link { font-size: .9rem; font-weight: 600; }
.more-chords { font-weight: 600; }

/* ── chord pages ── */
.crumbs { font-size: .9rem; color: var(--muted); }
.chord-page { max-width: 52rem; }
.chord-page h2 { font-size: 1.1rem; margin: 1.3rem 0 .35rem; }
.chord-h1 { margin: .5rem 0 .3rem; line-height: 1.15; display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .7rem; }
.chord-h1 .sym { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--accent); }
.chord-h1 .long { font-size: 1.25rem; font-weight: 700; }
.chord-facts { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .8rem; }
.chord-page .small, .chord-page p.small { color: var(--muted); font-size: .9rem; }
.diagram { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; }
.piano-svg { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; }
.pk-w { fill: var(--white-key); stroke: var(--white-key-edge); stroke-width: 1; }
.pk-b { fill: var(--black-key); }
.pk-w.on, .pk-b.on { fill: var(--accent); }
.pk-l { fill: var(--accent-ink); font: 700 10px system-ui, sans-serif; text-anchor: middle; }
.pk-c { fill: var(--muted); font: 9px system-ui, sans-serif; text-anchor: middle; }
.shapes { display: flex; flex-wrap: wrap; gap: .8rem; }
.shape { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .6rem .6rem; flex: 1 1 10rem; max-width: 15rem; }
.guitar-svg { display: block; width: 100%; max-width: 170px; height: auto; margin: 0 auto .3rem; }
.gd-fret { stroke: var(--fret); stroke-width: 1.5; }
.gd-nut { stroke: var(--ink); stroke-width: 5; }
.gd-str { stroke: var(--muted); stroke-width: 1.2; }
.gd-barre { fill: var(--accent); opacity: .45; }
.gd-dot { fill: var(--accent); }
.gd-dot.root { fill: var(--ghost); }
.gd-t { fill: var(--accent-ink); font: 700 8.5px system-ui, sans-serif; text-anchor: middle; }
.gd-dot.root + .gd-t { fill: var(--bg); }
.gd-open { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.gd-mark { fill: var(--ink); font: 700 14px system-ui, sans-serif; text-anchor: middle; }
.gd-base { fill: var(--muted); font: 10px system-ui, sans-serif; text-anchor: end; }
.gd-s { fill: var(--muted); font: 9px system-ui, sans-serif; text-anchor: middle; }
.shape figcaption { font-size: .9rem; line-height: 1.45; }
.tab { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: .05em; }
button.mini {
  font: inherit; font-size: .85rem; font-weight: 700; border-radius: 6px; padding: .2rem .6rem; min-height: 32px; margin-top: .3rem;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer;
}
.table-scroll { overflow-x: auto; max-width: 100%; }
.chord-page table { border-collapse: collapse; font-size: .92rem; }
.chord-page th, .chord-page td { border-bottom: 1px solid var(--line); padding: .3rem .6rem .3rem 0; text-align: left; vertical-align: middle; }
.inv td .small { display: inline-block; }
.chord-grid td a { display: inline-block; padding: .15rem 0; font-weight: 600; }
.chord-grid th, .chord-grid td { padding-right: .5rem; white-space: nowrap; }
.frets-table th, .frets-table td { padding-right: .45rem; text-align: center; white-space: nowrap; }
.chips { list-style: none; padding: 0; margin: .2rem 0 .6rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.chips a { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: .1rem .6rem; font-weight: 600; text-decoration: none; background: var(--panel); }
