/* ==========================================================================
   Handy- und Laptop-Ansicht
   ========================================================================== */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* --- Kopfzeile ---------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: calc(.6rem + var(--safe-t)) .9rem .6rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.who {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .25rem .6rem .25rem .25rem;
  border-radius: 999px;
  min-width: 0;
}
.who:active { background: var(--card-2); }
.who .avatar { font-size: 1.25rem; }
.who b { font-size: 1rem; }

/* --- Inhalt ------------------------------------------------------------- */
main {
  flex: 1;
  padding: 1rem .9rem 6.5rem;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  animation: fade .18s ease;
}

h2.section {
  margin: 1.6rem 0 .7rem;
  font-size: 1rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg-3);
}
h2.section:first-child { margin-top: .2rem; }

/* --- Fußleiste ---------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: .35rem .3rem calc(.35rem + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line-soft);
}
.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: .4rem 0 .2rem;
  border-radius: var(--r-sm);
  font-size: .68rem;
  font-weight: 600;
  color: var(--fg-3);
}
.tabbar button span { font-size: 1.4rem; line-height: 1.1; }
.tabbar button.on { color: var(--accent); }
.tabbar button:active { background: var(--card-2); }

/* --- Anmeldung ---------------------------------------------------------- */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: radial-gradient(120% 90% at 50% 0%, var(--wall-glow-1) 0%, var(--bg) 65%);
  z-index: 100;
}
.login-box { padding: 2rem 1.6rem; width: min(360px, 100%); text-align: center; }
.login-logo { font-size: 3.4rem; animation: pop .4s ease both; }
.login h1 { margin: .3rem 0 .2rem; font-size: 1.5rem; }
.pin-input {
  text-align: center;
  letter-spacing: .6em;
  font-size: 1.7rem;
  margin: 1.2rem 0 .8rem;
  padding: .5em;
  min-height: 64px;
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin: 0 0 .9rem;
}
.pin-pad button {
  min-height: 54px;
  font-size: 1.35rem;
  border-radius: var(--r-sm);
  background: var(--card-2);
  border: 1px solid var(--line);
  cursor: pointer;
}
.pin-pad button:active { background: var(--accent); color: #fff; }

/* --- Karten & Listen ---------------------------------------------------- */
.tile {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .85rem 1rem;
  border-radius: var(--r);
  background: var(--card);
  border: 1px solid var(--line-soft);
  margin-bottom: .5rem;
  animation: rise .2s ease both;
}
.tile.tap { cursor: pointer; transition: transform .12s; }
.tile.tap:active { transform: scale(.985); }
.tile .lead { font-size: 1.5rem; flex: none; width: 2rem; text-align: center; }

.day-head {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  margin: 1.3rem 0 .5rem;
  font-weight: 700;
}
.day-head.today { color: var(--accent); }
.day-head small { color: var(--fg-3); font-weight: 500; }

.mini-avatars { display: flex; gap: -4px; }
.mini-avatars .avatar { width: 1.7em; height: 1.7em; font-size: .85rem; margin-left: -6px; }
.mini-avatars .avatar:first-child { margin-left: 0; }

.empty {
  padding: 2.4rem 1rem;
  text-align: center;
  color: var(--fg-3);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
}
.empty .big { font-size: 2.6rem; display: block; margin-bottom: .4rem; }

/* --- Monatskalender ----------------------------------------------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.cal-head b { font-size: 1.15rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-grid .wd { text-align: center; font-size: .7rem; color: var(--fg-3); padding: .3rem 0; font-weight: 700; }
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1.05;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid transparent;
  padding: .25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: .8rem;
}
.cal-cell.out { opacity: .32; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.sel { background: var(--accent); color: var(--on-accent); }
.cal-cell { aspect-ratio: auto; min-height: 84px; align-items: stretch; overflow: hidden; }
.cal-cell .cal-num { text-align: center; font-weight: 600; }
.cal-ev {
  display: block;
  font-size: .64rem;
  line-height: 1.25;
  padding: 1px 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--c) 28%, transparent);
  border-left: 3px solid var(--c);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.cal-cell.sel .cal-ev { color: var(--on-accent); }
.cal-more { font-size: .62rem; color: var(--fg-3); text-align: center; }
.cal-ev .t { display: none; }                 /* auf dem Handy nur der Titel */
@media (min-width: 700px) { .cal-ev .t { display: inline; color: var(--fg-2); } }
@media (min-width: 700px) { .cal-cell { min-height: 110px; } .cal-ev { font-size: .74rem; } }

/* --- Listen ------------------------------------------------------------- */
.list-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem .9rem;
  border-radius: var(--r);
  background: var(--card);
  border: 1px solid var(--line-soft);
  margin-bottom: .4rem;
}
.list-item.done { opacity: .45; }
.list-item.done .txt { text-decoration: line-through; }
.check {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex: none;
  display: grid;
  place-items: center;
  font-size: .9rem;
  transition: transform .12s;
}
.check:active { transform: scale(.85); }
.check.on { background: var(--good); border-color: var(--good); color: #06210f; }

.add-row { display: flex; gap: .5rem; margin: .6rem 0 1rem; }

/* --- Stundenplan -------------------------------------------------------- */
.timetable { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.timetable table { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 520px; }
.timetable th { font-size: .75rem; color: var(--fg-3); font-weight: 700; }
.timetable td {
  background: var(--card);
  border-radius: 10px;
  padding: .45rem .5rem;
  vertical-align: top;
  font-size: .82rem;
  min-width: 84px;
}
.timetable td.free { background: transparent; }
.timetable .sub { font-weight: 700; }
.timetable .rm { color: var(--fg-3); font-size: .72rem; }
.timetable .per { color: var(--fg-3); font-size: .72rem; text-align: right; min-width: 34px; }

/* --- Sterne ------------------------------------------------------------- */
.kid-card {
  padding: 1rem;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--line-soft);
  margin-bottom: .8rem;
}
.kid-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .7rem; }
.kid-head .avatar { width: 2.6rem; height: 2.6rem; font-size: 1.4rem; }
.bar { height: 10px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--star); transition: width .5s ease; }

.chore-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.chore {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  aspect-ratio: 1;
  border-radius: var(--r);
  background: var(--card-2);
  border: 2px solid transparent;
  padding: .4rem;
  font-size: .72rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.15;
  transition: transform .12s;
  overflow: hidden;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.chore .em { font-size: 1.9rem; }
.chore:active { transform: scale(.93); }
.chore.done { background: color-mix(in srgb, var(--good) 22%, var(--card)); border-color: var(--good); }
.chore .pts { color: var(--star); font-weight: 800; }

.reward {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .9rem; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line-soft); margin-bottom: .4rem;
}
.reward.cheap { border-color: color-mix(in srgb, var(--star) 55%, transparent); }

/* --- Pinnwand ----------------------------------------------------------- */
.notes { columns: 2; column-gap: .6rem; }
@media (max-width: 420px) { .notes { columns: 1; } }
.note {
  break-inside: avoid;
  margin-bottom: .6rem;
  padding: .9rem;
  border-radius: 14px;
  color: #221a05;
  box-shadow: var(--shadow);
  animation: rise .2s ease both;
}
.note .meta { display: flex; align-items: center; gap: .4rem; font-size: .72rem; opacity: .7; margin-top: .5rem; }

/* --- Fotos -------------------------------------------------------------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: .35rem; }
.gallery img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 12px; background: var(--card-2); display: block;
}
.files .tile .lead { font-size: 1.3rem; }

/* --- Overlay / Formular-Blatt ------------------------------------------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); animation: fade .15s ease; }
.sheet {
  position: relative;
  width: min(560px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  padding: 1.1rem 1.1rem calc(1.4rem + var(--safe-b));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  animation: rise .22s ease both;
}
@media (min-width: 600px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: var(--r-xl); }
}
.sheet h3 { margin: .2rem 0 1rem; font-size: 1.2rem; }
.field { margin-bottom: .8rem; }
.field > label { display: block; font-size: .78rem; color: var(--fg-2); margin-bottom: .3rem; font-weight: 600; }
.sheet-actions { display: flex; gap: .6rem; margin-top: 1.1rem; }
.sheet-actions .btn { flex: 1; }

.picker { display: flex; flex-wrap: wrap; gap: .4rem; }
.picker button {
  padding: .4rem .7rem; border-radius: 999px;
  background: var(--card-2); border: 2px solid transparent; font-weight: 600; font-size: .85rem;
}
.picker button.on { border-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: .45rem; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: var(--fg); }

.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: .25rem; max-height: 180px; overflow-y: auto; }
.emoji-grid button { font-size: 1.5rem; padding: .25rem; border-radius: 10px; }
.emoji-grid button.on { background: var(--card-2); outline: 2px solid var(--accent); }

/* Schwebender Plus-Knopf */
.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(5.4rem + var(--safe-b));
  z-index: 25;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.9rem;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-lg);
  transition: transform .12s;
}
.fab:active { transform: scale(.9); }

/* --- Geburtstag, Essen, Zuhause ----------------------------------------- */
.tile.birthday {
  background: linear-gradient(120deg,
    color-mix(in srgb, var(--star) 20%, var(--card)), var(--card));
  border-color: color-mix(in srgb, var(--star) 45%, transparent);
}
.tile.is-today { border-color: var(--accent); }

.ha-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: .5rem; }
.ha-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .75rem .4rem;
  border-radius: var(--r);
  background: var(--card);
  border: 2px solid var(--line-soft);
  font-size: .74rem;
  transition: transform .12s;
}
.ha-tile:active { transform: scale(.94); }
.ha-tile .em { font-size: 1.7rem; filter: grayscale(1) opacity(.55); transition: filter .2s; }
.ha-tile .nm { font-weight: 700; max-width: 100%; }
.ha-tile .st { color: var(--fg-3); }
.ha-tile.on { border-color: var(--star); background: color-mix(in srgb, var(--star) 12%, var(--card)); }
.ha-tile.on .em { filter: none; }
.ha-tile.on .st { color: var(--star); }
.ha-tile:disabled { opacity: 1; pointer-events: none; }

/* --- Sparziele ----------------------------------------------------------- */
.goal { display: flex; align-items: center; gap: .6rem; margin-top: .7rem; }
.goal > span:first-child { font-size: 1.3rem; }

/* Wer ist bei einem rotierenden Ämtchen gerade dran */
.who-badge {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .7rem;
}
.chore { position: relative; }

/* --- Malen --------------------------------------------------------------- */
.draw-canvas {
  width: 100%;
  aspect-ratio: 900 / 640;
  border-radius: var(--r);
  background: #fff;
  touch-action: none;
  display: block;
  border: 1px solid var(--line);
}
.draw-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-top: .7rem; }
.note-img { width: 100%; border-radius: 10px; display: block; background: #fff; }

/* Im Kindermodus verschwinden die gefährlichen Knöpfe */
body.kid-mode .tabbar button[data-tab="settings"] { display: none; }

.seg { display: flex; background: var(--card-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { flex: 1; padding: .5rem .4rem; border-radius: 999px; font-weight: 600; font-size: .85rem; color: var(--fg-2); }
.seg button.on { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }

/* --- Design-Auswahl ------------------------------------------------------ */
/* Jede Karte trägt data-theme ihres Designs und zeigt sich in dessen Farben */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-bottom: .4rem; }
.theme-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .25rem;
  padding: .8rem; border-radius: var(--r); text-align: left; cursor: pointer;
  background: var(--bg); color: var(--fg); border: 2px solid var(--line); font-family: var(--font);
}
.theme-card b { font-family: var(--font-display); font-size: 1.1rem; }
.theme-card .tiny { color: var(--fg-2); }
.theme-card.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.theme-swatch { display: flex; gap: 4px; }
.theme-swatch i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); }
.theme-swatch i:nth-child(1) { background: var(--card); }
.theme-swatch i:nth-child(2) { background: var(--accent); }
.theme-swatch i:nth-child(3) { background: var(--star); }

/* Anmeldung mit Benutzername und Passwort */
#pw-form { text-align: left; display: flex; flex-direction: column; gap: .3rem; margin: 1rem 0 .4rem; }
#pw-form.hidden { display: none; }
#pw-form .muted { text-align: center; margin: 0 0 .5rem; }

/* --- Einstellungen in Gruppen ------------------------------------------- */
.set-group { background: var(--card); border: 1px solid var(--line-soft, var(--line)); border-radius: var(--r-lg, 16px);
  margin-bottom: .7rem; overflow: hidden; }
.set-group > summary { list-style: none; display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; cursor: pointer; }
.set-group > summary::-webkit-details-marker { display: none; }
.set-group > summary::after { content: '›'; font-size: 1.4rem; color: var(--fg-3); transition: transform .15s; }
.set-group[open] > summary::after { transform: rotate(90deg); }
.set-group > summary b { display: block; }
.set-group > summary small { display: block; color: var(--fg-3); font-size: .78rem; margin-top: .1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-group > summary .grow { min-width: 0; }
.set-icon { font-size: 1.5rem; flex: none; width: 2rem; text-align: center; }
.set-group[open] { padding-bottom: .8rem; }
.set-group[open] > summary { border-bottom: 1px solid var(--line-soft, var(--line)); margin-bottom: .3rem; }
.set-group > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
