:root {
  --bg: #faf6ef; --fg: #2b2620; --muted: #8a8175; --accent: #c47f17;
  --panel: #f1ebe0; --border: #e0d8c8; --hl: #ffe9a8;
  --font-size: 19px;
}
html[data-theme="dark"] {
  --bg: #1c1a17; --fg: #e6ded2; --muted: #94897a; --accent: #e0a33e;
  --panel: #26231f; --border: #38342d; --hl: #5c4a12;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif; }

/* Accueil */
.home { max-width: 480px; margin: 5vh auto; padding: 24px; text-align: center; }
.home .cover { max-width: 260px; width: 100%; border-radius: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.home h1 { margin: 24px 0 4px; }
.subtitle { color: var(--muted); font-style: italic; }
.beta-note { font-size: 15px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.join-form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.join-form input { padding: 12px; font-size: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); }
.join-form button, .hl-actions button, .hl-tags button {
  padding: 12px; font-size: 16px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; }
.meta { color: var(--muted); font-size: 14px; }

/* Liseuse */
.reader-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; background: transparent; z-index: 50; }
#scrollBar { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
#tocToggle { position: fixed; top: 10px; left: 10px; z-index: 40; font-size: 20px;
  background: var(--panel); color: var(--fg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
#sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 320px; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--border); padding: 54px 0 20px; transform: translateX(0); transition: transform .2s; z-index: 30; }
body.toc-hidden #sidebar { transform: translateX(-100%); }
.sidebar-head { padding: 0 18px 12px; border-bottom: 1px solid var(--border); }
.book-title { font-weight: bold; color: var(--fg); text-decoration: none; }
.reader-name { font-size: 13px; color: var(--muted); margin-top: 4px; }
.global-bar { height: 5px; background: var(--border); border-radius: 3px; margin-top: 6px; }
.global-bar > div { height: 100%; background: var(--accent); border-radius: 3px; }
.toc-part-title { padding: 14px 18px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toc-ch { display: flex; justify-content: space-between; gap: 8px; padding: 7px 18px; font-size: 14px;
  color: var(--fg); text-decoration: none; }
.toc-ch:hover { background: var(--border); }
.toc-ch.active { background: var(--border); font-weight: bold; }
.toc-ch.read span:first-child::after { content: " ✓"; color: var(--accent); }
.toc-ch.opened span:first-child::after { content: " ·"; color: var(--muted); }
.toc-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
main { max-width: 720px; margin: 0 auto; padding: 60px 24px 80px; margin-left: max(340px, calc((100% - 720px) / 2)); }
body.toc-hidden main { margin-left: auto; }
@media (max-width: 1100px) { main { margin-left: auto; } body:not(.toc-hidden) #sidebar { box-shadow: 0 0 40px rgba(0,0,0,.3); } }
.ch-tools { display: flex; gap: 8px; justify-content: flex-end; }
.ch-tools button { background: var(--panel); color: var(--fg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 15px; }
.ch-part { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; margin-top: 8px; }
article { font-size: var(--font-size); line-height: 1.75; }
article h1 { line-height: 1.25; }
article img { max-width: 100%; border-radius: 6px; }
article hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
article blockquote { border-left: 3px solid var(--accent); margin-left: 0; padding-left: 16px; color: var(--muted); }
mark.hl { background: var(--hl); color: inherit; border-radius: 2px; cursor: pointer; }
mark.hl[title] { border-bottom: 2px dotted var(--accent); }
.ch-meta { color: var(--muted); font-size: 14px; margin-top: 32px; border-top: 1px solid var(--border); padding-top: 12px; }
.ch-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 16px; }
.ch-nav a { color: var(--accent); text-decoration: none; max-width: 45%; }

/* Popup surlignage */
#hlPopup { position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; width: 280px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
  font-family: system-ui, sans-serif; }
.hl-tags { display: flex; gap: 6px; margin-bottom: 8px; }
.hl-tags button { font-size: 12px; padding: 6px 8px; background: var(--border); color: var(--fg); }
.hl-tags button.sel { background: var(--accent); color: #fff; }
#hlComment { width: 100%; height: 56px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--fg); padding: 8px; font-size: 14px; resize: vertical; }
.hl-actions { display: flex; gap: 8px; margin-top: 8px; }
.hl-actions button { font-size: 14px; padding: 8px 12px; flex: 1; }
#hlCancel { background: var(--border); color: var(--fg); }

/* Admin */
.admin { max-width: 960px; margin: 0 auto; padding: 32px 24px; font-family: system-ui, sans-serif; }
.stat-cards { display: flex; flex-wrap: wrap; gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; }
.stat b { display: block; font-size: 22px; }
.reader-row { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 10px 0; }
.reader-row summary { cursor: pointer; }
.reader-row table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.reader-row td, .reader-row th { text-align: left; padding: 4px 8px; border-top: 1px solid var(--border); }
.hl-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 10px 0; }
.hl-head { font-size: 13px; color: var(--muted); }
.hl-card blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding-left: 12px; }
.tag { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--border); }
.tag-top { background: #2e7d3222; } .tag-bof { background: #f9a82522; } .tag-pasdaccord { background: #c6282822; }
