:root {
  color-scheme: dark;
  --background: #090b0f;
  --surface: #11151b;
  --surface-raised: #181d25;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.17);
  --text: #f5f7fa;
  --muted: #8c95a2;
  --root: #c084fc;
  --scale: #6078aa;
  --chord: rgba(255, 255, 255, 0.7);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-height: 100vh;
  background: radial-gradient(circle at 78% 8%, rgba(192,132,252,.075), transparent 28%), var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select { font: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--root); outline-offset: 2px; }

.app { min-height: 100vh; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 20px clamp(20px, 4vw, 56px); border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-size: 13px; font-weight: 700; text-decoration: none; }
.brand-mark { width: 10px; height: 10px; background: linear-gradient(135deg, #67e8f9, var(--root)); border-radius: 50%; box-shadow: 0 0 14px rgba(192,132,252,.45); }
.site-header > p { margin: 0; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; padding: 24px clamp(20px, 4vw, 56px) 20px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .17em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(27px, 3.3vw, 44px); font-weight: 610; letter-spacing: -.05em; }
.intro { max-width: 470px; margin: 0 0 3px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.controls {
  display: grid;
  grid-template-columns: minmax(100px,.65fr) minmax(145px,1fr) minmax(190px,1.25fr) minmax(260px,1.5fr) auto;
  align-items: end; gap: 9px; padding: 0 clamp(20px, 4vw, 56px) 20px;
}

.control, .color-selector { min-width: 0; }
.control > span, .color-selector legend { display: block; margin-bottom: 6px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.control select {
  width: 100%; height: 40px; padding: 0 34px 0 11px; appearance: none;
  background: linear-gradient(45deg,transparent 50%,var(--muted) 50%) calc(100% - 16px) 17px/5px 5px no-repeat,
    linear-gradient(135deg,var(--muted) 50%,transparent 50%) calc(100% - 11px) 17px/5px 5px no-repeat, var(--surface-raised);
  color: var(--text); border: 1px solid var(--line); border-radius: 7px;
}

.color-selector { margin: 0; padding: 0; border: 0; }
.color-options { min-height: 40px; display: flex; align-items: center; gap: clamp(6px,.7vw,10px); padding: 0 11px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 7px; }
.color-option { width: 18px; height: 18px; padding: 0; background: var(--color); border: 2px solid transparent; border-radius: 50%; transition: border-color .15s, box-shadow .15s, transform .15s; }
.color-option:hover { transform: scale(1.12); }
.color-option.active { border-color: var(--text); box-shadow: 0 0 0 2px rgba(255,255,255,.12); }

.clear-button { height: 40px; padding: 0 15px; background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 7px; }
.clear-button:hover { color: var(--text); border-color: var(--line-strong); }

.fretboard-panel {
  min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr);
  margin: 0 clamp(20px,4vw,56px) clamp(20px,4vh,38px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}

.fretboard-meta { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.fretboard-meta > p { margin: 0; color: var(--muted); font-size: 9px; }
.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 15px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.legend-dot, .legend-ring { width: 10px; height: 10px; display: inline-block; border-radius: 50%; }
.legend-dot.root { background: var(--root); }
.legend-dot.scale { background: var(--scale); }
.legend-ring { border: 1px solid var(--chord); }

.fretboard-scroll { min-height: 0; display: flex; align-items: center; overflow-x: auto; overflow-y: hidden; scrollbar-color: #3b424d transparent; scrollbar-width: thin; }
.fretboard-stage { width: 100%; min-width: 1570px; padding: clamp(20px,4vh,44px) 22px 20px; }
.fretboard, .fret-numbers { width: 100%; display: grid; grid-template-columns: 60px repeat(22,minmax(62px,1fr)); }
.fretboard { background: linear-gradient(90deg,#303742 0 60px,#6f3519 60px,#8d4b24 100%); border: 1px solid #4b5563; border-radius: 7px 7px 0 0; overflow: hidden; }

.note {
  position: relative; height: clamp(50px,6vh,62px); display: flex; align-items: center; justify-content: center;
  border-right: 2px solid rgba(229,231,235,.72); cursor: pointer;
}
.note.open { background: rgba(35,42,52,.86); border-right: 5px solid #e5e7eb; }
.note::before { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: rgba(255,255,255,.28); }
.note.inlay::after { content: ""; position: absolute; width: 7px; height: 7px; right: 6px; bottom: 5px; border-radius: 50%; background: rgba(255,255,255,.25); }
.note.double-inlay::after { content: "••"; position: absolute; width: auto; height: auto; right: 5px; bottom: 3px; color: rgba(255,255,255,.35); font-size: 10px; letter-spacing: 3px; }
.note-marker {
  position: relative; z-index: 2; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: rgba(167,139,250,.16); color: #090b0f; border: 1px solid rgba(196,181,253,.5); border-radius: 50%;
  font-size: 12px; font-weight: 700; user-select: none;
  transition: background .13s,color .13s,border-color .13s,box-shadow .13s,transform .13s,opacity .13s;
}
.fretboard.scale-active .note:not(.scale-note) .note-marker { opacity: 0; pointer-events: none; }
.fretboard.chord-active .note.scale-note:not(.chord-tone) .note-marker { background: rgba(255,255,255,.3); color: #090b0f; border-color: rgba(255,255,255,.42); opacity: .55; }
.note:not(.active):hover .note-marker { background: rgba(167,139,250,.24); border-color: rgba(196,181,253,.72); }
.note.active .note-marker { background: var(--note-color); color: #090b0f; border-color: var(--note-color); transform: scale(1.06); }
.note.chord-tone .note-marker { box-shadow: 0 0 0 1px var(--chord), 0 0 0 4px rgba(255,255,255,.1); }
.note.active.chord-tone .note-marker { transform: scale(1.09); }

.fret-numbers { color: var(--muted); font-size: 10px; font-weight: 650; text-align: center; user-select: none; }
.fret-number { height: 27px; display: flex; align-items: center; justify-content: center; }

@media (max-width: 1000px) {
  .app { display: block; }
  .controls { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .color-selector { grid-column: 1/-1; }
  .fretboard-panel { min-height: 520px; }
}

@media (max-width: 620px) {
  .site-header, .page-heading, .controls { padding-right: 16px; padding-left: 16px; }
  .page-heading { align-items: start; flex-direction: column; gap: 10px; }
  .controls { grid-template-columns: 1fr; }
  .color-selector { grid-column: auto; }
  .fretboard-panel { min-height: 480px; margin-right: 16px; margin-left: 16px; }
  .fretboard-meta { align-items: start; flex-direction: column; gap: 8px; }
}
