:root {
  color-scheme: dark;
  --background: #090b0f;
  --surface: #11151b;
  --surface-raised: #181d25;
  --surface-soft: #202630;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.17);
  --text: #f5f7fa;
  --muted: #8c95a2;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --cyan: #67e8f9;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-height: 100vh; background: radial-gradient(circle at 78% 8%,rgba(167,139,250,.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, input { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app { min-height: 100vh; }

.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,var(--cyan),var(--accent)); border-radius: 50%; box-shadow: 0 0 14px rgba(167,139,250,.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: 520px; margin: 0 0 3px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.trainer-card { margin: 0 clamp(20px,4vw,56px) clamp(20px,4vh,38px); padding: clamp(16px,2vw,24px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.scale-controls { display: grid; grid-template-columns: repeat(8,minmax(120px,1fr)); gap: 9px; margin-bottom: 16px; }
.control-group { min-width: 0; }
.control-group label, .label, .tempo-section label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.control-group select, .sound-toggle { width: 100%; height: 40px; padding: 0 34px 0 11px; color: var(--text); border: 1px solid var(--line); border-radius: 7px; }
.control-group select { 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); }
.control-group select:hover, .sound-toggle:hover { border-color: var(--line-strong); }
#triadControl { display: none; }
body.triad-mode #triadControl { display: block; }
body.triad-mode #scaleControl, body.triad-mode #scalePhraseStyleControl { display: none; }
.sound-toggle { padding: 0 10px; background: var(--surface-raised); font-size: 12px; }
.sound-toggle.active { background: rgba(139,92,246,.16); border-color: rgba(167,139,250,.48); color: #ddd6fe; }

.phrase-preview { min-height: 85px; padding: 13px 14px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 9px 9px 0 0; }
.phrase-notes { display: flex; flex-wrap: wrap; gap: 6px; }
.phrase-note { min-width: 54px; padding: 7px 9px; background: var(--surface-soft); color: #c8ced7; border: 1px solid transparent; border-radius: 6px; font-size: 12px; font-weight: 700; text-align: center; }
.phrase-note small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.phrase-note.current { background: var(--accent-strong); color: white; }
.phrase-note.current small { color: #ede9fe; }
.phrase-note.completed { opacity: .32; }
.phrase-note.segment-start { margin-left: 12px; border-left: 2px solid var(--accent); }
.phrase-note.flow-cell-start { box-shadow: inset 2px 0 0 var(--cyan); }
.phrase-note.segment-start.flow-cell-start { border-left: 2px solid var(--accent); box-shadow: inset 2px 0 0 var(--cyan); }
.progress-track { width: 100%; height: 4px; margin-bottom: 18px; overflow: hidden; background: #292f39; }
.progress-bar { width: 0; height: 100%; background: var(--accent); transition: width .12s linear; }

.fretboard-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; padding-bottom: 7px; scrollbar-color: #3b424d transparent; scrollbar-width: thin; }
.fretboard-area { width: 100%; min-width: 1570px; }
.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; }
.fret { position: relative; height: clamp(50px,6vh,62px); display: flex; align-items: center; justify-content: center; border-right: 2px solid rgba(229,231,235,.72); }
.fret.open { background: rgba(35,42,52,.86); border-right: 5px solid #e5e7eb; }
.fret::before { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: rgba(255,255,255,.28); }
.fret.inlay::after { content: ""; position: absolute; width: 7px; height: 7px; right: 6px; bottom: 5px; border-radius: 50%; background: rgba(255,255,255,.25); }
.fret.double-inlay::after { content: "••"; width: auto; height: auto; right: 5px; bottom: 3px; background: none; 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; border: 1px solid transparent; border-radius: 50%; color: transparent; font-size: 13px; font-weight: 800; transition: background .12s,transform .12s,border-color .12s; }
.fret.phrase-note-map .note-marker { background: var(--accent); border-color: #ddd6fe; color: #090b0f; box-shadow: 0 2px 5px rgba(0,0,0,.4); }
.fret.active .note-marker { background: var(--cyan); border-color: #cffafe; color: #090b0f; transform: scale(1.12); box-shadow: 0 0 0 3px rgba(103,232,249,.28), 0 2px 5px rgba(0,0,0,.4); }
.fret.upcoming .note-marker::after { content: ""; position: absolute; width: 42px; height: 42px; border: 2px solid var(--cyan); border-radius: 50%; }
.fret.upcoming:not(.active) .note-marker { color: #090b0f; }
.fret.active.upcoming .note-marker::after { width: 46px; height: 46px; border-color: var(--cyan); }
.fret.countdown-target .note-marker { background: var(--cyan); color: #090b0f; border: 2px solid var(--accent); transform: scale(1.12); box-shadow: 0 0 0 4px rgba(167,139,250,.18); }
.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; }

.tempo-section { display: grid; grid-template-columns: auto minmax(100px,1fr) 40px; align-items: center; gap: 13px; margin-top: 15px; }
.tempo-section label { margin: 0; }
#bpm { width: 100%; accent-color: var(--accent); }
#bpmDisplay { font-size: 12px; text-align: right; }
.controls { display: flex; gap: 9px; margin-top: 15px; }
.controls button { min-height: 40px; padding: 0 15px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; font-weight: 700; }
button:disabled { cursor: default; opacity: .75; }
.primary { flex: 1; background: var(--accent-strong); color: white; border-color: transparent !important; }
.primary:hover:not(:disabled) { background: #7c3aed; }
.secondary { background: var(--surface-raised); color: var(--text); }
.secondary:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-soft); }
#loopBtn.looping { background: rgba(139,92,246,.2); border-color: rgba(167,139,250,.5); color: #ddd6fe; }

@media (max-width: 1700px) { .scale-controls { grid-template-columns: repeat(4,minmax(150px,1fr)); } }
@media (max-width: 900px) {
  .page-heading { align-items: start; flex-direction: column; gap: 10px; }
  .scale-controls { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 620px) {
  .site-header, .page-heading { padding-right: 16px; padding-left: 16px; }
  .trainer-card { margin-right: 16px; margin-left: 16px; padding: 12px; }
  .scale-controls { grid-template-columns: 1fr; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; }
  .primary { grid-column: 1 / -1; }
}
