/* ===== 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: 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"); }

/* ===== Tokens ===== */
:root {
  --bg: #EEECDF;
  --card: #F7F5EC;
  --ink: #17241B;
  --muted: #464E43;
  --accent: #6E4222;
  --on-accent: #FFFFFF;
  --warn: #8E261B;
  --tint: #E6E3D3;
  --line: #D6D4C2;
  --handle: #C9C7B4;
  --placeholder: #656C62;
  --edge: #C5C8B0;

  --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;
}

:root[data-theme="dark"] {
  --bg: #111912;
  --card: #18241B;
  --ink: #ECEADB;
  --muted: #B4B8AA;
  --accent: #D9A77C;
  --on-accent: #111912;
  --warn: #F0A08F;
  --tint: #1F2D23;
  --line: #2C3B30;
  --handle: #3A453C;
  --placeholder: #8F9688;
  --edge: #0A100B;
}

/* ===== Basis ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; }
a { color: var(--accent); }
a:hover { color: var(--ink); }
h1, h2, p { margin: 0; }

[hidden] { display: none !important; }

.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;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.noscript { padding: 20px; }

/* ===== Seite ===== */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: max(env(safe-area-inset-top), 16px) 20px calc(150px + env(safe-area-inset-bottom));
}

/* ===== Header ===== */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.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(--accent); }

.brand-mark-small {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.brand-mark-small em { font-style: italic; color: var(--accent); }

.mascot {
  width: 26px; height: 26px; flex: none;
  fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

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

.hbtn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 42px; padding: 0;
  background: transparent; border: 0; color: var(--ink);
}
.hbtn + .hbtn { border-left: 1.5px solid var(--ink); }
.hbtn:hover { background: var(--tint); }
.hbtn:focus-visible { outline-offset: -4px; }
.hbtn-theme { width: 42px; }
.hbtn-theme svg { width: 15px; height: 15px; }
.hbtn-lang { padding: 0 11px; font-family: var(--font-display); font-weight: 700; font-size: 15px; }

/* ===== Auswahl-Raster (Typen, Punkte, Ecken): wie ein Segment, mehrzeilig ===== */
.seg-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: 1.5px;
  background: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
}
.seg-grid button {
  height: 40px; padding: 0 4px;
  border: 0; border-radius: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 15px; text-transform: uppercase; line-height: 1.05;
}
.seg-grid button:hover { background: var(--tint); }
.seg-grid button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg-grid button:focus-visible { outline-offset: -4px; }
.types { --cols: 4; }
.design .seg-grid button { font-size: 14px; }

/* ===== Layout: mobil eine Spalte ===== */
.layout { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.side { display: contents; }
.preview-card { order: 0; }
.main { order: 1; }
.file-block { order: 2; }
.status.status-side, .type-title, .side-actions { display: none; }

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

.preview-card {
  padding: 12px;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.qr-box {
  position: relative;
  padding: 6px;
  border-radius: 6px;
  border: 2.5px solid transparent;
  background: #FFFFFF;
}
.qr-code svg { display: block; width: 100%; height: auto; }
.qr-box.has-frame { padding: 0; border: 0; background: none; }
.qr-box.is-empty .qr-code { opacity: .07; }

.qr-empty {
  position: absolute; inset: 6px;
  display: none; place-items: center;
  padding: 10px;
  text-align: center;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
  color: #464E43;
  border: 1.5px dashed #C9C7B4;
  border-radius: 4px;
}
.qr-box.is-empty .qr-empty { display: grid; }

.card-meta { display: grid; gap: 8px; align-content: center; min-width: 0; }
.card-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; text-transform: uppercase; }

.status { display: flex; gap: 6px; font-size: 13px; line-height: 1.4; }
.status-icon { flex: none; font-weight: 600; color: var(--muted); }
.status[data-kind="warn"] .status-icon { color: var(--warn); }
.status[data-kind="ok"] .status-icon { color: var(--accent); }
.status-text { text-wrap: pretty; }

/* ===== Formular ===== */
.main { display: grid; gap: 12px; min-width: 0; }

.intro { font-size: 14px; line-height: 1.55; color: var(--muted); text-wrap: pretty; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.span2 { grid-column: 1 / -1; }

.field label, .label { font-size: 14px; font-weight: 600; }

.field input, .field textarea, .field select {
  width: 100%; min-width: 0;
  height: 48px; padding: 0 14px;
  border: 1.5px solid var(--ink); border-radius: 6px;
  background: var(--card); color: var(--ink);
  font-size: 16px;
}
.field select { padding: 0 10px; }
.field textarea { height: 96px; padding: 12px 14px; line-height: 1.45; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
::placeholder { color: var(--placeholder); opacity: 1; }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { color-scheme: dark; }

.fields-utm input { height: 44px; }

.help { font-size: 12px; line-height: 1.45; color: var(--muted); }
.help[data-kind="accent"] { color: var(--accent); }
.help[data-kind="warn"] { color: var(--warn); }

.check {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0;
  border: 0; background: transparent; color: var(--ink);
  text-align: left; font-size: 15px; line-height: 1.35;
}
.check-box {
  flex: none; display: grid; place-items: center;
  width: 22px; height: 22px;
  border: 1.5px solid var(--ink); border-radius: 4px;
  font-size: 14px; font-weight: 600; color: transparent;
}
.check[aria-checked="true"] .check-box { background: var(--ink); color: var(--bg); }

.btn-outline {
  justify-self: start;
  height: 44px; padding: 0 14px;
  border: 1.5px solid var(--ink); border-radius: 6px;
  background: transparent; color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 16px; text-transform: uppercase;
}
.btn-outline:hover { background: var(--tint); }

/* ===== UTM (Kopf wie Gestaltungsgruppen) ===== */
.utm, .utm-panel { display: grid; gap: 10px; }
.group-head {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 8px 0;
  border: 0; border-top: 1px solid var(--handle);
  background: transparent; color: var(--ink); text-align: left;
}
.group-title { flex: none; font-family: var(--font-display); font-weight: 700; font-size: 19px; text-transform: uppercase; }
.group-tag {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.group-tag.is-set { color: var(--accent); }
.group-mark { flex: none; width: 18px; text-align: center; color: var(--accent); font-size: 18px; }

.note { font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: var(--muted); text-wrap: pretty; }

/* ===== Steckt im Code ===== */
.payload { display: grid; gap: 6px; }
.payload-head { display: flex; align-items: baseline; justify-content: space-between; }
.payload-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.payload-box {
  background: var(--tint);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-all;
  max-height: 120px; overflow: auto;
}

.text-btn, .text-btn-accent {
  border: 0; background: transparent; padding: 4px 0;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; text-transform: uppercase;
  text-decoration: underline; text-underline-offset: 4px;
  color: var(--ink);
}
.text-btn-accent { color: var(--accent); }

/* ===== Gestaltung ===== */
.design { display: grid; border-top: 1.5px solid var(--ink); margin-top: 6px; }
.design-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 0 6px; }
.design-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1; text-transform: uppercase; }

.group { display: grid; border-top: 1px solid var(--handle); }
.group .group-head { border-top: 0; }
.group-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: 0; }
.group-dot.is-on { opacity: 1; }
.group-body { display: grid; padding-bottom: 10px; }

.sub { display: grid; gap: 10px; padding: 12px 0; min-width: 0; }
.sub + .sub { border-top: 1px solid var(--line); }
.sub-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 16px; text-transform: uppercase; }
.sub-note { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

.swatch-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hex { margin-left: 4px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.sw {
  position: relative; flex: none;
  width: 38px; height: 38px; padding: 3px;
  border: 2px solid transparent; border-radius: 8px;
  background: transparent; cursor: pointer;
}
.sw > span:first-child { display: block; width: 100%; height: 100%; border-radius: 5px; box-shadow: inset 0 0 0 1.5px var(--ink); }
.sw[aria-pressed="true"], .sw-custom.is-on { border-color: var(--accent); }
.sw.sw-custom > .sw-plus {
  display: grid; place-items: center;
  box-shadow: none;
  border: 1.5px dashed var(--ink);
  background: var(--custom, transparent);
  color: var(--custom-fg, var(--ink));
  font-size: 17px; line-height: 1;
}
.sw-custom:not(.is-on) .sw-plus { color: var(--ink); }
.sw-custom input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.sw-custom:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }

.chip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.chip-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.chip-grid button {
  height: 40px; padding: 0 4px;
  border: 1.5px solid var(--ink); border-radius: 6px;
  background: transparent; color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 14px; text-transform: uppercase;
}
.chip-grid-5 button { height: 38px; display: grid; place-items: center; }
.chip-grid-5 svg { width: 20px; height: 20px; }
.chip-grid button:hover { background: var(--tint); }
.chip-grid button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.seg button:disabled:not([aria-pressed="true"]) { opacity: .45; }

.switch {
  display: flex; align-items: center; gap: 12px;
  min-height: 40px; padding: 0;
  border: 0; background: transparent; color: var(--ink);
  font-size: 15px; text-align: left;
}
.switch-track {
  flex: none; display: flex; align-items: center; justify-content: flex-start;
  width: 44px; height: 26px; padding: 0 3px;
  border: 1.5px solid var(--ink); border-radius: 999px;
}
.switch-knob { width: 17px; height: 17px; border-radius: 50%; background: var(--ink); }
.switch[aria-checked="true"] .switch-track { background: var(--accent); justify-content: flex-end; }
.switch[aria-checked="true"] .switch-knob { background: var(--on-accent); }

.design .check { min-height: 40px; }

.bg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.step-wrap { display: flex; align-items: center; gap: 8px; }
.step-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.step-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.step-text { display: grid; gap: 2px; }

.stepper { display: flex; align-items: center; flex: none; border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden; }
.stepper button { width: 38px; height: 38px; border: 0; background: transparent; color: var(--accent); font-size: 18px; }
.stepper button:first-child { border-right: 1.5px solid var(--ink); }
.stepper button:last-child { border-left: 1.5px solid var(--ink); }
.stepper button:hover:not(:disabled) { background: var(--tint); }
.stepper button:disabled { opacity: .4; }
.stepper button:focus-visible { outline-offset: -4px; }
.step-val { min-width: 52px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 17px; text-transform: uppercase; }

.logo-icons, .logo-img, .logo-size, .frame-opts { display: grid; gap: 10px; }
.frame-opts .fields { gap: 10px; }
.logo-size { padding-top: 4px; }

.text-btn:disabled, .dock-link:disabled { opacity: .4; }
.dock-link { padding: 10px 0; font-size: 17px; }
.btn-svg { height: 52px; padding: 0 20px; font-size: 18px; }
.copy-img { display: none; justify-self: start; padding: 2px 0; font-size: 16px; }
.remember { gap: 4px; }
.remember .switch { min-height: 44px; }

/* ===== Datei ===== */
.file-block {
  display: grid; gap: 12px;
  border-top: 1.5px solid var(--ink);
  padding-top: 14px;
}
.block-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.2; text-transform: uppercase; }

.seg { display: flex; border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden; }
.seg button {
  flex: 1; height: 40px; padding: 0 6px;
  border: 0; background: transparent; color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 15px; text-transform: uppercase; line-height: 1.05;
}
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button:hover { background: var(--tint); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:focus-visible { outline-offset: -4px; }
.seg-size button { height: 44px; padding: 0 4px; }

.btn-primary {
  flex: 1;
  height: 52px; padding: 0 16px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-display); font-weight: 700; font-size: 20px; text-transform: uppercase; letter-spacing: .03em;
}
.btn-primary:disabled { opacity: .4; }
.btn-primary:focus-visible { outline-offset: 3px; }

/* ===== Footer ===== */
.foot { display: grid; gap: 14px; border-top: 1.5px solid var(--ink); padding-top: 14px; }
.privacy { display: grid; gap: 10px; font-size: 14px; line-height: 1.55; }
.privacy-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1.2; text-transform: uppercase; }
.privacy-points { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.privacy-points li { position: relative; padding-left: 22px; text-wrap: pretty; }
.privacy-points li::before { content: "✓"; content: "✓" / ""; position: absolute; left: 0; top: 0; font-weight: 600; color: var(--accent); }
.privacy-note { font-size: 13px; color: var(--muted); }

.credits { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.ai-note { font-size: 12px; line-height: 1.5; color: var(--muted); text-wrap: pretty; }
.credit-line {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}
.credit-line a { color: inherit; }

/* ===== Leiste unten (mobil) ===== */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 10px 20px max(16px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1.5px solid var(--ink);
}
.dock-warn { flex-basis: 100%; display: flex; gap: 6px; font-size: 12px; line-height: 1.4; color: var(--warn); }
.dock-warn span:first-child { font-weight: 600; }

/* ===== Desktop ===== */
@media (min-width: 900px) {
  .app {
    max-width: 1080px;
    margin: 0 auto;
    padding: 36px 40px 48px;
    gap: 26px;
  }

  .brand { gap: 10px; }
  .logo { width: 30px; height: 35px; }
  .brand-mark-small { font-size: 28px; }
  .mascot { width: 32px; height: 32px; }

  .types { --cols: 8; }
  .types button { height: 44px; font-size: 17px; }

  .layout {
    display: grid;
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 48px;
    align-items: start;
  }
  .side { display: grid; gap: 16px; position: sticky; top: 20px; }
  .side.is-static { position: static; }
  .file-block { display: contents; }
  .block-title, .card-meta { display: none; }
  .status.status-side { display: flex; gap: 8px; font-size: 14px; line-height: 1.45; }
  .file-name { padding-top: 6px; }
  .side-actions { display: flex; gap: 10px; padding-top: 4px; }
  .copy-img { display: block; }

  .preview-card { display: block; padding: 20px; }
  .qr-box { padding: 12px; border-radius: 8px; border-width: 3px; }
  .qr-empty { inset: 12px; padding: 40px; font-size: 13px; line-height: 1.6; border-radius: 6px; }

  .main { gap: 14px; }
  .type-title { display: block; font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1; text-transform: uppercase; }
  .intro { font-size: 15px; }
  .fields { gap: 14px 16px; }
  .field textarea { height: 110px; }
  .note { max-width: 600px; }
  .payload { padding-top: 4px; }
  .payload-box { font-size: 13px; max-height: 160px; }
  .design-title { font-size: 30px; }
  .group-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; align-items: start; }
  .group-cols .sub:nth-child(2) { border-top: 0; }

  .foot { padding-top: 16px; }
  .privacy-points { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }

  .dock { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
