:root {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d22;
  --panel-2: #20282f;
  --paper: #fffaf0;
  --text: #f4efe7;
  --muted: #aeb7bf;
  --line: #303a43;
  --accent: #7ab6d6;
  --accent-2: #e0c06a;
  --green: #36a76b;
  --yellow: #d3a928;
  --red: #c95252;
  --black: #151719;
  --blue: #4f8cff;
}

body.light {
  color-scheme: light;
  --bg: #f2efe7;
  --panel: #fffaf0;
  --panel-2: #e9e1d2;
  --text: #171b1f;
  --muted: #5e6770;
  --line: #d3c8b8;
  --accent: #336f8e;
  --accent-2: #8b6d19;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 14px;
  font-weight: 800;
}

button:disabled {
  opacity: 0.42;
}

button:active {
  transform: scale(0.98);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 28vw) 1fr;
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.library-panel,
.work-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.library-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.work-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand-row,
.toolbar,
.score-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toolbar {
  min-height: 92px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.metric-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 30px;
}

h3 {
  margin-bottom: 8px;
  font-size: 22px;
}

.icon-button {
  width: 48px;
  padding: 0;
  font-size: 22px;
}

.mode-tabs,
.button-row,
.status-strip,
.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.mode-tab.active {
  background: var(--accent);
  color: #101418;
  border-color: var(--accent);
}

.search-row input {
  flex: 1;
  min-width: 170px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 0 12px;
}

.song-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.song-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
  text-align: left;
}

.song-card.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.song-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 900;
}

.song-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.screen {
  display: none;
  flex: 1;
  min-height: 0;
  padding: 18px 22px;
  overflow: auto;
}

.screen.active {
  display: block;
}

.welcome-grid,
.calibration-layout,
.practice-layout {
  display: grid;
  gap: 16px;
  height: 100%;
}

.welcome-grid {
  grid-template-columns: 1.6fr 1fr;
}

.calibration-layout {
  grid-template-columns: minmax(270px, 1fr) minmax(360px, 1.25fr) 260px;
}

.practice-layout {
  grid-template-columns: 1fr 280px;
}

.welcome-copy,
.signal-card,
.guess-card,
.keyboard-card,
.summary-card,
.score-area,
.practice-sidebar {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 18px;
}

.note-guess {
  font-size: clamp(64px, 9vw, 116px);
  font-weight: 950;
  line-height: 1;
}

.confidence-line,
.summary-card p,
.practice-sidebar p,
.welcome-copy p {
  color: var(--muted);
  line-height: 1.45;
}

.big-metric,
.summary-number {
  margin: 0 0 8px;
  font-size: 42px;
  font-weight: 950;
}

.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  gap: 9px;
}

.keyboard-grid button.selected {
  background: var(--accent);
  color: #101418;
}

.practice-layout,
.score-area {
  min-height: 0;
}

.score-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.notation-strip {
  display: flex;
  gap: 14px;
  min-height: 0;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  padding: 12px 0 8px;
}

.measure-card {
  flex: 0 0 260px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: #151719;
  padding: 14px;
}

.measure-card.active {
  border-color: var(--blue);
}

.measure-label {
  margin-bottom: 10px;
  color: #5b6268;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.note-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-chip {
  min-width: 48px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: white;
  font-weight: 900;
}

.note-chip.upcoming,
.dot.upcoming {
  background: var(--black);
}

.note-chip.active,
.dot.active {
  background: var(--blue);
}

.note-chip.correct,
.dot.correct {
  background: var(--green);
}

.note-chip.close,
.dot.close {
  background: var(--yellow);
}

.note-chip.wrong,
.dot.wrong {
  background: var(--red);
}

.legend {
  display: grid;
  gap: 8px;
}

.legend span {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.status-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 800;
}

.status-pill.muted {
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .calibration-layout,
  .practice-layout,
  .welcome-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    width: auto;
  }
}
