/* Family Hub – shared design (same tokens as the first Essensplan app). */
:root {
  --bg: #f5f2ec;
  --card: #ffffff;
  --ink: #1f2420;
  --muted: #6b716c;
  --line: #e6e1d8;
  --accent: #2f6f57;
  --accent-soft: #e3efe8;
  --warn: #9a5b13;
  --warn-soft: #f8ecd9;
  --danger: #a33a32;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --card: #212427;
    --ink: #eceeea;
    --muted: #9aa19b;
    --line: #30353a;
    --accent: #6fbf97;
    --accent-soft: #23352c;
    --warn: #e2b071;
    --warn-soft: #3a2f22;
    --danger: #ef8a80;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.92em; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 6px; white-space: nowrap; }

/* ---------- layout ---------- */

.shell { display: flex; flex-direction: column; min-height: 100vh; }
header.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--safe-top) + 10px) 12px 10px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  display: flex; align-items: center; gap: 6px;
}
header.top h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.top .icon-btn:first-child { margin-left: -10px; }
.spacer { width: 44px; }
main { flex: 1; padding: 4px 16px calc(var(--safe-bottom) + 28px); max-width: 720px; width: 100%; margin: 0 auto; }

.icon { width: 24px; height: 24px; flex: none; }
.icon.small { width: 16px; height: 16px; }
.icon-btn { background: none; border: 0; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--accent); }
.icon-btn:active { background: var(--accent-soft); }

/* ---------- common ---------- */

.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 12px; box-shadow: 0 1px 2px rgb(0 0 0 / 4%); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; display: block; font-weight: 400; }
.center { text-align: center; }
h2 { font-size: 20px; margin: 20px 2px 6px; letter-spacing: -0.01em; }
h2 + p { margin: 0 2px 10px; }
h3 { font-size: 17px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; margin-left: 6px; vertical-align: middle; }

.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600; text-decoration: none;
  background: var(--accent); color: #fff; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
}
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 10px; min-height: 44px; }
.btn:disabled { opacity: 0.5; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.actions .btn { flex: 1; }

.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); border-radius: 11px; padding: 3px; }
.segmented button { border: 0; background: none; padding: 8px 14px; min-height: 38px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 10%); }

.empty { text-align: center; padding: 34px 18px; }
.empty .big { font-size: 40px; }
.empty p { margin: 6px 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin: 4px 0 14px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 20px); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgb(0 0 0 / 20%);
}

/* ---------- login ---------- */

.login { max-width: 440px; margin: 0 auto; padding: calc(var(--safe-top) + 48px) 20px 40px; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin-bottom: 16px; }
.login h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.02em; }
.login textarea { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; resize: none; margin: 8px 0 0; font-family: ui-monospace, Menlo, monospace; font-size: 15px; }
.steps { padding-left: 22px; margin: 16px 0; }
.steps li { margin: 8px 0; }

/* ---------- start page ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 20px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 18px;
  background: var(--card); border-radius: 20px; padding: 16px; min-height: 120px;
  color: var(--ink); text-decoration: none; box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
}
.tile:active { transform: scale(0.98); }
.tile-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile-icon .icon { width: 28px; height: 28px; }
.tile-name { font-weight: 600; font-size: 17px; margin-top: auto; }
.tile-hint { position: absolute; top: 14px; right: 14px; color: var(--muted); }
.tile.soon { opacity: 0.6; }
.tile.soon .pill { position: absolute; top: 14px; right: 14px; margin: 0; }

/* ---------- profile & devices ---------- */

.device { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.device:first-child { border-top: 0; }

/* ---------- admin ---------- */

.table-wrap { overflow-x: auto; padding: 6px 8px; }
.matrix { width: 100%; border-collapse: collapse; font-size: 14px; }
.matrix th, .matrix td { padding: 10px 4px; text-align: center; border-top: 1px solid var(--line); }
.matrix thead th { border-top: 0; font-size: 12px; color: var(--muted); font-weight: 600; vertical-align: top; }
.matrix tbody th { text-align: left; font-weight: 600; white-space: nowrap; }
.matrix tbody th .pill { margin-left: 4px; }
.col-app { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer;
  transition: background 0.15s;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: transform 0.15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; }
.label { font-size: 14px; color: var(--muted); }
div.label { margin-top: 8px; }
.num { width: 84px; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 10px; text-align: right; }

@media (max-width: 380px) {
  .matrix { font-size: 13px; }
  .switch { width: 40px; }
  .switch:checked::after { transform: translateX(14px); }
}
