:root {
  --bg: #f4f1ec; --card: #ffffff; --ink: #1f2937; --muted: #6b7280; --line: #e5e1d8;
  --accent: #2563eb; --accent-ink: #fff; --ok: #16a34a; --danger: #dc2626;
  --nav: #1f2937; --nav-ink: #e5e7eb; --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font: 20px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  overflow: hidden; user-select: none; -webkit-user-select: none;
  transition: filter .6s;
}
body.night { filter: brightness(.5); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; }

#app { display: flex; height: 100%; }
#nav { width: 104px; background: var(--nav); display: flex; flex-direction: column; padding: 10px 8px; gap: 8px; overflow-y: auto; }
#nav button {
  background: transparent; color: var(--nav-ink); border-radius: 16px; padding: 14px 4px;
  font-size: 15px; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative;
}
#nav button span { font-size: 32px; line-height: 1; }
#nav button.active { background: #374151; color: #fff; }
#shopBadge {
  position: absolute; top: 6px; right: 14px; background: var(--danger); color: #fff; font-style: normal;
  font-size: 13px; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; padding: 0 5px;
}
#view { flex: 1; padding: 22px 26px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

h1 { font-size: 30px; margin: 0 0 16px; }
h2 { font-size: 21px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 14px; align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.btn { background: var(--accent); color: var(--accent-ink); padding: 12px 20px; border-radius: 14px; font-weight: 600; }
.btn.ghost { background: #e8e4db; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 14px; font-size: 17px; }

/* Heute */
.today-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; }
.clock { font-size: 84px; font-weight: 700; letter-spacing: -2px; line-height: 1; }
.date { font-size: 26px; color: var(--muted); margin-top: 6px; }
.ev { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: #9ca3af; }
.ev .t { width: 112px; color: var(--muted); flex: none; font-size: 18px; }
.ev .ti { font-weight: 600; }
.ev .loc { font-size: 16px; color: var(--muted); }

/* Chips / Aufgaben */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  background: #eee9df; border-radius: 999px; padding: 12px 18px; display: inline-flex; gap: 8px; align-items: center;
  font-size: 19px;
}
.chip.sel { outline: 3px solid var(--accent); background: #fff; }
.chore { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.chore:last-child { border-bottom: 0; }
.check {
  width: 44px; height: 44px; border-radius: 12px; border: 3px solid #cbd5e1; background: #fff; flex: none;
  display: grid; place-items: center; font-size: 28px; color: #fff;
}
.chore.done .check { background: var(--ok); border-color: var(--ok); }
.chore.done .name { text-decoration: line-through; color: var(--muted); }
.pts { color: #b45309; font-size: 17px; }
.person-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; font-size: 22px; font-weight: 700; }
.bar { height: 10px; background: #e8e4db; border-radius: 6px; overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--ok); }

/* Einkauf */
.add { display: flex; gap: 10px; margin-bottom: 14px; }
.add input { flex: 1; padding: 14px 18px; border-radius: 14px; border: 2px solid var(--line); background: #fff; user-select: text; -webkit-user-select: text; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: #fff; border-radius: 14px; margin-bottom: 8px; }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item .x { background: transparent; color: var(--muted); font-size: 26px; padding: 4px 10px; }
.qty { color: var(--muted); font-size: 17px; }

/* Kalender */
.cal-wrap { display: grid; grid-template-columns: 1.8fr 1fr; gap: 20px; align-items: start; }
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cal-head h1 { margin: 0; flex: 1; text-transform: capitalize; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow { text-align: center; color: var(--muted); font-size: 16px; }
.cell { background: #fff; border-radius: 12px; min-height: 92px; padding: 6px 7px; overflow: hidden; border: 3px solid transparent; }
.cell.other { opacity: .45; }
.cell.today .n { background: var(--accent); color: #fff; }
.cell.sel { border-color: var(--accent); }
.cell .n { display: inline-grid; place-items: center; min-width: 28px; height: 28px; border-radius: 14px; font-weight: 700; font-size: 17px; }
.mini { font-size: 13px; line-height: 1.15; padding: 2px 5px; border-radius: 5px; margin-top: 3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chead { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.ico { font-size: 14px; line-height: 1; white-space: nowrap; }

/* Wetter */
.wx { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.wx:empty { display: none; }
.wx-icon { font-size: 54px; line-height: 1; }
.wx-temp { font-size: 46px; font-weight: 700; }
.wx-info { font-size: 18px; line-height: 1.3; }
.card.alert { outline: 4px solid #f59e0b; background: #fffbeb; }
.btn[disabled], .chip[disabled] { opacity: .45; pointer-events: none; }
.x { background: transparent; color: var(--muted); font-size: 24px; padding: 4px 10px; }

/* Mehr-Menue */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.tile {
  background: var(--card); border-radius: var(--radius); padding: 26px 12px; font-size: 21px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.tile span { font-size: 52px; line-height: 1; }

/* Pinnwand */
.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.mini-notes { grid-template-columns: repeat(2, 1fr); gap: 10px; }
.note { padding: 16px; border-radius: 6px; min-height: 120px; box-shadow: 2px 4px 8px rgba(0,0,0,.15); transform: rotate(-1deg); display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.note:nth-child(even) { transform: rotate(1.2deg); }
.note-text { white-space: pre-wrap; word-break: break-word; font-size: 19px; color: #1f2937; }
.note-by { font-size: 15px; color: #4b5563; }
.mini-notes .note { min-height: 0; padding: 10px; }
.mini-notes .note-text { font-size: 16px; }

/* Essensplan */
.meal-grid { display: grid; grid-template-columns: 84px 1fr 1fr; gap: 8px; align-items: stretch; }
.meal-day { padding: 8px 4px; text-align: center; }
.meal-day.today b { background: var(--accent); color: #fff; border-radius: 10px; padding: 2px 10px; }
.meal { min-height: 64px; background: #fff; border-radius: 12px; padding: 8px 12px; font-size: 19px; text-align: left; color: var(--muted); }
.meal.filled { color: var(--ink); font-weight: 600; background: #fff7e6; }

/* Belohnungen */
.rewards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.reward { display: flex; align-items: center; gap: 10px; margin: 0 !important; }

/* Stundenplan */
.tt { display: grid; gap: 6px; max-width: 900px; }
.ttc { min-height: 54px; background: #fff; border-radius: 10px; font-size: 17px; padding: 4px 6px; }
.ttc.filled { background: #e0ecff; font-weight: 600; }

/* Fotos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #ddd; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff; border-radius: 10px; }

/* Bildschirmschoner */
#ss { position: fixed; inset: 0; background: #000; z-index: 50; color: #fff; }
.ss-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.8s; }
.ss-img.on { opacity: 1; }
.ss-box { position: absolute; left: 36px; bottom: 30px; text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.ss-time { font-size: 96px; font-weight: 700; line-height: 1; letter-spacing: -2px; }
.ss-date { font-size: 28px; opacity: .9; margin-top: 6px; }

/* Modal */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 10; }
#modal[hidden], #toast[hidden], #shopBadge[hidden] { display: none; }
#modalBox { background: #fff; border-radius: 22px; padding: 24px; width: min(640px, 94vw); max-height: 92vh; overflow-y: auto; }
#modalBox h1 { font-size: 26px; }
label { display: block; font-size: 16px; color: var(--muted); margin: 14px 0 6px; }
.field { width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; user-select: text; -webkit-user-select: text; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 12px; margin-top: 22px; justify-content: flex-end; }
.actions .left { margin-right: auto; }
.days { display: flex; gap: 8px; }
.days .chip { padding: 10px 14px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 22px; border-radius: 14px; z-index: 20; }

@media (max-width: 900px) {
  #nav { width: 78px; } #nav button { font-size: 12px; } #nav button span { font-size: 26px; }
  .today-grid, .cal-wrap { grid-template-columns: 1fr; }
  .clock { font-size: 60px; }
}

/* ---------- Energie und Geraete ---------- */
.energy-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.etile { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.etile .ic { font-size: 34px; line-height: 1; }
.etile .val { font-size: 34px; font-weight: 700; margin-top: 6px; }
.etile .sub { color: var(--muted); font-size: 17px; }
.etile.good .val { color: #15803d; }
.etile.bad .val { color: #b91c1c; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 12px; }
.chart .ax { stroke: #d6d3d1; stroke-width: 1; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 16px; margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 6px; vertical-align: -2px; }
.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.dev { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); text-align: left; display: flex; flex-direction: column; gap: 4px; min-height: 120px; border: 3px solid transparent; }
.dev .ic { font-size: 34px; line-height: 1; }
.dev .nm { font-weight: 700; font-size: 19px; }
.dev .st { color: var(--muted); font-size: 16px; }
.dev.on { border-color: #f59e0b; background: #fffbeb; }
.dev.off-line { opacity: .45; pointer-events: none; }
.surplus { color: #15803d; font-weight: 600; }

/* ---------- PIN, Timer, Wochenrueckblick, Vorrat ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay-box { background: var(--card); border-radius: 22px; padding: 24px; width: min(360px, 100%); text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.pin-dots { font-size: 32px; letter-spacing: 6px; margin: 10px 0 14px; min-height: 40px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-key { font-size: 28px; font-weight: 600; padding: 16px 0; border-radius: 16px; background: #e8e4db; color: var(--ink); }
.pin-key:active { background: #d6d3d1; }
#timerBar { position: fixed; right: 14px; bottom: 14px; z-index: 150; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.tchip { background: #111827; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 20px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.chip.big { font-size: 22px; padding: 14px 20px; }
.wk-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 12px 0 8px; }
.wk-cell { text-align: center; background: #f5f2ea; border-radius: 12px; padding: 8px 0; }
.wk-cell.today { outline: 3px solid var(--accent); }
.wk-val { font-size: 26px; font-weight: 700; }
.item.low { background: #fffbeb; }

/* ---------- Wochenuebersicht ---------- */
.wgrid { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 8px; overflow-x: auto; }
.wcol { background: var(--card); border-radius: 14px; padding: 8px; min-height: 260px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.wcol.today { outline: 3px solid var(--accent); }
.wcol-head { font-weight: 600; font-size: 18px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.wev { background: #f5f2ea; border-radius: 8px; padding: 6px 8px; font-size: 16px; }
.wev .muted { font-size: 14px; }
.wchip { background: #fef3c7; border-radius: 8px; padding: 4px 8px; font-size: 15px; }
.wmeal { background: #dcfce7; border-radius: 8px; padding: 4px 8px; font-size: 15px; }
a.btn { text-decoration: none; display: inline-block; }

/* Verwaltung */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.admin-card h2 { margin-top: 0; }
.admin-card h3 { margin: 4px 0 8px; font-size: 20px; }
.admin-card hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.admin-card .row { flex-wrap: wrap; margin-top: 10px; }
.frow { display: block; margin: 8px 0; }
.frow > span { display: block; font-size: 16px; color: var(--muted); margin-bottom: 4px; }
.chk { display: block; margin: 8px 0; }
.chk input { width: 22px; height: 22px; vertical-align: middle; margin-right: 6px; }
.kv > div { padding: 3px 0; }
pre.code { background: #1f2937; color: #e5e7eb; padding: 12px 14px; border-radius: 10px; overflow-x: auto; user-select: text; -webkit-user-select: text; }
