:root {
  --ink: #20231f;
  --muted: #687068;
  --paper: #fbf8f0;
  --paper-raised: #fffdf8;
  --canvas: #e8e3d8;
  --line: #d8d2c5;
  --line-strong: #aaa394;
  --green: #173f35;
  --green-2: #236b54;
  --green-soft: #dfece6;
  --gold: #e9b44c;
  --gold-soft: #fff0bf;
  --orange: #c66b3d;
  --blue: #345c9c;
  --shadow: 0 16px 50px rgb(37 38 31 / 9%);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 8%, rgb(255 255 255 / 55%), transparent 25rem),
    var(--canvas);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
.skip-link { position: fixed; z-index: 100; top: -5rem; left: 1rem; padding: .7rem 1rem; background: #fff; color: #111; }
.skip-link:focus { top: 1rem; }

.site-header {
  width: min(1220px, calc(100% - 36px));
  margin: 18px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand { display: inline-flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand img { border-radius: 12px; box-shadow: 0 5px 14px rgb(23 63 53 / 16%); }
.brand span { display: grid; line-height: 1.05; }
.brand b { font: 700 1.1rem/1 Georgia, serif; letter-spacing: -.015em; }
.brand small { margin-top: 5px; color: var(--muted); font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; }

main {
  width: min(1220px, calc(100% - 36px));
  margin: 18px auto 28px;
  padding: clamp(26px, 5vw, 64px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.section-kicker { margin: 0 0 9px; color: var(--green-2); font-size: .72rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
h2, h3, p { text-wrap: pretty; }

section + section { margin-top: clamp(62px, 9vw, 110px); }
h2 { margin: 0; font: 700 clamp(1.65rem, 3.4vw, 2.55rem)/1.05 Georgia, serif; letter-spacing: -.035em; }

.studio-heading, .section-heading { display: flex; justify-content: space-between; gap: 22px; align-items: end; margin-bottom: 18px; }
.version { margin: 0; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font: 700 .7rem/1 ui-monospace, monospace; }

.control-panel {
  display: grid;
  grid-template-columns: 1.2fr 1.6fr .7fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--green);
  border-radius: 13px;
  background: var(--green);
}

.control-panel label { display: grid; gap: 4px; padding: 11px 14px; background: var(--paper-raised); }
label > span { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
select { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; cursor: pointer; font-weight: 720; }

.mode-summary {
  display: grid;
  grid-template-columns: minmax(220px, .8fr) 1.5fr;
  gap: 30px;
  align-items: center;
  margin-top: 14px;
  padding: clamp(20px, 4vw, 36px);
  border-radius: var(--radius);
  color: #f8f5ec;
  background: var(--green);
}

.degree-label { margin: 0 0 5px; color: #b9d2c7; font-size: .75rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.mode-summary h3 { margin: 0; font: 700 clamp(2rem, 4vw, 3.25rem)/1 Georgia, serif; letter-spacing: -.04em; }
.mode-alias { min-height: 1.4em; margin: 7px 0 0; color: #b9d2c7; font-size: .88rem; }
.summary-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin: 0; }
.summary-facts > div:first-child { grid-column: 1 / -1; }
.summary-facts dt { color: #a9c8bb; font-size: .66rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.summary-facts dd { margin: 3px 0 0; color: #fff; font: 650 clamp(.95rem, 1.6vw, 1.13rem)/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f4f0e7; }
.segmented button { padding: 6px 10px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: .76rem; font-weight: 750; }
.segmented button.active { color: #fff; background: var(--green); }

.legend { display: flex; flex-wrap: wrap; gap: 12px 20px; margin: 0 0 12px; color: var(--muted); font-size: .75rem; }
.legend span { display: inline-flex; gap: 7px; align-items: center; }
.legend-note { width: 15px; height: 15px; border-radius: 50%; background: #fff; border: 2px solid var(--green); }
.legend-note.root { background: var(--gold); border-color: var(--gold); }
.legend-note.chord { border-radius: 3px; background: var(--green); }

.fretboard-shell { overflow-x: auto; padding: 12px 0 8px; scrollbar-color: var(--line-strong) transparent; }
.fretboard { min-width: 960px; }
.fretboard-grid { display: grid; grid-template-columns: 34px repeat(13, minmax(56px, 1fr)); position: relative; }
.fret-number { height: 28px; display: grid; place-items: center; color: var(--muted); font: 650 .67rem/1 ui-monospace, monospace; }
.string-label { display: grid; place-items: center; color: var(--muted); font: 750 .7rem/1 ui-monospace, monospace; }
.fret-cell { position: relative; height: 46px; display: grid; place-items: center; border-right: 1px solid #8f8a80; }
.fret-cell.open { border-right: 4px solid #6e695f; }
.fret-cell::after { content: ""; position: absolute; z-index: 0; left: 0; right: 0; top: 50%; height: var(--string-size, 1px); background: #716d65; box-shadow: 0 1px rgb(255 255 255 / 65%); transform: translateY(-50%); }
.fret-cell.marker::before { content: ""; position: absolute; z-index: 0; right: calc(50% - 4px); bottom: -4px; width: 8px; height: 8px; border-radius: 50%; background: #cbc4b6; }

.note-dot { position: relative; z-index: 1; width: 31px; height: 31px; display: grid; place-items: center; border: 2px solid var(--green); border-radius: 50%; color: var(--green); background: var(--paper-raised); font: 800 .68rem/1 ui-sans-serif, system-ui; box-shadow: 0 2px 5px rgb(32 35 31 / 10%); }
.note-dot.root { color: #272116; border-color: var(--gold); background: var(--gold); }
.note-dot.chord:not(.root) { border-radius: 5px; color: #fff; background: var(--green); }
.note-dot.both-label { width: 37px; height: 34px; font-size: .58rem; line-height: .9; }
.note-dot small { display: block; font-size: .51rem; font-weight: 700; opacity: .75; }

.positions-heading { align-items: end; }
.positions-help { max-width: 780px; margin: -2px 0 22px; color: var(--muted); font-size: .86rem; }
.positions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.position-card { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper-raised); transition: border-color .2s, transform .2s, box-shadow .2s; }
.position-card:hover { border-color: #aaa394; transform: translateY(-1px); }
.position-card.is-playing { border-color: var(--green-2); box-shadow: 0 9px 28px rgb(35 107 84 / 13%); }
.position-card header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.position-card h3 { margin: 0; font: 700 1.15rem/1 Georgia, serif; }
.position-card .range { color: var(--muted); font: 650 .67rem/1 ui-monospace, monospace; }
.position-actions { display: flex; gap: 10px; align-items: center; }
.play-button { min-width: 68px; padding: 6px 9px; border: 1px solid var(--green); border-radius: 999px; color: var(--green); background: transparent; cursor: pointer; font-size: .7rem; font-weight: 800; white-space: nowrap; }
.play-button:hover, .play-button.playing { color: #fff; background: var(--green); }
.play-button.loading { color: var(--muted); border-color: var(--line-strong); cursor: wait; }
.position-board { display: grid; grid-template-columns: 25px repeat(5, 1fr); }
.position-board .fret-number { height: 22px; }
.position-board .fret-cell { height: 38px; }
.position-board .note-dot { width: 27px; height: 27px; font-size: .61rem; }
.position-board button.note-dot { padding: 0; cursor: pointer; font-family: inherit; }
.position-board .shared-note { outline: 1px dashed var(--orange); outline-offset: 3px; }
.position-board .move-hint { position: absolute; z-index: 2; right: -7px; top: -7px; width: 15px; height: 15px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--orange); font: 850 .58rem/1 system-ui; }
.position-board .note-dot.is-sounding { z-index: 3; outline: 4px solid rgb(233 180 76 / 38%); outline-offset: 2px; transform: scale(1.12); }
.symmetric-card { overflow-x: auto; }
.pattern-sequence { margin: -2px 0 12px; color: var(--green-2); font: 750 .72rem/1.45 ui-monospace, monospace; }
.symmetry-board { min-width: 520px; }
.double-symmetric-card { grid-column: 1 / -1; }

.consult-tabs { display: inline-flex; gap: 4px; margin-bottom: 18px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #f4f0e7; }
.consult-tabs button { padding: 7px 11px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: .76rem; font-weight: 800; }
.consult-tabs button.active { color: #fff; background: var(--green); }
.consult-panel[hidden] { display: none; }
.reference-tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.reference-tabs button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; color: var(--muted); background: transparent; cursor: pointer; font-size: .77rem; font-weight: 750; }
.reference-tabs button.active { color: #fff; border-color: var(--green); background: var(--green); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--green); background: var(--green-soft); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.active-row td { background: var(--gold-soft); }
tbody tr { cursor: pointer; }
tbody tr:hover td { background-color: #f4f1e9; }
tbody tr.active-row:hover td { background: var(--gold-soft); }
.formula-cell { font: 650 .82rem/1.3 ui-monospace, monospace; white-space: nowrap; }
.alias-inline { display: block; color: var(--muted); font-size: .73rem; }

.tog-controls { display: grid; grid-template-columns: .7fr 1.3fr; gap: 1px; overflow: hidden; border: 1px solid var(--green); border-radius: 12px; background: var(--green); }
.tog-controls label { display: grid; gap: 4px; padding: 11px 14px; background: var(--paper-raised); }
.tog-help { max-width: 820px; margin: 12px 0 16px; color: var(--muted); font-size: .82rem; }
.tog-list { display: grid; gap: 7px; }
.tog-item { display: grid; grid-template-columns: 64px minmax(180px, .8fr) 1.3fr auto; gap: 12px; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-raised); }
.tog-level { color: var(--green-2); font: 850 .75rem/1 ui-monospace, monospace; }
.tog-scale { font-weight: 800; }
.tog-reading { color: var(--muted); font-size: .76rem; }
.tog-item.relative { border-left: 4px solid var(--gold); }
.tog-open { padding: 6px 10px; border: 1px solid var(--green); border-radius: 999px; color: var(--green); background: transparent; cursor: pointer; font-size: .69rem; font-weight: 800; white-space: nowrap; }
.tog-open:hover { color: #fff; background: var(--green); }
.tog-context { margin-top: 8px; color: var(--gold-soft); font-size: .77rem; font-weight: 800; }

.theory-toolbar { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 10px; }
.theory-toolbar p { max-width: 720px; margin: 0; color: var(--muted); font-size: .8rem; }
.theory-toolbar > div { display: flex; gap: 7px; flex: none; }
.theory-toolbar button, .theory-toolbar a { padding: 7px 10px; border: 1px solid var(--green); border-radius: 999px; color: var(--green); background: transparent; cursor: pointer; font-size: .71rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.pdf-frame { height: min(78vh, 820px); min-height: 520px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.pdf-frame object { width: 100%; height: 100%; border: 0; }
.pdf-frame:fullscreen { height: 100vh; border: 0; border-radius: 0; }

button:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgb(233 180 76 / 70%); outline-offset: 2px; }

@media (max-width: 850px) {
  .control-panel { grid-template-columns: 1fr 1fr; }
  .mode-summary { grid-template-columns: 1fr; }
  .positions-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .site-header { width: calc(100% - 24px); }
  main { width: 100%; margin-top: 12px; padding: 28px 16px 46px; border-right: 0; border-left: 0; border-radius: 0; }
  .control-panel { grid-template-columns: 1fr; }
  .mode-summary { gap: 22px; }
  .summary-facts { grid-template-columns: 1fr; }
  .summary-facts > div:first-child { grid-column: auto; }
  .section-heading, .positions-heading { display: grid; align-items: start; }
  .segmented { margin-top: 3px; }
  .position-card header { align-items: flex-start; }
  .position-actions { gap: 7px; }
  .consult-tabs { display: flex; overflow-x: auto; }
  .tog-controls { grid-template-columns: 1fr; }
  .tog-item { grid-template-columns: 54px 1fr auto; }
  .tog-reading { grid-column: 2 / -1; grid-row: 2; }
  .theory-toolbar { display: grid; }
  .theory-toolbar > div { flex-wrap: wrap; }
  .pdf-frame { min-height: 68vh; }
}

@media print {
  body { background: #fff; }
  .site-header, .control-panel, .segmented, .reference-section, .play-button { display: none; }
  main { width: 100%; margin: 0; padding: 0; border: 0; box-shadow: none; }
  section + section { margin-top: 24px; }
  .mode-summary { color: #000; background: #fff; border: 1px solid #777; }
  .mode-summary dt, .mode-summary dd, .degree-label, .mode-alias { color: #000; }
  .positions-grid { grid-template-columns: 1fr 1fr; }
  .position-card { break-inside: avoid; }
}
