@font-face { font-family: 'Lora'; src: url('/fonts/lora.woff') format('woff'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Chorus'; src: url('/fonts/chorus.woff') format('woff'); font-display: swap; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; color: #2b2520; background: #efe5d6; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
.bgwarm { position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 30%, #f6efe4 0%, #eadfcd 60%, #dccdb5 100%); z-index: -1; }
.hidden { display: none !important; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: #2f6f8f; color: #fff; font-weight: 650; padding: 11px 20px; border-radius: 12px; font-size: 15px; }
.btn:hover { filter: brightness(1.06); }
.btn.light { background: #f0e6d8; color: #4a3f35; }
.btn.danger { background: #b5473f; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 14px; color: #5a4c3f; }
.field input, .field select, .field textarea { border: 1px solid #d8cbb8; border-radius: 10px; padding: 11px 12px; background: #fff; font-size: 16px; color: #2b2520; }
.field input:focus, textarea:focus, select:focus { outline: 2px solid #2f6f8f; outline-offset: 1px; }
.errmsg { color: #b5473f; font-size: 14px; min-height: 20px; margin-bottom: 8px; }
.av { width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid #fff; flex: none; }

/* ---- écrans d'accueil */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { background: #fff; border-radius: 20px; box-shadow: 0 20px 50px rgba(60,40,20,.18); padding: 30px 28px; width: 100%; max-width: 400px; }
.card h1 { font-family: 'Lora', serif; font-size: 28px; margin-bottom: 6px; }
.card .sub { color: #7a6a5a; font-size: 15px; margin-bottom: 22px; line-height: 1.45; }
.logo { font-family: 'Lora', serif; font-weight: 700; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.logo img { width: 34px; height: 34px; }

/* ---- bibliothèque */
.appbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 12px max(20px, env(safe-area-inset-left)); background: rgba(255,255,255,.7); backdrop-filter: blur(8px); border-bottom: 1px solid rgba(80,60,40,.12); }
.appbar .sp { flex: 1; }
.avstack { display: flex; } .avstack .av { margin-left: -8px; }
.menu { position: relative; }
.menu .dd { position: absolute; right: 0; top: 44px; background: #fff; border-radius: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.18); padding: 6px; min-width: 220px; z-index: 20; }
.menu .dd button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 9px; font-size: 15px; }
.menu .dd button:hover { background: #f4ede3; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 30px 20px 60px; }
.wrap h2 { font-family: 'Lora', serif; font-size: 32px; }
.wrap .lead { color: #7a6a5a; margin: 4px 0 26px; }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 30px 26px; }
.bk { cursor: pointer; }
.cover { aspect-ratio: 470/610; border-radius: 4px 12px 12px 4px; color: #fff; position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 14px;
  box-shadow: 0 16px 28px rgba(60,40,20,.28), inset 10px 0 12px -6px rgba(0,0,0,.35); transition: transform .2s; }
.bk:hover .cover { transform: translateY(-4px); }
.cover .em { font-size: 54px; line-height: 1; margin-bottom: 16px; }
.cover .t { font-family: 'Lora', serif; font-size: 24px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.cover .s { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; opacity: .88; margin-top: 8px; }
.bk .meta { font-size: 13px; color: #7a6a5a; text-align: center; margin-top: 10px; }
.cover.new { background: rgba(255,255,255,.4); border: 2px dashed rgba(90,70,50,.35); box-shadow: none; color: #7a6a5a; }
.cover.new .em { font-size: 40px; }

/* ---- fenêtres */
.veil { position: fixed; inset: 0; background: rgba(40,30,20,.4); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal { background: #fff; border-radius: 20px; padding: 24px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; box-shadow: 0 30px 60px rgba(0,0,0,.3); }
.modal h3 { font-family: 'Lora', serif; font-size: 23px; margin-bottom: 14px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.swrow { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(0,0,0,.12); cursor: pointer; }
.sw.on { outline: 3px solid #2f6f8f; outline-offset: 2px; }
.emrow { display: flex; flex-wrap: wrap; gap: 6px; }
.emrow button { width: 42px; height: 42px; border-radius: 10px; background: #f6f0e7; font-size: 24px; }
.emrow button.on { outline: 3px solid #2f6f8f; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #2b2520; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 80; font-size: 15px; box-shadow: 0 10px 24px rgba(0,0,0,.25); }

/* ---- page (rendu commun) */
.pg { position: relative; overflow: hidden; background: #fbf8f2; flex: none; }
.pg .shade { position: absolute; inset: 0; pointer-events: none; }
.pg.l .shade { background: linear-gradient(to right, rgba(0,0,0,0) 82%, rgba(60,40,20,.15) 100%); }
.pg.r .shade { background: linear-gradient(to left, rgba(0,0,0,0) 82%, rgba(60,40,20,.17) 100%); }
.pat-lignes { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--s) * 29px), rgba(80,110,150,.18) calc(var(--s) * 29px), rgba(80,110,150,.18) calc(var(--s) * 30px)); }
.pat-carreaux { background-image: linear-gradient(rgba(80,110,150,.13) 1px, transparent 1px), linear-gradient(90deg, rgba(80,110,150,.13) 1px, transparent 1px); background-size: calc(var(--s) * 22px) calc(var(--s) * 22px); }
.pat-points { background-image: radial-gradient(rgba(90,70,50,.22) calc(var(--s) * 1.6px), transparent calc(var(--s) * 1.8px)); background-size: calc(var(--s) * 20px) calc(var(--s) * 20px); }
.pat-kraft { background-image: radial-gradient(rgba(120,80,40,.10) 1px, transparent 1px), radial-gradient(rgba(255,255,255,.12) 1px, transparent 1px); background-size: 7px 7px, 11px 11px; background-position: 0 0, 3px 5px; }
.el { position: absolute; transform-origin: 50% 50%; }
.el.photo { background: #fff; box-shadow: 0 calc(var(--s)*6px) calc(var(--s)*14px) rgba(60,40,20,.25); }
.el.photo .im { position: absolute; overflow: hidden; background: #e9e1d4; }
.el.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.el.photo .wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: #9a8a78; font-size: calc(var(--s) * 13px); padding: 6px; }
.el.photo.nu { background: transparent; box-shadow: 0 calc(var(--s)*4px) calc(var(--s)*12px) rgba(60,40,20,.22); }
.el.photo.rond { border-radius: 50%; background: transparent; box-shadow: none; }
.el.photo.rond .im { border-radius: 50%; box-shadow: 0 0 0 calc(var(--s)*6px) #fff, 0 calc(var(--s)*6px) calc(var(--s)*14px) rgba(60,40,20,.25); }
.el.photo .cap { position: absolute; left: 0; right: 0; text-align: center; font-family: 'Chorus', cursive; color: #4a3f35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.el .tape { position: absolute; left: 50%; opacity: .8; }
.el.text { white-space: pre-wrap; overflow-wrap: break-word; line-height: 1.22; }
.f-main { font-family: 'Chorus', cursive; } .f-titre { font-family: 'Lora', serif; font-weight: 700; } .f-simple { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; line-height: 1.5; } .f-moderne { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.el.sticker { display: flex; align-items: center; justify-content: center; line-height: 1; }
.pg .ghostadd { position: absolute; border: 2px dashed rgba(120,100,80,.35); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #9d8c79; }
.pg .pno { position: absolute; bottom: calc(var(--s)*14px); font-size: calc(var(--s)*12px); color: #a99a88; }
.pg.l .pno { left: calc(var(--s)*24px); } .pg.r .pno { right: calc(var(--s)*24px); }

/* ---- feuilleter */
.reader { position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 45%, #3a322b 0%, #1f1b18 75%); color: #f3e9dc; overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.reader .top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: 12px max(14px, env(safe-area-inset-left)); z-index: 10; }
.reader .top .ti { flex: 1; text-align: center; font-family: 'Lora', serif; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rbtn { height: 40px; min-width: 40px; padding: 0 14px; border-radius: 20px; background: rgba(255,255,255,.12); color: #f3e9dc; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.rbtn:hover { background: rgba(255,255,255,.2); }
.rbtn.on { background: #2f6f8f; }
.stagebox { position: absolute; left: 0; right: 0; top: 64px; bottom: 70px; perspective: 2600px; }
.bookv { position: absolute; transform-style: preserve-3d; }
.bookv .shadow { position: absolute; border-radius: 10px; box-shadow: 0 30px 60px rgba(0,0,0,.5), 0 8px 18px rgba(0,0,0,.35); }
.bookv .side { position: absolute; top: 0; }
.bookv .sheet { position: absolute; top: 0; transform-style: preserve-3d; transform-origin: 0 50%; }
.bookv .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.bookv .face.b { transform: rotateY(180deg); }
.bookv .lt { position: absolute; inset: 0; pointer-events: none; }
.reader .bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 70px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 12px env(safe-area-inset-bottom); z-index: 10; }
.reader .pind { font-size: 14px; opacity: .75; min-width: 90px; text-align: center; }
.navz { position: absolute; top: 64px; bottom: 70px; width: 16%; z-index: 4; cursor: pointer; }
.navz.l { left: 0; } .navz.r { right: 0; }
.pact { position: absolute; display: flex; gap: 6px; z-index: 3; }
.pact button { background: rgba(255,255,255,.92); color: #4a3f35; border-radius: 16px; padding: 5px 10px; font-size: 13px; font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.pact button.liked { color: #c0392b; }
.coverface { position: absolute; inset: 0; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.coverface .em { line-height: 1; }
.coverface .t { font-family: 'Lora', serif; font-weight: 700; line-height: 1.1; }

/* ---- éditeur */
.editor { position: fixed; inset: 0; display: flex; flex-direction: column; }
.etop { display: flex; align-items: center; gap: 6px; padding: 10px 12px; background: #fff; box-shadow: 0 2px 10px rgba(60,40,20,.1); z-index: 6; overflow-x: auto; }
.tb { height: 38px; padding: 0 13px; border-radius: 19px; display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: #5a4c3f; white-space: nowrap; }
.tb:hover { background: #f4ede3; }
.tb.on { background: #2f6f8f; color: #fff; }
.etop .status { font-size: 13px; color: #8a7a69; margin-left: auto; white-space: nowrap; padding: 0 8px; }
.ebody { flex: 1; display: flex; min-height: 0; }
.epanel { width: 270px; flex: none; background: #fff; border-right: 1px solid #eadfcf; overflow-y: auto; padding: 14px 12px 30px; }
.epanel h4 { font-size: 15px; margin: 4px 0 4px; }
.epanel .hint { font-size: 12.5px; color: #8a7a69; margin-bottom: 12px; line-height: 1.4; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; margin-bottom: 10px; }
.crumbs button { color: #2f6f8f; font-weight: 600; padding: 2px 4px; border-radius: 6px; }
.dirs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.dirs button { background: #f6f0e7; border-radius: 10px; padding: 10px 4px; font-weight: 650; font-size: 14px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.thumbs button { aspect-ratio: 1; border-radius: 7px; overflow: hidden; background: #eee4d6; position: relative; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .x { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #9a8a78; padding: 2px; text-align: center; }
.seg { display: flex; background: #f4ede3; border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 8px 6px; border-radius: 9px; font-size: 13px; font-weight: 650; color: #6b5b4b; }
.seg button.on { background: #fff; color: #2b2520; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { padding: 12px; border-radius: 10px; background: #f6f0e7; text-align: left; font-size: 15px; }
.opt.on { outline: 2px solid #2f6f8f; background: #eef5f8; }
.stk { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 14px; }
.stk button { aspect-ratio: 1; border-radius: 10px; background: #f6f0e7; font-size: 26px; display: flex; align-items: center; justify-content: center; }
.ecanvas { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; }
.ecanvas .pg { box-shadow: 0 20px 40px rgba(60,40,20,.25); border-radius: 4px; }
.sel-box { position: absolute; border: 2px solid #2f6f8f; pointer-events: none; transform-origin: 50% 50%; }
.handle { position: absolute; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid #2f6f8f; pointer-events: auto; touch-action: none; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #2f6f8f; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.handle.rs { right: -15px; bottom: -15px; cursor: nwse-resize; }
.handle.rot { left: 50%; top: -42px; margin-left: -13px; cursor: grab; }
.handle.del { right: -15px; top: -15px; background: #b5473f; border-color: #b5473f; color: #fff; cursor: pointer; }
.selbar { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; gap: 6px; background: #fff; padding: 6px; border-radius: 14px; box-shadow: 0 8px 20px rgba(0,0,0,.18); z-index: 4; }
.el.editable { cursor: move; touch-action: none; }
textarea.big { width: 100%; min-height: 90px; border: 1px solid #d8cbb8; border-radius: 10px; padding: 10px; font-size: 16px; resize: vertical; margin-bottom: 10px; }
.rowb { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.range { width: 100%; margin: 4px 0 14px; }
.lbl { font-size: 13px; color: #6b5b4b; font-weight: 650; margin: 6px 0; }

/* ---- famille */
.list { background: #fff; border-radius: 16px; box-shadow: 0 6px 18px rgba(60,40,20,.08); overflow: hidden; margin-bottom: 26px; }
.list .row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f0e8dc; }
.list .row:last-child { border-bottom: none; }
.list .row .nm { flex: 1; } .list .row .nm small { display: block; color: #8a7a69; font-size: 13px; }
.linkbox { background: #f6f0e7; border-radius: 12px; padding: 12px; font-size: 14px; overflow-wrap: anywhere; margin: 8px 0 12px; user-select: all; }

@media (max-width: 820px) {
  .ebody { flex-direction: column-reverse; }
  .epanel { width: auto; height: 38vh; border-right: none; border-top: 1px solid #eadfcf; }
  .thumbs { grid-template-columns: repeat(5, 1fr); }
  .dirs { grid-template-columns: repeat(4, 1fr); }
  .stk { grid-template-columns: repeat(8, 1fr); }
  .tb .lab { display: none; }
  .wrap h2 { font-size: 26px; }
  .books { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 16px; }
  .cover .em { font-size: 40px; } .cover .t { font-size: 19px; }
}
@media (max-width: 480px) { .appbar .logo .lt { display: none; } .appbar .avstack { display: none; } }
.livebadge { position: absolute; z-index: 2; background: rgba(255,255,255,.88); color: #3b3129; font-weight: 700; letter-spacing: .06em; padding: 2px 6px; border-radius: 6px; pointer-events: none; }
.el.photo.live { cursor: pointer; }
.livemini { position: absolute; left: 4px; top: 4px; background: rgba(255,255,255,.9); color: #3b3129; font-size: 9px; font-weight: 800; padding: 1px 4px; border-radius: 4px; }
.cover.photo { padding: 0; justify-content: flex-end; }
.cover.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.photo .shadeb { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.6), rgba(0,0,0,0) 60%); box-shadow: inset 10px 0 12px -6px rgba(0,0,0,.35); }
.cover.photo .txt { position: relative; padding: 14px 12px 18px; text-shadow: 0 2px 8px rgba(0,0,0,.4); }
.bk { position: relative; }
.bk .lock { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.92); border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
