/* ==========================================================================
   Gemeinsame Grundlagen für App und Wandpanel.
   Ein einziges Farb- und Formsystem, damit beides zusammengehört.
   ========================================================================== */

:root {
  /* Flächen */
  --bg:        #0e1116;
  --bg-2:      #141922;
  --card:      #1a2029;
  --card-2:    #212936;
  --line:      #2b3542;
  --line-soft: #232c38;

  /* Schrift */
  --fg:        #eef2f7;
  --fg-2:      #a9b6c7;
  --fg-3:      #6d7d90;

  /* Akzente */
  --accent:    #6ea8ff;
  --star:      #ffc94d;
  --good:      #3ddc97;
  --warn:      #ff9f45;
  --bad:       #ff6b81;

  /* Form */
  --r-sm: 10px;
  --r:    16px;
  --r-lg: 24px;
  --r-xl: 32px;

  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI',
          Inter, Roboto, system-ui, sans-serif;
  --font-display: var(--font);
  --on-accent: #06111f;          /* Text auf Akzent-Flächen */
  --wall-glow-1: #1d2837;        /* weiche Lichtflecken im Wand-Hintergrund */
  --wall-glow-2: #23202f;

  /* Sichere Ränder für iPhone-Notch / Home-Indikator */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ==========================================================================
   Designs - jede Person wählt eines aus, die Wand hat ein eigenes.
   "nacht" ist der Standard oben. Schriften liegen lokal (fonts/fonts.css).
   ========================================================================== */

/* 1 · Nacht auch einzeln (für Vorschaukarten in anderen Designs) */
[data-theme='nacht'] {
  --bg: #0e1116; --bg-2: #141922; --card: #1a2029; --card-2: #212936; --line: #2b3542;
  --fg: #eef2f7; --fg-2: #a9b6c7; --fg-3: #6d7d90; --accent: #6ea8ff; --on-accent: #06111f; --star: #ffc94d;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, system-ui, sans-serif; --font-display: var(--font);
  --r: 16px;
}

/* 2 · Papier - hell, wie ein gedruckter Familienplaner */
:root[data-theme='papier'], :root[data-theme='light'], [data-theme='papier'] {
  --bg: #f6f1e7; --bg-2: #fffdf8; --card: #fffdf8; --card-2: #efe7d6;
  --line: #d8cdb8; --line-soft: #e6dcc8;
  --fg: #221d16; --fg-2: #4a4137; --fg-3: #6f6556;
  --accent: #2f5d8a; --on-accent: #ffffff; --star: #b7791f; --good: #2f7d4f; --bad: #b4233c;
  --font: 'Source Sans 3', system-ui, sans-serif; --font-display: 'Fraunces', Georgia, serif;
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 18px;
  --shadow: 0 2px 10px rgba(60, 40, 10, .08); --shadow-lg: 0 12px 32px rgba(60, 40, 10, .14);
  --wall-glow-1: #fffdf8; --wall-glow-2: #efe7d6;
}

/* 3 · Kinderzimmer - kräftig, rund, große Knöpfe */
:root[data-theme='kinderzimmer'], [data-theme='kinderzimmer'] {
  --bg: #fff7e6; --bg-2: #ffffff; --card: #ffffff; --card-2: #ffeccc;
  --line: #f1d9a8; --line-soft: #f7e6c4;
  --fg: #1e2a3a; --fg-2: #3c4a5e; --fg-3: #5e6b7d;
  --accent: #3b5bdb; --on-accent: #ffffff; --star: #e8a400; --good: #12a150; --bad: #d6336c;
  --font: 'Baloo 2', ui-rounded, system-ui, sans-serif; --font-display: 'Baloo 2', ui-rounded, sans-serif;
  --r-sm: 14px; --r: 22px; --r-lg: 28px; --r-xl: 36px;
  --shadow: 0 4px 0 rgba(30, 42, 58, .9); --shadow-lg: 0 14px 34px rgba(30, 42, 58, .18);
  --wall-glow-1: #ffe8f1; --wall-glow-2: #e3ecff;
}

/* 4 · Skandi - gedämpftes Salbeigrün, viel Luft */
:root[data-theme='skandi'], [data-theme='skandi'] {
  --bg: #eef0ea; --bg-2: #ffffff; --card: #ffffff; --card-2: #f4f6f1;
  --line: #dfe3da; --line-soft: #e8ebe4;
  --fg: #2b2f2a; --fg-2: #4f574d; --fg-3: #6c7469;
  --accent: #3f5b4c; --on-accent: #ffffff; --star: #a5792b; --good: #3f7a56; --bad: #a33b3b;
  --font: 'Manrope', system-ui, sans-serif; --font-display: 'Manrope', system-ui, sans-serif;
  --r-sm: 6px; --r: 8px; --r-lg: 10px; --r-xl: 12px;
  --shadow: none; --shadow-lg: 0 10px 30px rgba(40, 50, 40, .10);
  --wall-glow-1: #f6f7f3; --wall-glow-2: #e4e8df;
}

/* 5 · Kontrast - Schwarz/Gelb, sehr gut lesbar */
:root[data-theme='kontrast'], [data-theme='kontrast'] {
  --bg: #000000; --bg-2: #000000; --card: #000000; --card-2: #141414;
  --line: #ffffff; --line-soft: #9a9a9a;
  --fg: #ffffff; --fg-2: #ffffff; --fg-3: #e6e6e6;
  --accent: #ffe14d; --on-accent: #000000; --star: #ffe14d; --good: #5cff9d; --bad: #ff7a8a;
  --font: 'Atkinson Hyperlegible', system-ui, sans-serif; --font-display: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --r-sm: 4px; --r: 6px; --r-lg: 8px; --r-xl: 10px;
  --shadow: none; --shadow-lg: none;
  --wall-glow-1: #000000; --wall-glow-2: #000000;
}
:root[data-theme='kontrast'] body { font-size: 18px; }
:root[data-theme='kontrast'] .card, :root[data-theme='kontrast'] .tile { border: 2px solid var(--line); }

/* 6 · Kreidetafel - grüne Tafel, Handschrift */
:root[data-theme='kreidetafel'], [data-theme='kreidetafel'] {
  --bg: #24352c; --bg-2: #2c4135; --card: #2c4135; --card-2: #34493c;
  --line: #4f6657; --line-soft: #415a4a;
  --fg: #f1efe6; --fg-2: #d5dccf; --fg-3: #aab8ad;
  --accent: #ffe08a; --on-accent: #24352c; --star: #ffe08a; --good: #a8e6bf; --bad: #f6b1c8;
  --font: 'Patrick Hand', 'Comic Neue', system-ui, sans-serif; --font-display: 'Caveat', 'Patrick Hand', cursive;
  --r-sm: 8px; --r: 12px; --r-lg: 14px; --r-xl: 18px;
  --wall-glow-1: #2c4135; --wall-glow-2: #1f2e26;
}
:root[data-theme='kreidetafel'] body.wall { border: 16px solid #6b4a2b; }

h1, h2, h3, .clock, .frame-clock, .cal-head b, .login h1 { font-family: var(--font-display); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior: none;
}

body { -webkit-font-smoothing: antialiased; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

/* --- Bausteine ---------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  min-height: 48px;
  padding: 0 1.15em;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--fg);
  font-weight: 600;
  border: 1px solid var(--line);
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .38; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.ghost   { background: transparent; }
.btn.danger  { color: var(--bad); }
.btn.round   { width: 48px; min-height: 48px; padding: 0; }

.input, select.input, textarea.input {
  width: 100%;
  min-height: 48px;
  padding: .6em .9em;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 90px; resize: vertical; }

.row { display: flex; align-items: center; gap: .6rem; }
.col { display: flex; flex-direction: column; gap: .6rem; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--fg-2); }
.tiny { font-size: .8rem; color: var(--fg-3); }
.center { text-align: center; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Avatar eines Familienmitglieds */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2em;
  height: 2.2em;
  border-radius: 50%;
  background: var(--card-2);
  border: 2px solid currentColor;
  font-size: 1em;
  flex: none;
  user-select: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .3em .7em;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--line);
  font-size: .85rem;
  font-weight: 600;
}

/* Sterne-Zähler */
.stars {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  color: var(--star);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* --- Animationen -------------------------------------------------------- */
@keyframes pop  { 0% { transform: scale(.7); opacity: 0 } 60% { transform: scale(1.08) } 100% { transform: scale(1); opacity: 1 } }
@keyframes rise { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes spin { to { transform: rotate(360deg) } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* --- Konfetti (Belohnung) ------------------------------------------------ */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* --- Sammel-Meldung ------------------------------------------------------ */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: center;
  pointer-events: none;
}
#toast div {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: .7em 1.2em;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  animation: rise .2s ease both;
  font-weight: 600;
}
#toast div.bad { border-color: var(--bad); color: var(--bad); }
