/* Exact Tune – hell & warm, folgt dem Dunkelmodus des Systems */
:root {
  --bg: #f3eee6;
  --surface: #fffaf2;
  --surface-2: #ebe4d8;
  --ink: #1d2230;
  --muted: #7d7f86;
  --track: #e1d9cb;
  --tick: #b9b1a3;
  --accent: #e2553a;      /* Marke: Koralle */
  --accent-ink: #ffffff;
  --good: #1f9d6b;
  --near: #d99a12;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 18px rgba(60, 40, 20, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141c;
    --surface: #1a2030;
    --surface-2: #232a3c;
    --ink: #eef0f4;
    --muted: #8a91a0;
    --track: #283044;
    --tick: #4a5368;
    --accent: #ff7a5c;
    --accent-ink: #1b0d08;
    --good: #35c98c;
    --near: #f0b62e;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  position: relative;
}

/* ---------- Kopf ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
.brand {
  font-size: 22px; font-weight: 600; letter-spacing: .02em;
  display: flex; align-items: center; gap: 5px;
}
.brand i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block;
}
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); }
.icon-btn:active { background: var(--surface-2); }

/* ---------- Instrument-Tabs ---------- */
.tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 6px 20px 4px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: flex; align-items: center; gap: 7px;
  padding: 9px 14px 9px 10px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow);
  font-size: 15px; font-weight: 550; color: var(--muted);
  transition: background .15s, color .15s;
}
.tab svg { flex: 0 0 auto; }
.tab.on { background: var(--ink); color: var(--bg); }
.tuning-line { padding: 10px 20px 0; font-size: 13px; color: var(--muted); letter-spacing: .04em; }

/* ---------- Zeigerbogen ---------- */
.gauge { position: relative; flex: 1 1 auto; min-height: 250px; }
#gaugeCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.center {
  position: absolute; left: 0; right: 0; bottom: 6%;
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
}
.big-note {
  font-size: clamp(72px, 22vw, 112px); font-weight: 700; line-height: .95;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.big-note sub { font-size: .28em; font-weight: 600; vertical-align: baseline; margin-left: 2px; color: var(--muted); letter-spacing: 0; }
.big-note.good { color: var(--good); }
.cents { font-size: 20px; font-weight: 650; margin-top: 6px; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.status {
  margin-top: 8px; font-size: 15px; font-weight: 600;
  padding: 6px 14px; border-radius: 99px; background: var(--surface-2); color: var(--muted);
  transition: background .2s, color .2s;
}
.status.off { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.status.near { background: color-mix(in srgb, var(--near) 18%, transparent); color: var(--near); }
.status.good { background: var(--good); color: #fff; }
.hz { margin-top: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Saiten ---------- */
.strings-panel { padding: 0 12px 10px; }
.mode {
  display: flex; margin: 0 auto 4px; width: fit-content;
  background: var(--surface-2); border-radius: 99px; padding: 4px;
}
.mode button { padding: 7px 14px; border-radius: 99px; font-size: 14px; color: var(--muted); font-weight: 550; }
.mode button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
#headSvg { display: block; width: 100%; height: min(44vh, 360px); }
.note-btn { cursor: pointer; }
.note-btn rect { fill: var(--surface); stroke: var(--track); stroke-width: 2; transition: fill .15s, stroke .15s; }
.note-btn text { fill: var(--ink); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.note-btn .n { font-size: 26px; font-weight: 700; }
.note-btn .oct { font-size: 13px; font-weight: 600; fill: var(--muted); }
.note-btn.active rect { fill: var(--accent); stroke: var(--accent); }
.note-btn.active text, .note-btn.active .oct { fill: var(--accent-ink); }
.note-btn.done rect { stroke: var(--good); stroke-width: 3; }
.note-btn.done.active rect { fill: var(--good); }
.note-btn.done.active text, .note-btn.done.active .oct { fill: #fff; }
.string { stroke-linecap: round; transition: stroke .15s, opacity .15s; }
.string.active { stroke: var(--accent); }
.string.done.active { stroke: var(--good); }
.string.wind.active { opacity: .35; }

/* ---------- Trommel ---------- */
.drum-panel { padding: 0 16px 16px; }
.drum-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: 22px; padding: 12px; box-shadow: var(--shadow);
}
#drumSvg { width: 42%; max-width: 190px; flex: 0 0 auto; }
.drum-side { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.target-label { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.target { display: flex; align-items: center; gap: 10px; }
.step { width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2); font-size: 22px; line-height: 1; }
.step.small { width: 34px; height: 34px; font-size: 18px; }
.step:active, .primary:active, .tab:active { transform: scale(.96); }
.target-val { text-align: center; min-width: 76px; }
.target-note { font-size: 24px; font-weight: 750; }
.target-hz { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.link-btn { font-size: 13px; color: var(--accent); font-weight: 600; padding: 4px 6px; }
.lug-nav { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.drum-tip { color: var(--muted); font-size: 13px; text-align: center; line-height: 1.45; margin: 10px 4px 0; }

.drum-head { fill: var(--surface-2); stroke: var(--tick); stroke-width: 6; }
.lug circle { fill: var(--surface); stroke: var(--tick); stroke-width: 2; transition: fill .15s; }
.lug text { fill: var(--ink); font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.lug.active circle { fill: var(--accent); stroke: var(--accent); }
.lug.active text { fill: var(--accent-ink); }
.lug.done circle { stroke: var(--good); }
.lug.done.active circle { fill: var(--good); stroke: var(--good); }
.lug.done.active text { fill: #fff; }
.tap-mark { fill: none; stroke: var(--accent); stroke-width: 3; }

/* ---------- Start ---------- */
.start-overlay {
  position: absolute; inset: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 24px;
}
.start-card { background: var(--surface); border-radius: 24px; padding: 28px 24px; text-align: center; max-width: 360px; box-shadow: var(--shadow); }
.start-icon { width: 68px; height: 68px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.start-card h2 { margin: 6px 0 8px; font-size: 21px; }
.start-card p { color: var(--muted); line-height: 1.5; font-size: 15px; margin: 0 0 20px; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 14px 28px; border-radius: 99px; font-size: 16px; }

/* ---------- Einstellungen ---------- */
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  animation: up .22s ease-out; max-height: 85%; overflow-y: auto;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 40px; height: 5px; border-radius: 99px; background: var(--track); margin: 0 auto 12px; }
.sheet h3 { margin: 4px 0 10px; font-size: 18px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--track); }
.s-title { font-weight: 600; }
.s-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 99px; padding: 4px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; background: var(--surface); font-size: 20px; }
.stepper span { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.seg { display: flex; background: var(--surface-2); border-radius: 99px; padding: 4px; }
.seg button { padding: 7px 14px; border-radius: 99px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--bg); font-weight: 700; }
.about { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 16px 0 0; }

@media (max-height: 680px) {
  .gauge { min-height: 210px; }
  .big-note { font-size: 72px; }
  #headSvg { height: 38vh; }
}

/* ---------- Startbildschirm ---------- */
.intro {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg);
  transition: opacity .28s ease-out, visibility .28s;
}
.intro img { width: 140px; height: 140px; border-radius: 32px; }
.intro-name { font-size: 40px; font-weight: 650; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.intro-name i { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.intro-tag { font-size: 15px; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.intro.gone { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .intro { transition: none; } }

/* ---------- Trommel-Auswahl ---------- */
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.chips:empty { display: none; }
.chip {
  padding: 8px 14px; border-radius: 99px; font-size: 14px; font-weight: 600;
  background: var(--surface); color: var(--muted); box-shadow: var(--shadow);
}
.chip.on { background: var(--ink); color: var(--bg); }
.chips.small .chip { padding: 6px 12px; font-size: 13px; }
.chips.small .chip.on { background: var(--accent); color: var(--accent-ink); }
.seg.mini { padding: 3px; }
.seg.mini button { padding: 4px 10px; font-size: 12px; }
.lug-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* Sprache: 5 Knöpfe nebeneinander, Zeile darf umbrechen */
.setting.wrap { flex-wrap: wrap; }
#langSeg button { padding: 7px 11px; }
#namesSeg button { padding: 7px 11px; }

/* Fokus sichtbar für Tastatur/Barrierefreiheit */
button:focus-visible, .note-btn:focus-visible, .lug:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.seg button, .chip, .mode button { white-space: nowrap; }

/* Bewerten / Teilen */
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.action {
  flex: 1 1 140px; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-weight: 600; font-size: 14px;
}
.action:first-child { background: var(--accent); color: var(--accent-ink); }
.action:active { transform: scale(.97); }

/* Referenzton: Knopf pulsiert, solange der Ton klingt */
@keyframes ring { 0% { stroke-width: 3; stroke-opacity: 1; } 100% { stroke-width: 14; stroke-opacity: 0; } }
.note-btn.playing rect { stroke: var(--accent); animation: ring 0.9s ease-out infinite; }
#drumTargetVal { cursor: pointer; border-radius: 12px; padding: 2px 6px; }
#drumTargetVal::after { content: "♪"; display: block; font-size: 12px; color: var(--accent); }
#drumTargetVal.playing { background: color-mix(in srgb, var(--accent) 14%, transparent); }
@media (prefers-reduced-motion: reduce) { .note-btn.playing rect { animation: none; } }

/* Hinweis unten */
.toast {
  position: absolute; left: 16px; right: 16px; bottom: calc(18px + var(--safe-bottom)); z-index: 25;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 16px;
  font-size: 14px; font-weight: 550; text-align: center; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }
#sensSeg button { padding: 7px 10px; }
.note-btn:focus, .lug:focus { outline: none; }
.diag { font-family: ui-monospace, monospace; font-size: 11px; margin-top: 6px; overflow-wrap: anywhere; }

/* ---------- Kleine oder gezoomte Bildschirme ----------
   Feste Teile (Kopfzeile, Reiter, Saiten) werden nie zusammengedrückt; der Zeigerbogen
   gibt nach. Reicht der Platz trotzdem nicht, lässt sich die Seite scrollen statt zu überlappen. */
.app { overflow-y: auto; overflow-x: hidden; }
.top, .tabs, .tuning-line, .strings-panel, .drum-panel { flex-shrink: 0; }
.gauge { min-height: 230px; flex: 1 0 230px; }
.tab { min-height: 40px; }
.big-note { font-size: clamp(56px, min(22vw, 11vh), 112px); }
#headSvg { height: clamp(220px, 40vh, 360px); }
@media (max-height: 700px) {
  .gauge { min-height: 210px; flex-basis: 210px; }
  .cents { font-size: 17px; margin-top: 2px; }
  .status { margin-top: 4px; font-size: 14px; padding: 4px 12px; }
  .hz { margin-top: 3px; font-size: 12px; }
}

/* ---------- Nur im Browser: Hinweis auf die App ---------- */
.get-app {
  flex-shrink: 0; align-self: center; margin: -2px 0 4px;
  padding: 6px 14px; border-radius: 99px; font-size: 13px; font-weight: 650;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}
.get-app::after { content: " ›"; }
.privacy-link { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
