/* Révisions médecine — style inspiré d'iOS : fond groupé, grands titres, anneaux de progression. */
:root {
  --bg: #F2F2F7; --card: #FFFFFF; --ink: #1C1C1E; --ink2: #3A3A3C; --sec: #8E8E93;
  --sep: rgba(60, 60, 67, .14); --fill: rgba(118, 118, 128, .12); --fill2: rgba(118, 118, 128, .22);
  --c1: #FF3B30; --c2: #FF9500; --c3: #34C759; --cr: #007AFF; --accent: #007AFF; --gold: #FFCC00;
  --bar: rgba(249, 249, 249, .82);
  --r-lg: 20px; --r: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 24px rgba(0, 0, 0, .05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1C1C1E; --ink: #F5F5F7; --ink2: #D1D1D6; --sec: #98989F;
    --sep: rgba(84, 84, 88, .55); --fill: rgba(118, 118, 128, .24); --fill2: rgba(118, 118, 128, .36);
    --c1: #FF453A; --c2: #FF9F0A; --c3: #30D158; --cr: #0A84FF; --accent: #0A84FF; --gold: #FFD60A;
    --bar: rgba(22, 22, 24, .82); --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 var(--font); -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { text-wrap: balance; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.fill { fill: currentColor; stroke: none; }
.muted { color: var(--sec); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--fill2); flex: none; }
.k-t1 { --k: var(--c1); } .k-t2 { --k: var(--c2); } .k-t3 { --k: var(--c3); } .k-relu { --k: var(--cr); }
.dot[class*="k-"] { background: var(--k); }

/* ---------- Structure ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: 248px; padding: 22px 14px; z-index: 10;
  display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--sep); background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -.01em; padding: 4px 10px 18px; }
.logo { width: 30px; height: 30px; flex: none; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; }
.side a:hover { background: var(--fill); }
.side a.on { background: var(--accent); color: #fff; }
.side-user { margin-top: auto; }
#main { margin-left: 248px; padding: 34px 40px 80px; max-width: 1288px; outline: 0; }
.tabbar, .gear { display: none; }

@media (max-width: 899px) {
  .side { display: none; }
  #main { margin-left: 0; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(98px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--bar); border-top: 1px solid var(--sep);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 500; color: var(--sec); padding: 4px 0; }
  .tabbar a .ic { width: 25px; height: 25px; }
  .tabbar a.on { color: var(--accent); }
  .gear { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--fill); color: var(--ink); flex: none; }
}

.vhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.vhead h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.022em; }
.vhead p { margin: 6px 0 0; color: var(--sec); max-width: 62ch; }

/* ---------- Progression ---------- */
.hero {
  display: grid; grid-template-columns: minmax(200px, 270px) 1fr; gap: 32px; align-items: center;
  background: var(--card); border-radius: var(--r-lg); padding: 26px 32px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.ring-svg { width: 100%; height: auto; display: block; }
.ring-arc { transition: stroke-dasharray 1.1s cubic-bezier(.2, .8, .2, 1); }
.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto 52px; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--sep); }
.legend li:last-child { border: 0; }
.legend span { font-weight: 500; }
.legend strong { font-size: 24px; font-weight: 700; letter-spacing: -.015em; }
.legend strong small { font-size: 14px; color: var(--sec); font-weight: 500; }
.legend em { font-style: normal; color: var(--sec); text-align: right; }
.legend .k-t1 strong { color: var(--c1); } .legend .k-t2 strong { color: var(--c2); } .legend .k-t3 strong { color: var(--c3); } .legend .k-relu strong { color: var(--cr); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.tile-l { color: var(--sec); font-size: 13px; font-weight: 500; }
.tile-v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
.tile-u { color: var(--sec); font-size: 13px; }

.panel { background: var(--card); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel > h2 { margin: 0 0 14px; font-size: 20px; font-weight: 700; letter-spacing: -.012em; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.grid-l { stroke: var(--sep); stroke-width: 1; }
.ax { fill: var(--sec); font-size: 11px; font-family: var(--font); }
.chart-leg { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; color: var(--sec); font-size: 13px; }
.chart-leg span { display: inline-flex; align-items: center; gap: 6px; }
.proj { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.proj li { display: flex; align-items: baseline; gap: 10px; line-height: 1.45; }
.proj .dot { transform: translateY(-1px); }
.next { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 22px; }
.next h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; }
.next p { margin: 2px 0 8px; font-size: 13px; }
.next .row { padding-left: 4px; padding-right: 4px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding: 20px; gap: 18px; }
  .rings { max-width: 220px; width: 100%; margin: 0 auto; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .vhead h1 { font-size: 30px; }
}

/* ---------- Barre d'outils, recherche, segments ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 12px; padding: 0 12px; color: var(--sec); }
.search input { flex: 1; border: 0; background: none; outline: 0; padding: 10px 0; color: var(--ink); min-width: 0; font-size: 16px; }
.seg { display: inline-flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { padding: 6px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 500; white-space: nowrap; color: var(--ink); }
.seg button[aria-selected="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button[aria-selected="true"] { background: #636366; } }
.count { color: var(--sec); font-size: 13px; margin: 0 0 10px; }

/* ---------- Cartes d'items ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; position: relative; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.card.lv1::before { background: var(--c1); } .card.lv2::before { background: var(--c2); } .card.lv3::before { background: var(--c3); }
.card-main { display: flex; flex-direction: column; gap: 7px; text-align: left; padding: 14px 16px 12px 18px; flex: 1; width: 100%; }
.card-main:hover .ttl { color: var(--accent); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.num { font-size: 12.5px; font-weight: 600; color: var(--sec); }
.ttl { font-weight: 600; font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.last { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); flex-wrap: wrap; }
.track { display: inline-flex; gap: 3px; flex: none; }
.track i { width: 18px; height: 6px; border-radius: 3px; background: var(--fill2); }
.track i.c1 { background: var(--c1); } .track i.c2 { background: var(--c2); } .track i.c3 { background: var(--c3); }
.card-act { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px 10px 16px; border-top: 1px solid var(--sep); }
.card-act .sp { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px; background: var(--fill); font-size: 12.5px; font-weight: 600; color: var(--ink2); white-space: nowrap; }
.chip .ic { width: 15px; height: 15px; }
.chip.has { color: var(--accent); }
.chip.has::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.chip.relu { color: var(--cr); }
.chip.go { background: color-mix(in srgb, var(--k) 15%, transparent); color: var(--k); }
.chip.done { background: none; color: var(--c3); }
.star { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--sec); flex: none; }
.star.on { color: var(--gold); }
.star:hover { background: var(--fill); }

/* ---------- Listes (timeline, relus, à faire) ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.card-group, .day .rows { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--sep); }
.rows li:last-child .row { border-bottom: 0; }
.row:hover { background: var(--fill); }
.row-n { font-weight: 700; color: var(--sec); min-width: 2.4em; font-size: 13px; }
.row-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-t .tt { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-t small { font-size: 12.5px; }
.row-k { font-size: 12px; font-weight: 600; color: var(--k); white-space: nowrap; }
.day { margin-bottom: 20px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 15px; font-weight: 600; margin: 0 4px 8px; }
.day-h .muted { font-weight: 400; font-size: 13px; }
@media (max-width: 560px) { .row .track { display: none; } }

.empty { background: var(--card); border-radius: var(--r); padding: 28px 22px; text-align: center; color: var(--sec); box-shadow: var(--shadow); }
.panel .empty { box-shadow: none; background: var(--fill); }

/* ---------- Boutons, formulaires ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 12px; font-weight: 600; background: var(--fill); color: var(--ink); }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: none; color: var(--accent); padding: 8px 10px; }
.btn.danger { color: var(--c1); }
.btn.wide { width: 100%; }
.btn.tour { background: var(--k); color: #fff; }
.btn.relu { background: color-mix(in srgb, var(--cr) 14%, transparent); color: var(--cr); }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; color: var(--sec); font-weight: 500; }
.field input { border: 0; background: var(--fill); border-radius: 12px; padding: 12px 14px; font-size: 16px; color: var(--ink); outline: 0; }
.field input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }
.form { display: grid; gap: 12px; max-width: 420px; }
.form.inline { grid-template-columns: 1fr 1fr auto; max-width: none; align-items: end; margin-top: 14px; }
@media (max-width: 640px) { .form.inline { grid-template-columns: 1fr; } }
.err { color: var(--c1); margin: 0; font-size: 14px; }
.users { list-style: none; margin: 10px 0 0; padding: 0; }
.users li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--sep); flex-wrap: wrap; }
.users li strong { flex: 1; }
.users .badge { font-size: 12px; color: var(--sec); }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--card); border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-card .logo { width: 72px; height: 72px; margin: 0 auto 4px; }
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.sub { margin: -6px 0 6px; color: var(--sec); }

/* ---------- Fiche d'un item ---------- */
#sheetRoot { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#sheetRoot:empty { display: none; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .32); opacity: 0; transition: opacity .25s; }
.sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(780px, 100%);
  background: var(--bg); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  padding: 16px 26px 40px; box-shadow: -10px 0 40px rgba(0, 0, 0, .15);
}
#sheetRoot.show { pointer-events: auto; }
#sheetRoot.show .backdrop { opacity: 1; }
#sheetRoot.show .sheet { transform: none; }
body.sheet-open { overflow: hidden; }
@media (max-width: 899px) {
  .sheet { width: 100%; top: auto; height: calc(100% - env(safe-area-inset-top) - 12px); border-radius: 16px 16px 0 0; transform: translateY(100%); padding: 10px 16px calc(30px + env(safe-area-inset-bottom)); }
}
.sheet-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); flex: none; }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn.danger { background: none; color: var(--c1); }
.sheet-title { font-size: 24px; line-height: 1.22; letter-spacing: -.015em; margin: 6px 0 16px; }
.steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.steps li { background: var(--card); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; border: 2px solid transparent; }
.steps li span { font-size: 12.5px; color: var(--sec); font-weight: 600; }
.steps li strong { font-size: 17px; }
.steps li.c1 { background: color-mix(in srgb, var(--c1) 13%, var(--card)); } .steps li.c1 strong { color: var(--c1); }
.steps li.c2 { background: color-mix(in srgb, var(--c2) 13%, var(--card)); } .steps li.c2 strong { color: var(--c2); }
.steps li.c3 { background: color-mix(in srgb, var(--c3) 13%, var(--card)); } .steps li.c3 strong { color: var(--c3); }
.steps li.next { border: 2px dashed var(--fill2); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.date-pick { display: inline-flex; align-items: center; gap: 6px; color: var(--sec); font-size: 13px; margin-left: auto; }
.date-pick input, .hist input[type="date"] { background: var(--fill); border: 0; border-radius: 8px; padding: 6px 8px; color: var(--ink); }
.all-done { display: inline-flex; gap: 6px; align-items: center; color: var(--c3); font-weight: 600; padding: 0 6px; }
.hist { background: var(--card); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; }
.hist summary { cursor: pointer; font-weight: 600; }
.hist ul { list-style: none; margin: 8px 0 0; padding: 0; }
.hist li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--sep); }
.hist li span { flex: 1; }

.notes { background: var(--card); border-radius: 16px; display: flex; flex-direction: column; flex: 1 0 auto; min-height: 360px; }
.notes-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 12px 0; }
.save-st { font-size: 12.5px; color: var(--sec); text-align: right; }
.save-st.err { color: var(--c1); }
.tb { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; border-bottom: 1px solid var(--sep); position: sticky; top: -16px; background: var(--card); z-index: 1; }
.tb button { min-width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; padding: 0 8px; }
.tb button:hover { background: var(--fill); }
.tb .tb-italic { font-style: italic; } .tb .tb-underline { text-decoration: underline; } .tb .tb-strikeThrough { text-decoration: line-through; }
.tb .tb-red { color: var(--c1); } .tb .tb-h { font-size: 13px; } .tb .tb-hl { color: #C9A000; }
.editor { position: relative; flex: 1; padding: 14px 16px 40px; outline: 0; line-height: 1.55; font-size: 16px; overflow-wrap: anywhere; min-height: 260px; }
.editor.is-empty::before { content: attr(data-ph); color: var(--sec); pointer-events: none; position: absolute; left: 16px; right: 16px; top: 14px; }
.editor h3 { font-size: 19px; margin: 14px 0 6px; }
.editor p, .editor div { margin: 0 0 6px; }
.editor ul, .editor ol { padding-left: 22px; margin: 0 0 8px; }
.editor img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 8px 0; cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .9); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- Message temporaire ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(30, 30, 32, .94); color: #fff; padding: 10px 16px; border-radius: 999px;
  display: flex; align-items: center; gap: 10px; font-weight: 500; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: #64D2FF; font-weight: 700; }
@media (max-width: 899px) { #toast { bottom: calc(86px + env(safe-area-inset-bottom)); } }

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