/* Mise en page et composants — utilise uniquement les variables de theme.css */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 150px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font-body); -webkit-font-smoothing: antialiased; }
body.no-select { user-select: none; cursor: grabbing; }
a { color: var(--accent); text-decoration: none; }
h2, h3, .lvl-badge b, .levelup-title, .ag-title { font-family: var(--font-display); text-transform: var(--display-transform); letter-spacing: var(--display-spacing); font-weight: var(--display-weight); }
h2 { font-size: 22px; margin: 0; }
h3 { font-size: 15px; margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.muted { color: var(--muted); } .small { font-size: 12px; } .grow { flex: 1; }
.txt-danger { color: var(--danger); } .txt-ok { color: var(--success); } .xp-txt { color: var(--xp); }
.clickable { cursor: pointer; } .clickable:hover { color: var(--accent); }
.empty { color: var(--faint); padding: 14px 4px; font-size: 13px; }

/* ---------- En-tête ---------- */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.hud { display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center; padding: 12px 24px; max-width: 1400px; margin: 0 auto; }
.hud-day { color: var(--muted); font-size: 13px; }
.hud-clock { font-family: var(--font-display); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hud-clock span { color: var(--faint); font-size: 16px; }
.hud-next { font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.hud-next b { color: var(--accent-2, var(--accent)); }
.hud-next .live-tag { background: var(--danger); color: #fff; padding: 1px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; vertical-align: 1px; }
.hud-level { display: flex; align-items: center; gap: 14px; min-width: 0; }
.lvl-badge { display: grid; place-items: center; width: 54px; height: 54px; border-radius: var(--radius); background: var(--accent); color: var(--accent-contrast); line-height: 1; flex: none; }
.lvl-badge span { font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.lvl-badge b { font-size: 24px; }
.lvl-main { flex: 1; min-width: 120px; }
.lvl-bar { height: 12px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.lvl-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--xp)); border-radius: inherit; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.lvl-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; font-size: 12px; }
.xp-num { color: var(--xp); font-variant-numeric: tabular-nums; display: inline-block; }
.xp-num.counting { transform: scale(1.15); transition: transform .15s; }
.wallet { flex: none; padding: 8px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); color: var(--xp); font-size: 13px; white-space: nowrap; }
.wallet span { color: var(--muted); }
.hud-streaks { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.streak { padding: 5px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
.streak-main { border-color: color-mix(in srgb, var(--warning) 50%, transparent); }
.nav { display: flex; gap: 4px; padding: 0 20px 8px; max-width: 1400px; margin: 0 auto; overflow-x: auto; }
.nav a { color: var(--muted); padding: 5px 10px; border-radius: var(--radius-sm); white-space: nowrap; font-size: 13px; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav { align-items: center; }
.sync { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 0 8px; white-space: nowrap; }
.sync[hidden] { display: none; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; }
.sync-busy i { background: var(--warning); } .sync-off i { background: var(--faint); } .sync-bad i { background: var(--danger); }
.sync-ok span { display: none; }
.sync:not([hidden]) + .search { margin-left: 0; }
.search { margin-left: auto; width: 240px; flex: none; padding: 5px 10px; font-size: 13px; }
.search-pop { min-width: 320px; max-width: 420px; padding: 6px; gap: 2px; max-height: 70vh; overflow: auto; }
.search-hit { font: inherit; display: flex; gap: 10px; align-items: center; text-align: left; background: none; border: 0; color: var(--text); padding: 7px 8px; cursor: pointer; width: 100%; }
.search-hit:hover, .search-hit.is-first { background: var(--surface-3); }
.sh-ico { font-size: 16px; width: 22px; text-align: center; flex: none; }
.sh-main { display: flex; flex-direction: column; min-width: 0; }
.sh-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-sub { font-size: 12px; color: var(--muted); }
@media (max-width: 960px) { .search { width: 160px; } }

/* ---------- Sections ---------- */
.main { max-width: 1400px; margin: 0 auto; padding: 8px 24px 120px; }
.sec { padding-top: 26px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h3 { flex: 1; }

.today-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.projects-grid, .goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.rewards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }

/* ---------- Lignes génériques ---------- */
.row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: var(--radius-sm); }
.row + .row { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.row-main { flex: 1; min-width: 0; cursor: pointer; }
.row-main:hover .row-title { color: var(--accent); }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.is-done .row-title, .subtask.is-done span { text-decoration: line-through; color: var(--faint); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); display: inline-block; flex: none; }
.xp-pill { font-size: 11px; font-weight: 700; color: var(--xp); background: color-mix(in srgb, var(--xp) 12%, transparent); padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.prio { font-size: 11px; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.prio-1 { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.prio-2 { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.prio-3 { background: var(--surface-3); color: var(--muted); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--surface-3); color: var(--muted); }
.badge-ok { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }

/* Case à cocher maison */
.check { width: 22px; height: 22px; flex: none; border-radius: 6px; border: 2px solid var(--faint); background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; transition: all .15s; }
.check svg { width: 14px; height: 14px; fill: none; stroke: var(--accent-contrast); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check:hover { border-color: var(--success); }
.check.on { background: var(--success); border-color: var(--success); }
.check.on svg { opacity: 1; }
.check:active { transform: scale(.88); }

/* ---------- Boutons & champs ---------- */
.btn { font: inherit; font-weight: 600; border-radius: var(--radius-sm); padding: 8px 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 85%, white); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.btn-ghost { background: transparent; }
.btn-xp { background: var(--xp); border-color: var(--xp); color: var(--xp-contrast); }
.btn-xp:hover:not(:disabled) { background: color-mix(in srgb, var(--xp) 85%, white); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }
.icon-btn { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 9px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=color] { padding: 2px; width: 42px; height: 34px; flex: none; cursor: pointer; }
input[type=checkbox] { width: auto; }
input[type=range] { padding: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
:root { color-scheme: dark; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field.dt { flex-direction: column; } .field.dt input + input { margin-top: 4px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-row { display: flex; gap: 10px; align-items: flex-start; }
.form-row > .field { flex: 1; }
.form-row > .field.small-field { flex: 0 0 110px; }
.form-row > .field.grow { flex: 2; }
.form-2col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 22px; }
.emoji-input { width: 64px; text-align: center; font-size: 18px; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 6px 0 10px; font-size: 13px; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { width: 36px; height: 20px; border-radius: 99px; background: var(--surface-3); position: relative; flex: none; transition: background .15s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: all .15s; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { left: 19px; background: var(--accent-contrast); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.seg button { font: inherit; font-size: 13px; background: transparent; border: 0; color: var(--muted); padding: 5px 11px; border-radius: 4px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.days-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.day-tog { font: inherit; font-size: 12px; width: 42px; padding: 6px 0; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; }
.day-tog.on { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 700; }
.quick-days { display: flex; gap: 6px; margin: -4px 0 12px; }
.rec-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px 4px; margin: 4px 0 0; }
.rec-box legend { color: var(--muted); font-size: 12px; font-weight: 600; padding: 0 4px; }
.rec-desc { margin: -4px 0 8px; }
.pick-list { max-height: 210px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; background: var(--surface-2); }
.pick { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.pick:hover { background: var(--surface-3); }
.pick span { flex: 1; }
.pick-group { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 6px 6px 2px; }
.links-box { margin: 6px 0 12px; }
.links-box summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.set-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.set-row select { width: 130px; flex: none; }
.log-row { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; font-size: 13px; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.log-row > span:first-child { width: 58px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Barres ---------- */
.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-lg { height: 12px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--xp)); border-radius: inherit; transition: width .6s; }

/* ---------- Aujourd'hui ---------- */
.rdv { --c: var(--muted); }
.rdv-time { width: 48px; font-weight: 700; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; line-height: 1.15; }
.rdv-time small { color: var(--faint); font-weight: 400; }
.rdv-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c); }
.rdv.is-past .row-title { color: var(--muted); }
.link-ico { cursor: pointer; }
.prio-rank { font-family: var(--font-display); font-weight: 700; color: var(--faint); width: 14px; text-align: center; }
.habit-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.habit-chip { font: inherit; text-align: left; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; transition: all .15s; }
.habit-chip:hover { border-color: var(--c); }
.habit-chip.on { background: color-mix(in srgb, var(--c) 22%, var(--surface-2)); border-color: var(--c); }
.habit-chip:active { transform: scale(.96); }
.hc-ico { grid-row: span 2; font-size: 22px; align-self: center; }
.hc-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-chip.on .hc-name::after { content: " ✓"; color: var(--success); }
.hc-meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.next-reward { display: flex; gap: 12px; align-items: center; padding: 8px 4px; cursor: pointer; }
.nr-ico { font-size: 34px; }
.nr-main { flex: 1; }
.nr-txt { margin-bottom: 6px; }
.affordable { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }

/* ---------- Tâches ---------- */
.project { border-top: 3px solid var(--c); }
.project-head h3 { display: flex; align-items: center; gap: 8px; }
.project-head .dot { background: var(--c); }
.task + .task { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.task .row { border: 0; }
.pin { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 15px; padding: 0 2px; }
.pin.on { color: var(--xp); }
.pin:hover { color: var(--xp); }
.subtasks { padding: 0 0 8px 36px; display: flex; flex-direction: column; gap: 4px; }
.subtask { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.subtask .check { width: 18px; height: 18px; border-radius: 5px; }
.subtask .check svg { width: 11px; height: 11px; }
.subtask span { flex: 1; }
.sub-edit { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.sub-edit input[type=checkbox] { flex: none; }

/* ---------- Objectifs ---------- */
.goal-desc { margin: 0 0 10px; }
.goal-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.goal-bar .bar { flex: 1; }
.goal-tasks { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.goal.is-reached { border-color: color-mix(in srgb, var(--success) 50%, transparent); }

/* ---------- Habitudes ---------- */
.habit-row { display: grid; grid-template-columns: minmax(220px, 1.2fr) auto 2fr; gap: 18px; align-items: center; padding: 10px 4px; }
.habit-row + .habit-row { border-top: 1px solid var(--border); }
.habit-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.habit-ico { font-size: 22px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--c) 18%, transparent); flex: none; }
.habit-stats { display: flex; gap: 16px; }
.habit-stats div { display: flex; flex-direction: column; align-items: center; min-width: 44px; }
.habit-stats b { font-variant-numeric: tabular-nums; }
.habit-stats span { font-size: 11px; color: var(--faint); }
.heatmap { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; justify-content: end; }
.hm-cell { border-radius: 2px; background: var(--surface-3); cursor: pointer; }
.hm-cell.off { background: color-mix(in srgb, var(--surface-3) 40%, transparent); }
.hm-cell.miss { background: var(--surface-3); }
.hm-cell.on { background: var(--c); }
.hm-cell.joker { background: repeating-linear-gradient(45deg, var(--c) 0 2px, transparent 2px 4px); opacity: .7; }
.hm-cell.today { outline: 1px solid var(--text); }
.hm-cell.future { background: transparent; cursor: default; }
.hm-cell:hover:not(.future) { outline: 1px solid var(--accent); }

/* ---------- Récompenses ---------- */
.reward { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.reward .bar { width: 100%; }
.reward-ico { font-size: 34px; }
.reward-title { font-weight: 700; }
.reward-cost { color: var(--xp); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.reward.is-ready { border-color: color-mix(in srgb, var(--xp) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--xp) 25%, transparent), 0 0 24px color-mix(in srgb, var(--xp) 10%, transparent); }
.wallet-big { color: var(--xp); font-weight: 700; }
.reward-history { margin-top: 14px; }

/* ---------- Agenda ---------- */
.agenda-card { padding: 0; overflow: hidden; }
.ag-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px 8px; flex-wrap: wrap; }
.ag-nav { display: flex; align-items: center; gap: 6px; }
.ag-title { font-size: 17px; margin-left: 8px; }
.ag-cats { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 0 14px 10px; border-bottom: 1px solid var(--border); }
.cat-chip { font: inherit; font-size: 12px; padding: 3px 10px 3px 8px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.cat-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.cat-chip.off { opacity: .4; text-decoration: line-through; }

.tg { display: flex; flex-direction: column; overflow-x: auto; }
.tg-head, .tg-allday, .tg-body { display: grid; min-width: fit-content; }
.tg-head { border-bottom: 1px solid var(--border); }
.tg-dayhead { text-align: center; padding: 6px 0; cursor: pointer; color: var(--muted); display: flex; flex-direction: column; line-height: 1.2; font-size: 12px; text-transform: capitalize; }
.tg-dayhead b { font-size: 18px; color: var(--text); font-family: var(--font-display); }
.tg-dayhead.is-today b { color: var(--accent-contrast); background: var(--accent); border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; margin: 2px auto 0; }
.tg-dayhead:hover { background: var(--surface-2); }
.tg-allday { border-bottom: 1px solid var(--border); min-height: 30px; }
.tg-gutter { display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; }
.tg-adcol { padding: 3px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.tg-scroll { height: 560px; overflow-y: auto; position: relative; }
.tg-body { position: relative; }
.tg-hours { position: relative; }
.tg-hour { position: absolute; right: 6px; transform: translateY(-50%); font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tg-col { position: relative; border-left: 1px solid var(--border); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 47px, var(--border) 47px, var(--border) 48px), repeating-linear-gradient(to bottom, transparent 0, transparent 23px, color-mix(in srgb, var(--border) 35%, transparent) 23px, color-mix(in srgb, var(--border) 35%, transparent) 24px); cursor: cell; touch-action: pan-y; }
.tg-col.is-today { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

.ev { --c: var(--accent); position: absolute; background: color-mix(in srgb, var(--c) 22%, var(--surface)); border-left: 3px solid var(--c); border-radius: 5px; padding: 3px 6px; font-size: 12px; overflow: hidden; cursor: grab; z-index: 2; display: flex; flex-direction: column; touch-action: none; user-select: none; transition: box-shadow .15s; }
.ev:hover { box-shadow: 0 0 0 1px var(--c); z-index: 4; }
.ev.dragging { opacity: .85; box-shadow: var(--shadow), 0 0 0 1px var(--c); z-index: 10; cursor: grabbing; }
.ev.is-done { opacity: .6; }
.ev-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 24px; }
.ev-time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ev-short { flex-direction: row; gap: 6px; align-items: center; padding-top: 1px; }
.ev-icons { position: absolute; top: 2px; right: 3px; display: flex; gap: 2px; align-items: center; font-size: 11px; color: var(--muted); }
.ev-link { background: none; border: 0; padding: 0 2px; cursor: pointer; font-size: 11px; opacity: .55; line-height: 1; }
.ev-link:hover { opacity: 1; }
.ev-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.ev-resize:hover { background: color-mix(in srgb, var(--c) 40%, transparent); }
.ev-allday { position: relative; padding: 2px 6px; cursor: pointer; }
.ev-ghost { position: absolute; left: 2px; right: 2px; background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: 5px; font-size: 11px; padding: 2px 6px; color: var(--accent); z-index: 5; pointer-events: none; }

.mo-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.mo-wd { text-align: center; color: var(--muted); font-size: 12px; padding: 6px 0; text-transform: capitalize; }
.mo-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(104px, auto); }
.mo-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; display: flex; flex-direction: column; gap: 2px; cursor: cell; min-width: 0; }
.mo-cell:nth-child(7n) { border-right: 0; }
.mo-cell.is-other { background: color-mix(in srgb, var(--bg) 50%, transparent); }
.mo-cell.is-other .mo-num { color: var(--faint); }
.mo-num { font-size: 12px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.mo-num:hover { background: var(--surface-3); }
.mo-cell.is-today .mo-num { background: var(--accent); color: var(--accent-contrast); }
.mo-chip { --c: var(--accent); display: flex; gap: 4px; align-items: center; font-size: 11px; padding: 2px 5px; border-radius: 4px; cursor: grab; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); min-width: 0; }
.mo-chip.is-allday { background: color-mix(in srgb, var(--c) 35%, var(--surface)); }
.mo-chip.is-done { opacity: .55; }
.mo-chip:hover { background: color-mix(in srgb, var(--c) 28%, transparent); }
.mo-t { color: var(--muted); font-variant-numeric: tabular-nums; }
.mo-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mo-more { font: inherit; font-size: 11px; background: none; border: 0; color: var(--muted); text-align: left; cursor: pointer; padding: 0 4px; }
.mo-more:hover { color: var(--accent); }
.drop-hover { background: var(--accent-soft) !important; outline: 1px dashed var(--accent); }

.list { padding: 6px 14px 14px; }
.li-day { margin-top: 10px; }
.li-date { font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.li-date.is-today { color: var(--accent); }
.li-time { width: 104px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; flex: none; }
.li-row .dot { background: var(--c); }
.li-row a { color: var(--accent); }

/* ---------- FAB, modales, popovers, toasts ---------- */
.fab { position: fixed; right: 26px; bottom: 26px; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-contrast); font-size: 34px; line-height: 1; cursor: pointer; box-shadow: var(--shadow); z-index: 40; transition: transform .15s; }
.fab:hover { transform: scale(1.07) rotate(90deg); }
.fab-menu { padding: 6px; display: flex; flex-direction: column; min-width: 180px; }
.fab-item { font: inherit; text-align: left; background: none; border: 0; color: var(--text); padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.fab-item:hover { background: var(--surface-3); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .12s; }
.modal-backdrop.closing { opacity: 0; transition: opacity .12s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .16s cubic-bezier(.2,.9,.3,1.2); }
.modal-wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.modal-body { padding: 8px 16px; overflow-y: auto; }
.modal-body p { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .push-left:first-child { margin-right: auto; }
.popover { position: fixed; z-index: 90; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; min-width: 240px; max-width: 340px; display: flex; flex-direction: column; gap: 6px; animation: pop .12s; }
.pop-title { font-size: 12px; color: var(--muted); font-weight: 600; }
.toasts { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 120; align-items: center; pointer-events: none; }
.toast { background: var(--surface-3); border: 1px solid var(--border); padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow); animation: pop .2s; transition: opacity .3s, transform .3s; }
.toast.out { opacity: 0; transform: translateY(10px); }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; }
.toast-btn { font: inherit; font-weight: 700; background: none; border: 0; color: var(--accent-2, var(--accent)); cursor: pointer; padding: 2px 4px; text-transform: uppercase; letter-spacing: .05em; }
.toast-btn:hover { text-decoration: underline; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }

/* ---------- Célébrations ---------- */
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 150; }
.float-xp { position: fixed; z-index: 160; pointer-events: none; font-family: var(--font-display); font-weight: 800; font-size: 26px; color: var(--xp); text-shadow: 0 2px 12px rgba(0, 0, 0, .6); transform: translate(-50%, -50%); animation: floatUp 1.3s ease-out forwards; }
.float-xp.reduced { font-size: 16px; animation-duration: 1s; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }
.levelup { position: fixed; inset: 0; z-index: 140; display: grid; place-items: center; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent), rgba(0, 0, 0, .75)); animation: fade .2s; cursor: pointer; }
.levelup[hidden] { display: none; }
.levelup-card { text-align: center; animation: lvlIn .6s cubic-bezier(.2,1.4,.3,1); }
.levelup-title { font-size: clamp(56px, 12vw, 140px); line-height: 1; color: var(--xp); text-shadow: 0 0 40px color-mix(in srgb, var(--xp) 60%, transparent), 0 6px 0 rgba(0, 0, 0, .35); font-weight: 900; font-style: italic; }
.levelup-num { font-size: 26px; margin-top: 10px; }
.levelup-num b { font-size: 40px; color: var(--accent); }
.levelup-hint { color: var(--muted); margin-top: 18px; font-size: 13px; }
.levelup .bonus-title { font-size: clamp(40px, 8vw, 100px); }
.levelup.is-bonus { background: radial-gradient(circle, color-mix(in srgb, var(--xp) 22%, transparent), rgba(0, 0, 0, .75)); }
.levelup.reduced { background: rgba(0, 0, 0, .55); }
.levelup.reduced .bonus-title { font-size: 36px; }
.levelup.reduced .levelup-title { font-size: 48px; text-shadow: none; }
.levelup.reduced .levelup-card { animation: pop .2s; }
@keyframes lvlIn { 0% { transform: scale(.3) rotate(-8deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ---------- Connexion ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 16px 20px 22px; }
.login-title { margin: 14px 0 18px; }
.login-btn { width: 100%; margin-top: 6px; padding: 11px; }
.login-error { margin: 0 0 10px; font-size: 13px; }

/* ---------- Mobile ---------- */
@media (max-width: 960px) {
  .hud { grid-template-columns: 1fr auto; gap: 10px 16px; padding: 10px 14px; }
  .hud-level { grid-column: 1 / -1; order: 3; }
  .main { padding: 4px 12px 110px; }
  .today-grid { grid-template-columns: 1fr; }
  .habit-row { grid-template-columns: 1fr auto; }
  .heatmap { grid-column: 1 / -1; justify-content: start; overflow-x: auto; }
  .form-2col { grid-template-columns: 1fr; }
  .projects-grid, .goals-grid, .settings-grid { grid-template-columns: 1fr; }
  html { scroll-padding-top: 190px; }
}
@media (max-width: 560px) {
  /* sur téléphone, l'en-tête défile avec la page pour laisser la place au contenu */
  .top { position: relative; }
  html { scroll-padding-top: 8px; }
  .hud-day { font-size: 12px; }
  .hud-streaks .streak:not(.streak-main):nth-of-type(n+3) { display: none; }
  .nav { flex-wrap: wrap; gap: 2px; padding-bottom: 10px; }
  .search { order: -1; width: 100%; margin: 0 0 6px; }
  .wallet span, .lvl-meta .muted { display: none; }
  .form-row { flex-wrap: wrap; }
  .fab { right: 16px; bottom: 16px; }
  .tg-scroll { height: 480px; }
}
/* Barre d'onglets du bas (téléphone) */
.tabbar { display: none; }
@media (max-width: 700px) {
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 58px; padding: 0; background: none; border: 0; border-top: 3px solid transparent;
    color: var(--muted); font: 500 10px/1 var(--font-label, inherit); text-transform: uppercase; letter-spacing: .04em;
    text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; }
  .tabbar .on { color: var(--text); border-top-color: var(--accent); }
  .tabbar .on svg { stroke: var(--accent-2, var(--accent)); }

  /* une seule section visible : celle de l'onglet choisi */
  .main > .sec { display: none; }
  body[data-tab="today"] #today, body[data-tab="agenda"] #agenda, body[data-tab="tasks"] #tasks,
  body[data-tab="goals"] #goals, body[data-tab="habits"] #habits, body[data-tab="rewards"] #rewards,
  body[data-tab="settings"] #settings { display: block; }
  .main > .sec:first-child, .main > .sec { margin-top: 0; }

  /* les liens du haut sont remplacés par la barre du bas ; on garde la recherche et le voyant */
  .nav a { display: none; }
  .nav { padding: 0 12px 10px; flex-wrap: nowrap; }
  .search { order: 0; flex: 1; width: auto; margin: 0; }
  .sync span { display: none; }

  .main { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  .fab { right: 16px; bottom: calc(74px + env(safe-area-inset-bottom)); width: 56px; height: 56px; }
  .tg-scroll { height: calc(100vh - 360px); min-height: 380px; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
