/* Carnet de Mia — thème Solarized (Ethan Schoonover) */
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/fraunces-latin-wght-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces'; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url('fonts/fraunces-latin-wght-italic.woff2') format('woff2');
}

:root {
  --base03:#002b36; --base02:#073642; --base01:#586e75; --base00:#657b83;
  --base0:#839496; --base1:#93a1a1; --base2:#eee8d5; --base3:#fdf6e3;
  --yellow:#b58900; --orange:#cb4b16; --red:#dc322f; --magenta:#d33682;
  --violet:#6c71c4; --blue:#268bd2; --cyan:#2aa198; --green:#859900;

  /* clair (défaut) */
  --bg:var(--base3); --bg-2:var(--base2); --bg-3:#e4ddc8;
  --card:color-mix(in srgb, var(--base3) 88%, transparent);
  --text:var(--base01); --text-strong:var(--base02); --text-dim:var(--base00); --text-soft:var(--base1);
  --line:#d9d2bd; --shadow:0 10px 34px rgba(0,43,54,.16); --shadow-sm:0 1px 3px rgba(0,43,54,.08);
  --accent:var(--blue); --danger:#c22a27;
  --serif:'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans:-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --radius:14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:var(--base03); --bg-2:var(--base02); --bg-3:#0b4350;
    --card:color-mix(in srgb, var(--base03) 82%, transparent);
    --text:var(--base1); --text-strong:var(--base2); --text-dim:var(--base0); --text-soft:var(--base01);
    --line:#124652; --shadow:0 10px 34px rgba(0,0,0,.5); --shadow-sm:0 1px 3px rgba(0,0,0,.3);
    --danger:#f0625f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:var(--base03); --bg-2:var(--base02); --bg-3:#0b4350;
  --card:color-mix(in srgb, var(--base03) 82%, transparent);
  --text:var(--base1); --text-strong:var(--base2); --text-dim:var(--base0); --text-soft:var(--base01);
  --line:#124652; --shadow:0 10px 34px rgba(0,0,0,.5); --shadow-sm:0 1px 3px rgba(0,0,0,.3);
  --danger:#f0625f;
  color-scheme: dark;
}

/* ---------- fonds (mêmes recettes que la startpage et le budget) ---------- */
html[data-bg] body { background-attachment:fixed; }
html[data-bg="nuit"] body { background-image:linear-gradient(165deg, var(--bg) 0%, var(--bg-2) 120%); }
html[data-bg="ocean"] body { background-image:linear-gradient(165deg, var(--bg) 30%, color-mix(in srgb, var(--blue) 32%, var(--bg)) 100%); }
html[data-bg="lagon"] body { background-image:linear-gradient(165deg, var(--bg) 30%, color-mix(in srgb, var(--cyan) 32%, var(--bg)) 100%); }
html[data-bg="foret"] body { background-image:linear-gradient(165deg, var(--bg) 30%, color-mix(in srgb, var(--green) 28%, var(--bg)) 100%); }
html[data-bg="crepuscule"] body { background-image:linear-gradient(165deg, var(--bg) 20%, color-mix(in srgb, var(--violet) 30%, var(--bg)) 65%, color-mix(in srgb, var(--magenta) 30%, var(--bg)) 100%); }
html[data-bg="aube"] body { background-image:linear-gradient(165deg, var(--bg) 25%, color-mix(in srgb, var(--orange) 24%, var(--bg)) 75%, color-mix(in srgb, var(--yellow) 30%, var(--bg)) 100%); }

* { box-sizing:border-box; }
[hidden] { display:none !important; }
html, body { margin:0; min-height:100%; }
body {
  background:var(--bg); color:var(--text); min-height:100vh; min-height:100dvh;
  font:15px/1.5 var(--sans); -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
}
button, input, select, textarea { font:inherit; color:inherit; }
h1, h2, h3 { color:var(--text-strong); margin:0; }
a { color:var(--accent); }
.ico { width:1.15em; height:1.15em; flex:none; stroke:currentColor; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; vertical-align:-.2em; }
.dim { color:var(--text-dim); } .soft { color:var(--text-soft); }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* ---------- démarrage, connexion ---------- */
.boot { min-height:100vh; display:grid; place-content:center; justify-items:center; gap:10px; color:var(--text-dim); }
.boot img { width:96px; height:96px; }
.auth { min-height:100vh; min-height:100dvh; display:grid; place-items:center; padding:24px 16px; }
.auth-card { width:min(380px, 100%); background:var(--card); border:1px solid var(--line); border-radius:22px; padding:28px 24px 24px; box-shadow:var(--shadow); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); }
.logo-mia { color:var(--red); display:block; }
.auth-card .logo-big { width:150px; height:150px; margin:-6px auto 6px; }
.auth-card h1 { font:600 26px/1.15 var(--serif); text-align:center; }
.auth-card .lead { text-align:center; color:var(--text-dim); margin:6px 0 20px; }
.auth-card .btn { width:100%; margin-top:6px; }

/* ---------- champs et boutons ---------- */
.field { display:grid; gap:4px; margin-bottom:12px; }
.field > span { font-size:13px; color:var(--text-dim); }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=search], select, textarea {
  width:100%; background:var(--bg); border:1px solid var(--line); border-radius:10px; padding:9px 11px; font-size:16px;
  outline:none; transition:border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color:var(--accent); box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize:vertical; }
.check { display:flex; gap:9px; align-items:flex-start; font-size:14px; margin:6px 0 10px; cursor:pointer; }
.check input { margin:3px 0 0; width:17px; height:17px; accent-color:var(--accent); flex:none; }
.check small { display:block; color:var(--text-dim); font-size:12.5px; }
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:7px; border:1px solid var(--line);
  background:var(--bg); border-radius:11px; padding:9px 15px; cursor:pointer; font-weight:500; white-space:nowrap; text-decoration:none; color:inherit;
  transition:transform .08s, background .15s, border-color .15s;
}
.btn:hover { border-color:var(--text-soft); }
.btn:active { transform:scale(.98); }
.btn.primary { background:var(--accent); border-color:var(--accent); color:var(--base3); }
.btn.primary:hover { filter:brightness(1.06); }
.btn.danger { color:var(--danger); }
.btn.ghost { background:none; border-color:transparent; }
.btn.ghost:hover { background:color-mix(in srgb, var(--text) 8%, transparent); }
.btn.small { padding:5px 10px; font-size:13.5px; border-radius:9px; }
.btn.big { padding:13px 18px; font-size:16px; border-radius:14px; }
.icon-btn { border:0; background:none; padding:7px; border-radius:9px; cursor:pointer; color:var(--text-dim); display:inline-grid; place-items:center; }
.icon-btn:hover { background:color-mix(in srgb, var(--text) 9%, transparent); color:var(--text-strong); }
.error { color:var(--danger); font-size:14px; min-height:1.2em; margin:4px 0 0; }
.link { background:none; border:0; padding:0; color:var(--accent); cursor:pointer; font-size:inherit; }

/* ---------- structure ---------- */
.top {
  position:sticky; top:0; z-index:30; display:flex; align-items:center; gap:12px;
  padding:calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background:color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
  border-bottom:1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand { display:flex; align-items:center; gap:7px; min-width:0; text-decoration:none; }
.brand-pre { font:500 17px/1 var(--serif); color:var(--text-dim); white-space:nowrap; font-style:italic; }
.brand .logo-mia { height:44px; width:44px; margin:-6px 0 -8px; }
.brand .age-pill { margin-left:4px; align-self:flex-end; }
.age-pill { font-size:12.5px; color:var(--text-dim); white-space:nowrap; }
.nav-top { display:flex; gap:2px; margin-left:auto; }
.nav-top a { display:flex; align-items:center; gap:6px; padding:6px 10px; border-radius:9px; text-decoration:none; color:var(--text-dim); font-size:14px; }
.nav-top a:hover { color:var(--text-strong); background:color-mix(in srgb, var(--text) 7%, transparent); }
.nav-top a.on { color:var(--text-strong); background:color-mix(in srgb, var(--accent) 15%, transparent); }
.sync { font-size:12px; color:var(--text-dim); display:flex; align-items:center; gap:5px; white-space:nowrap; }
.sync.warn { color:var(--orange); }

main { width:min(720px, 100%); margin:0 auto; padding:18px 16px 40px; }
.screen-title { display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin:6px 2px 14px; }
.screen-title h1 { font:600 26px/1.15 var(--serif); }
.screen-title p { margin:0; color:var(--text-dim); font-size:14px; }
.section-title { font:600 13px/1.2 var(--sans); text-transform:uppercase; letter-spacing:.08em; color:var(--text-dim); margin:26px 4px 10px; }

.nav-bottom { display:none; }
@media (max-width: 760px) {
  .nav-top { display:none; }
  main { padding-bottom:calc(96px + env(safe-area-inset-bottom)); }
  .nav-bottom {
    display:grid; grid-template-columns:repeat(5, 1fr); position:fixed; left:0; right:0; bottom:0; z-index:30;
    padding:6px 6px calc(6px + env(safe-area-inset-bottom));
    background:color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
    border-top:1px solid color-mix(in srgb, var(--line) 80%, transparent);
  }
  .nav-bottom a, .nav-bottom button {
    display:grid; justify-items:center; gap:2px; padding:5px 0; font-size:11px; color:var(--text-dim);
    text-decoration:none; background:none; border:0; cursor:pointer;
  }
  .nav-bottom .ico { width:23px; height:23px; }
  .nav-bottom .on { color:var(--accent); }
  .nav-bottom .note-btn .bubble {
    width:48px; height:48px; border-radius:16px; display:grid; place-items:center; margin-top:-18px;
    background:var(--accent); color:var(--base3); box-shadow:0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent);
  }
  .nav-bottom .note-btn .bubble .ico { width:25px; height:25px; }
  .brand-pre { font-size:15px; }
}

/* ---------- cartes ---------- */
.panel { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow-sm); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); }
.panel + .panel { margin-top:12px; }

/* ---------- saisie ---------- */
.composer { padding:14px; }
.composer textarea.main {
  border:0; background:transparent; box-shadow:none; padding:4px 2px; min-height:120px; font:400 19px/1.45 var(--serif);
  color:var(--text-strong); resize:none;
}
.composer textarea.main::placeholder { color:var(--text-soft); font-style:italic; }
.composer.is-quote textarea.main { font-style:italic; }
.composer .write { background:color-mix(in srgb, var(--bg-2) 70%, transparent); border-radius:12px; padding:10px 12px; border:1px solid transparent; transition:border-color .15s; }
.composer .write:focus-within { border-color:color-mix(in srgb, var(--accent) 50%, transparent); }
.chips { display:flex; flex-wrap:wrap; gap:7px; margin:12px 0 4px; }
.chip {
  --c:var(--blue);
  display:inline-flex; align-items:center; gap:6px; padding:6px 12px 6px 10px; border-radius:999px; cursor:pointer;
  border:1px solid var(--line); background:none; font-size:14px; color:var(--text); transition:background .15s, border-color .15s;
}
.chip .dot { width:9px; height:9px; border-radius:50%; background:var(--c); }
.chip .ico { color:var(--c); width:16px; height:16px; }
.chip:hover { border-color:color-mix(in srgb, var(--c) 60%, var(--line)); }
.chip.on { background:color-mix(in srgb, var(--c) 20%, transparent); border-color:var(--c); color:var(--text-strong); font-weight:500; }
.composer .row { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:10px; }
.when-btn { display:inline-flex; gap:6px; align-items:center; background:none; border:0; padding:4px 2px; color:var(--text-dim); cursor:pointer; font-size:14px; }
.when-btn:hover { color:var(--text-strong); }
.when-edit { display:grid; grid-template-columns:1fr 1fr auto; gap:8px; align-items:end; margin-top:8px; }
.when-edit .quick { display:flex; gap:6px; grid-column:1/-1; }
.details-toggle { margin-left:auto; }
.details { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:10px; }
.details .field { margin:0; }
.details .full { grid-column:1/-1; }
.word-row { display:grid; grid-template-columns:1fr auto 1fr; gap:8px; align-items:center; }
.word-row span { color:var(--text-dim); font-size:13px; }
.composer .actions { display:flex; align-items:center; gap:10px; margin-top:14px; }
.composer .actions .btn.primary { flex:1; }
.composer .hint { font-size:12px; color:var(--text-soft); text-align:center; margin-top:8px; }
@media (max-width: 520px) {
  .details { grid-template-columns:1fr; }
  .when-edit { grid-template-columns:1fr 1fr; }
  .when-edit .ok { grid-column:1/-1; }
}

/* ---------- souvenirs ---------- */
.entry {
  --c:var(--blue);
  position:relative; background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
  padding:12px 14px 11px 18px; box-shadow:var(--shadow-sm); cursor:pointer; overflow:hidden;
  transition:border-color .15s, transform .15s; backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
}
.entry::before { content:''; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--c); }
.entry:hover { border-color:color-mix(in srgb, var(--c) 50%, var(--line)); }
.entry + .entry { margin-top:9px; }
.entry .text { color:var(--text-strong); white-space:pre-wrap; overflow-wrap:anywhere; font-size:15.5px; }
.entry.quote .text { font:italic 400 19px/1.4 var(--serif); }
.entry .who { color:var(--text-dim); font-size:14px; margin-top:3px; }
.entry .dl .line + .line { margin-top:4px; }
.entry .dl .spk { font:normal 600 12.5px var(--sans); color:var(--text-dim); margin-right:4px; vertical-align:1px; }
.entry .dl .line:not(.her) .say { color:var(--text-dim); font-size:16.5px; }
.entry .dl .her .spk { color:var(--c); }
.aside { font:normal 400 13px var(--sans); color:var(--text-dim); white-space:nowrap; }
.composer textarea.main::placeholder { white-space:pre-line; }
.entry .word { display:inline-flex; gap:6px; align-items:baseline; margin-top:6px; font-size:13.5px; color:var(--text-dim); background:color-mix(in srgb, var(--c) 12%, transparent); padding:2px 9px; border-radius:7px; }
.entry .word b { font:italic 500 15px var(--serif); color:var(--text-strong); }
.meta { display:flex; flex-wrap:wrap; gap:4px 10px; margin-top:7px; font-size:12.5px; color:var(--text-dim); }
.meta .type { color:var(--c); font-weight:600; display:inline-flex; align-items:center; gap:4px; }
.meta .type .ico { width:14px; height:14px; }
.meta .age { color:var(--text-strong); font-weight:500; }
.meta .pending { color:var(--orange); }
.month { display:flex; align-items:baseline; justify-content:space-between; gap:10px; margin:24px 4px 10px; }
.month h2 { font:600 19px/1.2 var(--serif); }
.month span { font-size:13px; color:var(--text-dim); }

.memory {
  border:1.5px dashed color-mix(in srgb, var(--yellow) 70%, transparent); border-radius:var(--radius); padding:12px 14px;
  background:color-mix(in srgb, var(--yellow) 8%, var(--card)); margin-bottom:14px;
}
.memory .label { font-size:12.5px; color:var(--yellow); font-weight:600; display:flex; align-items:center; gap:6px; margin-bottom:6px; }
.memory .entry { box-shadow:none; }

.empty { text-align:center; padding:34px 16px; color:var(--text-dim); }
.empty h2 { font:600 20px var(--serif); margin-bottom:6px; }
.empty p { margin:0 auto 14px; max-width:36ch; }

.toolbar { display:flex; gap:8px; align-items:center; margin-bottom:10px; }
.toolbar .search { flex:1; position:relative; }
.toolbar .search .ico { position:absolute; left:11px; top:50%; transform:translateY(-50%); color:var(--text-soft); }
.toolbar .search input { padding-left:34px; }
.filters { display:flex; gap:6px; overflow-x:auto; scrollbar-width:none; padding-bottom:4px; margin-bottom:6px; }
.filters::-webkit-scrollbar { display:none; }
.filters .chip { flex:none; font-size:13px; padding:4px 10px 4px 8px; }
.count { font-size:13px; color:var(--text-dim); margin:2px 4px 0; }

.banner { display:flex; gap:10px; align-items:center; padding:10px 14px; border-radius:12px; margin-bottom:14px; font-size:14px;
  background:color-mix(in srgb, var(--yellow) 14%, var(--card)); border:1px solid color-mix(in srgb, var(--yellow) 40%, transparent); }
.banner .ico { color:var(--yellow); }
.banner .grow { flex:1; }

/* ---------- ses mots ---------- */
.words-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(260px, 1fr)); gap:10px; }
.words-grid .entry + .entry { margin-top:0; }
.words-grid .entry .text { font-size:20px; }
.lexicon { display:grid; gap:0; }
.lexicon .lx { display:grid; grid-template-columns:minmax(0, 1fr) auto minmax(0, 1fr) auto; gap:10px; align-items:baseline; padding:9px 4px; border-bottom:1px solid color-mix(in srgb, var(--line) 80%, transparent); cursor:pointer; }
.lexicon .lx:last-child { border-bottom:0; }
.lexicon .said { font:italic 500 18px var(--serif); color:var(--text-strong); }
.lexicon .arrow { color:var(--text-soft); }
.lexicon .means { color:var(--text); }
.lexicon .when { font-size:12.5px; color:var(--text-dim); white-space:nowrap; }

/* ---------- étapes ---------- */
.timeline { position:relative; padding-left:26px; }
.timeline::before { content:''; position:absolute; left:8px; top:8px; bottom:8px; width:2px; background:color-mix(in srgb, var(--text-soft) 50%, transparent); border-radius:2px; }
.step { position:relative; margin-bottom:14px; }
.step::before { content:''; position:absolute; left:-23px; top:14px; width:12px; height:12px; border-radius:50%; background:var(--c, var(--yellow)); box-shadow:0 0 0 4px var(--bg); }
.step .age-big { font:600 15px var(--serif); color:var(--text-strong); margin:0 0 4px 2px; }
.step .age-big span { font:400 13px var(--sans); color:var(--text-dim); margin-left:6px; }

/* ---------- lettres ---------- */
.letter { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:16px 18px; box-shadow:var(--shadow-sm); }
.letter + .letter { margin-top:10px; }
.letter h3 { font:600 18px var(--serif); margin-bottom:4px; }
.letter .body { font:400 16.5px/1.6 var(--serif); color:var(--text-strong); white-space:pre-wrap; margin-top:10px; overflow-wrap:anywhere; }
.letter.sealed { text-align:center; border-style:dashed; background:color-mix(in srgb, var(--violet) 7%, var(--card)); }
.letter.sealed .seal { width:46px; height:46px; border-radius:50%; margin:2px auto 10px; display:grid; place-items:center; background:color-mix(in srgb, var(--violet) 22%, transparent); color:var(--violet); }
.letter .meta { justify-content:space-between; }
.letter.sealed .meta { justify-content:center; }

/* ---------- réglages ---------- */
.settings section { margin-bottom:14px; }
.settings h2 { font:600 18px var(--serif); margin-bottom:4px; }
.settings .sub { color:var(--text-dim); font-size:14px; margin:0 0 12px; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns:1fr; } }
.seg { display:inline-flex; border:1px solid var(--line); border-radius:11px; padding:3px; gap:2px; background:var(--bg); }
.seg button { border:0; background:none; padding:6px 13px; border-radius:8px; cursor:pointer; font-size:14px; color:var(--text-dim); }
.seg button.on { background:var(--bg-2); color:var(--text-strong); font-weight:500; box-shadow:var(--shadow-sm); }
.swatches { display:flex; flex-wrap:wrap; gap:10px; margin-top:10px; }
.swatch { display:grid; justify-items:center; gap:4px; background:none; border:0; cursor:pointer; font-size:12px; color:var(--text-dim); padding:0; }
.swatch i { width:46px; height:46px; border-radius:12px; border:2px solid var(--line); display:block; }
.swatch.on i { border-color:var(--accent); box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.swatch.on { color:var(--text-strong); font-weight:500; }
.types-list { display:grid; }
.type-row { display:grid; grid-template-columns:auto auto minmax(0, 1fr) auto auto; align-items:center; gap:10px; padding:9px 2px; border-bottom:1px solid color-mix(in srgb, var(--line) 80%, transparent); }
.type-row:last-child { border-bottom:0; }
.type-row .handle { cursor:grab; color:var(--text-soft); padding:4px; touch-action:none; }
.type-row .tico { --c:var(--blue); width:30px; height:30px; border-radius:9px; display:grid; place-items:center; color:var(--c); background:color-mix(in srgb, var(--c) 16%, transparent); }
.type-row .name { font-weight:500; color:var(--text-strong); }
.type-row .name small { display:block; font-weight:400; color:var(--text-dim); font-size:12.5px; }
.type-row.is-hidden .name, .type-row.is-hidden .tico { opacity:.5; }
.type-row .n { font-size:12.5px; color:var(--text-dim); }
.sortable-ghost { opacity:.35; }
.sortable-fallback { box-shadow:var(--shadow); background:var(--bg); border-radius:10px; }
.colors { display:flex; flex-wrap:wrap; gap:8px; }
.colors button { width:32px; height:32px; border-radius:50%; border:3px solid transparent; cursor:pointer; background:var(--c); box-shadow:inset 0 0 0 2px var(--bg); }
.colors button.on { border-color:var(--text-strong); }
.icons { display:grid; grid-template-columns:repeat(auto-fill, minmax(40px, 1fr)); gap:6px; }
.icons button { aspect-ratio:1; border-radius:10px; border:1px solid var(--line); background:none; cursor:pointer; color:var(--text-dim); display:grid; place-items:center; }
.icons button.on { color:var(--c, var(--accent)); border-color:var(--c, var(--accent)); background:color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); }
.icons .ico { width:20px; height:20px; }
.list-row { display:flex; align-items:center; gap:10px; padding:8px 2px; border-bottom:1px solid color-mix(in srgb, var(--line) 80%, transparent); }
.list-row:last-child { border-bottom:0; }
.list-row .grow { flex:1; min-width:0; }
.tag { font-size:11.5px; padding:2px 7px; border-radius:6px; background:color-mix(in srgb, var(--violet) 18%, transparent); color:var(--text-strong); }
.btn-row { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }

/* ---------- dialogues ---------- */
dialog {
  border:1px solid var(--line); border-radius:20px; padding:0; width:min(560px, calc(100vw - 24px)); max-height:calc(100dvh - 24px);
  background:var(--bg); color:var(--text); box-shadow:var(--shadow);
}
dialog::backdrop { background:rgba(0,43,54,.45); backdrop-filter:blur(2px); }
dialog .dlg { padding:18px; overflow:auto; max-height:calc(100dvh - 26px); }
dialog .dlg-head { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
dialog .dlg-head h2 { font:600 20px var(--serif); flex:1; }
dialog .dlg-foot { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; margin-top:16px; }
dialog .dlg-foot .left { margin-right:auto; }
dialog .composer { padding:0; border:0; background:none; box-shadow:none; backdrop-filter:none; }
@media (max-width: 760px) {
  dialog { width:100vw; max-width:100vw; margin:auto 0 0; border-radius:20px 20px 0 0; border-bottom:0; }
  dialog .dlg { padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
}

/* ---------- menu « plus » ---------- */
.sheet-links { display:grid; gap:4px; }
.sheet-links a, .sheet-links button { display:flex; align-items:center; gap:12px; padding:12px; border-radius:12px; text-decoration:none; color:var(--text-strong); background:none; border:0; cursor:pointer; font-size:16px; text-align:left; }
.sheet-links a:hover, .sheet-links button:hover { background:var(--bg-2); }
.sheet-links .ico { color:var(--text-dim); width:22px; height:22px; }

/* ---------- messages ---------- */
.toasts { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(24px + env(safe-area-inset-bottom)); z-index:100; display:grid; gap:8px; width:min(420px, calc(100vw - 24px)); pointer-events:none; }
@media (max-width: 760px) { .toasts { bottom:calc(90px + env(safe-area-inset-bottom)); } }
.toast { pointer-events:auto; display:flex; align-items:center; gap:10px; padding:11px 14px; border-radius:13px; background:var(--base02); color:var(--base2); box-shadow:var(--shadow); font-size:14.5px; }
:root[data-theme="dark"] .toast { background:var(--base2); color:var(--base02); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background:var(--base2); color:var(--base02); } }
.toast .grow { flex:1; }
.toast button { background:none; border:0; color:var(--cyan); font-weight:600; cursor:pointer; padding:2px 4px; }
.toast.error { background:var(--red); color:var(--base3); }
.toast.error button { color:var(--base3); }

/* ---------- livre de l'année (lecture et impression) ---------- */
.book { width:min(680px, 100%); margin:0 auto; padding:24px 20px 60px; }
.book-tools { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:22px; }
.book-tools .push { margin-left:auto; }
.book-cover { text-align:center; padding:50px 0 40px; border-bottom:1px solid var(--line); margin-bottom:20px; }
.book-cover h1 { font:600 44px/1.1 var(--serif); }
.book-cover .y { font:italic 400 26px var(--serif); color:var(--text-dim); margin-top:8px; }
.book-cover p { color:var(--text-dim); }
.book h2 { font:600 24px var(--serif); margin:34px 0 4px; }
.book h2 + .sub { color:var(--text-dim); font-size:14px; margin-bottom:14px; }
.b-entry { margin:0 0 16px; padding-left:14px; border-left:3px solid var(--c, var(--blue)); break-inside:avoid; }
.b-entry .t { font:400 17px/1.5 var(--serif); color:var(--text-strong); white-space:pre-wrap; }
.b-entry.quote .t { font-style:italic; font-size:19px; }
.b-entry .m { font-size:12.5px; color:var(--text-dim); margin-top:3px; }
.b-entry .dl .line + .line { margin-top:3px; }
.b-entry .dl .spk { font:normal 600 12.5px var(--sans); color:var(--text-dim); margin-right:4px; }
.b-entry .dl .line:not(.her) .say { color:var(--text-dim); font-size:16px; }
.b-entry .dl .her .spk { color:var(--c, var(--blue)); }
.b-letter { margin:16px 0 26px; break-inside:avoid; }
.b-letter .t { font:400 16.5px/1.6 var(--serif); white-space:pre-wrap; color:var(--text-strong); }
@media print {
  html, html[data-bg] body, body { background:#fff !important; color:#222; }
  :root { --text-strong:#111; --text:#333; --text-dim:#666; --line:#ccc; }
  .book-tools, .toasts { display:none !important; }
  .book { padding:0; width:100%; }
  .book h2 { break-after:avoid; }
  .book-cover { break-after:page; border:0; padding-top:30vh; }
  @page { margin:18mm 16mm; }
}

@media (prefers-reduced-motion: reduce) { * { transition:none !important; } }
