:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #161616;
  --muted: #6b6b6b;
  --line: #e2dfd8;
  --accent: #161616;
  --accent-ink: #ffffff;
  --today: #fff7d6;
  --radius: 16px;
  --icon-filter: none;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151515;
    --card: #1f1f1f;
    --ink: #f1f1f1;
    --muted: #a0a0a0;
    --line: #333;
    --accent: #f1f1f1;
    --accent-ink: #151515;
    --today: #2b2716;
    --icon-filter: invert(1);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ——— Connexion ——— */
.login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 8px;
}
.login img { border-radius: 18px; }
.login h1 { margin: 4px 0 16px; }
.login form { width: min(340px, 100%); display: grid; gap: 10px; }
.login label { font-weight: 600; }
.login input {
  font: inherit;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
.login button[type="submit"] {
  padding: 12px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.error { color: #c0392b; min-height: 1.4em; margin: 0; }

/* ——— En-tête de semaine ——— */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top .title { text-align: center; }
.top h1 { font-size: 19px; margin: 0; }
.nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  background: var(--card);
  border: 1px solid var(--line);
}
.link { color: var(--muted); text-decoration: underline; font-size: 14px; padding: 4px; }

/* ——— Jours ——— */
.days {
  display: grid;
  gap: 12px;
  padding: 12px 16px;
  max-width: 640px;
  margin: 0 auto;
}
.day {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  scroll-margin-top: calc(env(safe-area-inset-top) + 72px);
}
.day.today { background: var(--today); border-color: var(--accent); border-width: 2px; }
.day.past { opacity: 0.6; }
.day > header { display: flex; align-items: center; gap: 8px; }
.dname { flex: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.dname h2 { font-size: 18px; margin: 0; }
.badge {
  font-size: 12px;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 1px 8px;
  border-radius: 999px;
}
.weather { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 15px; }
.weather b { color: var(--ink); }
.wicon { width: 30px; height: 30px; filter: var(--icon-filter); }
.preview-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.empty { margin: 8px 0 2px; color: var(--muted); font-size: 15px; }

.family, .events { list-style: none; margin: 6px 0 0; padding: 0; font-size: 15px; }
.family li { padding: 2px 0; }
.family li::before { content: "Famille · "; font-weight: 700; }
.time { display: inline-block; min-width: 3.4em; font-weight: 700; font-variant-numeric: tabular-nums; }

.child { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; }
.child-head { display: flex; align-items: center; gap: 8px; }
.child h3 { flex: 1; margin: 0; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.slots { display: flex; gap: 8px; }

.slot {
  width: 52px;
  height: 52px;
  padding: 6px;
  border-radius: 14px;
  border: 2px dashed var(--line);
  background: var(--card);
  transition: transform 0.12s ease;
}
.slot img { width: 100%; height: 100%; display: block; opacity: 0.22; filter: var(--icon-filter); }
.slot.on { border: 2.5px solid var(--accent); }
.slot.on img { opacity: 1; }
.slot:active { transform: scale(0.92); }
.slot-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.slot-cap { font-size: 11px; line-height: 1; color: var(--muted); white-space: nowrap; }
.slot:focus-visible, button:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }

/* ——— Actions ——— */
.actions {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 24px);
}
.secondary {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-weight: 600;
}

/* ——— Aperçu Kindle ——— */
dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  background: var(--card);
  color: var(--ink);
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
dialog header button { font-size: 18px; padding: 4px 8px; }
dialog img { display: block; width: 100%; height: auto; background: #fff; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 120%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
