/* Zahlenfeld-Web — Grundlayout nach iOS-Vorbild (Light-Mode erzwungen,
   schwarze Nav-/Toolbar, vertikaler Darstellungs-Stack + Zahl + Knöpfe). */

@font-face {
  font-family: 'Grundschrift';
  src: url('Grundschrift-Regular.otf') format('opentype');
  font-display: swap;
  /* Es gibt nur dieses eine Face (400). Ohne diesen Bereich synthetisiert der Browser
     bei font-weight 600/700 Fettdruck — und zerlegt dabei Glyphen wie V, i, r in hohle
     Umrisse. Der Bereich sagt "deckt alle Gewichte ab" ⇒ keine Synthese. */
  font-weight: 100 900;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fff;
  color: #000;
  color-scheme: light;
}

body {
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Navigationsleiste ---------- */
#navbar {
  flex: 0 0 auto;
  min-height: 48px;
  background: #000;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  padding-top: env(safe-area-inset-top, 0);
  z-index: 40;
}
#navbar.hidden { display: none; }
/* Web-Ersatz für die iOS-Systemeinstellungen: holt die ausgeblendete Navbar zurück. */
#navReveal {
  position: fixed; right: 10px; z-index: 45;
  top: calc(8px + env(safe-area-inset-top, 0));
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid rgba(0,0,0,0.2);
  background: rgba(255,255,255,0.85); color: #333;
  font-size: 18px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: background 0.2s;
}
#navReveal:hover { background: #fff; }
#navReveal.hidden { display: none; }
/* Per Reveal eingeblendet liegt der ✕-Knopf über der Leiste — rechts Platz schaffen. */
#navbar.nav-revealed { padding-right: 48px; }
.nav-group { display: flex; gap: 4px; }
.nav-btn {
  width: 42px; height: 42px;
  background: none; border: none; color: #fff;
  display: grid; place-items: center;
  cursor: pointer; border-radius: 8px;
}
.nav-btn:active { background: rgba(255,255,255,0.2); }
.nav-btn svg { width: 24px; height: 24px; fill: currentColor; }
.nav-btn.recording { color: rgb(255,60,60); }

/* ---------- Darstellungs-Stack ---------- */
#stack {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 20px 4px;
  /* min-height:auto — der Stack meldet den Mindestplatz seiner Darstellungen an,
     dadurch schrumpfen ZahlPicker/ActionView mit (iOS-Prioritäten-Äquivalent) */
  overflow: hidden;
}
.anzeige {
  flex: 0 0 auto;
  overflow: hidden;
  position: relative;
  transition: opacity 0.3s;
}
.anzeige.versteckt { display: none; }
.feld-flex { flex: 1 1 0; min-height: 48px; }
#zahlenlinieContainer { flex: 0 1 160px; min-height: 84px; }
#pfeilContainer { flex: 0 1 100px; min-height: 56px; }
.sprachzeile { flex: 0 1 40px; min-height: 22px; }

/* ---------- ZahlPicker-Bereich ---------- */
#zahlContainer {
  flex: 0 2 200px; /* schrumpft bei Platzmangel doppelt so schnell wie der Stack */
  min-height: 90px;
  width: 250px;
  max-width: 60vw;
  align-self: center;
  margin: 4px 0 2px;
  transition: flex-basis 0.3s, opacity 0.3s;
}
#zahlContainer.versteckt { flex-basis: 0; min-height: 0; opacity: 0; pointer-events: none; margin: 0; }

/* ---------- ActionView-Bereich ---------- */
#actionViewContainer {
  flex: 0 1 100px;
  min-height: 56px;
  margin: 0 20px 16px;
  transition: flex-basis 0.3s, opacity 0.3s;
}
/* min-height/overflow zurücksetzen, sonst bleibt die 56px-Geisterleiste stehen
   (die Start-Einblendung setzt opacity inline und schlägt die Klasse). */
#actionViewContainer.versteckt {
  flex-basis: 0; min-height: 0; overflow: hidden;
  opacity: 0; pointer-events: none; margin: 0 20px;
}

/* ---------- Toolbar ---------- */
#toolbar {
  flex: 0 0 auto;
  background: #000;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 40;
}
.toolbar-inner {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 4px 20px;
}
.tb-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; color: #fff;
  font-size: 15px;
  height: 40px;
  min-width: 44px;
  cursor: pointer;
  border-radius: 8px;
  justify-content: center;
}
.tb-btn:active { background: rgba(255,255,255,0.2); }
.tb-btn img { height: 28px; max-width: 52px; object-fit: contain; filter: invert(1); }
.tb-icon img { height: 30px; }
#btnBlitzblick.selected { background: rgba(255,255,255,0.32); }
.tb-btn.gedimmt { opacity: 0.2; }

.segmented {
  display: flex;
  background: rgba(255,255,255,0.52); /* wie Rechenfeld: halbtransparentes Weiß auf schwarzer Toolbar */
  border-radius: 7px;
  padding: 2px;
  height: 36px;
}
.segmented button {
  border: none; background: transparent;
  border-radius: 5px;
  width: 38px;
  display: grid; place-items: center;
  cursor: pointer;
}
.segmented button img { height: 22px; }
.segmented button.selected { background: #fff; } /* wie Rechenfeld */

.tb-farben { display: flex; gap: 10px; }
.color-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.color-btn.gedimmt { opacity: 0.2; }

/* ---------- Menüs & Popover ---------- */
.menu, .popover {
  position: fixed;
  z-index: 60;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  padding: 6px;
}
.hidden { display: none !important; }
.menu .menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 14px;
  border: none; background: none;
  font-size: 16px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.menu .menu-item:hover { background: #eee; }
.menu .menu-item img { height: 22px; width: 44px; object-fit: contain; }
.menu .menu-item .check { width: 18px; }

.popover.dark {
  background: #1c1c1e; color: #fff;
  padding: 20px;
  max-height: 70vh; overflow-y: auto;
  width: 320px;
}
.popover.dark h3 { font-size: 22px; margin-bottom: 14px; }
.check-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 0;
  font-size: 16px;
  width: 100%;
  border: none; background: none; color: #fff;
  cursor: pointer;
  text-align: left;
}
.check-row .dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #8e8e93;
  display: grid; place-items: center;
  flex: 0 0 24px;
  font-size: 15px;
}
.check-row.an .dot { background: #34c759; border-color: #34c759; color: #fff; }
.check-row hr { border: none; }
.popover-trenner { border: none; border-top: 1px solid #3a3a3c; margin: 10px 0; }

/* ---------- Sheets & Alerts ---------- */
.sheet {
  position: fixed; inset: 0;
  z-index: 70;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.sheet-card {
  background: #f2f2f7;
  border-radius: 14px;
  width: min(680px, 94vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sheet-card.dark { background: #1c1c1e; color: #fff; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 8px;
}
.sheet-head h2 { font-size: 28px; font-weight: 700; }
.close-btn {
  border: none; border-radius: 10px;
  background: none;
  color: #0a84ff;
  font-size: 17px; font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
}
#settingsBody { overflow-y: auto; padding: 0 20px 20px; }
.settings-section { margin-top: 18px; }
.settings-section > .section-title {
  font-size: 13px; color: #98989e;
  text-transform: uppercase;
  padding: 0 16px 6px;
}
.settings-group { background: #2c2c2e; border-radius: 10px; overflow: hidden; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 11px 16px;
  font-size: 16px;
  border-top: 0.5px solid rgba(255,255,255,0.15);
}
.settings-row:first-child { border-top: none; }
.settings-row .row-label { flex: 1; }
.settings-row input[type="range"] { flex: 1; }
.settings-info { font-size: 14px; line-height: 1.5; padding: 12px 16px; color: #d1d1d6; }
.settings-info a { color: #0a84ff; }
.settings-info h4 { margin: 10px 0 4px; color: #fff; }
.seg-textual { display: flex; background: rgba(255,255,255,0.12); border-radius: 8px; padding: 2px; flex-wrap: wrap; }
.seg-textual button {
  border: none; background: transparent;
  padding: 5px 10px; border-radius: 6px;
  font-size: 14px; cursor: pointer; color: #fff;
}
.seg-textual button.selected { background: #636366; }

/* iOS-artiger Switch (dunkel) */
.uiswitch {
  position: relative;
  width: 51px; height: 31px;
  flex: 0 0 51px;
  border-radius: 16px;
  border: none;
  background: rgba(120,120,128,0.32);
  cursor: pointer;
  transition: background 0.25s;
}
.uiswitch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  transition: transform 0.25s;
}
.uiswitch.on { background: #34c759; }
.uiswitch.on::after { transform: translateX(20px); }

.alert-card {
  background: #f2f2f7;
  border-radius: 14px;
  width: min(320px, 88vw);
  padding: 20px;
  text-align: center;
}
.alert-card h3 { font-size: 17px; margin-bottom: 6px; }
.alert-card p { font-size: 14px; margin-bottom: 12px; }
.alert-card input {
  width: 100%;
  font-size: 20px;
  text-align: center;
  padding: 8px;
  border: 1px solid #ccc; border-radius: 8px;
  margin-bottom: 14px;
  background: #fff;
}
.alert-buttons { display: flex; gap: 10px; }
.alert-buttons button {
  flex: 1;
  padding: 10px;
  border: none; border-radius: 10px;
  background: #e5e5ea;
  font-size: 16px;
  cursor: pointer;
}
.alert-buttons .primary { background: #0a7bff; color: #fff; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  #stack { padding: 3px 8px; }
  .toolbar-inner { justify-content: center; padding: 3px 8px; }
  #actionViewContainer { margin: 0 8px 12px; }
}
@media (max-height: 480px) {
  #navbar { min-height: 40px; }
  .nav-btn { width: 36px; height: 36px; }
  #zahlContainer { flex-basis: 130px; }
  #actionViewContainer { flex-basis: 70px; }
}

/* Teilen-Sheet */
.teilen-body { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 4px 4px; }
.teilen-qr { width: 220px; height: 220px; background: #fff; border-radius: 8px; padding: 8px; box-sizing: content-box; }
.teilen-link { width: 100%; font: 13px/1.4 ui-monospace, monospace; padding: 9px 11px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); color: #eee; box-sizing: border-box; }
.teilen-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.teilen-btn { padding: 10px 16px; font: inherit; border-radius: 8px; border: none; cursor: pointer;
  background: #3F8B81; color: #fff; }
.teilen-btn-secondary { background: rgba(255,255,255,0.15); }
.teilen-btn:active { opacity: 0.8; }
