:root {
  --paper: #eef1f6; --card: #ffffff; --ink: #0f1b33; --muted: #5d6a82; --rule: #d5dbe7;
  --accent: #ff5a36; --ok: #1f9d6b;
  --math: #2b5ce6; --data: #12a37a; --biz: #e0a21b; --hum: #8a4fd6; --none: #7b879c;
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #0b1426; --card: #131f38; --ink: #eaf0fb; --muted: #93a2bf; --rule: #24334f; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.45 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; padding: calc(max(20px, env(safe-area-inset-top)) + 8px) max(24px, env(safe-area-inset-right)) calc(max(40px, env(safe-area-inset-bottom)) + 16px) max(24px, env(safe-area-inset-left)); }
#app { max-width: 480px; margin: 0 auto; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.nav h1 { margin: 0; font-size: 1.05rem; font-weight: 600; text-align: center; flex: 1; text-transform: capitalize; }
.nav button { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 1px solid var(--rule); background: var(--card); font-size: 1.1rem; }
.today-btn { display: block; margin: -10px auto 14px; border: 0; background: none; color: var(--accent); font-weight: 600; padding: 6px 12px; }

.hero { margin-bottom: 26px; }
.hero .big { font-size: clamp(3.4rem, 17vw, 4.8rem); font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.hero .sub { color: var(--muted); margin-top: 10px; line-height: 1.5; }
.hero .sub b { color: var(--ink); font-weight: 600; }

.meter { margin: 24px 0 4px; }
.meter-row { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.meter-row b { color: var(--ink); }
.bar { height: 10px; border-radius: 99px; background: var(--rule); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.bar.full > i { background: var(--ok); }
.chips { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.chip { border: 1px solid var(--rule); background: var(--card); border-radius: 99px; padding: 9px 16px; min-height: 40px; font-size: .9rem; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.note { background: var(--card); border-left: 4px solid var(--accent); border-radius: 8px; padding: 14px 16px; margin: 16px 0; font-size: .95rem; line-height: 1.45; }

/* La ligne : chaque événement est un arrêt, les révisions sont des segments épais */
.line { list-style: none; margin: 32px 0 0; padding: 0; }
.stop { display: grid; grid-template-columns: 50px 24px 1fr; column-gap: 14px; position: relative; }
.stop .t { text-align: right; padding-top: 14px; font-size: .85rem; color: var(--muted); }
.stop .rail { position: relative; }
.stop .rail::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: var(--c, var(--rule)); }
.stop:first-child .rail::before { top: 22px; }
.stop:last-child .rail::before { bottom: calc(100% - 22px); }
.stop .dot { position: absolute; left: 50%; top: 16px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--paper); border: 4px solid var(--c, var(--none)); }
.stop.study .rail::before { width: 10px; margin-left: -5px; border-radius: 5px; }
.stop.study .dot { display: none; }
.stop.commute .rail::before { background: repeating-linear-gradient(to bottom, var(--none) 0 6px, transparent 6px 12px); }
.stop.commute .dot, .stop.gap .dot { border-color: var(--rule); width: 12px; height: 12px; margin-left: -6px; top: 18px; }
.stop.exam .dot { background: var(--accent); border-color: var(--accent); }
.stop.perso .dot { background: var(--ink); border-color: var(--ink); }
.stop.depart .dot, .stop.home .dot { background: var(--ink); border-color: var(--ink); }

.body { padding: 10px 0 18px; min-width: 0; }
.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; border: 1px solid var(--rule); }
.stop.study .card { border-color: var(--c); background: color-mix(in srgb, var(--c) 9%, var(--card)); }
.stop.exam .card { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.card h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.card p { margin: 6px 0 0; font-size: .92rem; line-height: 1.45; color: var(--muted); }
.card .tag { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--c); color: #fff; margin-left: 6px; vertical-align: 2px; font-weight: 500; }
.body.plain { padding-top: 14px; padding-bottom: 12px; color: var(--muted); font-size: .95rem; line-height: 1.45; }
.body.plain b { color: var(--ink); font-weight: 600; }
.del { float: right; border: 0; background: none; color: var(--muted); font-size: 1.1rem; padding: 0 4px; }

.add { margin-top: 36px; }
.add h2, .exams h2 { font-size: 1rem; margin: 0 0 8px; font-weight: 600; }
.add form { display: flex; gap: 8px; }
.add input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--rule); background: var(--card); color: var(--ink); }
.add button { border: 0; background: var(--accent); color: #fff; font-weight: 600; border-radius: var(--r); padding: 0 20px; }
.add small { display: block; margin-top: 10px; line-height: 1.45; color: var(--muted); }
.err { color: var(--accent); }

.exams { margin-top: 36px; }
.exam-row { display: flex; align-items: baseline; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--rule); font-size: .92rem; }
.exam-row .in { width: 54px; font-weight: 700; flex: none; }
.exam-row .n { flex: 1; min-width: 0; }
.exam-row .n small { display: block; color: var(--muted); }
.exam-row .k { color: var(--muted); font-size: .8rem; }
.now .card, .now .body.plain { box-shadow: 0 0 0 2px var(--accent); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.restore { margin-top: 12px; }
.stop.study .del, .stop.class .del { margin: -2px -4px 0 0; }

.week { margin-top: 36px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.week summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 16px 0; font-weight: 600; }
.week summary::-webkit-details-marker { display: none; }
.week summary::after { content: "+"; font-size: 1.4rem; font-weight: 400; color: var(--muted); }
.week[open] summary::after { content: "–"; }
.week .wk-list { padding: 2px 0 14px; }
.wk { margin-bottom: 16px; }
.wk-top { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 4px; }
.wk-top span:last-child { color: var(--muted); }
.bar.thin { height: 6px; }

.card { position: relative; }
.chk { float: left; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--c, var(--rule)); background: var(--card); color: #fff; font-weight: 700; margin: 1px 10px 0 0; padding: 0; line-height: 1; }
.chk[aria-pressed="true"] { background: var(--c, var(--ok)); }
.card.is-done h3, .card.is-done p { opacity: .55; }
.card.is-done h3 { text-decoration: line-through; }
.card h3 { overflow: hidden; }

.ok { color: var(--ok); }
