/* Bulles — feuille de style. Pas de style inline (CSP stricte). */
:root {
  --bg: #f6f2ea;
  --surface: #fffdf9;
  --surface-2: #efe9dd;
  --border: #e0d8c8;
  --ink: #1d1a16;
  --ink-2: #57504a;
  --ink-3: #8a8178;
  --accent: #c8421b;
  --accent-ink: #ffffff;
  --accent-soft: #f7dfd4;
  --bar: #c8421b;
  --track: #ece5d8;
  --danger: #b3261e;
  --success-bg: #e3f1e4; --success-ink: #1e5b28;
  --error-bg: #fbe4e1;   --error-ink: #8c1d16;
  --info-bg: #e5edf7;    --info-ink: #1f4570;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 16px rgba(40, 30, 20, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --surface: #1e2127;
    --surface-2: #272b32;
    --border: #333841;
    --ink: #eeeae4;
    --ink-2: #b4ada4;
    --ink-3: #857e76;
    --accent: #ff7a4f;
    --accent-ink: #1a0d07;
    --accent-soft: #3b2219;
    --bar: #ff7a4f;
    --track: #2b3038;
    --danger: #ff8a80;
    --success-bg: #1d3322; --success-ink: #a7dcae;
    --error-bg: #3a1d1b;   --error-ink: #ffb4ab;
    --info-bg: #1b2a3d;    --info-ink: #aecbf0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-underline-offset: 2px; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
.muted { color: var(--ink-3); font-weight: normal; }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mt { margin-top: 1rem; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 28px; padding-bottom: 48px; }

/* ---------- En-tête ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.brand-bubble { width: 28px; height: 22px; background: var(--accent); border-radius: 50%; position: relative; }
.brand-bubble::after { content: ""; position: absolute; left: 5px; bottom: -6px; border: 6px solid transparent; border-top-color: var(--accent); border-left-color: var(--accent); border-width: 7px 4px 0 4px; }
.main-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.main-nav a:not(.btn) { color: var(--ink-2); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.main-nav a:not(.btn):hover { color: var(--ink); background: var(--surface-2); }
.main-nav a.active { color: var(--ink); background: var(--surface-2); }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; line-height: 20px; text-align: center; font-weight: 700; }

.site-footer { color: var(--ink-3); font-size: .85rem; padding: 24px 0; border-top: 1px solid var(--border); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--error-bg); }
.btn-sm { padding: 6px 12px; font-size: .875rem; border-radius: 8px; }
.btn-block { width: 100%; }
.link-sm { background: none; border: 0; padding: 0; font: inherit; font-size: .85rem; color: var(--ink-2); text-decoration: underline; cursor: pointer; }
.link-danger { color: var(--danger); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Cartes & formulaires ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.narrow { max-width: 460px; margin: 0 auto; }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-narrow { max-width: 110px; }
label { font-weight: 600; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit; min-height: 44px;
}
input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=file] { font: inherit; font-size: .85rem; max-width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: normal; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.field-error { color: var(--danger); font-size: .85rem; margin: 0; }
.req { color: var(--accent); }
.form-foot { text-align: center; margin: 18px 0 0; color: var(--ink-2); font-size: .92rem; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.row-between h1 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.series-row { grid-template-columns: 1fr 110px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.code-input { font-size: 1.5rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; }
.flash-success { background: var(--success-bg); color: var(--success-ink); }
.flash-error { background: var(--error-bg); color: var(--error-ink); }
.flash-info { background: var(--info-bg); color: var(--info-ink); }
.flash a { color: inherit; font-weight: 600; }

/* Formulaire BD */
.comic-form { gap: 22px; }
.status-choice { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.status-choice legend { font-weight: 700; margin-bottom: 8px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: normal; }
.radio-card input { margin-top: 4px; accent-color: var(--accent); }
.radio-card span { display: flex; flex-direction: column; }
.radio-card small { color: var(--ink-3); }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.comic-form-body { display: grid; grid-template-columns: 200px 1fr; gap: 24px; }
.fields { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cover-field { display: flex; flex-direction: column; gap: 8px; }
.cover-drop { aspect-ratio: 3 / 4; border: 2px dashed var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--surface-2); }
.cover-preview { width: 100%; height: 100%; object-fit: cover; }
.cover-empty { color: var(--ink-3); font-size: .9rem; }
.people { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.people legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.people-list { display: flex; flex-direction: column; gap: 8px; }
.people .btn { align-self: flex-start; }

/* ---------- Couvertures ---------- */
.cover { display: block; object-fit: cover; border-radius: 4px; background: var(--surface-2); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.cover-sm { width: 52px; height: 70px; }
.cover-md { width: 96px; height: 130px; flex-shrink: 0; }
.cover-placeholder { display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; color: var(--ink-3); border: 1px solid var(--border); }

/* ---------- Diary ---------- */
.diary { display: flex; flex-direction: column; gap: 28px; }
.diary-month-title { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--ink); padding-bottom: 6px; font-family: var(--font-display); font-size: 1.3rem; text-transform: uppercase; letter-spacing: .04em; }
.diary-month-title .count { font-family: var(--font); font-size: .8rem; color: var(--ink-3); text-transform: none; letter-spacing: 0; font-weight: 500; }
.diary-list { list-style: none; margin: 0; padding: 0; }
.diary-row { display: grid; grid-template-columns: 52px 52px 1fr auto; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.diary-day { text-align: center; display: flex; flex-direction: column; line-height: 1; }
.diary-day .d { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.diary-day .wd { font-size: .72rem; color: var(--ink-3); text-transform: uppercase; margin-top: 4px; }
.diary-day.same .d { color: var(--ink-3); font-size: 1.3rem; }
.diary-main { min-width: 0; }
.diary-title { font-size: 1.05rem; margin: 0; }
.diary-series { margin: 2px 0 0; color: var(--accent); font-size: .9rem; font-weight: 600; }
.diary-people, .diary-meta { margin: 2px 0 0; color: var(--ink-2); font-size: .85rem; }
.diary-meta { color: var(--ink-3); }
.role { color: var(--ink-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.diary-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; }
.diary-started { margin: 0; font-size: .82rem; color: var(--ink-2); background: var(--surface-2); padding: 6px 10px; border-radius: 8px; line-height: 1.35; }
.diary-started .lbl { color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.chip { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); color: var(--ink-2); text-decoration: none; font-size: .9rem; background: var(--surface); }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.empty { text-align: center; padding: 40px 22px; color: var(--ink-2); }

/* ---------- En cours ---------- */
.reading-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.reading-card { display: flex; gap: 16px; padding: 16px; }
.reading-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.reading-title { font-size: 1.05rem; margin: 0; }
.reading-since { margin: 6px 0 4px; font-size: .88rem; }
.finish-form { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.finish-form input { max-width: 170px; min-height: 36px; padding: 6px 8px; }
.reading-actions { display: flex; gap: 14px; align-items: center; margin-top: 6px; }

/* ---------- Accueil ---------- */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center; padding: 30px 0; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.02; }
.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 36em; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.hero-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.hero-points li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; }
.hero-points strong { color: var(--accent); font-family: var(--font-display); font-size: 1.2rem; }
.hero-points span { color: var(--ink-2); }

/* ---------- Compte ---------- */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 18px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.danger-zone { border-color: var(--danger); }

/* ---------- Stats ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; }
.tile-value { font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--ink-2); font-size: .88rem; margin-top: 6px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.stat-card h2 { margin-bottom: 14px; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 38%) 1fr 36px; gap: 10px; align-items: center; font-size: .9rem; padding: 2px 4px; border-radius: 6px; }
.bar-row:hover { background: var(--surface-2); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.bar-track { height: 12px; border-radius: 0 4px 4px 0; position: relative; background: var(--track); }
.bar-fill { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 0; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }
.more { margin-top: 10px; }
.more summary { cursor: pointer; color: var(--ink-2); font-size: .88rem; padding: 4px 0; }
.more .bars { margin-top: 8px; }

.cols-scroll { overflow-x: auto; padding-bottom: 6px; }
.cols { display: flex; gap: 14px; min-width: min-content; }
.cols-year { display: flex; flex-direction: column; flex: 1 0 auto; }
.cols-bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; border-bottom: 1px solid var(--border); }
.col { position: relative; width: 26px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: default; outline: none; }
.col-bar { display: block; width: 18px; background: var(--bar); border-radius: 4px 4px 0 0; }
.col-bar.h0 { height: 0; }
.col-label { position: absolute; bottom: -20px; font-size: .7rem; color: var(--ink-3); }
.col-tip { position: absolute; top: -4px; transform: translateY(-100%); background: var(--ink); color: var(--bg); font-size: .75rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .1s; white-space: nowrap; }
.col:hover .col-tip, .col:focus .col-tip { opacity: 1; }
.col:hover .col-bar, .col:focus .col-bar { filter: brightness(1.15); }
.cols-year-label { margin-top: 24px; font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table td:last-child, .table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .grid-2, .status-choice, .account-grid, .stats-grid, .hero { grid-template-columns: 1fr; }
  .series-row { grid-template-columns: 1fr 90px; }
  .comic-form-body { grid-template-columns: 1fr; }
  .cover-field { max-width: 200px; }
  .diary-row { grid-template-columns: 40px 46px 1fr; gap: 12px; }
  .diary-side { grid-column: 3; align-items: flex-start; text-align: left; flex-direction: row; flex-wrap: wrap; }
  .cover-sm { width: 46px; height: 62px; }
  .reading-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: minmax(0, 42%) 1fr 30px; }
  .card { padding: 18px; }
}
@media (forced-colors: active) {
  .bar-fill, .col-bar { background: CanvasText; }
}

/* ---------- Largeurs / hauteurs des barres (générées : pas de style inline avec la CSP) ---------- */
.w0{width:0%}.h0{height:0%}
.w1{width:1%}.h1{height:1%}
.w2{width:2%}.h2{height:2%}
.w3{width:3%}.h3{height:3%}
.w4{width:4%}.h4{height:4%}
.w5{width:5%}.h5{height:5%}
.w6{width:6%}.h6{height:6%}
.w7{width:7%}.h7{height:7%}
.w8{width:8%}.h8{height:8%}
.w9{width:9%}.h9{height:9%}
.w10{width:10%}.h10{height:10%}
.w11{width:11%}.h11{height:11%}
.w12{width:12%}.h12{height:12%}
.w13{width:13%}.h13{height:13%}
.w14{width:14%}.h14{height:14%}
.w15{width:15%}.h15{height:15%}
.w16{width:16%}.h16{height:16%}
.w17{width:17%}.h17{height:17%}
.w18{width:18%}.h18{height:18%}
.w19{width:19%}.h19{height:19%}
.w20{width:20%}.h20{height:20%}
.w21{width:21%}.h21{height:21%}
.w22{width:22%}.h22{height:22%}
.w23{width:23%}.h23{height:23%}
.w24{width:24%}.h24{height:24%}
.w25{width:25%}.h25{height:25%}
.w26{width:26%}.h26{height:26%}
.w27{width:27%}.h27{height:27%}
.w28{width:28%}.h28{height:28%}
.w29{width:29%}.h29{height:29%}
.w30{width:30%}.h30{height:30%}
.w31{width:31%}.h31{height:31%}
.w32{width:32%}.h32{height:32%}
.w33{width:33%}.h33{height:33%}
.w34{width:34%}.h34{height:34%}
.w35{width:35%}.h35{height:35%}
.w36{width:36%}.h36{height:36%}
.w37{width:37%}.h37{height:37%}
.w38{width:38%}.h38{height:38%}
.w39{width:39%}.h39{height:39%}
.w40{width:40%}.h40{height:40%}
.w41{width:41%}.h41{height:41%}
.w42{width:42%}.h42{height:42%}
.w43{width:43%}.h43{height:43%}
.w44{width:44%}.h44{height:44%}
.w45{width:45%}.h45{height:45%}
.w46{width:46%}.h46{height:46%}
.w47{width:47%}.h47{height:47%}
.w48{width:48%}.h48{height:48%}
.w49{width:49%}.h49{height:49%}
.w50{width:50%}.h50{height:50%}
.w51{width:51%}.h51{height:51%}
.w52{width:52%}.h52{height:52%}
.w53{width:53%}.h53{height:53%}
.w54{width:54%}.h54{height:54%}
.w55{width:55%}.h55{height:55%}
.w56{width:56%}.h56{height:56%}
.w57{width:57%}.h57{height:57%}
.w58{width:58%}.h58{height:58%}
.w59{width:59%}.h59{height:59%}
.w60{width:60%}.h60{height:60%}
.w61{width:61%}.h61{height:61%}
.w62{width:62%}.h62{height:62%}
.w63{width:63%}.h63{height:63%}
.w64{width:64%}.h64{height:64%}
.w65{width:65%}.h65{height:65%}
.w66{width:66%}.h66{height:66%}
.w67{width:67%}.h67{height:67%}
.w68{width:68%}.h68{height:68%}
.w69{width:69%}.h69{height:69%}
.w70{width:70%}.h70{height:70%}
.w71{width:71%}.h71{height:71%}
.w72{width:72%}.h72{height:72%}
.w73{width:73%}.h73{height:73%}
.w74{width:74%}.h74{height:74%}
.w75{width:75%}.h75{height:75%}
.w76{width:76%}.h76{height:76%}
.w77{width:77%}.h77{height:77%}
.w78{width:78%}.h78{height:78%}
.w79{width:79%}.h79{height:79%}
.w80{width:80%}.h80{height:80%}
.w81{width:81%}.h81{height:81%}
.w82{width:82%}.h82{height:82%}
.w83{width:83%}.h83{height:83%}
.w84{width:84%}.h84{height:84%}
.w85{width:85%}.h85{height:85%}
.w86{width:86%}.h86{height:86%}
.w87{width:87%}.h87{height:87%}
.w88{width:88%}.h88{height:88%}
.w89{width:89%}.h89{height:89%}
.w90{width:90%}.h90{height:90%}
.w91{width:91%}.h91{height:91%}
.w92{width:92%}.h92{height:92%}
.w93{width:93%}.h93{height:93%}
.w94{width:94%}.h94{height:94%}
.w95{width:95%}.h95{height:95%}
.w96{width:96%}.h96{height:96%}
.w97{width:97%}.h97{height:97%}
.w98{width:98%}.h98{height:98%}
.w99{width:99%}.h99{height:99%}
.w100{width:100%}.h100{height:100%}
