:root {
  --color-bg: #f6efdc;
  --color-surface: #fffdf8;
  --color-surface-alt: #f3ecd9;
  --color-text: #3a3226;
  --color-text-dim: #8a7f68;
  --color-accent: #c9a961;
  --color-accent-light: #e9d49a;
  --color-accent-dark: #9c7d3a;
  --color-green: #8a6a1f;
  --color-orange: #b5651d;
  --color-red: #b4584c;
  --color-border: #e0d5b8;
  --font-serif: 'Optima', 'Georgia', 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(130% 90% at 50% -10%, #fffdf6 0%, #f6efdc 45%, #ede3c8 100%);
  color: var(--color-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  overflow: hidden;
}

.app::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: repeating-linear-gradient(115deg, #fff 0px, #fff 1px, transparent 1px, transparent 3px);
  pointer-events: none;
  z-index: 0;
}

.app > * {
  position: relative;
  z-index: 1;
}

.app__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app__title {
  font-size: 0.78rem;
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--color-accent-dark);
  margin: 0 0 6px 0;
  position: relative;
}

.app__title::after {
  content: "";
  display: block;
  width: 38px;
  height: 1px;
  margin-top: 6px;
  background: linear-gradient(90deg, var(--color-accent), transparent);
}

.app__subtitle {
  font-size: 0.68rem;
  color: var(--color-text-dim);
  margin: 0;
  letter-spacing: 0.2px;
}

/* Schieber: dezente Tiefe (sanftes Highlight oben, weicher Schatten unten),
   bewusst zwischen flacher Pille und stark vertieftem Mechanik-Look. */
.reference-switch {
  position: relative;
  display: flex;
  flex: 1 1 230px;
  max-width: 260px;
  background: var(--color-surface-alt);
  border-radius: 999px;
  padding: 4px;
  box-shadow: inset 0 1px 3px rgba(154, 130, 70, 0.22), inset 0 -1px 0 rgba(255, 255, 255, 0.4);
}

.reference-switch__thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(33.3333% - 2.667px);
  border-radius: 999px;
  background: linear-gradient(165deg, #f8edc9, var(--color-accent));
  border: 1px solid #b48f45;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), 0 2px 5px rgba(120, 95, 35, 0.3);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.reference-switch__thumb[data-index="1"] {
  transform: translateX(100%);
}

.reference-switch__thumb[data-index="2"] {
  transform: translateX(200%);
}

.reference-switch__option {
  position: relative;
  z-index: 1;
  flex: 1;
  border: none;
  background: transparent;
  color: var(--color-text-dim);
  padding: 10px 10px;
  min-height: 48px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.2s ease-out;
}

.reference-switch__option[aria-pressed="true"] {
  color: #3a2a0f;
}

.start-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  text-align: center;
  padding: 24px;
}

.start-screen__text {
  color: var(--color-text-dim);
  max-width: 320px;
  line-height: 1.5;
}

.start-button {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 28%, #fdf8e8 0%, #f0dfa9 35%, var(--color-accent) 75%, #a9823f 100%);
  color: var(--color-text);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 6px #fffdf8, 0 0 0 9px var(--color-border), 0 10px 24px rgba(154, 130, 70, 0.3);
}

.start-button::after {
  content: "";
  position: absolute;
  top: 10%;
  left: 20%;
  width: 45%;
  height: 22%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0));
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.start-screen__error {
  color: var(--color-red);
  max-width: 340px;
  line-height: 1.5;
  background: var(--color-surface-alt);
  border-radius: 12px;
  padding: 16px;
}

.tuner {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.string-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.string-button {
  flex: 1;
  min-height: 56px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: linear-gradient(180deg, #fffefb, var(--color-surface-alt));
  color: var(--color-text);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -3px 4px rgba(154, 130, 70, 0.12), 0 3px 6px rgba(154, 130, 70, 0.18);
  transition: background 0.2s ease-out, border-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

.string-button__speaker {
  font-size: 0.85rem;
  opacity: 0.75;
}

.string-button[aria-pressed="true"] {
  border-color: var(--color-accent);
  box-shadow: inset 0 0 0 2px var(--color-accent);
}

.string-button--active {
  background: linear-gradient(160deg, var(--color-surface-alt), var(--color-surface));
  border-color: var(--color-accent);
}

/* In-Tune-Saite: Gold statt Gruen, mit dezenter Tiefe (Mittelweg zwischen
   flacher Flaeche und ueberladener Cabochon-Fassung). */
.string-button--in-tune {
  background: linear-gradient(160deg, #f8edc9 0%, var(--color-accent) 100%);
  border-color: #b48f45;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.55), 0 2px 5px rgba(120, 95, 35, 0.28);
  color: #3a2a0f;
}

.string-button--in-tune .string-button__speaker {
  opacity: 0.85;
}

/* Zifferblatt: rundes, kuehles Silber-Sunburst mit Gehaeusering, angelehnt an
   klassische Uhren-Dials (z. B. Longines Conquest). */
.note-display {
  width: 220px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #ffffff 0%, #eef0f1 35%, #d7dbdd 68%, #b9c0c3 100%);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 7px #fbfcfd, 0 0 0 10px #d5dadf, 0 10px 26px rgba(90, 100, 112, 0.2), inset 0 0 16px rgba(90, 100, 112, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Feiner Sunburst-Schimmer (dezent, kein Moiré). */
.note-display::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.4) 0deg 1.5deg, rgba(130, 138, 146, 0.1) 1.5deg 3deg);
  mix-blend-mode: soft-light;
  opacity: 0.5;
  pointer-events: none;
}

/* Glasreflex oben links, wie bei einem gewoelbten Uhrglas. */
.note-display::after {
  content: "";
  position: absolute;
  top: 4%;
  left: 14%;
  width: 52%;
  height: 20%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.note-display__name {
  font-family: var(--font-serif);
  font-size: 4rem;
  font-weight: 400;
  line-height: 1;
  color: #292d33;
  position: relative;
  z-index: 1;
}

.note-display__details {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  color: #7b8188;
  font-size: 0.95rem;
  position: relative;
  z-index: 1;
}

.note-display__details span:nth-child(2) {
  color: #1f3a5f;
}

.gauge {
  background: linear-gradient(165deg, var(--color-surface), var(--color-surface-alt));
  border: 1px solid var(--color-border);
  border-radius: 18px;
  padding: 16px 16px 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 6px 20px rgba(154, 130, 70, 0.12);
}

.gauge__svg {
  width: 100%;
  display: block;
}

.gauge__arc {
  fill: none;
  stroke-linecap: round;
}

/* Duenner, ruhiger Grundbogen. */
.gauge__arc--base {
  stroke: #a7adb5;
  stroke-width: 1.6;
}

/* Die zweite (weitere) Zone ist bewusst ausgeblendet, um das Bild ruhig zu
   halten – nur die eigentliche Toleranzzone wird hervorgehoben. */
.gauge__arc--orange {
  opacity: 0;
}

/* Toleranzzone: polierte Stahl-Applikation (hell in der Mitte) statt eines
   flaechigen Gruentons. */
.gauge__arc--green {
  stroke: url(#steelZoneSymmetric);
  stroke-width: 7;
  opacity: 1;
  filter: drop-shadow(0 1px 1px rgba(20, 22, 25, 0.2));
}

/* Gebläuter Stahlzeiger mit Glanzverlauf, ohne Aussenleuchten – der Status
   wird ausschliesslich ueber den Text unter der Anzeige vermittelt. */
.gauge__needle {
  stroke: url(#bluedSteel);
  stroke-width: 2.6;
  stroke-linecap: round;
  transition: x2 0.18s ease-out, y2 0.18s ease-out, opacity 0.3s ease-out;
  opacity: 1;
}

/* Solange kein Ton erkannt wird, bleibt der Zeiger an der zuletzt
   gemessenen Position stehen. Die Farbe bleibt immer das volle, satte
   Dunkelblau – nur das Ziffernblatt drumherum dimmt sich leicht ab. */
.gauge__needle--idle {
  opacity: 1;
}

.note-display--idle {
  opacity: 0.55;
}

.gauge__pivot {
  fill: url(#bluedSteelPivot);
}

.gauge__scale {
  display: flex;
  justify-content: space-between;
  color: var(--color-text-dim);
  font-size: 0.85rem;
  padding: 0 4px;
}

.status-text {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 1px;
  min-height: 1.4em;
  margin: 0;
}

.status-text--green { color: var(--color-green); }
.status-text--orange { color: var(--color-orange); }
.status-text--red { color: var(--color-red); }
.status-text--idle { color: var(--color-text-dim); }

.mode-row {
  display: flex;
  justify-content: center;
}

.mode-button {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-dim);
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  cursor: pointer;
}

.mode-button:hover,
.mode-button:focus-visible {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.mode-button--hidden {
  visibility: hidden;
}

.footer-note {
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-text-dim);
  font-size: 0.8rem;
  margin: 0;
}

.footer-note::before {
  content: "";
  display: block;
  width: 60px;
  height: 1px;
  margin: 0 auto 10px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

/* Eigener, dezenter Hinweis des Seitenbetreibers (kein Drittanbieter-Werbe-
   banner, kein Pop-up, nichts zum Wegklicken) – daher bewusst ruhig gehalten
   und passend zum restlichen, zurückhaltenden Design. */
.promo-note {
  text-align: center;
  color: var(--color-text-dim);
  font-size: 0.8rem;
  line-height: 1.5;
  max-width: 360px;
  margin: 4px auto 8px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.promo-note__links {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.promo-note__button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 999px;
  background: linear-gradient(145deg, #f7efd8, var(--color-accent));
  border: 1px solid #b48f45;
  color: #3a2a0f;
  font-weight: 600;
  letter-spacing: 0.3px;
  font-size: 0.85rem;
  text-decoration: none;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), 0 2px 6px rgba(154, 110, 40, 0.25);
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

.promo-note__button:hover,
.promo-note__button:focus-visible {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), 0 4px 10px rgba(154, 110, 40, 0.35);
}

.promo-note__button:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 2px rgba(120, 90, 30, 0.35);
}

.faq-note {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 4px 16px;
}

.faq-note details {
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.faq-note details:last-child {
  border-bottom: none;
}

.faq-note summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
}

.faq-note p {
  margin: 8px 0 0 0;
  font-size: 0.78rem;
  color: var(--color-text-dim);
  line-height: 1.5;
}

.donate-note {
  text-align: center;
  color: var(--color-text-dim);
  font-size: 0.8rem;
  line-height: 1.5;
  margin-top: 16px;
}

.donate-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid rgba(156, 125, 58, 0.35);
  background: transparent;
  color: var(--color-accent-dark);
  text-decoration: none;
  font-size: 0.8rem;
}

.donate-link:hover,
.donate-link:focus-visible {
  border-color: rgba(156, 125, 58, 0.6);
}

.legal-note {
  text-align: center;
  color: var(--color-text-dim);
  font-size: 0.72rem;
  margin-top: 14px;
}

.legal-note a {
  color: var(--color-text-dim);
  text-decoration: underline;
}

.legal-note a:hover,
.legal-note a:focus-visible {
  color: var(--color-accent-dark);
}

.promo-note__badge {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 999px;
  background: linear-gradient(145deg, #f7efd8, var(--color-accent));
  border: 1px solid #b48f45;
  color: #3a2a0f;
  font-weight: 600;
}

/* Kleinere/ältere Handys (z.B. iPhone SE) ohne Adressleisten-Puffer: der
   komplette Stimmbereich (Saiten, Zifferblatt, Zeiger, Status) muss beim
   Laden ohne Scrollen sichtbar sein – dafür hier gezielt verdichtet, ohne
   die großzügige Optik auf normal hohen Bildschirmen zu verändern. */
@media (max-height: 700px) {
  .app {
    padding: 10px;
    gap: 8px;
  }

  .tuner {
    gap: 10px;
  }

  .string-button {
    min-height: 44px;
  }

  .note-display {
    width: 160px;
  }

  .note-display__name {
    font-size: 2.8rem;
  }

  .gauge {
    padding: 10px 10px 4px;
  }

  .mode-button {
    min-height: 40px;
  }
}
