:root {
  /* Dark Mode als Standard (immer dunkel) */
  --bg: #141627;
  --surface: #1e2135;
  --surface-2: #262a42;
  --text: #e9ebf5;
  --muted: #a0a5be;
  --line: #313653;
  --accent: #7f93f5;
  --danger: #e8675f;
  --ok: #3fb178;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  line-height: 1.4;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 12px calc(32px + var(--safe-bottom));
}

/* ---------------- Kopf ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
}
.brand .paw { font-size: 1.35rem; }
.brand .secret-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #fff;
  background: linear-gradient(135deg, #8a5cff, #5b76f0);
  padding: 3px 8px;
  border-radius: 999px;
}
.topbar .spacer { flex: 1; }

.iconbtn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 12px;
  font-size: 1.15rem;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.iconbtn:active { transform: scale(0.96); }

/* ---------------- Monatsnavigation ---------------- */
.monthbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.monthbar .title {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}
.nav {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  height: 40px; min-width: 40px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 1.1rem;
  cursor: pointer;
}
.nav.today-btn { font-size: 0.9rem; font-weight: 600; }

/* ---------------- Wunsch-Posteingang ---------------- */
.wishbox {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid #e8a13a;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.wishbox h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.wish {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
  flex-wrap: wrap;
}
.wish:first-of-type { border-top: 0; }
.wish .wtext { flex: 1; min-width: 160px; font-size: 0.92rem; }
.wish .wtext small { color: var(--muted); display: block; }
.wish .wactions { display: flex; gap: 6px; }

/* ---------------- Kalender ---------------- */
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.weekdays div {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cell {
  position: relative;
  aspect-ratio: 1 / 1.08;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 5px 6px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 52px;
}
.cell:active { transform: scale(0.98); }
.cell.out { opacity: 0.4; }
.cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell .num {
  font-size: 0.82rem;
  font-weight: 700;
  position: relative;
  z-index: 2;
}
.cell .fill {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.cell .fill.single { background: color-mix(in srgb, var(--c) 42%, var(--surface)); }
.cell .fill.split {
  background: linear-gradient(118deg,
    color-mix(in srgb, var(--cb) 44%, var(--surface)) 0 48%,
    color-mix(in srgb, var(--ca) 44%, var(--surface)) 52% 100%);
}
.cell .markers {
  position: relative;
  z-index: 2;
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}
.cell .chg {
  position: absolute;
  z-index: 2;
  top: 4px; right: 5px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-radius: 6px;
  padding: 0 3px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--d); display: inline-block; }
.cell .note-i { font-size: 0.72rem; z-index: 2; position: relative; }
.cell .wish-i {
  position: absolute; z-index: 2; top: 3px; left: 4px;
  font-size: 0.7rem; color: #b8791b;
}
.cell.has-wish { border-style: dashed; border-color: #e8a13a; }
.ho-bar {
  position: relative; z-index: 2;
  display: flex; gap: 2px; margin-top: 2px;
}
.ho-chip {
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 0 4px;
  border-radius: 5px;
  color: #fff;
  background: var(--d);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------- Legende ---------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 0.85rem; }
.legend .swatch { width: 15px; height: 15px; border-radius: 5px; background: var(--c); }
.legend .sep { width: 100%; height: 0; }
.legend .label-muted { color: var(--muted); font-size: 0.78rem; width: 100%; }

.subscribe-row {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.linklike {
  background: none; border: 0; color: var(--accent);
  font-size: 0.85rem; cursor: pointer; padding: 4px 2px; text-decoration: underline;
}

/* ---------------- Sheets / Modals ---------------- */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 12, 25, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  padding: 16px 16px calc(18px + var(--safe-bottom));
  max-height: 92vh;
  overflow-y: auto;
  animation: slideup 0.2s ease;
}
@keyframes slideup { from { transform: translateY(24px); opacity: 0.6; } }
@media (min-width: 620px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 20px; }
}
.sheet h2 { margin: 2px 0 2px; font-size: 1.1rem; }
.sheet .sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 14px; }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.section { margin: 14px 0; }
.section h4 {
  margin: 0 0 8px; font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted);
}

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.pill .swatch { width: 13px; height: 13px; border-radius: 4px; background: var(--c); }
.pill.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.pill.ghost { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; border-radius: 12px;
  padding: 11px 16px;
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer;
  background: var(--surface-2); color: var(--text);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger-outline { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 11px; font-size: 0.85rem; border-radius: 10px; }
.btn:active { transform: scale(0.98); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

input[type=text], input[type=date], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 0.95rem;
  font-family: inherit;
}
input[type=color] {
  width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); cursor: pointer;
}
textarea { resize: vertical; min-height: 60px; }
label.fld { display: block; font-size: 0.82rem; color: var(--muted); margin: 10px 0 4px; }

.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

.ho-item, .person-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.ho-item:first-child, .person-item:first-child { border-top: 0; }
.ho-item .main, .person-item .main { flex: 1; min-width: 140px; font-size: 0.9rem; }
.ho-item .main small, .person-item .main small { color: var(--muted); display: block; }

.copybox {
  display: flex; gap: 6px; align-items: center;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 6px 6px 10px; margin-top: 6px;
}
.copybox code { flex: 1; font-size: 0.78rem; overflow-x: auto; white-space: nowrap; }

.field-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------- Toast ---------------- */
#toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(18px + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 80; pointer-events: none;
}
.toast {
  background: #222638; color: #fff;
  padding: 10px 16px; border-radius: 999px;
  font-size: 0.88rem; box-shadow: var(--shadow);
  animation: toastin 0.18s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes toastin { from { transform: translateY(10px); opacity: 0; } }

.loading { text-align: center; color: var(--muted); padding: 40px 0; }
.hint { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }
