/* mofu Gutscheine: the design book's paper, ink and coral (design-tokens.json, ui.colors). */
:root {
  --paper: #FBF6F0;
  --card: #FFFFFF;
  --tile: #FFFDF9;
  --ink: #3A3046;
  --ink-soft: #6B5F70;
  --line: #EADFD6;
  --coral: #E38B6F;
  --coral-ink: #9A4A33;
  --lavender: #C9B8F0;
  --sage: #86BF6F;
  --sage-ink: #2F5A22;
  --sage-tint: #DCEFD2;
  --butter: #FFE08A;
  --butter-ink: #5A4300;
  --rose-tint: #FBE1E8;
  --grey-tint: #EEE8E3;
  --gold: #F2C04E;
  --gold-rim: #C8932B;
  --gold-paw: #B07A1E;
  --shadow: 0 1px 0 rgba(58, 48, 70, .04), 0 10px 30px -14px rgba(58, 48, 70, .22);
  --r-card: 26px;
  --r-button: 18px;
  --r-chip: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(1200px 500px at 85% -10%, #F7E6F0 0%, transparent 60%), radial-gradient(900px 400px at -10% 0%, #FFF1DA 0%, transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font: 600 15px/1.45 Nunito, system-ui, sans-serif;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: Fredoka, Nunito, sans-serif; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-soft); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; letter-spacing: .04em; }
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 24px 64px; }
@media (max-width: 640px) { .wrap { padding: 16px 16px 48px; } }

/* Top bar */
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand small { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 700; margin-top: -2px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-soft); }
.demo-flag { background: var(--butter); color: var(--butter-ink); border-radius: 10px; padding: 3px 9px; font-size: 12px; font-weight: 800; }

/* Coin */
.coin { display: inline-grid; place-items: center; width: 1.25em; height: 1.25em; border-radius: 50%; background: var(--gold); box-shadow: inset 0 0 0 .1em var(--gold-rim); vertical-align: -.22em; flex: none; }
.coin svg { width: 62%; height: 62%; fill: var(--gold-paw); }
.coin.big { width: 44px; height: 44px; box-shadow: inset 0 0 0 3.5px var(--gold-rim); }

/* Buttons */
.btn { appearance: none; border: 0; cursor: pointer; border-radius: var(--r-button); min-height: 40px; padding: 0 16px; font-weight: 800; font-size: 14px; background: rgba(58, 48, 70, .07); display: inline-flex; align-items: center; gap: 8px; justify-content: center; white-space: nowrap; transition: transform .12s ease, background .15s ease; }
.btn:hover { background: rgba(58, 48, 70, .11); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--coral); color: #fff; box-shadow: 0 6px 16px -8px var(--coral); }
.btn.primary:hover { background: #DB7E61; }
.btn.danger { color: var(--coral-ink); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 13px; }
:focus-visible { outline: 3px solid var(--lavender); outline-offset: 2px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); }
.pad { padding: 22px; }
@media (max-width: 640px) { .pad { padding: 18px; } }

/* KI */
.ai { margin-bottom: 18px; display: grid; gap: 12px; }
.ai-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.ai-sub { margin: 6px 0 0; font-size: 15px; }
.build-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.build-row .small { flex: 1 1 260px; }
.ai { grid-template-columns: minmax(0, 1fr); }
.ai-meta a { color: var(--coral-ink); font-weight: 800; }
.bars { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; align-items: end; height: 84px; }
.bars .bar { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 3px; text-align: center; }
.bars .bar span { align-self: end; display: flex; align-items: flex-end; min-height: 2px; border-radius: 6px 6px 3px 3px; background: var(--line); overflow: hidden; }
.bars .bar i { display: block; width: 100%; background: var(--sage); }
.bars small { font-size: 10px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; }
.relay-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.relay-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.relay-table th, .relay-table td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.relay-table thead th { border-top: 0; font-size: 12px; color: var(--ink-soft); font-weight: 800; white-space: nowrap; }
.relay-table .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.relay-table .mono { font-size: 12px; letter-spacing: 0; white-space: nowrap; }
.runs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.runs li { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-radius: 14px; background: var(--tile); border: 1px solid var(--line); }
.runs .commit { flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.state { border-radius: 10px; padding: 2px 9px; font-size: 12px; font-weight: 800; background: var(--grey-tint); }
.state.ok { background: var(--sage-tint); color: var(--sage-ink); }
.state.bad { background: var(--rose-tint); color: var(--coral-ink); }
.state.run, .state.wait { background: var(--butter); color: var(--butter-ink); }
.seg button:disabled { cursor: default; opacity: .6; }
@media (max-width: 640px) { .seg.three { grid-template-columns: 1fr; } }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat b { display: flex; align-items: center; gap: 8px; font-family: Fredoka, sans-serif; font-weight: 600; font-size: 28px; line-height: 1.15; margin-top: 4px; }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* Toolbar */
.bar { display: flex; gap: 10px; align-items: center; margin: 4px 0 12px; flex-wrap: wrap; }
.bar h2 { margin-right: auto; }
.search { position: relative; }
.search input { width: 300px; max-width: 100%; }
@media (max-width: 640px) { .search, .search input { width: 100%; } }

input[type=text], input[type=number], input[type=datetime-local], input[type=search] {
  border: 1.5px solid var(--line); background: var(--tile); border-radius: 14px; min-height: 42px; padding: 0 12px; outline: none; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { border-color: var(--lavender); box-shadow: 0 0 0 4px rgba(201, 184, 240, .35); }
input::placeholder { color: #A99DA9; }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 800; }
label.field .hint { font-weight: 600; color: var(--ink-soft); }

/* Aktionen list */
.list { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.5fr) 150px 120px; gap: 16px; align-items: center; padding: 16px 20px; cursor: pointer; text-align: left; width: 100%; border: 1px solid var(--line); transition: transform .12s ease, border-color .15s ease; }
.row:hover { border-color: #DCCBBE; transform: translateY(-1px); }
.row .name { font-family: Fredoka, sans-serif; font-weight: 600; font-size: 17px; line-height: 1.25; }
.row .meta { font-size: 13px; color: var(--ink-soft); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 900px) {
  .row { grid-template-columns: 1fr auto; }
  .row .gift { grid-column: 1 / -1; order: 3; }
  .row .use { grid-column: 1 / -1; order: 4; }
}
.empty { text-align: center; padding: 44px 20px; }
.empty .coin { margin-bottom: 10px; }

.gift { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 12px; padding: 4px 10px; font-size: 13px; font-weight: 800; background: rgba(58, 48, 70, .06); white-space: nowrap; }
.pill.taler { background: #FFF4D6; }
.tag { display: inline-block; border-radius: 8px; padding: 2px 8px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.tag.aktiv { background: var(--sage-tint); color: var(--sage-ink); }
.tag.geplant { background: #E7E0FA; color: #4B3C7A; }
.tag.abgelaufen, .tag.aufgebraucht { background: var(--grey-tint); color: var(--ink-soft); }
.tag.abgeschaltet { background: var(--rose-tint); color: var(--coral-ink); }
.code-chip { background: var(--ink); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 12px; }

.use .nums { font-size: 13px; font-weight: 800; display: flex; justify-content: space-between; margin-bottom: 6px; }
.meter { height: 8px; border-radius: 6px; background: rgba(58, 48, 70, .08); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--sage); transition: width .4s ease; }

/* Sheet (create + detail) */
.scrim { position: fixed; inset: 0; background: rgba(58, 48, 70, .28); backdrop-filter: blur(3px); z-index: 10; }
.scrim.enter { animation: fade .2s ease; }
.sheet { position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(560px, calc(100vw - 24px)); background: var(--paper); border-radius: 30px; z-index: 11; display: flex; flex-direction: column; box-shadow: 0 30px 80px -20px rgba(58, 48, 70, .45); overflow: hidden; }
.sheet.enter { animation: slide .28s cubic-bezier(.2, .9, .3, 1); }
.sheet header { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 12px; }
.sheet header > div { flex: 1; min-width: 0; }
.sheet .body { flex: 1; overflow: auto; padding: 4px 22px 22px; display: grid; gap: 18px; align-content: start; }
.sheet footer { padding: 14px 22px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; background: rgba(255, 253, 249, .9); }
.sheet footer .btn.primary { margin-left: auto; min-width: 160px; }
@media (max-width: 640px) {
  .sheet { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 92vh; border-radius: 26px; }
}
@keyframes slide { from { transform: translateY(16px) scale(.985); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: rgba(58, 48, 70, .06); padding: 4px; border-radius: 16px; }
.seg button { border: 0; background: transparent; border-radius: 12px; min-height: 52px; cursor: pointer; text-align: left; padding: 8px 12px; font-weight: 800; }
.seg button small { display: block; font-weight: 600; font-size: 12px; color: var(--ink-soft); }
.seg button[aria-pressed=true] { background: var(--card); box-shadow: 0 2px 8px -3px rgba(58, 48, 70, .25); }

.group { display: grid; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { border: 1.5px solid var(--line); background: var(--tile); border-radius: 12px; min-height: 34px; padding: 0 12px; cursor: pointer; font-weight: 800; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.quick button[aria-pressed=true] { border-color: var(--gold-rim); background: #FFF4D6; }

.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.item { border: 1.5px solid var(--line); background: var(--tile); border-radius: 18px; padding: 10px 10px 9px; cursor: pointer; text-align: left; display: grid; gap: 2px; position: relative; transition: border-color .12s ease, transform .12s ease; }
.item:hover { transform: translateY(-1px); }
.item b { font-family: Fredoka, sans-serif; font-weight: 600; font-size: 15px; }
.item span { font-size: 12px; color: var(--ink-soft); font-weight: 800; display: flex; gap: 4px; align-items: center; }
.item[aria-pressed=true] { border-color: var(--coral); box-shadow: 0 0 0 1.5px var(--coral) inset; }
.item[aria-pressed=true]::after { content: "✓"; position: absolute; top: 8px; right: 10px; color: var(--coral); font-weight: 800; }
.item .swatch { width: 26px; height: 26px; border-radius: 9px; margin-bottom: 4px; }

/* Voucher preview: a little paper ticket */
.ticket { position: relative; background: linear-gradient(135deg, #FFF8EC, #FDEFF4); border: 1.5px dashed #E6CFC0; border-radius: 22px; padding: 18px 20px; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.ticket .code { font-size: 18px; }
.ticket .worth { font-size: 13px; color: var(--ink-soft); }

.error { background: var(--rose-tint); color: var(--coral-ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 14px; }
.note { background: rgba(58, 48, 70, .05); border-radius: 14px; padding: 10px 14px; font-size: 13px; color: var(--ink-soft); }

/* Codes table */
.codes { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--card); }
.codes .line { display: grid; grid-template-columns: 1fr auto; gap: 10px; min-height: 48px; padding: 6px 8px 6px 14px; border-top: 1px solid var(--line); align-items: center; font-size: 14px; }
.codes .line:first-child { border-top: 0; }
.codes .line.used { color: var(--ink-soft); }
.codes .line.used .mono { text-decoration: line-through; text-decoration-color: rgba(58, 48, 70, .35); }
.codes .more { padding: 10px 14px; text-align: center; font-size: 13px; color: var(--ink-soft); border-top: 1px solid var(--line); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 700; }

/* Sign-in */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate .card { max-width: 420px; width: 100%; text-align: center; padding: 34px 28px; display: grid; gap: 14px; justify-items: center; }
.gate .cmd { background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 12px; font-size: 12px; text-align: left; width: 100%; overflow-x: auto; white-space: nowrap; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 16px; padding: 10px 16px; font-weight: 800; font-size: 14px; z-index: 20; box-shadow: var(--shadow); animation: fade .2s ease; }

.lookup-result { margin-bottom: 14px; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(58, 48, 70, .15); border-top-color: var(--ink); animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 640px) { .bars .bar:nth-child(odd) small { visibility: hidden; } }
