:root {
  --bg: #fbf6ef;
  --paper: #fffdf9;
  --ink: #2a2220;
  --muted: #8a7b75;
  --line: #eadfd4;
  --rose: #d6455d;
  --rose-ink: #fff;
  --ok: #3f9b6b;
  --warn: #d8901f;
  --bad: #c2412f;
  --shadow: 0 1px 0 rgba(42, 34, 32, .04), 0 10px 30px -12px rgba(120, 60, 50, .25);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1817;
    --paper: #2a2321;
    --ink: #f3e9e2;
    --muted: #a99791;
    --line: #3d3330;
    --rose: #ec6178;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 24px);
}
main, #setup { max-width: 34rem; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Kopf */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 0 18px; }
.eyebrow { margin: 0; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--rose); font-weight: 600; }
h1 { margin: 2px 0 6px; font: 600 2rem/1.1 var(--serif); letter-spacing: -.01em; }
h2 { font: 600 1.05rem var(--serif); margin: 28px 0 10px; }
.status { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .92rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status[data-state="ok"] .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.status[data-state="warn"] .dot { background: var(--warn); }
.status[data-state="bad"] .dot { background: var(--bad); }
.status[data-state="bad"] { color: var(--bad); }
.status[data-state="off"] .dot { background: transparent; border: 2px solid var(--muted); }

.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* Kassenzettel zum Schreiben */
.receipt {
  position: relative;
  background: var(--paper);
  border-radius: 6px 6px 0 0;
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
  font-family: var(--mono);
  margin-bottom: 14px;
}
.receipt::after { /* gezackte Abrisskante */
  content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background:
    linear-gradient(-45deg, transparent 7px, var(--paper) 0) 0 0 / 14px 10px repeat-x,
    linear-gradient(45deg, transparent 7px, var(--paper) 0) 0 0 / 14px 10px repeat-x;
}
.receipt-head {
  display: flex; align-items: baseline; gap: 10px; font-size: .85rem; color: var(--muted);
  padding-bottom: 10px; border-bottom: 1px dashed var(--line);
}
.receipt-head b { color: var(--ink); }
.receipt-head #nowStamp { margin-left: auto; }
.heart { color: var(--rose); font-size: 1.1rem; }
textarea {
  display: block; width: 100%; border: 0; background: transparent; color: var(--ink);
  font: 1.05rem/1.5 var(--mono); padding: 12px 0; resize: none; min-height: 8.5em; outline: none;
}
textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.receipt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
#counter { font-size: .8rem; color: var(--muted); }
.hint { font: .82rem/1.4 var(--sans); color: var(--muted); margin: 0 0 8px; }

button { font: inherit; }
.send {
  border: 0; border-radius: 999px; background: var(--rose); color: var(--rose-ink);
  font: 600 1rem var(--sans); padding: 11px 20px; min-height: 44px; cursor: pointer;
  transition: transform .12s ease, opacity .2s;
}
.send:active { transform: scale(.97); }
.send:disabled { opacity: .35; cursor: default; }
.send.wide { width: 100%; margin-top: 8px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 2px; scrollbar-width: none; margin: 0 -16px; padding-inline: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; min-height: 40px; cursor: pointer; white-space: nowrap;
}
.chip:active { background: color-mix(in srgb, var(--rose) 12%, var(--paper)); }

/* Verlauf */
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.log li { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.log li.in { border-color: color-mix(in srgb, var(--rose) 35%, var(--line)); background: color-mix(in srgb, var(--rose) 7%, var(--paper)); }
.log p { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { font-size: .8rem; color: var(--muted); }
.state.printed { color: var(--ok); font-weight: 600; }
.state.printed::before { content: "✓ "; }
.state.outbox { color: var(--warn); }
.empty { color: var(--muted); font-style: italic; }

/* Formular */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
fieldset { border: 0; margin: 0 0 12px; padding: 0; }
legend { font: 600 1.05rem var(--serif); margin-bottom: 8px; }
label { display: block; font-size: .9rem; margin-bottom: 12px; }
label small { color: var(--muted); }
input:not([type="checkbox"]) {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 1rem var(--sans);
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
textarea:focus-visible { outline: none; }
.receipt:focus-within { box-shadow: var(--shadow), 0 0 0 2px color-mix(in srgb, var(--rose) 45%, transparent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 20px; height: 20px; accent-color: var(--rose); }
.error { color: var(--bad); font-size: .9rem; }
.tools { display: grid; gap: 10px; }
.ghost {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 10px; padding: 11px 14px; min-height: 44px; cursor: pointer; text-align: left;
}
.ghost.danger { color: var(--bad); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px;
  font-size: .92rem; max-width: calc(100vw - 32px); box-shadow: var(--shadow); z-index: 10;
  animation: rise .25s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .send { transition: none; } }
