/* Travaux maison — ambiance « Nid douillet » : pastels, arrondis, mobile d'abord, mode sombre auto. */
:root {
  --bg: #F3F4FA; --card: #FFFFFF; --ink: #33344D; --muted: #74758F; --line: #E4E5F0;
  --accent: #4F8E6E; --on-accent: #FFFFFF; --soft: #E3F0E8; --lilac: #E9E4F7; --peach: #F9E3DA;
  --warn: #B86E15; --warn-bg: #FBEBD5; --bad: #C2483F; --bad-bg: #F8DEDB;
  --marge: #FCEFDF; --hatch: #DCDDEA; --bar-ink: #33344D;
  --shadow: 0 4px 14px -8px rgba(80, 80, 140, .28);
  --head: 'Baloo 2', ui-rounded, system-ui, sans-serif;
  --body: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181F; --card: #22232D; --ink: #ECEBF5; --muted: #A0A1B8; --line: #30313F;
    --accent: #7DBB9A; --on-accent: #17181F; --soft: #22362B; --lilac: #2D2943; --peach: #3A2C2B;
    --warn: #F0B46A; --warn-bg: #3B2E1C; --bad: #F08A80; --bad-bg: #3D2423;
    --marge: #33291D; --hatch: #3A3B4C; --shadow: 0 4px 14px -8px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 16px/1.45 var(--body); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.top { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(16px, env(safe-area-inset-right, 0px)) 4px max(16px, env(safe-area-inset-left, 0px)); }
.top .date { font-size: .8rem; color: var(--muted); }
.net { border: 0; font: 800 .72rem var(--body); padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--accent); white-space: nowrap; }
.net.off { background: var(--warn-bg); color: var(--warn); }
.screen { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px; }
.screen > * { flex-shrink: 0; }
.tabbar { flex: none; display: flex; border-top: 1px solid var(--line); background: var(--card); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabbar button { flex: 1; border: 0; background: transparent; color: var(--muted); font: 800 .72rem var(--body); padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.tabbar svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-current="true"] { color: var(--accent); }

h1, h2, h3, h4 { font-family: var(--head); margin: 0; line-height: 1.15; text-wrap: balance; }
.vtitle { font-size: 1.45rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.sub { color: var(--muted); font-size: .82rem; }
.hint { color: var(--muted); font-size: .78rem; margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.box { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow, .grow { flex: 1; min-width: 0; }

.btn { border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 800 .9rem var(--body); border-radius: 14px; padding: 9px 14px; cursor: pointer; }
.btn.main { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--bad); }
.btn.danger.sure { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 5px 10px; font-size: .8rem; border-radius: 10px; }
.btn.wide { width: 100%; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--bg); color: var(--ink); font: 800 1rem var(--body); cursor: pointer; flex: none; display: grid; place-items: center; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.link { border: 0; background: transparent; color: var(--muted); font: 700 .82rem var(--body); text-decoration: underline; cursor: pointer; padding: 0; }

.pill { font: 800 .68rem var(--body); padding: 2px 8px; border-radius: 999px; white-space: nowrap; flex: none; }
.pill.ok, .pill.fini, .pill.libre { background: var(--soft); color: var(--accent); }
.pill.marge { background: var(--warn-bg); color: var(--warn); }
.pill.retard, .pill.impossible { background: var(--bad-bg); color: var(--bad); }
.pill.fait, .pill.vide { background: var(--line); color: var(--muted); }

/* Accueil */
.ring { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, var(--lilac), var(--peach)); border-radius: var(--r); padding: 14px; }
.ring svg { flex: none; }
.ring .big { font: 800 2rem/1 var(--head); }
.ring p { margin: 3px 0 0; font-size: .85rem; }
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tasks li { display: flex; gap: 10px; align-items: center; font-size: .9rem; }
.tasks .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.tasks .t { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 6px 0; cursor: pointer; }
.tasks .t b { display: block; font-weight: 700; }
.alert { border-left: 4px solid var(--warn); background: var(--warn-bg); border-radius: 14px; padding: 10px 12px; font-size: .86rem; }
.alert.bad { border-color: var(--bad); background: var(--bad-bg); }
.alert b { display: block; }
.alert button { margin-top: 6px; }
.jal { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; font-size: .88rem; padding: 8px 0; border-bottom: 1px solid var(--line); }
.jal:last-child { border-bottom: 0; }
.bars { display: flex; flex-direction: column; gap: 8px; font-size: .82rem; }
.bars .r { display: grid; grid-template-columns: 100px 1fr 34px; gap: 8px; align-items: center; }
.bars .t { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bars .t i { display: block; height: 100%; background: var(--accent); }
.empty { text-align: center; padding: 22px 16px; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* Planning : bascule */
.bascule { display: flex; gap: 4px; background: var(--card); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.bascule button { flex: 1; border: 0; background: transparent; color: var(--muted); font: 800 .88rem var(--body); padding: 7px 0; border-radius: 999px; cursor: pointer; }
.bascule button[aria-pressed="true"] { background: var(--lilac); color: var(--ink); }

/* Calendrier */
.cal-nav { display: flex; justify-content: space-between; align-items: center; }
.cal-nav b { font-family: var(--head); font-size: 1.15rem; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: .62rem; text-align: center; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.cal .d { min-height: 52px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); padding: 4px; display: flex; flex-direction: column; gap: 2px;
  font: 700 .74rem var(--body); text-align: left; cursor: pointer; min-width: 0; }
.cal .d.vide { visibility: hidden; }
.cal .d.passe { opacity: .45; }
.cal .d.we, .cal .d.conge { background: var(--card); color: var(--ink); }
.cal .d.marge { background: var(--marge); }
.cal .d.pause { background: repeating-linear-gradient(135deg, var(--hatch) 0 4px, transparent 4px 8px); }
.cal .d.bloque { background: var(--line); color: var(--muted); text-decoration: line-through; }
.cal .d.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .d.jal { box-shadow: inset 0 0 0 2px var(--ink); }
.cal .d.sel { outline: 3px solid #B8A9E8; outline-offset: 0; }
.cal .d i { display: block; height: 6px; border-radius: 3px; }
.cal .d small { font-size: .55rem; font-weight: 800; line-height: 1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .74rem; color: var(--muted); }
.keys span { display: flex; align-items: center; gap: 5px; }
.keys i { width: 14px; height: 14px; border-radius: 5px; display: inline-block; }

/* Frise */
.gantt { display: flex; background: var(--card); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.glab { flex: none; width: 88px; border-right: 1px solid var(--line); }
.glab div { height: 34px; display: flex; align-items: center; padding: 0 8px 0 10px; font-size: .74rem; font-weight: 800; line-height: 1.1; }
.glab .gh { height: 64px; align-items: flex-end; padding-bottom: 4px; color: var(--muted); font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; }
.gscroll { flex: 1; overflow-x: auto; overflow-y: hidden; min-width: 0; }
.gtrack { position: relative; }
.gm { position: absolute; top: 2px; bottom: 0; font-size: .62rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-left: 3px; border-left: 1px solid var(--line); }
.gcap { position: absolute; top: 52px; height: 8px; border-radius: 4px; }
.gzone { position: absolute; top: 64px; bottom: 0; }
.gzone.marge { background: var(--marge); }
.gzone.pause { background: repeating-linear-gradient(135deg, var(--hatch) 0 4px, transparent 4px 9px); }
.gline { position: absolute; bottom: 0; width: 2px; background: var(--ink); }
.gline.today { background: var(--accent); top: 64px; }
.gflag { position: absolute; font: 800 .6rem var(--body); background: var(--ink); color: var(--card); padding: 2px 6px; border-radius: 999px; white-space: nowrap; }
.seg { position: absolute; height: 22px; border: 0; border-radius: 999px; font: 800 .62rem var(--body); color: var(--bar-ink); padding: 0 7px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; text-align: left; cursor: pointer; }
.seg.marge { box-shadow: 0 0 0 2px var(--warn); }
.seg.retard, .seg.impossible { box-shadow: 0 0 0 2px var(--bad); }

/* Liste des tâches */
.tlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tlist li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.tlist li:first-child { border-top: 0; }
.tlist .t { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; cursor: pointer; padding: 0; }
.tlist .t b { display: block; font-weight: 700; font-size: .92rem; }
.tlist .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.tlist .ord { display: flex; flex-direction: column; gap: 2px; }
.tlist .ord .icon-btn { width: 28px; height: 22px; border-radius: 8px; font-size: .75rem; }
.tlist li.fait b { text-decoration: line-through; color: var(--muted); }

/* Feuille (bas d'écran) */
.veil { position: absolute; inset: 0; background: rgba(25, 25, 45, .38); z-index: 5; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; max-height: 92%; overflow-y: auto; background: var(--card); border-radius: 26px 26px 0 0;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 -8px 30px rgba(0, 0, 0, .2); }
.sheet h4 { font-size: 1.2rem; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 800; color: var(--muted); }
.field input, .field select, .field textarea, .inp { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 9px 11px; font: 600 .95rem var(--body); width: 100%; min-width: 0; }
.field textarea { min-height: 60px; resize: vertical; }
.step { display: flex; align-items: center; gap: 12px; }
.checks { max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; display: flex; flex-direction: column; }
.checks label { display: flex; gap: 8px; align-items: center; padding: 5px 0; font: 600 .88rem var(--body); color: var(--ink); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .86rem; }
.kv span:nth-child(odd) { color: var(--muted); }

/* Achats */
.notes { list-style: none; margin: 0; background: var(--card); border-radius: var(--r); padding: 2px 14px; box-shadow: var(--shadow); }
.notes li { display: flex; align-items: center; gap: 10px; min-height: 46px; border-bottom: 1px solid var(--line); }
.notes li:last-child { border-bottom: 0; }
.chk { flex: none; width: 24px; height: 24px; border: 2px solid var(--muted); background: transparent; border-radius: 50%; cursor: pointer; padding: 0; display: grid; place-items: center; color: var(--on-accent); }
.chk[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.chk[aria-pressed="true"]::after { content: ""; width: 10px; height: 5px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(-45deg) translate(1px, -1px); }
.notes input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 600 1rem var(--body); padding: 10px 0; }
.notes input:focus { outline: none; }
.notes li.done input { text-decoration: line-through; color: var(--muted); }
.notes li.add .plus { width: 24px; text-align: center; color: var(--muted); font-weight: 800; flex: none; }
.etiquette { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 800; margin: 4px 0 0; }

/* Réglages */
.set { display: flex; flex-direction: column; gap: 10px; }
.set .line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.set .line > .inp { flex: 1 1 120px; }
.set .bloc { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.set .bloc:first-of-type { border-top: 0; padding-top: 0; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { border-color: var(--ink); }
.datefield { display: flex; flex-direction: column; gap: 2px; font-size: .7rem; font-weight: 800; color: var(--muted); flex: 1 1 90px; min-width: 0; }

/* Connexion */
.login { margin: auto 0; display: flex; flex-direction: column; gap: 12px; }
.login .err { color: var(--bad); font-size: .85rem; min-height: 1.2em; margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 9px 16px;
  border-radius: 999px; font: 700 .85rem var(--body); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
