/* ==========================================================================
   Lectures — feuille de style
   Identité : une reliure toilée vert viridian, titrée à l'or (thème
   « Reliure », sombre, par défaut) ; ou la page d'un livre ouvert, avec le
   viridian en couleur d'accent (thème « Papier », clair). Titres en
   caractères à empattements (New York sur iPhone), le reste en police
   système. Un seul élément décoratif : la progression dessinée comme la
   TRANCHE des pages d'un livre, dorée.
   ========================================================================== */

/* --- Couleurs ------------------------------------------------------------ */
/* Le vert viridian (#40826D, le pigment) en est la couleur : toile viridian
   foncée pour le fond, viridian lumineux pour les boutons, dorure pour la
   tranche des pages, les étoiles et le signet des citations. */
:root {
  --bg: #0F2C23;          /* toile viridian, très foncée */
  --panel: #16392E;
  --panel-2: #1D4438;
  --line: #295145;
  --ink: #EEF4F1;         /* papier */
  --muted: #ABC4BC;
  --faint: #6C9387;
  --accent: #5EAD93;      /* viridian lumineux : boutons, onglet actif */
  --accent-ink: #7FC9AF;  /* viridian pour du texte sur fond foncé */
  --on-accent: #0A1F18;
  --accent-soft: rgba(94, 173, 147, .15);
  --gold: #DDB664;        /* dorure : tranche, étoiles, signet */
  --gold-ink: #E5C47F;
  --track: rgba(238, 244, 241, .07);
  --page-line: rgba(238, 244, 241, .17);   /* filets de la tranche */
  --done: #9FDBC8;        /* livre lu */
  --bad: #E8806F;
  --card-shadow: none;
  --shadow: 0 14px 38px rgba(2, 12, 9, .55);
  --cover-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px rgba(0, 0, 0, .28);
  --band: #0F2C23;
  --radius: 16px;
  --tabbar-h: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #EEF3F2; --panel: #FFFFFF; --panel-2: #E3EBE8; --line: #D3DEDB;
  --ink: #14342A; --muted: #557269; --faint: #90A7A0;
  --accent: #40826D; --accent-ink: #2F6F5B; --on-accent: #FFFFFF; --accent-soft: rgba(64, 130, 109, .12);
  --gold: #C29539; --gold-ink: #8A6418;
  --track: rgba(20, 52, 42, .06); --page-line: rgba(20, 52, 42, .17); --done: #2F6F5B; --bad: #C2443A;
  --card-shadow: 0 1px 2px rgba(20, 52, 42, .05), 0 4px 14px rgba(20, 52, 42, .05);
  --shadow: 0 14px 38px rgba(20, 52, 42, .18);
  --cover-shadow: 0 1px 2px rgba(20, 52, 42, .18), 0 5px 14px rgba(20, 52, 42, .16);
  --band: #0F2C23;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #EEF3F2; --panel: #FFFFFF; --panel-2: #E3EBE8; --line: #D3DEDB;
    --ink: #14342A; --muted: #557269; --faint: #90A7A0;
    --accent: #40826D; --accent-ink: #2F6F5B; --on-accent: #FFFFFF; --accent-soft: rgba(64, 130, 109, .12);
    --gold: #C29539; --gold-ink: #8A6418;
    --track: rgba(20, 52, 42, .06); --page-line: rgba(20, 52, 42, .17); --done: #2F6F5B; --bad: #C2443A;
    --card-shadow: 0 1px 2px rgba(20, 52, 42, .05), 0 4px 14px rgba(20, 52, 42, .05);
    --shadow: 0 14px 38px rgba(20, 52, 42, .18);
    --cover-shadow: 0 1px 2px rgba(20, 52, 42, .18), 0 5px 14px rgba(20, 52, 42, .16);
    --band: #0F2C23;
    color-scheme: light;
  }
}

/* --- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.row, .chip, .btn, .seg button, .tabbar a, .book-row, .icon-btn, .stars button {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }

.view {
  max-width: 640px; margin: 0 auto;
  padding: calc(var(--safe-top) + 28px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 32px);
  min-height: 100vh;
}

/* --- Titres --------------------------------------------------------------- */
.page-head { margin: 8px 0 18px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-title { font-family: var(--serif); font-size: 34px; line-height: 1.08; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.page-sub { color: var(--muted); margin: 6px 0 0; font-size: 15px; }
.section-title { font-family: var(--serif); font-size: 21px; font-weight: 600; margin: 30px 0 10px; letter-spacing: -0.005em; }
.section-title small { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 30px 0 10px; }
.section-head .section-title { margin: 0; }

/* --- Cartes ---------------------------------------------------------------- */
.card { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--card-shadow); min-width: 0; }
.card + .card { margin-top: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.hint { font-size: 13.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.danger-text { color: var(--bad); }

/* --- Couverture --------------------------------------------------------------
   Proportions d'un livre (2/3), dos à gauche un peu plus sombre. Sans image :
   une couverture « toilée » à la couleur tirée du titre, titre et auteur gravés. */
.cover {
  position: relative; flex: none; width: var(--w, 64px); aspect-ratio: 2 / 3; overflow: hidden;
  border-radius: 2px 5px 5px 2px; background: var(--panel-2); box-shadow: var(--cover-shadow);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover::after { /* le dos du livre */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 7%;
  background: linear-gradient(90deg, rgba(0, 0, 0, .28), rgba(0, 0, 0, .06) 70%, rgba(255, 255, 255, .08));
  pointer-events: none;
}
.cover.cloth {
  background-color: var(--cloth, #2F6B58);
  background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 3px),
                    repeating-linear-gradient(-45deg, rgba(0, 0, 0, .05) 0 1px, transparent 1px 3px);
  color: #F3E2B8; display: flex; flex-direction: column; justify-content: center; text-align: center;
  /* marges proportionnelles à la couverture (un % serait celui de la ligne entière) */
  padding: calc(var(--w, 64px) * .14) calc(var(--w, 64px) * .09) calc(var(--w, 64px) * .14) calc(var(--w, 64px) * .14); gap: calc(var(--w, 64px) * .05);
}
.cover.cloth b { font-family: var(--serif); font-weight: 600; font-size: calc(var(--w, 64px) * .14); line-height: 1.12; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cover.cloth span { font-size: calc(var(--w, 64px) * .095); opacity: .8; line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cover.cloth.tiny b { font-size: calc(var(--w, 64px) * .16); -webkit-line-clamp: 3; }
.cover.cloth.tiny span { display: none; }

/* --- La tranche : l'avancement d'un livre ------------------------------------
   Des filets fins comme les pages vues de côté ; la partie lue est dorée. */
.edge { position: relative; height: 10px; border-radius: 2px; overflow: hidden;
  background: repeating-linear-gradient(90deg, var(--page-line) 0 1px, transparent 1px 3px), var(--track); }
.edge i { position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); border-radius: 2px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .28) 0 1px, transparent 1px 3px), var(--gold);
  transition: width .5s cubic-bezier(.3, .8, .3, 1); }
.edge.done i { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .25) 0 1px, transparent 1px 3px), var(--done); }
.edge.thin { height: 6px; }
@media (prefers-reduced-motion: reduce) { .edge i { transition: none; } }

/* --- Livres en cours (écran Lectures) ------------------------------------ */
.reading { display: grid; gap: 12px; }
.reading-card { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; padding: 16px; }
.reading-cover { grid-row: span 2; cursor: pointer; }
.reading-card .cover { --w: 78px; }
.reading-main { min-width: 0; cursor: pointer; }
.book-title { font-family: var(--serif); font-weight: 600; font-size: 19px; line-height: 1.2; margin: 0; overflow-wrap: anywhere; }
.book-author { color: var(--muted); font-size: 14.5px; margin-top: 3px; }
.reading-progress { align-self: end; display: grid; gap: 8px; min-width: 0; }
.progress-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; color: var(--muted); }
.progress-line b { color: var(--ink); font-weight: 650; }
.progress-line .pct { font-family: var(--serif); font-size: 17px; color: var(--gold-ink); font-weight: 600; }
.log-btn {
  display: inline-flex; align-items: center; gap: 8px; justify-self: start; margin-top: 4px;
  min-height: 40px; padding: 0 14px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; font-size: 15px;
}
.log-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.log-btn:active { opacity: .7; }

/* --- Liste des livres ------------------------------------------------------ */
.book-list { background: var(--panel); border-radius: var(--radius); box-shadow: var(--card-shadow); padding: 2px 14px; }
.book-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; cursor: pointer; min-height: 84px; }
.book-row + .book-row { border-top: 1px solid var(--line); }
.book-row:active { opacity: .65; }
.book-row .cover { --w: 44px; }
.book-row-main { flex: 1; min-width: 0; }
.book-row .book-title { font-size: 16.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-row .book-author { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-meta { font-size: 13px; color: var(--faint); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.book-meta .edge { width: 80px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.tag.done { color: var(--done); }
.tag.reading { color: var(--gold-ink); }
.tag.dropped { color: var(--faint); }
.mini-stars { color: var(--gold-ink); letter-spacing: 1px; font-size: 12px; }

/* Filtres (À lire, Lus…) et champ de filtre */
.filters { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter-input { position: relative; margin-bottom: 12px; }
.filter-input svg { position: absolute; left: 13px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; stroke: var(--faint); fill: none; stroke-width: 2; stroke-linecap: round; }
.filter-input .input { padding-left: 40px; min-height: 44px; font-size: 16px; background: var(--panel); box-shadow: var(--card-shadow); }

/* --- Fiche d'un livre ------------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -6px 0 14px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; border: 0; cursor: pointer;
  background: var(--panel); color: var(--ink); box-shadow: var(--card-shadow);
}
.icon-btn svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { opacity: .7; }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.book-head { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: end; }
.book-head .cover { --w: 118px; }
.book-head .book-title { font-size: 26px; line-height: 1.12; letter-spacing: -0.01em; }
.book-sub { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 16px; margin-top: 4px; }
.book-head .book-author { font-size: 16px; color: var(--ink); margin-top: 8px; }
.book-facts { color: var(--muted); font-size: 13.5px; margin-top: 6px; line-height: 1.5; }
.status-seg { margin-top: 20px; }

.big-progress { display: grid; gap: 10px; }
.big-progress .progress-line { font-size: 15px; }
.big-progress .pct { font-size: 22px; }
.log-form { display: flex; gap: 10px; align-items: stretch; margin-top: 6px; }
.log-form .input { flex: 1; min-width: 0; font-size: 20px; font-weight: 650; }
.log-form .btn { width: auto; flex: none; padding: 0 18px; }
.log-preview { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.log-preview:empty { display: none; }
.big-progress [data-log-other] { justify-self: start; padding: 0; }
.log-preview b { color: var(--accent-ink); }

.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; min-height: 48px; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.h-day { font-size: 15px; }
.h-page { font-size: 14px; color: var(--muted); }
.h-delta { font-family: var(--serif); font-weight: 600; font-size: 16px; color: var(--gold-ink); min-width: 64px; text-align: right; }
.h-delta.neg { color: var(--bad); }
.h-delta.zero, .h-delta.start { color: var(--faint); font-family: var(--sans); font-size: 13px; font-weight: 500; }
.history .del { width: 34px; height: 34px; margin-right: -6px; border: 0; border-radius: 50%; background: none; color: var(--faint); cursor: pointer; display: grid; place-items: center; }
.history .del svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.history .del:active { background: var(--panel-2); }
.facts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin-top: 14px; }
.fact b { display: block; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.fact span { font-size: 13px; color: var(--muted); }

.stars { display: flex; gap: 2px; margin: -4px 0 8px -6px; }
.stars button { width: 44px; height: 44px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; color: var(--faint); }
.stars svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.stars button.on { color: var(--gold); }
.stars button.on svg { fill: currentColor; }
textarea.input { min-height: 110px; padding: 12px 14px; line-height: 1.45; resize: vertical; }

.summary { font-family: var(--serif); font-size: 16.5px; line-height: 1.6; color: var(--ink); white-space: pre-line; margin: 0; }
.summary.clamped { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.more-link { border: 0; background: none; padding: 6px 0; color: var(--accent-ink); font-weight: 650; cursor: pointer; }
.info-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14.5px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; overflow-wrap: anywhere; }
.info-list a { color: var(--accent-ink); }

/* --- Citations --------------------------------------------------------------- */
.quotes { display: grid; gap: 12px; }
.quote { position: relative; padding: 18px 18px 14px 22px; cursor: pointer; }
.quote::before { /* filet doré, comme un signet */
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 0 2px 2px 0; background: var(--gold);
}
.quote blockquote { margin: 0; font-family: var(--serif); font-style: italic; font-size: 17.5px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.quote-src { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.quote-src b { color: var(--ink); font-weight: 600; }
.quote-note { margin-top: 8px; font-size: 14.5px; color: var(--muted); white-space: pre-line; border-top: 1px solid var(--line); padding-top: 8px; }

/* --- Bilan ---------------------------------------------------------------------- */
.goal-card { padding: 20px 18px; }
.goal-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.goal-num { font-family: var(--serif); font-size: 46px; line-height: 1; font-weight: 600; letter-spacing: -0.02em; }
.goal-num small { font-size: 22px; color: var(--muted); font-weight: 500; }
.goal-label { color: var(--muted); font-size: 15px; }
.goal-card .edge { height: 14px; margin: 16px 0 12px; }
.goal-pace { margin: 0; font-size: 15px; }
.goal-pace b { color: var(--gold-ink); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.kpi { background: var(--panel); border-radius: var(--radius); padding: 14px; box-shadow: var(--card-shadow); min-width: 0; }
.kpi b { display: block; font-family: var(--serif); font-size: 28px; line-height: 1.1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi span { font-size: 13px; color: var(--muted); }
.mbars { display: flex; align-items: stretch; gap: 4px; height: 170px; }
.mb { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.mb-val { font-size: 10.5px; font-weight: 650; min-height: 14px; color: var(--muted); white-space: nowrap; }
.mb-track { flex: 1; width: 100%; max-width: 30px; display: flex; align-items: flex-end; border-radius: 3px 3px 0 0; border-bottom: 2px solid var(--line); overflow: hidden; }
.mb-track i { display: block; width: 100%; border-radius: 3px 3px 0 0; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .22) 0 1px, transparent 1px 3px), var(--accent); }
.mb-lab { font-size: 11px; color: var(--muted); font-weight: 600; }
.mb-books { font-size: 10.5px; color: var(--done); font-weight: 700; min-height: 14px; }
.mb.current .mb-lab { color: var(--accent-ink); font-weight: 800; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 14px 10px; }
.shelf .cover { --w: 64px; width: 100%; cursor: pointer; }
.facts-list { list-style: none; margin: 0; padding: 0; }
.facts-list li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 15px; }
.facts-list li:first-child { border-top: 0; }
.facts-list li span:first-child { color: var(--muted); }
.facts-list li b { font-weight: 650; text-align: right; }

/* --- Ajouter : scan et recherche ------------------------------------------- */
body.scanning { background: #000; }
body.scanning .view { padding: 0; max-width: none; }
body.scanning::before { display: none; }
.scan { position: fixed; inset: 0; display: flex; flex-direction: column; color: #fff; overflow: hidden;
  padding: calc(var(--safe-top) + 12px) 0 calc(var(--tabbar-h) + var(--safe-bottom) + 14px); }
.scan video { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.scan-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .35s ease; }
.scan-canvas.live { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .scan-canvas { transition: none; } }
.scan-top { position: relative; z-index: 2; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 0 16px; }
.scan-top .icon-btn { position: absolute; right: 16px; background: rgba(0, 0, 0, .35); color: #fff; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.scan-hint { position: relative; z-index: 2; text-align: center; font-weight: 600; margin: 12px 16px 0;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .85), 0 0 2px rgba(0, 0, 0, .6); }
/* Viseur aux proportions d'un code-barres de livre (EAN-13), coins dorés */
.viewfinder { --c: #DDB664; position: relative; z-index: 2; width: min(78vw, 330px); aspect-ratio: 1.7; margin: auto; }
.viewfinder i { position: absolute; width: 30px; height: 30px; border: 3px solid var(--c); transition: opacity .2s ease; }
.viewfinder i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.viewfinder i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.viewfinder i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.viewfinder i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.viewfinder.busy i { opacity: .35; }
.scan-bottom { position: relative; z-index: 2; display: grid; gap: 8px; padding: 0 16px; max-width: 520px; width: 100%; margin: 0 auto; }
.scan-bottom form { display: flex; gap: 8px; }
.scan-bottom .input { background: rgba(255, 255, 255, .14); border: 0; color: #fff; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.scan-bottom .input::placeholder { color: rgba(255, 255, 255, .72); }
.scan-bottom .btn.small { min-height: 50px; width: auto; padding: 0 18px; background: #fff; color: #000; }
.scan-bottom .link-btn { color: #fff; text-align: center; text-shadow: 0 1px 8px rgba(0, 0, 0, .7); }
.photo-scan { position: relative; z-index: 2; margin: auto 24px; display: grid; justify-items: center; gap: 8px; text-align: center; }
.photo-shutter { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: #5EAD93; color: #0A1F18; box-shadow: 0 0 0 6px rgba(94, 173, 147, .28); }
.photo-shutter svg { width: 36px; height: 36px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.photo-scan.busy .photo-shutter { opacity: .45; pointer-events: none; }
.photo-hint { color: rgba(255, 255, 255, .78); font-size: 14px; max-width: 30ch; margin: 0; }
.photo-status { font-weight: 650; margin: 6px 0 0; }

.mode-seg { background: rgba(0, 0, 0, .35); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); width: min(320px, 72vw); }
.mode-seg button { color: rgba(255, 255, 255, .8); }
.mode-seg button[aria-pressed="true"] { background: #fff; color: #000; }
.search-head .mode-seg { background: var(--panel); margin: 0 auto 18px; }
.search-head .mode-seg button { color: var(--muted); }
.search-head .mode-seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.search-form { display: grid; gap: 0; }
.search-form .field { margin-bottom: 12px; }
.results { margin-top: 18px; }
.result-note { font-size: 13px; color: var(--faint); margin: 8px 2px 0; }

/* --- Contrôles ---------------------------------------------------------------- */
.seg { display: flex; background: var(--panel); border-radius: 13px; padding: 4px; gap: 3px; box-shadow: var(--card-shadow); }
.seg button {
  flex: 1; min-height: 40px; border: 0; background: none; border-radius: 10px; cursor: pointer;
  font-weight: 650; font-size: 14.5px; color: var(--muted); padding: 0 6px;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 52px; padding: 0 20px; border-radius: 13px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 17px;
}
.btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn:active { opacity: .8; }
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--panel-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.inline { width: auto; }
.link-btn { background: none; border: 0; color: var(--accent-ink); font-weight: 650; padding: 10px 0; cursor: pointer; }
.stack > * + * { margin-top: 10px; }
.row-actions { display: flex; gap: 10px; }
.row-actions .btn { flex: 1; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; font-size: 17px;
  border: 1.5px solid transparent; background: var(--panel-2); color: var(--ink);
}
.input:focus { border-color: var(--accent); outline: none; }
.input[type="date"] { -webkit-appearance: none; appearance: none; display: flex; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px; padding: 0 15px; border-radius: 999px; border: 0; cursor: pointer; flex: none;
  background: var(--panel-2); font-size: 15px; font-weight: 600; color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
}
.filters .chip { background: var(--panel); box-shadow: var(--card-shadow); }
.chip small { font-size: 13px; color: var(--muted); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .75; }
.stepper { display: flex; align-items: center; background: var(--panel-2); border-radius: 13px; overflow: hidden; }
.stepper button { width: 58px; height: 54px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--ink); }
.stepper input { flex: 1; min-width: 0; text-align: center; border: 0; background: none; font-size: 24px; font-weight: 700; height: 54px; padding: 0 6px; font-family: var(--serif); }
.stepper input:focus { outline: none; }

/* --- Réglages ------------------------------------------------------------------- */
.list-card { padding: 4px 16px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 10px 0; cursor: pointer; color: inherit; }
.row + .row { border-top: 1px solid var(--line); }
.row:active { opacity: .65; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 13.5px; }
.chev { color: var(--faint); }
.chev svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.ok { background: var(--done); }
.dot.ko { background: var(--bad); }

/* --- Fenêtre du bas ------------------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(3, 14, 10, .58); z-index: 40; animation: fade .2s; touch-action: none; }
html.sheet-open { overscroll-behavior: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 600px; margin: 0 auto;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--panel); border-radius: 22px 22px 0 0; padding: 10px 20px calc(var(--safe-bottom) + 22px);
  animation: rise .3s cubic-bezier(.2, .9, .3, 1); box-shadow: var(--shadow);
}
.sheet::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 16px; }
.sheet h2 { font-family: var(--serif); font-size: 23px; font-weight: 600; margin: 0 0 16px; letter-spacing: -0.01em; }
.sheet .input, .sheet .stepper, .sheet .chip:not([aria-pressed="true"]), .sheet .btn.secondary, .sheet .seg { background: var(--panel-2); }
.sheet .seg { box-shadow: none; }
.sheet .seg button[aria-pressed="true"] { background: var(--accent); }
.sheet-text { color: var(--muted); margin: -6px 0 18px; line-height: 1.5; font-size: 15px; }
.sheet-book { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-bottom: 18px; }
.sheet-book .cover { --w: 84px; }
.sheet-book .book-title { font-size: 20px; }
.found-from { font-size: 12.5px; color: var(--faint); margin-top: 6px; }
@keyframes rise { from { translate: 0 100%; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-backdrop { animation: none; } }

/* --- Connexion ------------------------------------------------------------------ */
body.auth .tabbar { display: none; }
.auth-screen { max-width: 400px; margin: 9vh auto 0; }
.auth-logo { border-radius: 20px; margin-bottom: 18px; box-shadow: var(--cover-shadow); }
.auth-screen .page-title { margin-bottom: 6px; }
.auth-screen .page-sub { margin-bottom: 24px; }
.auth-error { color: var(--bad); font-weight: 600; min-height: 1.4em; margin: 0 0 10px; }

/* --- Barre d'onglets ---------------------------------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding: 0 6px var(--safe-bottom);
  display: flex; justify-content: space-around; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.tabbar a { flex: 1; max-width: 120px; display: grid; justify-items: center; gap: 3px; color: var(--faint); font-size: 10.5px; font-weight: 650; padding: 6px 0; }
.tabbar a svg { width: 25px; height: 25px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent-ink); }
.tabbar a.active svg { stroke-width: 2.1; }
.tabbar .tab-add { flex: none; width: 56px; height: 56px; margin-top: -18px; border-radius: 50%; padding: 0; place-items: center; align-content: center;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }
.tabbar .tab-add svg { width: 28px; height: 28px; stroke-width: 2; }
.tabbar .tab-add.active { color: var(--on-accent); }
body.scanning .tabbar { background: rgba(0, 0, 0, .32); border-top-color: transparent; }
body.scanning .tabbar a { color: rgba(255, 255, 255, .72); }
body.scanning .tabbar a.active { color: #fff; }
body.scanning .tabbar .tab-add, body.scanning .tabbar .tab-add.active { background: #fff; color: #000; }

/* Bande sous l'heure et la batterie de l'iPhone */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: calc(var(--safe-top) + 22px);
  background: linear-gradient(to bottom, var(--band) 0, var(--band) var(--safe-top), transparent 100%);
  z-index: 35; pointer-events: none;
}

/* --- Message éphémère, états vides, attente ----------------------------------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 12px); z-index: 60;
  translate: -50% -20px; opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-weight: 650; font-size: 15px; max-width: calc(100vw - 32px); width: max-content;
  transition: opacity .2s, translate .2s;
}
.toast.show { opacity: 1; translate: -50% 0; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: #fff; border-radius: 14px; }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding-right: 8px; }
.toast button { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 750; text-decoration: underline; padding: 4px 8px; cursor: pointer; }
body.scanning .toast { top: calc(var(--safe-top) + 70px); }
.empty { text-align: center; padding: 30px 12px; }
.empty-icon svg { width: 46px; height: 46px; stroke: var(--faint); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin: 0 auto 10px; }
.empty p { color: var(--muted); margin: 6px auto 18px; max-width: 34ch; }
.empty .btn { width: auto; padding: 0 24px; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite, appear .2s .3s both; margin: 34px auto;
}
@keyframes spin { to { rotate: 360deg; } }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* --- Mises à jour (voir js/updater.js) ---------------------------------------- */
.update-banner {
  position: fixed; left: 50%; translate: -50% 0; top: calc(var(--safe-top) + 10px); z-index: 55;
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: var(--bg); font: inherit; font-size: 15px; box-shadow: var(--shadow);
}
.update-banner b { text-decoration: underline; text-underline-offset: 3px; }
body.scanning .update-banner { display: none; }
.ptr {
  position: fixed; left: 50%; top: calc(var(--safe-top) - 34px); z-index: 34;
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); color: var(--muted); box-shadow: var(--shadow);
  transform: translate(-50%, 0); opacity: 0; transition: opacity .15s, color .15s; pointer-events: none;
}
.ptr.show { opacity: 1; }
.ptr.ready, .ptr.loading { color: var(--accent-ink); }
.ptr svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ptr.loading svg { display: none; }
.ptr.loading::after { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }

/* --- Grands écrans ------------------------------------------------------------- */
@media (min-width: 700px) {
  .view { padding-top: calc(var(--safe-top) + 36px); }
  .reading { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .book-head .cover { --w: 150px; }
}
