/* PDF2EPUB — design system repris d'Oralia. Ni framework, ni police web, ni ressource externe
   (CSP : 'self' seulement). Palette : bleu encre (marque) + ambre (accent) sur fond bleuté. */
:root {
  --brand: #2f5bd3; --brand-2: #5b8def; --brand-soft: #e8eefc;
  --accent: #f2a541; --accent-soft: #fdf3e3;
  --bg: #f4f6fb; --surface: #fff; --surface-2: #f9fafe; --ink: #1a1e2e; --muted: #656b80;
  --line: #e2e6f2; --ok: #12a37f; --ok-soft: #e3f6f0; --warn: #c27c0e; --warn-soft: #fdf3e1;
  --danger: #e5484d; --danger-soft: #fdecec;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(20 40 110 / 5%), 0 8px 24px rgb(20 40 110 / 7%);
  --shadow-lift: 0 2px 4px rgb(20 40 110 / 6%), 0 16px 40px rgb(20 40 110 / 12%);
  --gradient: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7a9cff; --brand-2: #9db6ff; --brand-soft: #1f2a4d;
    --accent: #f5b866; --accent-soft: #3a2c16;
    --bg: #0f121c; --surface: #181c29; --surface-2: #1e2333; --ink: #e9ecf8; --muted: #9fa5b8;
    --line: #2a3045; --ok: #3ccf9f; --ok-soft: #13342b; --warn: #f0b350; --warn-soft: #3a2c12;
    --danger: #ff6b6f; --danger-soft: #3d1a1d;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / 35%), 0 16px 40px rgb(0 0 0 / 35%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.55; font-size: 16px; }
a { color: var(--brand); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
h1 { font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 .9rem; letter-spacing: -.01em; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------------------------------------------------------------- logo */
.logo { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit; font-weight: 750; font-size: 1.2rem; letter-spacing: -.02em; }
.logo-mark { display: inline-flex; align-items: center; gap: 0; height: 30px; padding: 0 8px; border-radius: 9px; background: var(--gradient); }
.logo-mark i { display: block; width: 9px; height: 15px; border: 2px solid #fff; }
.logo-mark i:nth-child(1) { border-radius: 4px 1px 1px 4px; border-right-width: 1px; }
.logo-mark i:nth-child(2) { border-radius: 1px 4px 4px 1px; border-left-width: 1px; }
.logo-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: -3px; }

/* ---------------------------------------------------------------- app shell */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1.5rem; padding: .75rem clamp(1rem, 4vw, 2rem); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: .3rem; flex: 1; overflow-x: auto; }
.topbar nav a { padding: .45rem .8rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 550; white-space: nowrap; }
.topbar nav a:hover { color: var(--ink); background: var(--surface-2); }
.topbar nav a.active { color: var(--brand); background: var(--brand-soft); }
.user-menu { position: relative; }
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 0; background: var(--gradient); color: #fff; font-weight: 700; cursor: pointer; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; padding: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lift); }
.menu[hidden] { display: none; }
.menu .who { padding: .5rem .7rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .35rem; overflow-wrap: anywhere; }
.menu .who strong { display: block; }
.menu a, .menu button { display: block; width: 100%; padding: .55rem .7rem; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); }
.container { max-width: 1120px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.25rem) clamp(1rem, 4vw, 2rem) 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: 0; }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.1rem, 3vw, 1.6rem); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.empty { text-align: center; padding: 3rem 1.5rem; }
.empty h2 { font-size: 1.35rem; }
.empty p { max-width: 46ch; margin: 0 auto 1.5rem; }

/* ---------------------------------------------------------------- controls */
label { display: block; font-weight: 600; font-size: .92rem; margin: 1rem 0 .4rem; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; margin-top: .35rem; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; padding: .75rem .9rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
input:disabled { opacity: .7; }
input.code-input { text-align: center; font-size: 1.6rem; letter-spacing: .45em; font-variant-numeric: tabular-nums; }

button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .7rem 1.15rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .1s, box-shadow .15s, background .15s, border-color .15s; }
button:hover:not(:disabled), .button:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--gradient); color: #fff; border-color: transparent; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 30%, transparent); }
.primary:hover:not(:disabled) { box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 40%, transparent); border-color: transparent; }
.danger { color: var(--danger); }
.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.block { width: 100%; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1.25rem; }
.link-button { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- feedback */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.done { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.error { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge.active { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.badge.active::before { animation: pulse 1.2s ease-in-out infinite; }
.notice { padding: .85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .95rem; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.success { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--brand-soft); color: var(--ink); }

/* ---------------------------------------------------------------- auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; padding: clamp(2rem, 5vw, 3.5rem); background: var(--gradient); color: #fff; }
.auth-hero::after { content: ""; position: absolute; width: 440px; height: 440px; right: -150px; bottom: -170px; border-radius: 50%; background: radial-gradient(circle, rgb(242 165 65 / 50%), transparent 65%); pointer-events: none; }
.auth-hero .logo { color: #fff; }
.auth-hero .logo-mark { background: rgb(255 255 255 / 18%); }
.auth-hero h2 { font-size: clamp(1.9rem, 3.6vw, 2.9rem); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 1rem; max-width: 15ch; }
.auth-hero p { font-size: 1.05rem; opacity: .92; max-width: 40ch; }
.auth-hero .features { display: grid; gap: .55rem; padding: 0; margin: 0; list-style: none; position: relative; z-index: 1; }
.auth-hero .features li { display: flex; gap: .6rem; align-items: center; opacity: .95; }
.auth-hero .features li::before { content: "✓"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgb(255 255 255 / 20%); font-size: .75rem; font-weight: 700; }
.auth-panel { display: grid; place-items: center; padding: clamp(1.5rem, 5vw, 3rem); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { margin-bottom: .35rem; }
.auth-card .lead { color: var(--muted); margin-bottom: 1.5rem; }
.auth-card .switch { margin-top: 1.5rem; text-align: center; color: var(--muted); font-size: .92rem; }
.auth-card .primary.block { margin-top: 1.5rem; padding: .85rem 1.15rem; }
.auth-mobile-logo { display: none; margin-bottom: 2rem; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-mobile-logo { display: inline-flex; }
  .auth-panel { place-items: start center; padding-top: 3rem; }
}
.qr { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.qr img { width: 180px; height: 180px; border-radius: 12px; background: #fff; padding: 6px; border: 1px solid var(--line); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; word-break: break-all; padding: .6rem .8rem; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--line); }
.steps-list { padding-left: 1.2rem; margin: 0 0 1rem; } .steps-list li { margin-bottom: .4rem; }

/* ---------------------------------------------------------------- lists and forms */
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.list-row .who { min-width: 0; overflow-wrap: anywhere; }
.list-row .who strong { display: block; }
.inline-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form > div { flex: 1 1 260px; }
.inline-form label { margin-top: 0; }
.empty .book { font-size: 3rem; line-height: 1; margin-bottom: 1rem; }
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
@media (max-width: 640px) {
  .topbar { gap: .75rem; } .topbar .logo .word { display: none; }
}

/* ---------------------------------------------------------------- books */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.book-card { display: flex; flex-direction: column; gap: .4rem; min-height: 140px; padding: 1.2rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: inherit; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.book-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.book-card h3 { margin: 0; font-size: 1.05rem; line-height: 1.35; overflow-wrap: anywhere; }
.book-card .meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; color: var(--muted); font-size: .875rem; margin-top: auto; }
.dropzone { border: 2px dashed color-mix(in srgb, var(--brand) 35%, var(--line)); border-radius: var(--radius); padding: 2.5rem 1.25rem; text-align: center; background: var(--surface-2); cursor: pointer; transition: background .15s, border-color .15s; margin-top: 1rem; }
.dropzone strong { display: block; font-size: 1.05rem; margin-bottom: .3rem; }
.dropzone.over, .dropzone:hover { background: var(--brand-soft); border-color: var(--brand); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 1rem 0 .4rem; }
.bar span { display: block; height: 100%; width: 0; background: var(--gradient); transition: width .2s; }
label.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; margin: 0; }
label.check input { margin-top: .3rem; accent-color: var(--brand); width: 1.1rem; height: 1.1rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .book-card, .bar span { transition: none; } }
@media (max-width: 640px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: .4rem; } }
.steps { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .5rem; }
.steps li { display: flex; align-items: center; gap: .7rem; }
.steps .icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: .8rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.steps li.done .icon { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.steps li.active .icon { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.steps li.error .icon { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.steps li.pending { color: var(--muted); }
.anomalies { padding-left: 1.2rem; margin: .5rem 0 0; } .anomalies li { margin-bottom: .3rem; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; margin-top: .75rem; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.table-wrap { overflow-x: auto; }
.ai p { margin: .2rem 0; }
