:root {
  --bg: #14110d;
  --accent: #c9a35c;
  --ink: #efe6d4;
  --muted: #a89c86;
  --panel: rgba(20, 17, 13, 0.92);
  --bar-h: 56px;
  --top-h: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: Georgia, "Times New Roman", serif; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; }

/* Full-screen states: loading / lock / error */
.fb-screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at center, #241d15 0%, var(--bg) 70%); z-index: 10; }
.fb-brand-mark { font-size: 13px; letter-spacing: .35em; text-transform: uppercase; color: var(--accent); }
.fb-load-title { font-size: clamp(22px, 4vw, 34px); max-width: 640px; line-height: 1.2; }
.fb-progress { width: min(320px, 70vw); height: 2px; background: rgba(255,255,255,.12); overflow: hidden; }
.fb-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.fb-load-note, .fb-err-msg { color: var(--muted); font-size: 15px; max-width: 520px; }

.fb-lock-form { display: flex; flex-direction: column; gap: 12px; width: min(380px, 90vw); }
.fb-lock-form label { color: var(--muted); font-size: 15px; }
.fb-lock-row { display: flex; gap: 8px; }
.fb-lock-row input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 6px;
  border: 1px solid rgba(201,163,92,.45); background: rgba(0,0,0,.35); color: var(--ink); font-size: 16px; }
.fb-lock-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.fb-lock-row button { padding: 0 20px; border: 0; border-radius: 6px; background: var(--accent);
  color: #1b150e; font-weight: bold; cursor: pointer; }
.fb-lock-row button:disabled { opacity: .6; cursor: wait; }
.fb-lock-error { color: #e98b7a; min-height: 1.2em; font-size: 14px; }

.fb-shelf { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; width: min(480px, 90vw); }
.fb-shelf a { display: block; padding: 14px 16px; border: 1px solid rgba(201,163,92,.35); border-radius: 6px;
  color: var(--ink); text-decoration: none; text-align: left; }
.fb-shelf a:hover { border-color: var(--accent); }
.fb-shelf small { display: block; color: var(--muted); margin-top: 3px; }

/* Reader layout */
#fb-app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.fb-top { height: var(--top-h); flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 16px; border-bottom: 1px solid rgba(201,163,92,.18); }
.fb-titles { min-width: 0; display: flex; align-items: baseline; gap: 10px; overflow: hidden; }
.fb-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-subtitle { font-size: 13px; color: var(--muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-brand-link { flex: none; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--accent); text-decoration: none; }
.fb-brand-link img { height: 26px; display: block; }

.fb-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.fb-zoom { position: absolute; inset: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.fb-zoom.is-zoomed { overflow: auto; display: block; cursor: grab; }
.fb-book-wrap { margin: 0 auto; transform-origin: center center; transition: transform .25s ease; }
.fb-zoom.is-zoomed .fb-book-wrap { transform-origin: 0 0; }

.fb-page { background: #f4efe6; overflow: hidden; }
.fb-page img { width: 100%; height: 100%; display: block; object-fit: fill; user-select: none; -webkit-user-drag: none; }
.fb-page .fb-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: #e9e2d4; color: #8d806a; font-size: 13px; letter-spacing: .2em; }

.fb-side { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 72px; border: 0;
  background: rgba(0,0,0,.25); color: var(--ink); font-size: 34px; cursor: pointer; border-radius: 6px; z-index: 5; }
.fb-side:hover { background: rgba(0,0,0,.5); color: var(--accent); }
.fb-side-prev { left: 8px; } .fb-side-next { right: 8px; }

.fb-bar { height: var(--bar-h); flex: none; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0 8px; border-top: 1px solid rgba(201,163,92,.18); background: var(--panel); overflow-x: auto; }
.fb-bar button { width: 40px; height: 40px; flex: none; border: 0; border-radius: 6px; background: transparent;
  color: var(--ink); font-size: 18px; cursor: pointer; }
.fb-bar button:hover, .fb-bar button.is-on { color: var(--accent); background: rgba(201,163,92,.12); }
.fb-bar button:focus-visible, .fb-side:focus-visible { outline: 2px solid var(--accent); }
.fb-sep { width: 1px; height: 24px; background: rgba(255,255,255,.15); margin: 0 6px; flex: none; }
.fb-counter { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--muted); padding: 0 6px; flex: none; }
.fb-counter input { width: 52px; text-align: center; padding: 6px 2px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.3); color: var(--ink); font: inherit; }

.fb-thumbs { flex: none; height: 132px; display: flex; gap: 10px; padding: 10px 14px; overflow-x: auto;
  border-top: 1px solid rgba(201,163,92,.18); background: rgba(0,0,0,.35); }
.fb-thumb { flex: none; width: 76px; cursor: pointer; text-align: center; font-size: 11px; color: var(--muted); border: 0;
  background: none; padding: 0; }
.fb-thumb .fb-thumb-img { width: 76px; height: 96px; background: #2a2219 center/cover no-repeat; border: 2px solid transparent; }
.fb-thumb.is-current .fb-thumb-img { border-color: var(--accent); }

.fb-toast { position: fixed; left: 50%; bottom: calc(var(--bar-h) + 16px); transform: translateX(-50%) translateY(10px);
  background: #000; color: var(--ink); padding: 10px 16px; border-radius: 6px; font-size: 14px; opacity: 0;
  pointer-events: none; transition: all .25s; border: 1px solid rgba(201,163,92,.4); }
.fb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
  .fb-subtitle, .fb-side { display: none; }
  .fb-bar { justify-content: flex-start; }
  .fb-bar #fb-first, .fb-bar #fb-last { display: none; }
}

.fb-gate-input { width: 100%; padding: 12px 14px; border-radius: 6px; border: 1px solid rgba(201,163,92,.45);
  background: rgba(0,0,0,.35); color: var(--ink); font-size: 16px; font-family: inherit; }
.fb-gate-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Access form */
.fb-lock-form { display: flex; flex-direction: column; gap: 10px; width: min(380px, 90vw); }
.fb-lock-intro { color: var(--muted); font-size: 15px; margin: 0 0 4px; }
.fb-gate-input { width: 100%; padding: 12px 14px; border-radius: 6px; border: 1px solid rgba(201,163,92,.45);
  background: rgba(0,0,0,.35); color: var(--ink); font-size: 16px; font-family: inherit; }
.fb-gate-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.fb-gate-input.is-bad { border-color: #e98b7a; }
.fb-open-btn { padding: 13px; border: 0; border-radius: 6px; background: var(--accent); color: #1b150e;
  font-weight: bold; font-size: 16px; cursor: pointer; font-family: inherit; }
.fb-open-btn:disabled { opacity: .6; cursor: wait; }

/* Embedded in a page: no top bar */
body.is-embed .fb-top { display: none; }

/* Library page */
body.fb-library { overflow: auto; height: auto; min-height: 100%; }
.fb-lib-head { text-align: center; padding: 48px 16px 12px; }
.fb-lib-head .fb-brand-mark { text-decoration: none; }
.fb-lib-head h1 { font-weight: normal; font-size: clamp(30px, 5vw, 46px); margin: 12px 0 0; }
.fb-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 28px;
  max-width: 1100px; margin: 0 auto; padding: 32px 20px 60px; }
.fb-lib-card { color: var(--ink); text-decoration: none; display: flex; flex-direction: column; gap: 6px; }
.fb-lib-cover { aspect-ratio: 1 / 1.414; background: #241d15; border: 1px solid rgba(201,163,92,.3); overflow: hidden;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: transform .2s; }
.fb-lib-card:hover .fb-lib-cover { transform: translateY(-4px); border-color: var(--accent); }
.fb-lib-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fb-lib-cover-text { padding: 16px; text-align: center; color: var(--accent); font-size: 20px; }
.fb-lib-title { font-size: 17px; }
.fb-lib-sub { font-size: 14px; color: var(--muted); font-style: italic; }
.fb-lib-lock { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }

.fb-consent { display: flex; gap: 10px; align-items: flex-start; text-align: left; font-size: 14px; color: var(--muted); line-height: 1.4; cursor: pointer; }
.fb-consent input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

/* Book host */
.fb-book { width: 100%; height: 100%; }
body.is-spread .fb-book-wrap { filter: drop-shadow(0 18px 30px rgba(0,0,0,.45)); }

/* Clickable links inside pages */
.fb-page { position: relative; }
.fb-link { position: absolute; display: block; z-index: 3; cursor: pointer; border-radius: 3px; transition: background .2s; }
.fb-link:hover { background: rgba(201,163,92,.22); outline: 1px solid rgba(201,163,92,.6); }

/* Slide effect */
.fb-slider { position: relative; overflow: hidden; touch-action: pan-y pinch-zoom; user-select: none; }
.fb-track { display: flex; width: 100%; height: 100%; transition: transform .45s cubic-bezier(.22,.7,.2,1); }
.fb-slide { flex: 0 0 100%; height: 100%; display: flex; justify-content: center; }
.fb-slide .fb-page { height: 100%; aspect-ratio: auto; flex: 0 0 auto; width: 100%; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.fb-slide.is-pair .fb-page { width: 50%; }
.fb-slide.is-pair .fb-page:first-child { box-shadow: inset -18px 0 24px -18px rgba(0,0,0,.35), 0 6px 24px rgba(0,0,0,.35); }
.fb-slide.is-pair .fb-page:last-child { box-shadow: inset 18px 0 24px -18px rgba(0,0,0,.35), 0 6px 24px rgba(0,0,0,.35); }
body.is-spread .fb-slide:not(.is-pair) .fb-page { width: 50%; }

/* Share panel */
.fb-share-panel { position: fixed; right: 14px; bottom: calc(var(--bar-h) + 10px); z-index: 20; width: 230px;
  background: #1d1812; border: 1px solid rgba(201,163,92,.35); border-radius: 10px; padding: 8px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.fb-share-title { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); padding: 6px 10px 8px; }
.fb-share-panel a, .fb-share-panel button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0;
  background: none; color: var(--ink); text-decoration: none; font: inherit; font-size: 15px; cursor: pointer; border-radius: 6px; text-align: left; }
.fb-share-panel a:hover, .fb-share-panel button:hover { background: rgba(201,163,92,.12); }
.fb-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Phones on their side and short screens: give the magazine the whole screen */
@media (max-height: 520px) {
  :root { --bar-h: 44px; }
  .fb-top { display: none; }
  .fb-side { display: none; }
  .fb-bar button { width: 36px; height: 36px; font-size: 16px; }
  .fb-thumbs { height: 104px; }
  .fb-thumb .fb-thumb-img { height: 68px; width: 54px; }
  .fb-thumb { width: 54px; }
}

.fb-page img.fb-lowres { filter: blur(1.5px); transform: scale(1.01); }
