/* ===== Fonts (selbst gehostet, siehe fonts/) ===== */
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/barlow-condensed-700.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: italic; font-weight: 700; font-display: swap; src: url("fonts/barlow-condensed-700-italic.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-500.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/source-serif-4-400.woff2") format("woff2"); }

/* ===== Tokens ===== */
:root {
  --bg: #EEECDF;
  --card: #F7F5EC;
  --hover: #ECE9DD;
  --line: #D6D4C2;
  --line-soft: #E2E0D0;
  --handle: #C9C7B4;
  --edge: #C5C8B0;
  --ink: #17241B;
  --text: #253129;
  --muted: #586155;
  --violet: #6A44B0;
  --violet-text: #6A44B0;
  --on-violet: #FFFFFF;
  --tint: #E9E2F5;
  --scrim: rgba(23, 36, 27, .4);
  --comb: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2752%27 height=%2790%27 viewBox=%270 0 52 90%27%3E%3Cpath d=%27M26 0L52 15V45L26 60L0 45V15Z M26 60V90%27 fill=%27none%27 stroke=%27%23DEDCCB%27 stroke-width=%271%27/%3E%3C/svg%3E");
  --wave: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2716%27 height=%278%27 viewBox=%270 0 16 8%27%3E%3Cpath d=%27M0 4Q4 0 8 4T16 4%27 fill=%27none%27 stroke=%27%236A44B0%27 stroke-width=%272.5%27/%3E%3C/svg%3E");

  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --font-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Code", "Cascadia Mono", Consolas, "Roboto Mono", "Liberation Mono", "DejaVu Sans Mono", monospace;
  --font-serif: "Source Serif 4", Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
}

:root[data-theme="dark"] {
  --bg: #111912;
  --card: #18241B;
  --hover: #1F2E23;
  --line: #2C3B30;
  --line-soft: #243229;
  --handle: #3A4A3E;
  --edge: #0A100B;
  --ink: #ECEADB;
  --text: #D9DACB;
  --muted: #A3AC9F;
  --violet: #9A7BE6;
  --violet-text: #B9A2F0;
  --on-violet: #111912;
  --tint: #2A2440;
  --scrim: rgba(0, 0, 0, .5);
  --comb: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2752%27 height=%2790%27 viewBox=%270 0 52 90%27%3E%3Cpath d=%27M26 0L52 15V45L26 60L0 45V15Z M26 60V90%27 fill=%27none%27 stroke=%27%231C281F%27 stroke-width=%271%27/%3E%3C/svg%3E");
  --wave: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2716%27 height=%278%27 viewBox=%270 0 16 8%27%3E%3Cpath d=%27M0 4Q4 0 8 4T16 4%27 fill=%27none%27 stroke=%27%239A7BE6%27 stroke-width=%272.5%27/%3E%3C/svg%3E");
}

/* ===== Basis ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.sheet-open { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--comb);
  background-repeat: repeat-x;
  background-position: top center;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
}

button { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

.noscript { padding: 20px; color: var(--ink); }

:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }

/* ===== Header ===== */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: max(env(safe-area-inset-top), 10px) 20px 0;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }

.logo { width: 24px; height: 28px; flex: none; }
.logo-outer { fill: var(--bg); stroke: var(--ink); stroke-width: 6.5; stroke-linejoin: round; }
.logo-inner { fill: var(--violet); }

.brand-mark-small {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}
.brand-mark-small em { font-style: italic; color: var(--violet-text); }

.mascot {
  width: 24px; height: 21px; flex: none;
  fill: none; stroke: var(--violet-text); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round;
}

.hgroup {
  display: flex;
  flex: none;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
}

.hbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--ink);
  cursor: pointer;
}
.hbtn:hover { background: var(--hover); }
.hbtn:focus-visible { outline-offset: -4px; }

.hbtn-theme { width: 44px; border-right: 1.5px solid var(--ink); border-radius: 4px 0 0 4px; }
.hbtn-theme svg { width: 16px; height: 16px; }
.hbtn-lang {
  padding: 0 12px;
  border-radius: 0 4px 4px 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
}
.lang-wrap { display: flex; }

/* ===== Seite ===== */
.page {
  display: grid;
  gap: 20px;
  padding: 22px 20px 130px;
  align-content: start;
}

/* ===== Hauptsatz ===== */
.sentence {
  margin: 0;
  padding-top: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  line-height: 1.28;
  color: var(--ink);
  text-transform: uppercase;
  text-wrap: balance;
}

.pick {
  display: inline;
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--violet-text);
  cursor: pointer;
  text-decoration: underline wavy var(--violet);
  text-decoration-thickness: 2px;
  text-underline-offset: 7px;
  text-decoration-skip-ink: none;
}
.pick:focus-visible { outline-offset: 4px; border-radius: 4px; }

.pick-wrap { position: relative; display: inline-block; }
.nowrap { display: inline-block; white-space: nowrap; }

.amount { display: inline-flex; align-items: baseline; gap: 6px; position: relative; }

.step {
  position: relative;
  align-self: center;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.step::after { content: ""; position: absolute; inset: -5px -3px; }
.step:hover { background: var(--hover); }
.step:disabled { opacity: .35; cursor: default; background: transparent; }

.amount-input { display: none; }
.amount-pick { display: inline; }

/* ===== Zweiter Satz ===== */
.extras {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.45;
  color: var(--muted);
  text-transform: uppercase;
}
.extras .pick { padding: 4px 0; }

/* ===== Karte ===== */
.card {
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--edge);
}

.card-bar { display: contents; }
.count { margin: 0; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.output {
  margin: 0;
  padding: 18px;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}
.output.is-code { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65; }

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  padding: 0 24px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .03em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 var(--violet);
  cursor: pointer;
  transition: transform 60ms, box-shadow 60ms;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 0 0 var(--violet); }
.btn-primary.is-copied { background: var(--ink); color: var(--bg); }
.btn-primary:focus-visible { outline-offset: 5px; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.link-btn:hover { color: var(--violet-text); }
.link-btn kbd { display: none; }

.actions {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom, 16px));
  background: var(--bg);
  border-top: 1.5px solid var(--ink);
}
.actions .btn-primary { flex: 1; }
.card-bar .count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Footer ===== */
.site-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.site-footer p { margin: 0; }
.footer-note { display: grid; gap: 6px; }
.disclaimer { max-width: 640px; }
.crest { display: flex; align-items: center; gap: 8px; }
.crest-icon {
  width: 18px; height: 16px; flex: none;
  fill: none; stroke: var(--violet-text); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round;
}
.version { font-family: var(--font-mono); }
.version a { color: inherit; text-underline-offset: 2px; }
.version a:hover { color: var(--violet-text); }

/* ===== Popover (Desktop) ===== */
.scrim { position: fixed; inset: 0; z-index: 40; }
.scrim-sheet { background: var(--scrim); z-index: 55; }

.pop {
  position: absolute;
  top: calc(100% + 14px);
  left: -10px;
  z-index: 50;
  min-width: 260px;
  padding: 6px;
  display: grid;
  gap: 2px;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 5px 0 var(--violet);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
  text-wrap: wrap;
  text-align: left;
  color: var(--text);
}
.pop-style { min-width: 300px; }
.pop.align-right { left: auto; right: -10px; }

.pop .list { display: grid; gap: 2px; }

.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.opt:hover { background: var(--hover); }
.opt:focus-visible { outline-offset: -2px; }
.opt[aria-selected="true"] { background: var(--tint); font-weight: 600; }

.hex {
  flex: none;
  width: 10px; height: 12px;
  background: transparent;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.opt[aria-selected="true"] .hex { background: var(--violet); }

.opt-body { display: grid; gap: 1px; min-width: 0; }
.opt-label { font-size: 16px; }
.opt-prev { font-size: 13px; color: var(--muted); font-weight: 400; }
.prev-serif { font-family: var(--font-serif); }
.prev-mono { font-family: var(--font-mono); font-size: 12px; }

.pop-amount { width: 340px; padding: 14px; gap: 10px; }
.hint { margin: 0; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset {
  height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
}
.preset:hover { background: var(--hover); }
.preset.is-on { background: var(--violet); border-color: var(--violet); color: var(--on-violet); }

/* ===== Bottom-Sheet (Mobile) ===== */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom, 10px));
  background: var(--card);
  border-top: 1.5px solid var(--ink);
  border-radius: 14px 14px 0 0;
  color: var(--text);
}
.grab { justify-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--handle); }

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  text-transform: uppercase;
  color: var(--ink);
}
.done {
  min-height: 44px;
  padding: 0 4px;
  background: none;
  border: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  cursor: pointer;
}

.sheet .list { display: grid; gap: 2px; }
.sheet .opt { min-height: 54px; }
.sheet .opt-label { font-size: 17px; }

.sheet-amount { display: flex; align-items: center; gap: 12px; }
.sheet-amount .step { flex: none; width: 56px; height: 56px; font-size: 26px; }
.sheet-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 64px;
  padding: 0 12px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: #FFFFFF;
  color: var(--violet-text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  text-align: center;
}
:root[data-theme="dark"] .sheet-input { background: #111912; }
.sheet .preset { height: 44px; font-size: 14px; }

/* ===== Desktop ===== */
@media (min-width: 900px) {
  body { background-repeat: repeat; }

  .top { min-height: 68px; padding: 0 40px; }
  .brand { gap: 10px; }
  .logo { width: 26px; height: 30px; }
  .logo-outer { stroke-width: 6.5; }
  .brand-mark-small { font-size: 1.5rem; }
  .mascot { width: 26px; height: 22px; }
  .hbtn-lang { font-size: 16px; }

  .page {
    max-width: 900px;
    margin: 0 auto;
    gap: 26px;
    padding: 40px 40px 48px;
  }

  .sentence { padding-top: 0; font-size: 64px; line-height: 1.2; }
  .pick { text-decoration-thickness: 3px; text-underline-offset: 10px; }

  .step { width: 40px; height: 40px; font-size: 22px; }
  .amount-input {
    display: inline-block;
    padding: 0 0 6px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--wave) repeat-x left bottom / 16px 8px;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    text-align: center;
    color: var(--violet-text);
    caret-color: var(--violet);
    width: .65em;
  }
  .amount-input:focus { outline: none; }
  .amount-input:focus-visible { outline: 3px solid var(--violet); outline-offset: 4px; border-radius: 4px; }
  .amount-pick { display: none; }

  .extras { font-size: 28px; }

  .card-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px 14px 32px;
    border-bottom: 1px solid var(--line-soft);
  }
  .card-bar .count { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }

  .actions {
    position: static;
    padding: 0;
    gap: 22px;
    background: none;
    border-top: 0;
  }
  .actions .btn-primary { flex: none; min-width: 130px; height: 44px; font-size: 17px; }
  .link-btn kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    text-decoration: none;
    color: var(--muted);
  }

  .output { padding: 30px 32px 36px; font-size: 19px; max-width: 784px; }
  .output.is-code { font-size: 14px; }

  .site-footer { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary { transition: none; }
}
