:root {
  color-scheme: light;
  --bg: #f5eee2;
  --surface: #fffdf8;
  --paper: #fffefb;
  --ink: #2a1f17;
  --muted: #7b6b5d;
  --line: #e7dccb;
  --accent: #b0481f; /* Geigenlack */
  --accent-dark: #8c3413;
  --accent-soft: #fbe6d8;
  --good: #23874a;
  --good-soft: #dff3e4;
  --fair: #b97f00;
  --bad: #c93a2b;
  --gold: #eda400;
  /* Jede Saite hat ihre Farbe - im Notenblatt wie auf dem Griffbrett. */
  --str-g: #6a47c2;
  --str-d: #1b74c5;
  --str-a: #c7306a;
  --str-e: #cf7c00;
  --radius: 18px;
  font-family: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.string-G { --str: var(--str-g); }
.string-D { --str: var(--str-d); }
.string-A { --str: var(--str-a); }
.string-E { --str: var(--str-e); }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
small { font-size: 13px; color: var(--muted); font-weight: 500; }
a { color: inherit; text-decoration: none; }

button, a, label {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.icon {
  width: 24px;
  height: 24px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}
.icon-button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  white-space: nowrap;
}
.button:active { transform: translateY(1px); }
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.primary.active { background: var(--ink); border-color: var(--ink); }
.button.quiet { border-color: transparent; background: transparent; color: var(--muted); padding: 0 8px; }

.stars { display: inline-flex; gap: 1px; font-size: 18px; line-height: 1; }
.stars i { font-style: normal; color: #ddd2c1; }
.stars i.on { color: var(--gold); }
.stars.big { font-size: 54px; gap: 6px; }

/* ------------------------------------------------------------ Übersicht */

.home {
  max-width: 720px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 40px;
  display: grid;
  gap: 16px;
}

.hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.hero p { color: var(--muted); font-weight: 500; }

.continue {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 8px 20px -10px var(--accent-dark);
}
.continue span { display: grid; min-width: 0; }
.continue small { color: #ffd9c4; font-weight: 600; }
.continue strong { font-size: 21px; font-weight: 800; line-height: 1.2; }
.continue .icon {
  width: 52px;
  height: 52px;
  padding: 13px;
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
}

.shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
}
.tile span { display: grid; min-width: 0; }
.tile strong { font-weight: 800; }
.tile small { line-height: 1.25; }
.tile .icon { width: 30px; height: 30px; color: var(--accent); }
.big-star { font-size: 30px; line-height: 1; color: var(--gold); }

.level {
  padding: 18px 18px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.level-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.level-badge {
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}
.level-count { font-size: 13px; color: var(--muted); font-weight: 600; }
.level h2 { font-size: 22px; font-weight: 800; }
.level > p { color: var(--muted); font-weight: 500; margin-bottom: 8px; }

.songs { list-style: none; margin: 0; padding: 0; }
.songs li + li { border-top: 1px solid var(--line); }
.song {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  min-height: 60px;
}
.song-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}
.song-text { display: grid; }
.song-text strong { font-weight: 700; line-height: 1.25; }
.song:hover strong { color: var(--accent); }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 4px 12px; }

/* ------------------------------------------------- Kopfzeile der Ansichten */

.bar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px;
  padding: max(6px, env(safe-area-inset-top)) 8px 6px;
}
.bar-title { display: grid; min-width: 0; text-align: center; }
.bar-title strong,
.bar-title small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar-title strong { font-size: 18px; font-weight: 800; line-height: 1.2; }

.progress {
  grid-column: 1 / -1;
  height: 5px;
  margin: 2px 6px 0;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.progress i { display: block; width: 0; height: 100%; border-radius: 3px; background: var(--good); transition: width 0.25s; }

/* ----------------------------------------------------------------- Üben */

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

.sheet {
  position: relative;
  overflow-y: auto;
  margin: 4px 8px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
.system + .system { margin-top: 2px; }
.system svg { display: block; width: 100%; height: auto; overflow: visible; }

.staff { color: var(--ink); }
.staff-line { stroke: #8a7b6d; stroke-width: 0.9; }
.bar-line { stroke: currentColor; stroke-width: 1.1; }
.ledger { stroke: currentColor; stroke-width: 1.1; }
.stem { stroke: currentColor; stroke-width: 1.3; }
.time-sig { font: 800 21px Georgia, 'Times New Roman', serif; text-anchor: middle; fill: currentColor; }

.note { color: var(--ink); }
.note.done.sauber { color: var(--good); }
.note.done.knapp { color: var(--fair); }
.note.current { color: var(--accent); }
.note-glow { fill: transparent; }
.note.current .note-glow { fill: var(--accent-soft); }
.note-hit { fill: transparent; cursor: pointer; }
.finger { fill: var(--str); }
.finger-text { font-size: 10.5px; font-weight: 800; fill: #fff; text-anchor: middle; }
.finger-text.narrow { font-size: 8.5px; }
.note-name { font-size: 10.5px; font-weight: 600; fill: var(--muted); text-anchor: middle; }
.note.current .note-name { fill: var(--accent-dark); font-weight: 800; }

.panel {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 6px 14px max(12px, env(safe-area-inset-bottom));
}
.panel-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.panel-foot { grid-column: 1 / -1; display: grid; gap: 8px; }

.target { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.target-name { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.target-grip { color: var(--muted); font-weight: 700; font-size: 15px; }

.status { min-height: 2.8em; overflow-wrap: anywhere; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--muted); }
.status[data-tone='good'] { color: var(--good); }
.status[data-tone='bad'] { color: var(--bad); }

.actions { display: flex; gap: 8px; }
.actions .button { flex: 1; padding: 0 10px; }

.mic-level { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.mic-level i { display: block; width: 0; height: 100%; background: var(--muted); }

.meter-track { position: relative; height: 16px; margin: 6px 0; border-radius: 8px; background: var(--line); }
.meter-zone {
  position: absolute;
  inset: 0 auto 0 50%;
  transform: translateX(-50%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--good) 38%, var(--line));
}
.meter-middle { position: absolute; inset: -3px auto -3px 50%; width: 2px; margin-left: -1px; background: var(--good); }
.meter-needle {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 10px;
  height: 28px;
  margin-left: -5px;
  border: 2px solid var(--surface);
  border-radius: 6px;
  background: var(--bad);
  transition: left 0.09s linear, background-color 0.15s;
}
.meter.good .meter-needle { background: var(--good); }
.meter.idle .meter-needle { opacity: 0; }
.meter-labels { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; color: var(--muted); }

/* Griffbrett */
.fingerboard { display: block; width: 100%; height: auto; }
.board { fill: #2d2421; }
.nut { fill: #efe5d3; stroke: #cdbfa8; }
.tape { stroke: rgba(255, 255, 255, 0.3); stroke-width: 1.4; }
.tape-label { font-size: 10px; font-weight: 800; fill: var(--muted); text-anchor: middle; }
.string { stroke: #bdb4a8; }
.string.active { stroke: var(--str); }
.open circle { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.open text { font-size: 12.5px; font-weight: 800; fill: var(--muted); text-anchor: middle; }
.open.on-string circle { stroke: var(--str); stroke-width: 2; }
.open.on-string text { fill: var(--str); }
.open.active circle { fill: var(--str); stroke: var(--str); }
.open.active text { fill: #fff; }
.target-dot circle { fill: var(--str); stroke: #fff; stroke-width: 2; }
.target-dot text { font-size: 12px; font-weight: 800; fill: #fff; text-anchor: middle; }
.live { fill: none; stroke: #fff; stroke-width: 3; }
.live.in-tune { stroke: #5fdc8a; }

/* Geschafft */
.finish {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(42, 31, 23, 0.5);
}
.finish[hidden] { display: none; }
.finish-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(100%, 400px);
  padding: 28px 22px 22px;
  border-radius: 26px;
  background: var(--surface);
  text-align: center;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.finish-card h2 { font-size: 24px; font-weight: 800; line-height: 1.2; }
.finish-card p { font-weight: 600; }
.finish-detail { color: var(--muted); font-size: 14px; }
.finish-actions { display: flex; gap: 10px; width: 100%; margin-top: 12px; }
.finish-actions .button { flex: 1; }
.finish-actions .icon { width: 20px; height: 20px; }
@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
}

/* Breit oder quer: Notenblatt links, Griffbrett und Anzeige rechts. */
@media (min-width: 900px), (min-width: 620px) and (max-height: 560px) {
  .play {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .play .bar { grid-column: 1 / -1; }
  .sheet { margin: 4px 0 12px 12px; padding: 12px 8px; }
  .panel {
    grid-template-columns: 1fr;
    align-content: start;
    justify-items: center;
    overflow-y: auto;
    padding: 4px 20px 16px;
  }
  .panel-main, .panel-foot { width: 100%; }
  .fingerboard { width: 168px; }
}
@media (min-width: 620px) and (max-height: 560px) {
  .panel { grid-template-columns: 84px minmax(0, 1fr); align-items: start; }
  .fingerboard { width: 100%; }
  .target-name { font-size: 34px; }
}

/* ------------------------------------------------------------ Stimmgerät */

.tuner { min-height: 100dvh; }
.tuner-body {
  display: grid;
  gap: 14px;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 20px 32px;
}
.string-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.string-button {
  position: relative;
  display: grid;
  justify-items: center;
  padding: 10px 0 8px;
  border: 3px solid var(--str);
  border-radius: 20px;
  background: var(--surface);
}
.string-button strong { font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--str); }
.string-button small { font-size: 11px; }
.string-button.locked { background: var(--str); }
.string-button.locked strong,
.string-button.locked small { color: #fff; }
.string-button.tuned::after {
  content: '✓';
  position: absolute;
  top: -9px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--good);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}
.tuner-display { display: grid; justify-items: center; padding-top: 6px; }
.tuner-name { font-size: 104px; font-weight: 800; line-height: 1; color: var(--muted); }
.tuner-name[data-string='G'] { color: var(--str-g); }
.tuner-name[data-string='D'] { color: var(--str-d); }
.tuner-name[data-string='A'] { color: var(--str-a); }
.tuner-name[data-string='E'] { color: var(--str-e); }
.tuner-cents { min-height: 1.4em; font-size: 18px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.tuner .status { text-align: center; }
.tuner .meter-track { height: 20px; border-radius: 10px; }
.tuner .meter-needle { height: 32px; }
.tip {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: #6b3a22;
  font-size: 14px;
  font-weight: 500;
}

/* --------------------------------------------------------- Einstellungen */

.settings {
  width: min(92vw, 440px);
  max-height: 90dvh;
  padding: 22px;
  border: 0;
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
}
.settings::backdrop { background: rgba(42, 31, 23, 0.5); }
.settings h2 { font-size: 24px; font-weight: 800; }
.settings h3 { margin: 18px 0 8px; font-size: 15px; font-weight: 800; }
.choices { display: grid; gap: 8px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice span { display: grid; }
.choice input, .switch input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.switch { display: flex; align-items: center; gap: 12px; padding: 8px 2px; font-weight: 600; cursor: pointer; }
.field { display: grid; gap: 6px; }
.field select {
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font: inherit;
  font-weight: 700;
  color: inherit;
}
.dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 20px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
