/* FirneHub – Design-Tokens
   Palette: Papierweiß #FAFAF8 · Tinte #1C2321 · Tanne #16594E · Honig #E9A13B
   Typo: System-Stack (SF Pro auf iOS) für natives PWA-Gefühl, Display-Gewicht 800 */
:root {
  --bg: #FAFAF8;
  --card: #FFFFFF;
  --ink: #1C2321;
  --muted: #6B7370;
  --line: #E6E5DF;
  --primary: #16594E;
  --primary-soft: #E3EEEB;
  --accent: #E9A13B;
  --danger: #C4453B;
  --radius: 14px;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.45;
  overscroll-behavior-y: none;
}
button { font: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input, select, textarea {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; background: var(--card); width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
.hidden { display: none !important; }

#app { max-width: 640px; margin: 0 auto; padding: calc(var(--sat) + 12px) 16px calc(96px + var(--sab)); }

/* ---- Kopfbereich ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 16px; }
.page-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.page-head .sub { color: var(--muted); font-size: 14px; }

/* ---- Karten & Listen ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.done .title { text-decoration: line-through; color: var(--muted); }

/* ---- Mitglieder: das Signatur-Element ---- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 20px;
  background: var(--card); border: 2.5px solid var(--mcolor, var(--primary));
}
.avatar.lg { width: 64px; height: 64px; font-size: 32px; border-width: 3px; }
.avatar.sm { width: 26px; height: 26px; font-size: 13px; border-width: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--mcolor, var(--primary)) 14%, white);
  color: color-mix(in srgb, var(--mcolor, var(--primary)) 80%, black);
}
.avatar-stack { display: flex; }
.avatar-stack .avatar.sm { margin-left: -8px; background: var(--bg); }
.avatar-stack .avatar.sm:first-child { margin-left: 0; }

/* ---- Login ---- */
.login-wrap { min-height: 85vh; display: flex; flex-direction: column; justify-content: center; }
.login-title { text-align: center; font-size: 32px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 28px; }
.user-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.user-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 8px; font-weight: 600; transition: transform .1s;
}
.user-card:active { transform: scale(.95); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(340px, 90vw); margin: 20px auto 0; }
.pinpad button {
  height: 70px; font-size: 27px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.pinpad button:active { background: var(--primary-soft); }
.pinpad button.ok { color: var(--muted); }
.pinpad button.ok.ready { background: var(--primary); border-color: var(--primary); color: #fff; }
.pin-cancel { display: block; margin: 18px auto 0; padding: 10px 20px; color: var(--muted); font-size: 15px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 4px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dot.full { background: var(--primary); border-color: var(--primary); }

/* ---- Tab-Bar ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 2px calc(6px + var(--sab));
}
.tabbar button {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10px; font-weight: 600; color: var(--muted); padding: 4px 0; border-radius: 10px;
  white-space: nowrap;
}
.tabbar button.active { color: var(--primary); }
.tabbar .tab-icon { font-size: 20px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: #fff; font-weight: 600;
  padding: 12px 18px; border-radius: 12px; width: 100%;
}
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.btn.danger { background: #FBEAE8; color: var(--danger); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; }
.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--sab)); z-index: 40;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 28px;
  box-shadow: 0 6px 18px rgba(22,89,78,.35);
  display: grid; place-items: center;
}

/* ---- Segmente / Filter ---- */
.segments { display: flex; background: var(--primary-soft); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.segments button { flex: 1; padding: 8px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--primary); }
.segments button.active { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ---- Kalender ---- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { font-size: 19px; font-weight: 700; text-transform: capitalize; }
.cal-nav { font-size: 22px; padding: 6px 14px; color: var(--primary); font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 14px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 14px; position: relative;
}
.cal-day.other { color: #C6C9C4; }
.cal-day.today { background: var(--primary-soft); font-weight: 800; color: var(--primary); }
.cal-day.selected { background: var(--primary); color: #fff; font-weight: 700; }
.cal-day .dots { display: flex; gap: 2px; height: 5px; }
.cal-day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal-day.selected .dot { background: #fff; }

/* ---- Wetter-Karte (Heute) ---- */
.weather-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.weather-card .w-now { font-size: 34px; font-weight: 800; letter-spacing: -1px; white-space: nowrap; }
.weather-card .w-info { text-align: right; min-width: 0; }
.weather-card .w-place { font-weight: 600; font-size: 15px; }
.weather-card .w-meta { font-size: 13px; color: var(--muted); }

/* ---- Google-Kalender-Chip ---- */
.gcal-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: #ECECEA; color: var(--muted);
  white-space: nowrap; max-width: 170px; overflow: hidden; text-overflow: ellipsis;
}

/* ---- Checkbox ---- */
.check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; flex-shrink: 0; font-size: 15px; color: transparent;
  transition: all .15s;
}
.check.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- Punkte ---- */
.points-badge {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13px;
  color: #8A5A00; background: #FCF0DA; padding: 3px 9px; border-radius: 999px;
}
.leaderboard { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.leader-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; min-width: 88px;
}
.leader-card .name { font-size: 13px; font-weight: 600; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,28,26,.45); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--bg); width: 100%; max-width: 640px;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + var(--sab));
  max-height: 88vh; overflow-y: auto;
  animation: slideUp .22s ease-out;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }
.modal h2 { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.member-select { display: flex; gap: 8px; flex-wrap: wrap; }
.member-select .avatar { opacity: .4; transition: all .12s; }
.member-select .avatar.sel { opacity: 1; transform: scale(1.08); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mcolor) 30%, transparent); }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--sab)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Wiki ---- */
.wiki-cat { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.md h1 { font-size: 22px; margin: 14px 0 8px; }
.md h2 { font-size: 18px; margin: 12px 0 6px; }
.md h3 { font-size: 16px; margin: 10px 0 5px; }
.md p { margin-bottom: 9px; }
.md ul, .md ol { margin: 0 0 9px 22px; }
.md code { background: var(--primary-soft); padding: 1px 6px; border-radius: 5px; font-size: 14px; }
.md a { color: var(--primary); }

/* ---- Mehr-Menü ---- */
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 14px; margin-bottom: 8px; font-weight: 600; font-size: 16px; text-align: left;
}
.menu-item .mi-icon { font-size: 24px; }
.menu-item .chev { margin-left: auto; color: var(--muted); }

.status-pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.status-idee    { background: #EEE9FB; color: #5B3FA8; }
.status-geplant { background: #FCF0DA; color: #8A5A00; }
.status-gebucht { background: #E0F1E7; color: #146C43; }
.status-vorbei  { background: #ECECEA; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.back-btn { color: var(--primary); font-weight: 700; font-size: 16px; padding: 6px 0; margin-bottom: 4px; }

/* ---- Keller-Lager ---- */
.st-chips { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.st-chips:empty { display: none; }
.st-loc-chip {
  flex-shrink: 0; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.st-loc-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.st-loc-chip .cnt { opacity: .75; font-size: 12px; }

.st-shelf { display: grid; gap: 5px; margin-bottom: 14px; }
.st-cell {
  aspect-ratio: 1.25; min-height: 46px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .1s;
}
.st-cell:active { transform: scale(.94); }
.st-cell .st-zone {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; font-weight: 700; letter-spacing: .03em;
}
.st-cell .st-count {
  font-size: 10.5px; font-weight: 700; line-height: 16px; min-width: 18px; text-align: center;
  background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 0 5px;
}
.st-cell.empty .st-zone { color: var(--muted); opacity: .55; }
.st-cell.empty .st-count { visibility: hidden; }
.st-cell.sel {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 3px 10px rgba(22,89,78,.3);
}
.st-cell.sel .st-count { background: rgba(255,255,255,.25); color: #fff; visibility: visible; }
.st-shelf.mini { gap: 4px; }
.st-shelf.mini .st-cell { aspect-ratio: auto; min-height: 40px; padding: 4px 2px; }
.st-shelf.mini .st-cell .st-zone { font-size: 11px; }

.zone-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  background: var(--primary-soft); color: var(--primary);
  padding: 2px 7px; border-radius: 6px;
}

.st-thumb {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover;
  flex-shrink: 0; border: 1px solid var(--line); background: var(--primary-soft);
}
.st-thumb.ph { display: grid; place-items: center; font-size: 24px; }

.st-preview {
  display: block; max-width: 100%; max-height: 200px;
  border-radius: 12px; margin-top: 10px; border: 1px solid var(--line);
}
.st-photo-big {
  display: block; width: 100%; border-radius: 14px; margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
