/* Dönnerstage – kompaktes Material Design 3
   Farbrollen aus einer warmen Seed-Farbe (Terrakotta). Hell/Dunkel über prefers-color-scheme
   oder html[data-theme]. */

@font-face { font-family: 'Poppins'; font-weight: 400; font-display: swap; src: url(../fonts/poppins-400.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 500; font-display: swap; src: url(../fonts/poppins-500.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 600; font-display: swap; src: url(../fonts/poppins-600.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 700; font-display: swap; src: url(../fonts/poppins-700.woff2) format('woff2'); }
@font-face { font-family: 'Material Symbols Rounded'; font-weight: 400 600; font-display: block; src: url(../fonts/material-symbols-rounded.woff2) format('woff2'); }

:root {
  --primary: #9a4521; --on-primary: #fff; --primary-container: #ffdbcd; --on-primary-container: #380d00;
  --secondary: #77574a; --on-secondary: #fff; --secondary-container: #ffdbcd; --on-secondary-container: #2c160c;
  --tertiary: #685f30; --on-tertiary: #fff; --tertiary-container: #f1e4a8; --on-tertiary-container: #211b00;
  --error: #ba1a1a; --on-error: #fff; --error-container: #ffdad6; --on-error-container: #410002;
  --success: #2e6a3b; --on-success: #fff; --success-container: #b1f1b9; --on-success-container: #00210a;
  --surface: #fff8f6; --on-surface: #231a16; --on-surface-variant: #53433e;
  --surface-lowest: #fff; --surface-low: #fef1ec; --surface-container: #f8ebe6; --surface-high: #f2e5e0; --surface-highest: #ece0db;
  --outline: #85736d; --outline-variant: #d8c2ba;
  --inverse-surface: #392e2b; --inverse-on-surface: #ffede7; --inverse-primary: #ffb597;
  --scrim: rgba(0, 0, 0, .32);
  --shadow: 0 1px 2px rgba(0,0,0,.18), 0 2px 6px 2px rgba(0,0,0,.08);
  --ease: cubic-bezier(.2, 0, 0, 1);
  --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 28px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #ffb597; --on-primary: #5a1c00; --primary-container: #7b2f0c; --on-primary-container: #ffdbcd;
    --secondary: #e7beae; --on-secondary: #442a1f; --secondary-container: #5d4034; --on-secondary-container: #ffdbcd;
    --tertiary: #d4c88e; --on-tertiary: #373106; --tertiary-container: #4f4719; --on-tertiary-container: #f1e4a8;
    --error: #ffb4ab; --on-error: #690005; --error-container: #93000a; --on-error-container: #ffdad6;
    --success: #95d5a0; --on-success: #003915; --success-container: #11522a; --on-success-container: #b1f1b9;
    --surface: #1a110e; --on-surface: #f1dfd9; --on-surface-variant: #d8c2ba;
    --surface-lowest: #140c09; --surface-low: #231a16; --surface-container: #271e1a; --surface-high: #322824; --surface-highest: #3d322f;
    --outline: #a08d86; --outline-variant: #53433e;
    --inverse-surface: #f1dfd9; --inverse-on-surface: #392e2b; --inverse-primary: #9a4521;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #ffb597; --on-primary: #5a1c00; --primary-container: #7b2f0c; --on-primary-container: #ffdbcd;
  --secondary: #e7beae; --on-secondary: #442a1f; --secondary-container: #5d4034; --on-secondary-container: #ffdbcd;
  --tertiary: #d4c88e; --on-tertiary: #373106; --tertiary-container: #4f4719; --on-tertiary-container: #f1e4a8;
  --error: #ffb4ab; --on-error: #690005; --error-container: #93000a; --on-error-container: #ffdad6;
  --success: #95d5a0; --on-success: #003915; --success-container: #11522a; --on-success-container: #b1f1b9;
  --surface: #1a110e; --on-surface: #f1dfd9; --on-surface-variant: #d8c2ba;
  --surface-lowest: #140c09; --surface-low: #231a16; --surface-container: #271e1a; --surface-high: #322824; --surface-highest: #3d322f;
  --outline: #a08d86; --outline-variant: #53433e;
  --inverse-surface: #f1dfd9; --inverse-on-surface: #392e2b; --inverse-primary: #9a4521;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; min-height: 100vh; background: var(--surface); color: var(--on-surface);
  font: 400 14px/1.45 'Poppins', system-ui, sans-serif; letter-spacing: .1px;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Typo-Skala (kompakt) */
.t-headline { font-size: 22px; line-height: 28px; font-weight: 600; }
.t-title-l { font-size: 18px; line-height: 24px; font-weight: 600; }
.t-title { font-size: 15px; line-height: 22px; font-weight: 600; }
.t-body { font-size: 14px; }
.t-label { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .4px; }
.t-small { font-size: 12px; line-height: 16px; }
.muted { color: var(--on-surface-variant); }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }

/* Icons */
.i {
  font-family: 'Material Symbols Rounded'; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1;
  display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga'; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
  user-select: none; flex: none;
}
.i.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20; }
.i.s18 { font-size: 18px; } .i.s24 { font-size: 24px; } .i.s32 { font-size: 32px; } .i.s48 { font-size: 48px; }

/* State-Layer für alles Klickbare */
.st { position: relative; overflow: hidden; cursor: pointer; }
.st::after {
  content: ''; position: absolute; inset: 0; background: currentColor; opacity: 0;
  transition: opacity .15s var(--ease); pointer-events: none; border-radius: inherit;
}
@media (hover: hover) { .st:hover::after { opacity: .08; } }
.st:active::after, .st:focus-visible::after { opacity: .12; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border: 0; border-radius: 18px; font-size: 14px; font-weight: 500;
  background: transparent; color: var(--primary); white-space: nowrap; text-decoration: none;
}
.btn .i { font-size: 18px; margin-left: -4px; }
.btn.filled { background: var(--primary); color: var(--on-primary); }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.outlined { border: 1px solid var(--outline); }
.btn.danger { color: var(--error); }
.btn.danger.filled { background: var(--error); color: var(--on-error); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 22px; border-radius: 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: .38; pointer-events: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: transparent; color: var(--on-surface-variant); flex: none;
}
.icon-btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn:disabled { opacity: .38; pointer-events: none; }

.fab {
  position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 20;
  display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 18px 0 16px;
  border: 0; border-radius: var(--r-lg); background: var(--primary-container); color: var(--on-primary-container);
  box-shadow: var(--shadow); font-weight: 600;
}
.fab .i { font-size: 22px; }
/* Mini-FAB (Feedback): dezente Pille mit Beschriftung; über einem normalen FAB gestapelt */
.fab.mini {
  height: 40px; padding: 0 14px 0 12px; gap: 6px; border-radius: 20px; font-size: 13px; font-weight: 500;
  background: var(--surface-high); color: var(--on-surface-variant); box-shadow: var(--shadow); opacity: .92;
}
.fab.mini .i { font-size: 19px; }
.fab.mini:hover { opacity: 1; color: var(--primary); }
body.has-fab .fab.mini { bottom: calc(80px + 52px + 12px + env(safe-area-inset-bottom)); }

/* Karten */
.card { background: var(--surface-low); border-radius: var(--r-md); padding: 12px 14px; }
.card.outlined { background: var(--surface); border: 1px solid var(--outline-variant); }
.card.high { background: var(--surface-container); }
.card + .card, .card + .section, .section + .card, .section + .section { margin-top: 12px; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 18px 4px 8px; font-size: 13px; font-weight: 600; color: var(--on-surface-variant); }
.section-title .grow { flex: 1; }

/* Listen */
.list { background: var(--surface-low); border-radius: var(--r-md); overflow: hidden; }
.list.plain { background: transparent; border-radius: 0; }
.item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px 8px 14px; }
.item + .item { border-top: 1px solid var(--outline-variant); }
.list.plain .item { padding-left: 4px; padding-right: 4px; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 500; overflow-wrap: anywhere; }
.item .sub { font-size: 12px; line-height: 16px; color: var(--on-surface-variant); overflow-wrap: anywhere; }
.item .end { display: flex; align-items: center; gap: 4px; flex: none; text-align: right; }
.item.dim { opacity: .55; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--primary-container); color: var(--on-primary-container); font-weight: 600; font-size: 15px;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
/* Am Desktop umbrechen statt seitlich wischen (dort sieht man nicht, dass es weitergeht) */
@media (min-width: 840px) { .chips.scroll { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; } }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 12px; flex: none;
  border: 1px solid var(--outline-variant); border-radius: var(--r-sm); background: transparent;
  font-size: 13px; font-weight: 500; color: var(--on-surface-variant); white-space: nowrap;
}
.chip .i { font-size: 18px; margin-left: -4px; }
.chip.on { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.chip.input { padding-right: 6px; }
a.chip, a.btn, a.item, a.icon-btn, a.nav-item { text-decoration: none; }

/* Status-Pillen */
.pill {
  display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-highest); color: var(--on-surface-variant);
}
.pill .i { font-size: 15px; margin-left: -2px; }
.pill.ok { background: var(--success-container); color: var(--on-success-container); }
.pill.warn { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.pill.bad { background: var(--error-container); color: var(--on-error-container); }
.pill.pri { background: var(--primary-container); color: var(--on-primary-container); }
button.pill { border: 0; cursor: pointer; }

/* Eingabefelder (kompakt, Label oben) */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; margin: 0 0 4px 2px; font-size: 12px; font-weight: 500; color: var(--on-surface-variant); }
.input {
  display: block; width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--outline);
  border-radius: var(--r-sm); background: transparent; outline: none; transition: border-color .15s;
}
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.input.big { height: 52px; font-size: 20px; text-align: center; letter-spacing: 6px; font-weight: 600; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row > .input, .input-row > .field { flex: 1; margin-bottom: 0; }
.search { position: relative; }
.search .i { position: absolute; left: 11px; top: 10px; color: var(--on-surface-variant); }
.search .input { padding-left: 38px; border-radius: 20px; background: var(--surface-high); border-color: transparent; }
.hint { font-size: 12px; color: var(--on-surface-variant); margin: -6px 2px 12px; }
.err { color: var(--error); font-size: 13px; margin: 4px 2px 10px; }

/* Switch */
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.switch-row .body { flex: 1; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 13px; border: 2px solid var(--outline); background: var(--surface-highest);
  transition: background .2s var(--ease), border-color .2s var(--ease); pointer-events: none;
}
.switch i::after {
  content: ''; position: absolute; top: 4px; left: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--outline);
  transition: all .2s var(--ease);
}
.switch input:checked + i { background: var(--primary); border-color: var(--primary); }
.switch input:checked + i::after { left: 20px; top: 2px; width: 18px; height: 18px; background: var(--on-primary); }

/* Segmented Buttons */
.seg { display: flex; border: 1px solid var(--outline); border-radius: 18px; overflow: hidden; }
.seg button { flex: 1; height: 34px; border: 0; background: transparent; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.seg button + button { border-left: 1px solid var(--outline); }
.seg button.on { background: var(--secondary-container); color: var(--on-secondary-container); }
.seg button .i { font-size: 18px; }

/* Stepper */
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-high); border-radius: 16px; }
.stepper .n { min-width: 22px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Dialog + Bottom Sheet */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); opacity: 0; transition: opacity .2s var(--ease); }
.scrim.show { opacity: 1; }
.dialog {
  position: fixed; z-index: 51; left: 50%; top: 50%; width: min(400px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  overflow: auto; transform: translate(-50%, -48%) scale(.96); opacity: 0; transition: all .2s var(--ease);
  background: var(--surface-high); border-radius: var(--r-xl); padding: 22px 22px 14px;
}
.dialog.show { transform: translate(-50%, -50%); opacity: 1; }
.dialog h2 { font-size: 20px; font-weight: 600; margin-bottom: 12px; }
.dialog .actions, .sheet .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface-low); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .25s var(--ease);
}
.sheet.show { transform: none; }
.sheet .handle { width: 32px; height: 4px; border-radius: 2px; background: var(--outline); opacity: .5; margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.sheet-head .body { flex: 1; }
.sheet-head h2 { font-size: 18px; line-height: 24px; font-weight: 600; }
/* Aktionsleiste, die beim Scrollen unten im Sheet stehen bleibt */
.sheet-foot {
  position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); z-index: 1; margin: 12px -18px calc(-18px - env(safe-area-inset-bottom));
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); background: var(--surface-low);
}
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(640px, calc(100vw - 48px)); max-height: 86vh; border-radius: var(--r-xl);
           transform: translate(-50%, -46%); opacity: 0; transition: all .2s var(--ease); }
  .sheet.show { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .handle { display: none; }
  .sheet { padding-top: 20px; }
}

/* Snackbar */
.snackbar {
  position: fixed; z-index: 60; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  width: max-content; max-width: calc(100vw - 24px); display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 4px 8px 4px 16px; border-radius: var(--r-xs);
  background: var(--inverse-surface); color: var(--inverse-on-surface); box-shadow: var(--shadow);
  opacity: 0; transition: all .2s var(--ease); pointer-events: none;
}
.snackbar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.snackbar .btn { color: var(--inverse-primary); height: 32px; padding: 0 10px; }
.snackbar .msg { padding: 8px 0; }

/* Leerer Zustand */
.empty { text-align: center; padding: 36px 16px; color: var(--on-surface-variant); }
.empty > .i { font-size: 48px; opacity: .6; margin-bottom: 8px; }
.empty p { margin-bottom: 14px; }
/* Spruch (js/core/fun.js) */
.quip { text-align: center; font-size: 13px; font-style: italic; color: var(--on-surface-variant); margin: 10px 8px; }
.empty .quip { margin-top: -6px; }
.owe .quip { text-align: left; margin: 6px 0 0; color: inherit; opacity: .85; }

/* Ladebalken */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 70; overflow: hidden; pointer-events: none; }
.progress::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: var(--primary);
  animation: prog 1s var(--ease) infinite;
}
@keyframes prog { to { left: 100%; } }
.skeleton { height: 64px; border-radius: var(--r-md); background: var(--surface-container); animation: pulse 1.2s ease-in-out infinite; }
.skeleton + .skeleton { margin-top: 10px; }
@keyframes pulse { 50% { opacity: .5; } }

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap-s { gap: 4px; }
.mt { margin-top: 12px; } .mt-s { margin-top: 6px; } .mb { margin-bottom: 12px; }
.divider { height: 1px; background: var(--outline-variant); margin: 12px 0; }
