@font-face {
  font-family: "Source Serif 4";
  src: url("/fonts/source-serif-4.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
:root {
  --paper: #fbfaf6;
  --paper-raised: #f1efe8;
  --ink: #1d2326;
  --ink-soft: #566063;
  --rule: #d9d6cc;
  --teal: #0f5e5a;
  --teal-deep: #0a4744;
  --on-teal: #fbfaf6;
  --error: #a3261b;
  --taste-aktiv: #e0ddd2;
  --graph-1: #0072b2;
  --graph-2: #c24a00;
  --graph-3: #00806a;
  --graph-4: #b8508f;
  --graph-5: #9a6b00;
  --graph-6: #3a8fc7;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14191b;
    --paper-raised: #1e2527;
    --ink: #e9e7e0;
    --ink-soft: #9aa5a7;
    --rule: #2e383b;
    --teal: #5fc2ba;
    --teal-deep: #5fc2ba;
    --on-teal: #14191b;
    --error: #ff9b8f;
    --taste-aktiv: #2e383b;
    --graph-1: #2687be;
    --graph-2: #cb6526;
    --graph-3: #269380;
    --graph-4: #c36aa0;
    --graph-5: #a98126;
    --graph-6: #58a0cf;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 "Atkinson Hyperlegible Next", system-ui, sans-serif;
}
.seite { flex: 1; width: 100%; max-width: 70ch; margin: 0 auto; padding: 24px 16px; }
.rechner-seite { max-width: 34rem; }
h1, h2 { font-family: "Source Serif 4", Georgia, serif; font-weight: 500; line-height: 1.2; }
a { color: var(--teal); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.hinweis, .entwurf, .offen, .einleitung { color: var(--ink-soft); }
.entwurf { border: 1px solid var(--rule); padding: 8px 12px; border-radius: 6px; }
.zurueck { display: inline-block; min-height: 44px; line-height: 44px; }

.beschriftung {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}
#ausdruck {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.3;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.fehler {
  color: var(--error);
  min-height: 1.5em;
  margin: 8px 0 0;
}
.ergebnis-zeile {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 16px;
}
.ergebnis {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 1.1em;
  text-align: right;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 500;
  line-height: 1.1;
  font-feature-settings: "tnum" 1, "lnum" 1;
  overflow-wrap: anywhere;
}
.anzeige-umschalter {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 4px 8px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.anzeige-umschalter[aria-pressed="true"] {
  background: var(--teal);
  color: var(--on-teal);
  border-color: var(--teal);
}
.bruch-huelle {
  display: inline-flex;
  align-items: center;
  gap: 0.18em;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.bruch {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  font-size: 0.42em;
  line-height: 1.05;
  max-width: 100%;
}
.bruch-zaehler {
  padding: 0 0.18em 0.06em;
  border-bottom: 1.5px solid currentColor;
  overflow-wrap: anywhere;
  text-align: center;
}
.bruch-nenner {
  padding: 0.06em 0.18em 0;
  overflow-wrap: anywhere;
  text-align: center;
}
.nur-vorgelesen {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.umschalter { display: flex; gap: 8px; margin-bottom: 16px; }
.umschalt-taste {
  flex: 1;
  min-height: 44px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.umschalt-taste[aria-pressed="true"] {
  background: var(--teal);
  color: var(--on-teal);
  border-color: var(--teal);
}
.funktionen {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.funktionen[hidden] { display: none; }
.tastenfeld {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.taste {
  min-width: 44px;
  min-height: 56px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 120ms ease;
  padding: 4px;
}
.taste-operator, .taste-funktion { background: var(--paper); color: var(--teal); }
.taste:active { background: var(--taste-aktiv); }
.taste-gleich { background: var(--teal); color: var(--on-teal); border-color: var(--teal); }
.taste-gleich:active { background: var(--teal-deep); }
@media (prefers-reduced-motion: reduce) {
  .taste { transition: none; }
}
/* Graph und Reiter */
.ansicht { min-width: 0; }
.graph-canvas {
  display: block;
  width: 100%;
  height: 340px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  touch-action: none;
  cursor: grab;
}
.graph-canvas:active { cursor: grabbing; }
.graph-bereich { color: var(--ink-soft); font-size: 0.8125rem; margin: 8px 0; }
.graph-taste {
  min-height: 44px;
  padding: 4px 12px;
  margin-bottom: 16px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.graph-taste:disabled { color: var(--ink-soft); cursor: default; }
.graph-liste { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.graph-zeile { display: flex; align-items: flex-start; gap: 8px; }
.graph-punkt {
  flex: 0 0 28px;
  margin-top: 20px;
  border-top: 3px solid var(--ink);
}
.graph-mitte { flex: 1 1 auto; min-width: 0; }
.graph-eingabe {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.5rem;
  line-height: 1.3;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.graph-zeile.hat-fehler .graph-eingabe { border-color: var(--error); }
.graph-fehler { color: var(--error); margin: 4px 0 0; }
.graph-fehler:empty { margin: 0; }
.graph-loeschen {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 4px 8px;
  background: var(--paper);
  color: var(--teal);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.reiter {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  background: var(--paper);
}
.reiter-taste {
  flex: 1;
  min-height: 44px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.reiter-taste[aria-selected="true"] {
  background: var(--teal);
  color: var(--on-teal);
  border-color: var(--teal);
}
@media (max-width: 599px) {
  .ansicht { display: none; }
  .ansicht.aktiv { display: block; }
}
@media (min-width: 600px) {
  .rechner-seite { max-width: 72rem; }
  .ansichten { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .reiter { display: none; }
}
.fuss {
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.fuss a { display: inline-block; min-height: 44px; line-height: 44px; padding: 0 8px; }
