:root {
  --bg: #f4efe6;
  --card: #fffdf9;
  --ink: #1d2427;
  --muted: #6f7477;
  --line: #e4ddd0;
  --accent: #c0532a;
  --accent-soft: #f6dfd3;
  --green: #2f6f55;
  --warn: #b7791f;
  --danger: #b3261e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 14px rgba(40, 30, 20, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a1c;
    --card: #212527;
    --ink: #ece8e1;
    --muted: #9a9fa2;
    --line: #2f3437;
    --accent: #e57a4e;
    --accent-soft: #3a2a22;
    --green: #6cc49c;
    --warn: #e0a84a;
    --danger: #f2827a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: .9rem; }
.error { color: var(--danger); }

.brand { font: 700 2.4rem/1 Georgia, "Times New Roman", serif; letter-spacing: -.02em; }
.brand span { color: var(--accent); }
.brand.small { font-size: 1.5rem; }

/* ---------- connexion */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); display: grid; gap: 14px; }

/* ---------- structure */
#app { max-width: 760px; margin: 0 auto; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 18px 6px;
}
main { padding: 6px 14px 20px; }
.view { display: grid; gap: 14px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: .72rem;
  padding: 9px 0 10px; display: grid; gap: 2px; justify-items: center; cursor: pointer;
}
.tabbar button span { font-size: 1.2rem; line-height: 1.2; }
.tabbar button.active { color: var(--accent); font-weight: 600; }

/* ---------- cartes */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 10px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; align-items: baseline;
}
.card h2 .count { color: var(--accent); }
.empty { color: var(--muted); font-style: italic; font-size: .92rem; margin: 2px 0; }

/* ---------- météo */
.weather-main { display: flex; align-items: center; gap: 14px; }
.weather-icon { font-size: 2.8rem; line-height: 1; }
.weather-temp { font-size: 2.2rem; font-weight: 600; letter-spacing: -.02em; }
.weather-meta { color: var(--muted); font-size: .9rem; }
.hours { display: flex; gap: 6px; overflow-x: auto; margin-top: 12px; padding-bottom: 4px; scrollbar-width: none; }
.hour {
  flex: 0 0 auto; min-width: 52px; text-align: center; font-size: .8rem;
  background: var(--bg); border-radius: 10px; padding: 6px 4px;
}
.hour b { display: block; font-size: .95rem; }
.hour .rain { color: #3b7fc4; }

/* ---------- briefing */
.briefing { border-left: 4px solid var(--accent); }
.briefing .md h3 { font-size: 1rem; margin: 12px 0 4px; }
.briefing .md p { margin: 6px 0; }
.briefing .md ul { margin: 4px 0; padding-left: 20px; }
.briefing .stamp { font-size: .75rem; color: var(--muted); margin-top: 8px; }

/* ---------- listes */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 2px;
  border-top: 1px solid var(--line);
}
.list .item:first-child { border-top: 0; }
.check {
  flex: 0 0 auto; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--muted); background: none; cursor: pointer; padding: 0;
  display: grid; place-items: center; color: #fff; font-size: .8rem;
}
.check.prio-2 { border-color: var(--accent); }
.check.on { background: var(--green); border-color: var(--green); }
.square .check { border-radius: 7px; }
.item-body { flex: 1; min-width: 0; cursor: pointer; }
.item-title { overflow-wrap: anywhere; }
.done .item-title { text-decoration: line-through; color: var(--muted); }
.item-meta { font-size: .78rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.late { color: var(--danger); font-weight: 600; }
.tag { background: var(--bg); border-radius: 6px; padding: 0 6px; }
.by-claude::after { content: "✦ Claude"; color: var(--accent); }
.del { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 0 4px; }

.event { display: flex; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.list .event:first-child { border-top: 0; }
.event-time { flex: 0 0 52px; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; font-size: .9rem; }
.event-loc { font-size: .78rem; color: var(--muted); }

/* ---------- semaine */
.day.today { border-color: var(--accent); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.day-name { font-weight: 700; text-transform: capitalize; }
.day-weather { font-size: .85rem; color: var(--muted); }

/* ---------- formulaires */
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); }
.quick-add { display: flex; gap: 8px; }
.quick-add input[name="title"], .quick-add input[name="name"] { flex: 1; }
.quick-add input[type="date"] { width: 9.5em; flex: 0 0 auto; }
.btn {
  font: inherit; font-weight: 600; border-radius: 12px; padding: 10px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.icon-btn {
  font-size: 1.3rem; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
}
.icon-btn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented button {
  font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
.segmented button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- feuille d'édition */
dialog {
  border: 0; padding: 0; background: transparent; color: inherit;
  width: min(560px, 100%); max-width: 100%; margin: auto auto 0;
}
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.sheet {
  background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  display: grid; gap: 12px;
}
@media (min-width: 600px) { dialog { margin: auto; } .sheet { border-radius: 20px; } }
.sheet h3 { margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem;
  box-shadow: var(--shadow); z-index: 10;
}
.offline-banner { background: var(--warn); color: #fff; text-align: center; font-size: .8rem; padding: 4px; border-radius: 8px; }
