:root {
  --bg: #0a0c09;
  --surface: #0d100c;
  --surface-2: #11140f;
  --line: #2c3128;
  --line-soft: #20241d;
  --text: #f2f4ec;
  --muted: #90978a;
  --muted-2: #62695e;
  --accent: #cfff4f;
  --accent-soft: rgba(207, 255, 79, .10);
  color: var(--text);
  background: var(--bg);
  font-family: Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button, select, input { outline: none; }
button { color: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.shell {
  width: min(1360px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  color: var(--text);
  text-decoration: none;
  font: 800 13px/1 ui-monospace, "JetBrains Mono", monospace;
  letter-spacing: .14em;
}
.brand span { color: var(--accent); }
.export-button {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.export-button:hover { border-color: var(--accent); }

.hero {
  padding: 64px 0 54px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .65fr);
  align-items: end;
  gap: 64px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(58px, 6.8vw, 98px);
  line-height: .91;
  letter-spacing: -.062em;
  font-weight: 760;
}
.hero h1 span { color: var(--accent); }
.hero p {
  max-width: 520px;
  margin: 0 0 6px auto;
  color: #aab0a3;
  font-size: 16px;
  line-height: 1.68;
}

.controls {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr 1fr .95fr;
  border: 1px solid var(--line);
  background: var(--surface);
}
.control {
  min-width: 0;
  min-height: 104px;
  padding: 16px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}
.control-last { border-right: 0; }
.control > span,
.search > span,
.tuning-heading > span,
.section-kicker {
  color: var(--muted);
  font: 700 10px/1.2 ui-monospace, "JetBrains Mono", monospace;
  letter-spacing: .10em;
  text-transform: uppercase;
}
.control select,
.search input {
  width: 100%;
  height: 42px;
  border: 0;
  border-bottom: 1px solid #4a5144;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  color-scheme: dark;
  padding: 0 2px;
  font-size: 14px;
}
.switch-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.switch-pair button,
.edit-button,
.secondary,
.primary {
  min-height: 40px;
  border: 1px solid #353b31;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}
.switch-pair button { color: var(--muted); font-size: 13px; }
.switch-pair button.active {
  color: #0a0c09;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}
.edit-button { width: 100%; text-align: left; padding: 0 12px; color: #c7cbc2; }
.edit-button:hover, .secondary:hover { border-color: #656d5d; }

.current-tuning {
  min-height: 76px;
  display: grid;
  grid-template-columns: 230px 1fr;
  border: 1px solid var(--line);
  border-top: 0;
}
.tuning-heading {
  padding: 15px 16px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
}
.tuning-heading strong {
  font-size: 17px;
  letter-spacing: -.02em;
}
.tuning-notes {
  display: grid;
  grid-template-columns: repeat(var(--strings, 6), 1fr);
  min-width: 0;
}
.tuning-note {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  min-width: 0;
  border-right: 1px solid var(--line-soft);
  color: #d8dcd2;
  font: 760 15px/1 ui-monospace, "JetBrains Mono", monospace;
}
.tuning-note:last-child { border-right: 0; }
.tuning-note span {
  color: var(--muted-2);
  font: 700 8px/1 ui-monospace, "JetBrains Mono", monospace;
  letter-spacing: .08em;
}

.reference-head {
  padding: 56px 0 22px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 32px;
}
.reference-head h2 {
  margin: 8px 0 0;
  font-size: clamp(31px, 3.2vw, 46px);
  letter-spacing: -.045em;
}
.search {
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search input::placeholder { color: #50564c; }

.legend {
  min-height: 48px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 22px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font: 700 10px/1 ui-monospace, "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.legend > span { display: inline-flex; align-items: center; gap: 7px; }
.legend b { color: var(--text); font-weight: 800; }
.legend-root,
.legend-note {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-style: normal;
  font-size: 8px;
}
.legend-root { background: var(--accent); }
.legend-note { background: #e9ece4; color: #11140f; }
.shape-counter { margin-left: auto; }
.shape-counter b { color: var(--accent); }

.chord-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.chord-card {
  min-width: 0;
  min-height: 300px;
  padding: 18px 18px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  position: relative;
}
.chord-card::before {
  content: attr(data-index);
  position: absolute;
  top: 18px;
  right: 18px;
  color: #444a40;
  font: 700 9px/1 ui-monospace, "JetBrains Mono", monospace;
}
.card-head { min-height: 48px; }
.chord-name {
  margin: 0;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -.035em;
}
.chord-quality {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.chord-shape {
  width: min(184px, 82%);
  margin: 20px auto 17px;
}
.marker-row {
  display: grid;
  grid-template-columns: repeat(var(--strings), 1fr);
  margin: 0 -8px 8px;
  color: #bbc0b4;
  font: 700 13px/1 ui-monospace, "JetBrains Mono", monospace;
}
.marker-row span { text-align: center; min-height: 13px; }
.neck-wrap { position: relative; padding-left: 22px; }
.fret-number {
  position: absolute;
  left: -8px;
  top: 8px;
  color: var(--muted-2);
  font: 700 9px/1 ui-monospace, "JetBrains Mono", monospace;
}
.neck {
  position: relative;
  height: 146px;
  border-top: 3px solid #c3c7bd;
  border-bottom: 1px solid #555c50;
}
.neck .fret,
.neck .string {
  position: absolute;
  display: block;
  background: #555c50;
  pointer-events: none;
}
.neck .fret { left: 0; right: 0; height: 1px; }
.neck .string { top: 0; bottom: 0; width: 1px; transform: translateX(-.5px); }
.dot {
  position: absolute;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ecefe7;
  color: #10120e;
  font: 850 10px/1 ui-monospace, "JetBrains Mono", monospace;
  z-index: 2;
}
.dot.root { background: var(--accent); }

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted-2);
  font: 700 8px/1.3 ui-monospace, "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.card-meta .frets { color: #92998b; text-align: right; }
.no-shape {
  height: 186px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted-2);
  font: 700 10px/1.5 ui-monospace, "JetBrains Mono", monospace;
  text-transform: uppercase;
}
.no-results {
  grid-column: 1 / -1;
  min-height: 220px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

footer {
  min-height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  color: var(--muted-2);
  font: 700 9px/1.4 ui-monospace, "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .07em;
}

#customDialog {
  width: min(690px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #0d100c;
  color: var(--text);
}
#customDialog::backdrop { background: rgba(0,0,0,.78); }
.dialog-panel { padding: 24px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-head h3 { margin: 8px 0 0; font-size: 30px; letter-spacing: -.04em; }
.dialog-close { border: 0; background: transparent; color: var(--muted); font-size: 25px; cursor: pointer; }
.dialog-panel > p { color: var(--muted); font-size: 13px; }
.custom-strings {
  display: grid;
  grid-template-columns: repeat(var(--strings), minmax(0, 1fr));
  gap: 6px;
  margin: 24px 0;
}
.custom-strings input {
  min-width: 0;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #090b08;
  color: var(--text);
  text-align: center;
  font: 800 16px/1 ui-monospace, "JetBrains Mono", monospace;
}
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.secondary, .primary { padding: 0 14px; }
.primary { background: var(--accent); color: #0a0c09; border-color: var(--accent); font-weight: 800; }

@media (max-width: 1050px) {
  .controls { grid-template-columns: repeat(2, 1fr); }
  .control { border-bottom: 1px solid var(--line); }
  .control:nth-child(2n) { border-right: 0; }
  .control-last { grid-column: 1 / -1; border-right: 0; }
  .chord-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 1360px); }
  .hero { grid-template-columns: 1fr; gap: 24px; padding: 46px 0 38px; }
  .hero p { margin: 0; }
  .controls { grid-template-columns: 1fr; }
  .control, .control:nth-child(2n), .control-last { border-right: 0; }
  .current-tuning { grid-template-columns: 1fr; }
  .tuning-heading { border-right: 0; border-bottom: 1px solid var(--line); }
  .tuning-notes { min-height: 64px; }
  .reference-head { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .chord-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chord-card { min-height: 280px; padding: 14px; }
  .chord-shape { width: 90%; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; }
}
@media (max-width: 500px) {
  .topbar { min-height: 64px; }
  .hero h1 { font-size: 52px; }
  .chord-grid { grid-template-columns: 1fr; }
  .legend { gap: 14px; padding: 12px; }
  .shape-counter { width: 100%; margin-left: 0; }
}

@media print {
  body { background: #fff; color: #111; }
  .topbar, .hero p, .controls, .search, footer, .legend { display: none !important; }
  .shell { width: 100%; }
  .hero { display: block; padding: 0 0 18px; }
  .hero h1 { font-size: 38px; color: #111; }
  .hero h1 span { color: #111; }
  .current-tuning, .chord-grid { border-color: #aaa; }
  .chord-card { break-inside: avoid; border-color: #aaa; }
  .chord-grid { grid-template-columns: repeat(4, 1fr); }
  .reference-head { padding-top: 24px; }
}
