:root {
  --bg: #f4f1ec;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2f6f5e;
  --error: #b91c1c;
  --radius: 20px;
  --shadow: 0 2px 10px rgb(0 0 0 / .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- Avatar ---------- */
.avatar {
  --size: 64px;
  width: var(--size); height: var(--size); flex: none;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  display: grid; place-items: center;
  font-size: calc(var(--size) * .42); font-weight: 700;
  box-shadow: 0 8px 24px rgb(0 0 0 / .12);
  position: relative; overflow: hidden;
}
.avatar img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 15%;
  transform: scale(1.3); transform-origin: 50% 28%;
  background: #fff;
}
.avatar::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 4px var(--c); }

/* ---------- Login ---------- */
.login {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 40px; padding: 24px;
}
.login h1 { margin: 0; font-size: clamp(26px, 4vw, 40px); }
.faces { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(16px, 4vw, 56px); }
.face {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: none; border: 0; padding: 8px; border-radius: var(--radius);
}
.face .avatar { --size: clamp(100px, 16vw, 160px); transition: transform .15s; }
.face:active .avatar { transform: scale(.94); }
.face .name { font-size: 22px; font-weight: 600; }

.pin { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.dots { display: flex; gap: 18px; }
.dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--text); transition: background .1s; }
.dots span.on { background: var(--text); }
.msg { min-height: 24px; color: var(--error); font-weight: 500; text-align: center; }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.pad button {
  height: 76px; border: 0; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 28px; font-weight: 600;
}
.pad button:active { background: #e5e7eb; }
.pad .ghost { background: transparent; box-shadow: none; font-size: 18px; color: var(--muted); }

.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

/* ---------- Allgemein ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 10px 18px;
  background: var(--accent); color: #fff; font-weight: 600;
}
.btn.light { background: #e5e7eb; color: var(--text); }
.card { background: var(--card); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 14px; font-size: 20px; }
.muted { color: var(--muted); }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 20px; background: var(--card); box-shadow: var(--shadow);
}
.clock { display: flex; align-items: baseline; gap: 14px; }
.clock b { font-size: 34px; font-variant-numeric: tabular-nums; }
.clock span { font-size: 18px; color: var(--muted); }
.me { display: flex; align-items: center; gap: 12px; }
.me .avatar { --size: 42px; box-shadow: none; }

/* ---------- Dashboard ---------- */
.dash {
  flex: 1;
  display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 20px;
  padding: 20px;
}
.people { display: flex; flex-direction: column; gap: 16px; }
.person {
  display: flex; gap: 16px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; border-left: 6px solid var(--c);
}
.who { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.who .name { font-weight: 700; font-size: 17px; }
.who .avatar { --size: 72px; }
.events { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; font-size: 15px; }
.events li { padding: 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events .day { font-weight: 700; font-size: 13px; text-transform: uppercase; color: var(--c); padding-top: 8px; }
.events .day:first-child { padding-top: 0; }
.events .t { display: inline-block; min-width: 64px; color: var(--muted); font-variant-numeric: tabular-nums; }
.events .family::after { content: " 👨‍👩‍👧"; }

.events .ev { cursor: pointer; }
.btn.danger { background: var(--error); }

/* ---------- Dialog ---------- */
.modal {
  position: fixed; inset: 0; z-index: 10;
  background: rgb(0 0 0 / .45);
  display: grid; place-items: center; padding: 16px;
}
.sheet {
  width: min(460px, 100%); max-height: 100%; overflow: auto;
  background: var(--card); border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.sheet h3 { margin: 0; font-size: 22px; }
.sheet p { margin: 0; }
.sheet label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); flex: 1; }
.sheet input, .sheet select {
  font: inherit; font-size: 17px; color: var(--text); user-select: text;
  padding: 10px 12px; border: 1px solid #d6d3d1; border-radius: 12px; background: #fff;
}
.sheet .check { flex-direction: row; align-items: center; gap: 10px; font-size: 17px; color: var(--text); }
.sheet .check input { width: 22px; height: 22px; }
.sheet .row { display: flex; gap: 12px; }
.sheet .actions { display: flex; justify-content: flex-end; gap: 10px; }

.rate-dish { font-size: 26px; font-weight: 700; }
.stars { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.stars button { border: 0; background: none; font-size: 54px; line-height: 1; color: #d6d3d1; padding: 2px 4px; }
.stars button.on { color: #f59e0b; }

/* ---------- Wally ---------- */
.wally-fab {
  --f: 1;                                         /* Füllstand 0..1, setzt app.js */
  --tc: hsl(calc(var(--f) * 120) 70% 42%);        /* 120 = grün, 0 = rot */
  position: fixed; right: 20px; bottom: 20px; z-index: 5;
  border: 0; padding: 6px; border-radius: 50%;
  background: conic-gradient(var(--tc) calc(var(--f) * 360deg), #d6d3d1 0);
  box-shadow: 0 6px 20px rgb(0 0 0 / .3);
}
.wally-fab.low { animation: pulse-ring 1.6s infinite; }
@keyframes pulse-ring { 50% { box-shadow: 0 0 0 10px rgb(185 28 28 / .25); } }
.wally-fab .avatar { --size: 72px; box-shadow: none; }
.w-low { background: #fee2e2; color: var(--error); padding: 8px 16px; font-size: 14px; font-weight: 600; }
.w-low[hidden] { display: none; }
.w-topup input { width: 80px; font: inherit; padding: 6px 8px; border: 1px solid #d6d3d1; border-radius: 10px; }
.wally-panel {
  position: fixed; right: 20px; bottom: 116px; z-index: 6;
  width: min(420px, calc(100vw - 24px)); height: min(620px, calc(100vh - 124px));
  background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 40px rgb(0 0 0 / .3);
  display: flex; flex-direction: column; overflow: hidden;
}
.wally-panel[hidden] { display: none; }
.w-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--accent); color: #fff; }
.w-head .avatar { --size: 40px; box-shadow: none; }
.w-head b { flex: 1; font-size: 18px; }
.w-close, .w-gear { background: none; border: 0; color: #fff; font-size: 20px; }
.w-set { padding: 12px 16px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.w-set[hidden] { display: none; }
.w-set label { display: flex; align-items: center; gap: 10px; }
.w-set label > :first-child { width: 80px; flex: none; }
.w-set select { flex: 1; min-width: 0; font: inherit; padding: 8px; border: 1px solid #d6d3d1; border-radius: 10px; background: #fff; }
.w-set input[type=range] { flex: 1; min-width: 0; }
.w-set-row { display: flex; align-items: center; gap: 10px; }
.w-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; user-select: text; }
.w-msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; line-height: 1.4; position: relative; }
.w-msg p { margin: 0; }
.w-msg.bot { background: var(--bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.w-msg.me { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.w-msg.err { background: #fee2e2; color: var(--error); }
.w-speak { background: none; border: 0; padding: 4px 0 0; font-size: 16px; }
.w-chips { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.w-chips button { border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 999px; padding: 8px 14px; font-size: 15px; }
.w-card { background: #fff; border-radius: 12px; padding: 10px 12px; margin-top: 8px; box-shadow: 0 1px 4px rgb(0 0 0 / .12); }
.w-card-title { font-weight: 700; }
.w-card .muted { font-size: 14px; }
.w-card-act { display: flex; gap: 8px; margin-top: 8px; }
.w-card-act select { flex: 1; min-width: 0; font: inherit; padding: 8px; border: 1px solid #d6d3d1; border-radius: 10px; background: #fff; }
.w-card-act .btn { padding: 8px 12px; white-space: nowrap; }
.w-card .ok { color: var(--accent); font-weight: 600; }
.w-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e5e7eb; }
.w-input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid #d6d3d1; border-radius: 12px; user-select: text; }
.w-mic { flex: none; width: 46px; border: 0; border-radius: 50%; background: #e5e7eb; font-size: 20px; }
.w-mic.on { background: var(--error); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgb(185 28 28 / .2); } }
.dash { padding-bottom: 110px; }
@media (max-width: 600px) {
  .wally-panel { right: 12px; bottom: 112px; height: calc(100vh - 132px); }
}

.main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.meal { background: var(--bg); border-radius: 14px; padding: 12px; min-height: 110px; }
.meal .d { font-weight: 700; margin-bottom: 6px; }
.meal .d span { font-weight: 400; color: var(--muted); font-size: 14px; }
.meal .dish { font-size: 15px; line-height: 1.3; }
.meal[data-day] { cursor: pointer; }
.meal.today { background: var(--accent); color: #fff; }
.meal.today .d span { color: #d1fae5; }
.meal.past { opacity: .5; }
.soon { border: 2px dashed #d6d3d1; box-shadow: none; background: transparent; }

/* Handy / schmale Bildschirme */
@media (max-width: 900px) {
  .dash { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .week { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .clock b { font-size: 26px; }
  .clock span { font-size: 15px; }
}
