:root {
  --bg: #000000; --surface: #0b0b0e; --surface-2: #121216;
  --line: #1f1f26; --line-2: #2e2e38;
  --text: #f5f5f7; --muted: #8d8d98; --dim: #5e5e6a;
  --accent: #f5f5f7; --accent-ink: #000000;
  --success: #4ade80; --danger: #f87171;
  --routine: #a78bfa; --sport: #4ade80; --ics: #60a5fa; --manual: #8b8b9c;
  --r: 16px; --hour: 64px;
  color-scheme: dark;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 Inter, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
svg { display: block; flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; text-align: left; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
small { font-size: 14px; }
h1 { font-size: 26px; letter-spacing: -.025em; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; color: var(--muted); }

/* ===== Structure ===== */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 224px; z-index: 40; display: flex; flex-direction: column; gap: 14px; padding: 20px 12px; background: rgba(5,5,7,.9); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding: 0 8px; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-2); }
.cmd-btn { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.cmd-btn kbd { margin-left: auto; font: 13px ui-monospace, monospace; color: var(--dim); }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: var(--muted); font-weight: 550; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--text); color: #000; }
.nav-item.on kbd { color: #000; }
.nav-item kbd { margin-left: auto; font: 13px ui-monospace, monospace; color: var(--dim); }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--muted); }
.side-lvl { display: flex; justify-content: space-between; margin-bottom: 8px; }
.side-lvl b { color: var(--text); }
.shell { margin-left: 224px; }
.page { display: none; max-width: 1200px; margin: 0 auto; padding: 28px clamp(14px, 3vw, 36px) 80px; }
.page.on { display: flex; flex-direction: column; gap: 16px; }
.page.wide { max-width: 1600px; }
.page.narrow { max-width: 1000px; }
.cols.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.summary .kpi { background: none; border: 0; padding: 0; }
.summary .kpi b { font-size: 21px; }
summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
summary:hover { color: var(--text); }
details[open] > summary { margin-bottom: 10px; }
details.card { display: block; }
#nav hr { border: 0; border-top: 1px solid var(--line); margin: 8px 4px; }
.item.now { background: var(--surface-2); box-shadow: inset 2px 0 var(--text); }
.mark { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.page-head p { color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.between { justify-content: space-between; }
.row > label { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head.sub { border-top: 1px solid var(--line); padding-top: 12px; }
.empty { color: var(--dim); text-align: center; padding: 16px 0; }
.scroll { max-height: 300px; overflow-y: auto; }

/* ===== Contrôles ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 1px solid var(--line-2); border-radius: 10px; font-weight: 600; text-align: center; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 14px; }
.link { color: var(--muted); font-size: 14px; }
.link:hover { color: var(--text); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 11px; }
.seg button { padding: 5px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--text); color: #000; }
input:not([type=checkbox], [type=color]), select, textarea { width: 100%; padding: 9px 12px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); font-weight: 600; }
label input, label select { color: var(--text); font-weight: 400; font-size: 14.5px; }
.check-label { flex-direction: row; align-items: center; gap: 8px; }
.inline-form { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; }
.inline-form input, .inline-form select { flex: 1 1 110px; width: auto !important; min-width: 0; }
.inline-form input:first-child { flex-basis: 200px; }
.inline-form input[type=number] { flex: 0 0 90px; }
.icon-btn { color: var(--dim); padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { color: var(--danger); background: var(--bg); }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .6s ease; }

/* ===== Indicateurs ===== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.kpis.flat .kpi { background: var(--surface-2); border: 0; }
.kpi span { color: var(--muted); font-size: 14px; }
.kpi b { font-size: 26px; letter-spacing: -.02em; line-height: 1.15; }
.kpi b small { font-size: 14px; color: var(--muted); font-weight: 500; }
.big { font-size: 30px; font-weight: 750; }
.big small { font-size: 14px; color: var(--muted); font-weight: 500; }
.up { color: var(--success); } .down { color: var(--danger); }

/* ===== Listes ===== */
.item { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 10px; min-width: 0; }
.item:hover { background: var(--surface-2); }
.item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item.done .grow { color: var(--dim); text-decoration: line-through; }
.item .time { width: 44px; flex-shrink: 0; color: var(--muted); font-size: 14px; }
.item .tail { color: var(--muted); font-size: 14px; white-space: nowrap; }
.tick { display: grid; place-items: center; width: 20px; height: 20px; flex-shrink: 0; border: 2px solid var(--line-2); border-radius: 99px; color: transparent; }
.tick:hover { border-color: var(--success); }
.done .tick { background: var(--success); border-color: var(--success); color: var(--bg); }
button.item { width: 100%; }
.dot { width: 8px; height: 8px; border-radius: 99px; background: var(--c, var(--line-2)); flex-shrink: 0; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.quick { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--surface-2); border: 1px solid transparent; border-radius: 11px; font-weight: 600; font-size: 14.5px; line-height: 1.3; min-width: 0; }
.quick:hover { border-color: var(--line-2); }
.quick > svg { color: var(--text); }
.quick small { display: block; color: var(--muted); font-weight: 500; }
.quick.removing { border: 1px dashed var(--danger); }
.dom { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 6px 0; }
.dom svg { color: var(--text); }
.dom .bar { grid-column: 2 / -1; height: 4px; }
.dom .bar i { background: var(--c); }
.goal { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }

.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heatmap i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.heatmap i.l1 { background: #3a3a44; } .heatmap i.l2 { background: #5b5b68; }
.heatmap i.l3 { background: #8b8b9c; } .heatmap i.l4 { background: #e8e8ef; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.badge { padding: 9px 11px; border-radius: 10px; background: var(--surface-2); opacity: .45; line-height: 1.35; }
.badge b { display: block; font-size: 14px; }
.badge small { color: var(--muted); }
.badge.got { opacity: 1; box-shadow: inset 3px 0 var(--accent); }

/* ===== Focus ===== */
.pomo { align-items: center; padding: 28px; }
.pomo-clock { position: relative; width: min(260px, 100%); aspect-ratio: 1; }
.pomo-clock svg { transform: rotate(-90deg); fill: none; stroke-width: 9; }
.pomo-clock .p-bg { stroke: var(--line); }
.pomo-clock .p-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .4s linear; }
.pomo-clock.rest .p-fg { stroke: var(--success); }
.pomo-clock > div { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pomo-clock .t { font-size: 48px; font-weight: 750; }
.pomo-float { position: fixed; right: 20px; bottom: 20px; z-index: 45; display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--accent); font-weight: 750; font-size: 17px; }
.pomo-float small { color: var(--muted); font-weight: 500; }

/* ===== Calendrier ===== */
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border: 1px solid var(--line-2); border-radius: 99px; font-size: 13.5px; font-weight: 600; }
.chip.off { opacity: .4; text-decoration: line-through; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.cal-main { padding: 0; overflow: hidden; }
.tg-scroll { overflow: auto; max-height: max(440px, calc(100vh - 270px)); }
.tg { display: grid; grid-template-columns: 58px repeat(var(--n), minmax(0, 1fr)); min-width: calc(58px + var(--n) * 80px); }
.tg-head { position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--line-2); border-left: 1px solid var(--line); padding: 8px 6px; text-align: center; }
.tg-head button { width: 100%; text-align: center; }
.tg-head span { display: block; font-size: 14px; color: var(--muted); text-transform: capitalize; }
.tg-head b { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 99px; font-size: 17px; }
.tg-head.today b { background: var(--accent); color: var(--accent-ink); }
.tg-head.sel { background: var(--surface-2); }
.tg-head small { display: block; color: var(--dim); font-size: 13px; }
.tg-allday { border-left: 1px solid var(--line); border-bottom: 1px solid var(--line-2); padding: 3px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tg-corner { font-size: 13px; color: var(--dim); text-align: right; padding: 5px 6px; }
.tg-hours { position: relative; }
.tg-hours span { position: absolute; right: 7px; transform: translateY(-50%); font-size: 13px; color: var(--dim); }
.tg-col { position: relative; border-left: 1px solid var(--line); cursor: copy; background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour) - 1px), var(--line) calc(var(--hour) - 1px) var(--hour)); }
.tg-col.today { background-color: #c4b5fd0a; }
.tg-pr { position: absolute; left: 0; right: 0; border-top: 1px dashed #a78bfa66; pointer-events: none; }
.cal-prayers { display: flex; flex-wrap: wrap; gap: 4px 22px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: #b9a8fb; font-size: 14px; }
.cal-prayers b { color: var(--text); }
.tg-col.past .ev:not(.done) { opacity: .65; }
@media (hover: hover) {
  .tg .ev:not(.done) .tick { display: none; }
  .tg .ev:hover .tick, .tg .ev:focus-within .tick { display: grid; }
}
.tg-now { position: absolute; left: 0; right: 0; border-top: 2px solid var(--accent); z-index: 4; pointer-events: none; }
.ev { display: flex; gap: 5px; align-items: flex-start; padding: 3px 5px; border-radius: 7px; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface)); font-size: 13.5px; line-height: 1.3; overflow: hidden; cursor: pointer; user-select: none; min-width: 0; }
.ev:hover { background: color-mix(in srgb, var(--c) 30%, var(--surface)); z-index: 5; }
.tg-col .ev { position: absolute; z-index: 2; cursor: grab; }
.ev .tick { width: 13px; height: 13px; margin-top: 1px; border-color: var(--c); }
.ev .tick svg { width: 9px; height: 9px; }
.ev > div { min-width: 0; overflow: hidden; overflow-wrap: break-word; }
.ev small { display: block; font-size: 13px; color: var(--muted); }
.ev.short > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.short small { display: none; }
.ev.done { opacity: .5; }
.ev.done > div { text-decoration: line-through; }
.ev.dragging { opacity: .9; z-index: 8; cursor: grabbing; box-shadow: 0 10px 26px #0009; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-dow { padding: 8px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.m-day { min-height: 112px; padding: 5px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.m-day:nth-child(7n) { border-right: 0; }
.m-day:hover, .m-day.sel { background: var(--surface-2); }
.m-day.sel { box-shadow: inset 0 0 0 1px var(--accent); }
.m-day.out { opacity: .38; }
.m-top { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.m-top b { display: grid; place-items: center; min-width: 22px; height: 22px; border-radius: 99px; }
.m-day.today .m-top b { background: var(--accent); color: var(--accent-ink); }
.m-top small { color: var(--accent); font-size: 13px; }
.m-ev { font-size: 13px; padding: 1px 5px; border-left: 3px solid var(--c); border-radius: 4px; background: color-mix(in srgb, var(--c) 16%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-ev.done { opacity: .45; text-decoration: line-through; }
.m-more { font-size: 13px; color: var(--muted); }
.m-foot { margin-top: auto; }
.cal-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.cal-side h2 { text-transform: capitalize; }

/* ===== Tableaux, notes, livres ===== */
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.r { text-align: right; }
/* trois colonnes sur toute la hauteur : dossiers, liste, note — chacune défile seule */
#page-notes { max-width: none; padding: 0; gap: 0; }
.notes { display: grid; grid-template-columns: 320px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100vh; }
.note-folders { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 10px; max-height: 40vh; padding: 16px 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow-y: auto; min-width: 0; }
.note-folders .folder { padding: 6px 10px; }
.note-folders h1 { font-size: 21px; }
.note-folders > div:first-child { padding: 0 8px; }
.folder-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.folder { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-shrink: 0; padding: 7px 11px; border: 1px solid transparent; border-radius: 9px; color: var(--muted); font-weight: 550; overflow-wrap: anywhere; }
.folder:hover { background: var(--surface-2); color: var(--text); }
.folder.on { background: var(--surface-2); color: var(--text); border-color: var(--line-2); }
.folder.drop { border-color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; gap: 4px; }
.toolbar button { padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 14px; color: var(--muted); }
.toolbar button:hover { background: var(--surface-2); color: var(--text); }
.toolbar button:disabled { opacity: .35; cursor: default; }
.toolbar .push { margin-left: auto; color: var(--text); }
#printTitle { display: none; }
.review { display: flex; flex-direction: column; gap: 16px; text-align: center; align-items: stretch; }
.review-q { font-size: 20px; font-weight: 650; overflow-wrap: anywhere; }
.review-a { padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; overflow-wrap: anywhere; }
.head-actions select { width: auto; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.note-side { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.side-head { display: flex; gap: 8px; padding: 12px 12px 0; }
.side-head .btn { flex: 1; white-space: nowrap; }
.side-head select { width: 96px; flex: 0 0 auto; padding: 6px 4px; font-size: 14px; }
.side-head input { min-width: 0; padding: 6px 10px; font-size: 14px; }
.note-list { flex: 1; overflow-y: auto; }
.note-card { display: block; width: 100%; padding: 11px 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; line-height: 1.4; }
.note-card:hover { background: var(--surface); }
.note-card.on { background: var(--surface-2); box-shadow: inset 3px 0 var(--accent); }
.note-card b { font-size: 14.5px; }
.note-card p { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0; }
.note-card small { font-size: 13px; color: var(--dim) !important; }

.note-doc { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.note-empty { margin: auto; padding: 24px; color: var(--dim); text-align: center; }
.note-editor { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.note-back { display: none; }
.note-top { display: flex; align-items: center; gap: 10px; padding: 14px 28px 10px; }
.note-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.note-tools .btn.on { background: var(--surface-2); }
.menu { position: relative; }
.menu summary { list-style: none; font-size: 15px; color: var(--text); }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] > summary { margin: 0; background: var(--surface-2); }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; width: 190px; padding: 5px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 12px 30px #000a; }
.menu-list button { padding: 8px 11px; border-radius: 7px; font-size: 14px; }
.menu-list button:hover { background: var(--line-2); }
.menu-list .danger { color: var(--danger); }
.note-bar { padding: 0 28px 10px; border-bottom: 1px solid var(--line); }
.note-bar .toolbar { align-items: center; }
.note-bar .toolbar button { border-color: transparent; }
#tableTools { margin-top: 6px; }
#noteInsert { width: auto; padding: 5px 10px; font-size: 14px; margin-right: 6px; }
.note-body { display: flex; flex: 1; min-height: 0; }
.note-scroll { flex: 1; min-width: 0; overflow-y: auto; scroll-behavior: auto; }
.note-page { display: flex; flex-direction: column; gap: 10px; min-height: 100%; max-width: 940px; margin: 0 auto; padding: 40px 56px 0; }
.note-page #noteTitle { resize: none; overflow: hidden; flex-shrink: 0; background: none; border: 0; padding: 0; font: 750 32px/1.2 Inter, system-ui, sans-serif; letter-spacing: -.02em; }
.note-props { display: flex; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.note-props select { width: auto; max-width: 45%; background: var(--surface-2); border-color: transparent; font-size: 14px; padding: 5px 9px; }
.note-props input { background: none; border-color: transparent; font-size: 14px; color: var(--muted); padding: 5px 9px; }
.note-props input:hover, .note-props input:focus { border-color: var(--line-2); }
#noteBody { flex: 1; min-height: 400px; resize: none; margin-bottom: 24px; font: 15px/1.65 ui-monospace, monospace; background: var(--surface); }
.rich-box { position: relative; display: flex; flex-direction: column; flex: 1; min-width: 0; padding: 8px 0 120px; }
.rich-box > .rich { flex: 1; }
.rich-box > .handle { left: -30px; }
.outline { width: 220px; flex-shrink: 0; overflow-y: auto; padding: 22px 14px; border-left: 1px solid var(--line); }
.outline h3 { margin-bottom: 8px; padding-left: 8px; }
.outline button { display: block; width: 100%; padding: 5px 8px; border-radius: 7px; font-size: 13.5px; line-height: 1.35; color: var(--muted); }
.outline button:hover { background: var(--surface-2); color: var(--text); }
.outline .lvl1, .outline .lvl2 { color: var(--text); }
.outline .lvl3 { padding-left: 20px; }
.notes.wide.editing { grid-template-columns: minmax(0, 1fr); }
.notes.wide.editing .note-doc { grid-column: 1; }
.notes.wide.editing .note-side, .notes.wide.editing .note-folders { display: none; }
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f3f4f6; --text: #111; --muted: #444; --dim: #666; --line: #ddd; --line-2: #bbb; --accent: #111; color-scheme: light; }
  body { background: #fff; }
  .sidebar, .toast-zone, .pomo-float, .note-folders, .note-side, .note-empty, .note-top, .note-bar, .outline, #noteTitle, .note-props, #noteBody, .block-head, .block pre { display: none !important; }
  .shell { margin: 0; padding: 0; }
  .page.on, .notes, .note-doc, .note-editor, .note-body, .note-scroll, .note-page { display: block !important; height: auto; max-width: none; min-height: 0; overflow: visible; margin: 0; padding: 0; }
  #printTitle { display: block; margin-bottom: 14px; }
  .rich-box { display: block !important; padding: 0; }
  .rich pre, .rich table, .rich img, .rich .block, .rich blockquote { break-inside: avoid; }
  .rich pre code { white-space: pre-wrap; }
}
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

/* ===== Dialogues et toasts ===== */
dialog { margin: auto; width: min(440px, 94vw); background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; }
dialog::backdrop { background: #05060acc; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.actions .danger { margin-right: auto; }
#palette { margin-top: 12vh; padding: 10px; width: min(560px, 94vw); }
#paletteList { max-height: 340px; overflow-y: auto; margin-top: 8px; }
#paletteList .item.on { background: var(--surface-2); box-shadow: inset 3px 0 var(--accent); }
.toast-zone { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: 92vw; }
.toast { padding: 10px 18px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 10px 30px #0008; }
.toast small { display: block; color: var(--muted); }

/* ===== Écrans étroits ===== */
@media (max-width: 1150px) { .cal-layout { grid-template-columns: minmax(0, 1fr); } .cal-side { position: static; max-height: none; } }
@media (max-width: 900px) { .cols, .cols.even { grid-template-columns: minmax(0, 1fr); } }
/* ===== Ordinateur : menu en haut ===== */
#navInk { display: none; }
@media (min-width: 761px) {
  :root { --top: 60px; }
  .sidebar { inset: 0 0 auto 0; width: 100%; height: var(--top); flex-direction: row; align-items: center; gap: 12px; padding: 0 18px; border-right: 0; border-bottom: 1px solid var(--line); background: rgba(5,5,7,.82); backdrop-filter: blur(14px); }
  .shell { margin-left: 0; padding-top: var(--top); }
  .brand { padding: 0; }
  #nav { flex: 1; order: 1; position: relative; flex-direction: row; justify-content: center; align-items: center; gap: 2px; min-width: 0; }
  #nav hr { width: 1px; height: 22px; margin: 0 8px; border: 0; background: var(--line-2); }
  #navInk { display: block; position: absolute; left: 0; top: 50%; height: 36px; margin-top: -18px; border-radius: 10px; background: var(--text); transition: transform .35s cubic-bezier(.3, 1.25, .5, 1), width .3s ease; }
  .nav-item { position: relative; z-index: 1; gap: 8px; height: 36px; padding: 0 12px; white-space: nowrap; }
  .nav-item.on, .nav-item.on:hover { background: transparent; color: #000; }
  .cmd-btn { order: 2; padding: 7px 10px; }
  .cmd-btn kbd { margin-left: 4px; }
  .side-foot { order: 3; width: 96px; margin: 0; padding: 0; border: 0; }
  .side-lvl { margin-bottom: 5px; font-size: 14px; }
  #sideStreak, #sideXp { display: none; }
  .side-foot .bar { height: 4px; }
  .notes { height: calc(100vh - var(--top)); }
  .cal-side { top: calc(var(--top) + 16px); max-height: calc(100vh - var(--top) - 32px); }
  .tg-scroll { max-height: max(440px, calc(100vh - 270px - var(--top))); }
}
/* moins de place : seul l'onglet actif garde son nom */
@media (min-width: 761px) and (max-width: 1360px) {
  .nav-item:not(.on) .nav-txt, .cmd-btn .nav-txt, .cmd-btn kbd { display: none; }
}
@media (min-width: 761px) and (max-width: 900px) {
  .side-foot, .brand, #nav hr { display: none; }
  .nav-item { padding: 0 9px; }
}

/* le sommaire n'apparaît que s'il reste assez de place pour la note */
@media (max-width: 1250px) { .outline, #outlineBtn { display: none !important; } }
@media (max-width: 760px) {
  .sidebar { inset: auto 0 0 0; width: 100%; padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .brand, .side-foot, .cmd-btn, #nav hr { display: none; }
  #nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .kpis, .card.summary { grid-template-columns: 1fr 1fr; gap: 14px; }
  .nav-item { flex: 1 0 64px; flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 13px; text-align: center; }
  .shell { margin-left: 0; padding-bottom: 70px; }
  /* une seule vue à la fois : la liste ou la note */
  .notes, .notes.wide.editing { display: block; height: auto; }
  .note-folders { max-height: none; border: 0; padding: 16px 12px; }
  .note-side { border: 0; }
  .note-doc { display: none; }
  .notes.editing .note-doc { display: flex; height: calc(100vh - 70px); }
  .notes.editing .note-side, .notes.editing .note-folders { display: none; }
  .note-back { display: inline-flex; }
  [data-act=note-wide], #noteModeBtn + .menu { margin: 0; }
  [data-act=note-wide], .note-top small { display: none; }
  .note-top, .note-bar { padding-left: 12px; padding-right: 12px; }
  /* une seule ligne qui défile : la barre ne mange pas l'écran */
  #noteToolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #noteToolbar > * { flex-shrink: 0; }
  .note-page { padding: 16px 14px 0 30px; }
  .note-page #noteTitle { font-size: 24px; }
  .rich-box > .handle { left: -26px; }
}
/* ===== Survols ===== */
.btn, .nav-item, .cmd-btn, .item, .folder, .chip, .quick, .card, .kpi, .badge, .tick, .icon-btn, .link, .seg button, .toolbar button, .menu-list button, .m-day, .ev, .tg-head button, .flashcard, .quiz-option, input, select, textarea {
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .2s ease, transform .18s ease, filter .16s ease, opacity .16s ease;
}
.note-card { transition: background-color .16s ease, padding .16s ease, box-shadow .2s ease; }
.nav-item svg, .quick > svg { transition: transform .2s cubic-bezier(.3, 1.5, .5, 1); }
.btn:active, .nav-item:active, .quick:active, .chip:active { transform: scale(.96); }
input:not([type=checkbox], [type=color]):focus, select:focus, textarea:focus { border-color: var(--muted); }
::selection { background: #a78bfa55; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
@media (hover: hover) {
  .btn:hover { transform: translateY(-1px); border-color: var(--muted); }
  .btn.primary:hover { box-shadow: 0 6px 18px #ffffff26; }
  .btn.danger:hover { border-color: var(--danger); background: #f871711a; }
  .nav-item:hover svg { transform: translateY(-2px) scale(1.12); }
  .cmd-btn:hover { border-color: var(--line-2); color: var(--text); }
  .card:hover { border-color: var(--line-2); }
  .kpis:not(.flat) > .kpi:hover { border-color: var(--line-2); transform: translateY(-2px); }
  .quick:hover { transform: translateY(-3px); box-shadow: 0 10px 22px #0009; }
  .quick:hover > svg { transform: scale(1.2) rotate(-6deg); }
  .tick:hover { transform: scale(1.18); }
  .badge.got:hover { transform: translateY(-2px); }
  .chip:hover { border-color: var(--muted); }
  .note-card:hover { padding-left: 18px; }
  .folder:hover { transform: translateX(2px); }
  .ev:hover { box-shadow: 0 6px 16px #000b; }
  .m-day:hover .m-top b { transform: scale(1.15); }
  .icon-btn:hover { transform: scale(1.15); }
  .flashcard:hover { border-color: var(--muted); transform: translateY(-2px); }
  .quiz-option:hover { border-color: var(--muted); }
}

/* ===== Animations ===== */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes tick-pop { 40% { transform: scale(1.45); } }
@keyframes fade { from { opacity: 0; } }
/* à l'ouverture d'une page seulement : un rafraîchissement ne rejoue rien */
.page.on > * { animation: rise .38s cubic-bezier(.22, 1, .36, 1) backwards; }
.page.on > :nth-child(2) { animation-delay: .05s; }
.page.on > :nth-child(3) { animation-delay: .1s; }
.page.on > :nth-child(n+4) { animation-delay: .15s; }
dialog[open] { animation: pop-in .22s cubic-bezier(.22, 1, .36, 1); }
dialog[open]::backdrop { animation: fade .22s ease; }
.menu[open] .menu-list, .slash-menu:not([hidden]), .handle-menu:not([hidden]) { animation: pop-in .16s ease; }
.toast { animation: rise .3s cubic-bezier(.22, 1, .36, 1); }
.tick.pop { animation: tick-pop .32s ease; }
.note-editor:not([hidden]) .note-page { animation: fade .25s ease; }
details.card[open] > :not(summary), details[open] > #weeklyQuests { animation: rise .25s ease; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after, ::backdrop { transition: none !important; animation: none !important; } }

/* ===== Mise en page simplifiée ===== */
.more-menu { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 2px; width: 230px; padding: 6px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 16px 40px #000c; animation: pop-in .18s ease; }
.more-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: var(--muted); font-weight: 550; }
.more-item:hover { background: var(--line-2); color: var(--text); }
.more-item.on { background: var(--text); color: #000; }
.menu-list hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 6px; }
.menu-list label { padding: 6px 11px 4px; }

/* notes : un en-tête, des pastilles, la liste */
.note-folders { gap: 10px; padding: 14px 12px 10px; border-bottom: 0; max-height: 36vh; overflow-x: hidden; }
.notes-head { display: flex; align-items: center; gap: 6px; }
.notes-head > div:first-child { margin-right: auto; display: flex; flex-direction: column; line-height: 1.2; flex-shrink: 0; }
.notes-head h1 { font-size: 20px; }
.notes-head .btn { white-space: nowrap; padding: 6px 10px; }
.notes-head #noteCount { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-folders .folder-list { flex-direction: row; flex-wrap: wrap; gap: 6px; margin: 0; }
.note-folders .folder { gap: 7px; padding: 4px 11px; border: 1px solid var(--line-2); border-radius: 99px; font-size: 13.5px; }
.note-folders .folder.on { background: var(--text); border-color: var(--text); color: #000; }
.note-folders .folder:hover { transform: none; }
.note-folders .tags { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0; flex-shrink: 0; }
.note-folders .tags:empty { display: none; }
.note-folders .tags .chip { flex-shrink: 0; border-color: transparent; color: var(--dim); padding: 1px 6px; }
.note-folders .tags .chip::before { content: "#"; margin-right: -5px; }
.note-folders .tags .chip.on { color: var(--text); }
.note-side .side-head { padding: 0 12px 10px; }
.note-card { padding: 10px 14px; }
.note-card small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* plan du jour : la croix ne distrait qu'au survol */
@media (hover: hover) {
  #plansToday .icon-btn { opacity: 0; }
  #plansToday .item:hover .icon-btn, #plansToday .icon-btn:focus-visible { opacity: 1; }
}
@media (hover: none) { #plansToday .icon-btn { display: none; } }

@media (min-width: 761px) {
  .more-menu { top: calc(var(--top) + 4px); }
  .nav-item { padding: 0 16px; }
}
@media (min-width: 761px) and (max-width: 1360px) {
  .nav-item:not(.on) .nav-txt { display: inline; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .cmd-btn .nav-txt, .cmd-btn kbd { display: none; }
}

@media (max-width: 760px) {
  /* barre du bas : cinq onglets de même largeur, rien ne déborde */
  #nav { overflow: visible; width: 100%; }
  .nav-item { flex: 1 1 0; min-width: 0; }
  .more-menu { right: 8px; bottom: calc(76px + env(safe-area-inset-bottom)); width: min(250px, 92vw); }
  .page { padding: 16px 12px 24px; gap: 12px; }
  #page-notes { padding: 0; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
  /* accueil : le bouton à côté du titre, le résumé sur une ligne */
  #page-overview .page-head { flex-wrap: nowrap; align-items: flex-start; }
  #page-overview .page-head .btn { padding: 10px; flex-shrink: 0; }
  #page-overview .page-head .lbl { display: none; }
  .card.summary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 12px; }
  .summary .kpi span { font-size: 13px; white-space: nowrap; }
  .summary .kpi b { font-size: 18px; }
  .summary .kpi b small { display: block; font-size: 13px; white-space: nowrap; }
  .item { padding: 7px 2px; gap: 9px; }
  /* calendrier : commandes sur deux lignes, ajout par un bouton flottant */
  #page-calendar .head-actions { width: 100%; gap: 8px; }
  #calViews { width: 100%; }
  #calViews button { flex: 1; text-align: center; }
  #page-calendar .head-actions .row { margin-right: auto; }
  .btn.fab { position: fixed; right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 30; padding: 13px 18px; border-radius: 99px; box-shadow: 0 10px 28px #000c; }
  .cal-prayers { flex-wrap: nowrap; overflow-x: auto; gap: 16px; padding: 8px 12px; white-space: nowrap; scrollbar-width: none; }
  .tg-scroll { max-height: calc(100vh - 300px); }
  /* notes : la liste commence tout de suite */
  .note-folders { max-height: none; padding: 12px 12px 8px; }
  .note-folders .folder-list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .note-folders .folder { flex-shrink: 0; }
  .note-back + small { display: inline; }
  .notes-head #noteCount { display: none; }
}

/* ===== Pas de superposition sur mobile ===== */
@media (max-width: 760px) {
  .toast-zone { top: calc(10px + env(safe-area-inset-top)); bottom: auto; }
  .toast { padding: 8px 14px; }
  .pomo-float { right: auto; left: 12px; bottom: calc(82px + env(safe-area-inset-bottom)); }
  .m-more, .m-foot { display: none; }
  .page { padding-bottom: 48px; }
  #page-notes { padding-bottom: 0; }
}

/* ===== iPhone (écran d'accueil) ===== */
html { -webkit-text-size-adjust: 100%; }
button, a, summary, label, [data-act] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
@media (max-width: 760px) {
  /* sous 16 px, iOS zoome la page à chaque saisie */
  input:not([type=checkbox], [type=color]), select, textarea:not(#noteTitle), .rich { font-size: 16px !important; }
  body { overscroll-behavior-y: none; }
  /* la barre d'accueil de l'iPhone ne recouvre rien */
  .shell { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .notes.editing .note-doc { height: calc(100vh - 70px - env(safe-area-inset-bottom)); height: calc(100dvh - 70px - env(safe-area-inset-bottom)); }
}

.header-tools { display: flex; align-items: center; gap: 12px; }
@media (min-width: 761px) {
  .sidebar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); column-gap: 12px; }
  .sidebar .brand { display: flex; grid-column: 1; grid-row: 1; justify-self: start; }
  .sidebar #nav { grid-column: 2; grid-row: 1; justify-self: center; }
  .header-tools { grid-column: 3; grid-row: 1; justify-self: end; }
}
@media (min-width: 761px) and (max-width: 940px) {
  .sidebar .nav-item { padding-inline: 8px; }
  .sidebar .side-foot { display: none; }
}
@media (max-width: 760px) { .header-tools { display: none; } }
