/* FitnessWiki Books — reader app styles (login, library, reader) */
:root {
  --bg: #0d0f0c;
  --panel: #151913;
  --panel-2: #1c2119;
  --line: #2a3125;
  --text: #e9ede4;
  --muted: #8a9383;
  --accent: #c8f31d;
  --accent-ink: #0d0f0c;
  --danger: #ff6b5b;
  --radius: 16px;
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Anton', 'Impact', 'Arial Narrow', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: .9rem 1.5rem; font-weight: 800; text-decoration: none; font-size: 1rem;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px -8px rgba(200, 243, 29, .6); }
.btn:disabled { opacity: .6; cursor: progress; transform: none; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.block { width: 100%; }

/* ---------- centered card pages (login / messages) ---------- */
.center-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(60rem 30rem at 50% -10%, rgba(200, 243, 29, .12), transparent 60%), var(--bg); }
.card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 32px 26px; box-shadow: 0 30px 80px -30px rgba(0,0,0,.7); }
.card h1 { font-family: var(--display); font-weight: 400; text-transform: uppercase; letter-spacing: .01em; font-size: 2rem; line-height: 1.05; margin: 0 0 .5rem; }
.card p { line-height: 1.6; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: .12em; font-size: .78rem; color: var(--accent); margin-bottom: 1.5rem; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-size: .9rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 1.1rem 0 .45rem; }
input[type=email], input[type=text] {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: .95rem 1rem; font-size: 1.05rem; outline: none; transition: border-color .15s;
}
input:focus { border-color: var(--accent); }
.otp-input { letter-spacing: .5em; text-align: center; font-size: 1.6rem !important; font-weight: 800; }
.form-actions { margin-top: 1.2rem; display: grid; gap: .7rem; }
.notice { border-radius: 12px; padding: .8rem 1rem; font-size: .92rem; line-height: 1.5; margin-top: 1rem; }
.notice.error { background: rgba(255, 107, 91, .12); border: 1px solid rgba(255, 107, 91, .35); color: #ffb3aa; }
.notice.ok { background: rgba(200, 243, 29, .08); border: 1px solid rgba(200, 243, 29, .3); color: #e6f8a8; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: .3rem; font-size: .9rem; }
.small { font-size: .85rem; }

/* ---------- library ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem clamp(16px, 4vw, 40px); background: rgba(13, 15, 12, .85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar .brand { margin: 0; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px) 80px; }
.page-title { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: clamp(2rem, 6vw, 3rem); margin: .5rem 0 1.5rem; }
.book-card { display: grid; grid-template-columns: 160px 1fr; gap: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 24px; }
.book-card img { width: 100%; border-radius: 10px; box-shadow: 0 20px 40px -18px rgba(0,0,0,.9); }
.book-card h2 { margin: 0 0 .3rem; font-size: 1.5rem; }
.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 1rem 0 .4rem; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bonus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 18px; }
.bonus { display: block; text-decoration: none; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; transition: border-color .15s, transform .15s; }
.bonus:hover { border-color: var(--accent); transform: translateY(-2px); }
.bonus b { display: block; margin-bottom: .3rem; }
.bonus span { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.bonus .tag { display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .08em; color: var(--accent); margin-bottom: .4rem; }
@media (max-width: 600px) { .book-card { grid-template-columns: 1fr; } .book-card img { max-width: 180px; } }

/* ---------- reader ---------- */
body.reader { --r-bg: #fbfaf6; --r-text: #1d1f1a; --r-muted: #6b6f66; --r-line: #e6e3da; --r-panel: #ffffff; --r-link: #3d6b00;
  background: var(--r-bg); color: var(--r-text); transition: background .2s, color .2s; }
body.reader.theme-sepia { --r-bg: #f4ecd8; --r-text: #3b2f22; --r-muted: #7a6a55; --r-line: #e2d5b8; --r-panel: #faf3e2; --r-link: #6b4a00; }
body.reader.theme-dark { --r-bg: #111310; --r-text: #dfe3d9; --r-muted: #8a9383; --r-line: #262b22; --r-panel: #181c16; --r-link: #c8f31d; }

.r-bar { position: fixed; inset: 0 0 auto 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: .5rem; padding: 0 10px;
  background: color-mix(in srgb, var(--r-bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--r-line); transition: transform .25s ease; }
.r-bar.hide { transform: translateY(-100%); }
.r-title { flex: 1; min-width: 0; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; color: var(--r-muted); }
.icon-btn { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px; border: 0; background: transparent; color: var(--r-text); text-decoration: none; }
.icon-btn:hover { background: color-mix(in srgb, var(--r-text) 8%, transparent); }
.icon-btn svg { width: 22px; height: 22px; }
.r-progress { position: fixed; top: 56px; left: 0; right: 0; height: 3px; z-index: 31; background: transparent; }
.r-progress span { display: block; height: 100%; width: 0; background: var(--r-link); transition: width .1s linear; }

.r-main { max-width: var(--measure, 40rem); margin: 0 auto; padding: 88px 22px 40px; font-family: var(--r-font, Georgia, 'Iowan Old Style', 'Times New Roman', serif);
  font-size: var(--fs, 19px); line-height: var(--lh, 1.7); position: relative; }
.r-main.sans { --r-font: var(--font); }
.r-content h1 { font-family: var(--font); font-size: 1.7em; line-height: 1.2; margin: .5em 0 1em; letter-spacing: -.01em; }
.r-content h2 { font-family: var(--font); font-size: 1.2em; line-height: 1.3; margin: 2em 0 .7em; }
.r-content h3 { font-family: var(--font); font-size: 1.05em; margin: 1.6em 0 .5em; }
.r-content p { margin: 0 0 1em; }
.r-content a { color: var(--r-link); }
.r-content figure { margin: 1.8em 0; text-align: center; }
.r-content img { max-width: 100%; height: auto; border-radius: 10px; pointer-events: none; }
.r-content figcaption { font-family: var(--font); font-size: .72em; line-height: 1.5; color: var(--r-muted); margin-top: .7em; text-align: left; }
.r-content table { width: 100%; border-collapse: collapse; font-family: var(--font); font-size: .78em; line-height: 1.45; margin: 1.4em 0; display: block; overflow-x: auto; }
.r-content th, .r-content td { border: 1px solid var(--r-line); padding: .55em .7em; text-align: left; vertical-align: top; }
.r-content th { background: color-mix(in srgb, var(--r-text) 5%, transparent); }
.r-content blockquote { margin: 1.2em 0; padding: .2em 0 .2em 1em; border-left: 3px solid var(--r-link); color: var(--r-muted); }
.r-content ul, .r-content ol { padding-left: 1.3em; }
.r-content li { margin: .3em 0; }
.r-content .title-page { text-align: center; padding: 10vh 0; }
.r-content .author-name { letter-spacing: .2em; margin-top: 2em; }

/* deter copying (not bulletproof — nothing on the web is) */
.protected { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.watermark { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: .045; background-repeat: repeat; }
body.theme-dark .watermark { opacity: .06; filter: invert(1); }
@media print { body * { display: none !important; } body::after { content: 'Printing is disabled for this book.'; display: block; padding: 2rem; font: 16px sans-serif; } }

.r-nav { display: flex; justify-content: space-between; gap: 12px; max-width: var(--measure, 40rem); margin: 0 auto; padding: 8px 22px 60px; font-family: var(--font); }
.r-nav button, .r-nav a { flex: 1; text-align: left; background: var(--r-panel); border: 1px solid var(--r-line); color: var(--r-text); border-radius: 14px; padding: 14px 16px; text-decoration: none; min-width: 0; }
.r-nav .next { text-align: right; }
.r-nav small { display: block; color: var(--r-muted); font-size: .75rem; margin-bottom: .2rem; }
.r-nav b { display: block; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-nav [disabled] { visibility: hidden; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(380px, 88vw); z-index: 41; background: var(--r-panel); color: var(--r-text); border-right: 1px solid var(--r-line);
  transform: translateX(-102%); transition: transform .25s ease; display: flex; flex-direction: column; font-family: var(--font); }
.drawer.right { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--r-line); transform: translateX(102%); }
.drawer.open { transform: none; }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--r-line); }
.drawer header b { font-size: 1rem; }
.toc { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.toc a { display: flex; gap: .7rem; align-items: baseline; padding: 10px 12px; border-radius: 10px; color: var(--r-text); text-decoration: none; font-size: .92rem; line-height: 1.35; }
.toc a:hover { background: color-mix(in srgb, var(--r-text) 6%, transparent); }
.toc a.current { background: color-mix(in srgb, var(--r-link) 14%, transparent); font-weight: 700; }
.toc .meta { margin-left: auto; color: var(--r-muted); font-size: .75rem; white-space: nowrap; }
.toc .lock { opacity: .55; }
.settings { padding: 18px; display: grid; gap: 22px; }
.settings h4 { margin: 0 0 .6rem; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--r-muted); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 12px 8px; border-radius: 12px; border: 1px solid var(--r-line); background: transparent; color: var(--r-text); font-weight: 600; }
.seg button.active { border-color: var(--r-link); box-shadow: inset 0 0 0 1px var(--r-link); }
.swatch-light { background: #fbfaf6 !important; color: #1d1f1a !important; }
.swatch-sepia { background: #f4ecd8 !important; color: #3b2f22 !important; }
.swatch-dark { background: #111310 !important; color: #dfe3d9 !important; }

.paywall { font-family: var(--font); text-align: center; background: var(--r-panel); border: 1px solid var(--r-line); border-radius: 20px; padding: 32px 22px; margin: 2rem 0; }
.paywall h2 { margin: 0 0 .5rem; }
.paywall .btn { margin-top: 1rem; }
.sample-banner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 29; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #0d0f0c; color: #e9ede4; font-family: var(--font); font-size: .92rem; border-top: 1px solid #2a3125; }
.sample-banner .btn { padding: .65rem 1.1rem; font-size: .9rem; }
body.sample .r-nav { padding-bottom: 110px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: #0d0f0c; color: #e9ede4; border: 1px solid #2a3125; padding: 12px 18px; border-radius: 12px; font-family: var(--font); font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.loading { padding: 4rem 0; text-align: center; color: var(--r-muted); font-family: var(--font); }

/* ---------- admin ---------- */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 24px; border-bottom: 1px solid var(--line); }
.admin-tabs button { background: none; border: 0; color: var(--muted); padding: 12px 14px; font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.kpi small { display: block; color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpi b { display: block; font-size: 1.7rem; margin-top: .3rem; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .82rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 20px; overflow-x: auto; }
.panel h3 { margin: 0 0 12px; font-size: 1rem; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--panel-2); }
.pill { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .74rem; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); }
.pill.ok { color: var(--accent); border-color: rgba(200,243,29,.35); }
.pill.bad { color: #ffb3aa; border-color: rgba(255,107,91,.4); }
.pill.warn { color: #ffd27a; border-color: rgba(255,200,90,.4); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row input, .row select { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: .65rem .8rem; font: inherit; min-width: 0; }
.btn.sm { padding: .5rem .9rem; font-size: .85rem; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; position: relative; }
.bars div:hover { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; margin-top: 6px; }
.check { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; width: min(760px, 100%); max-height: 88dvh; overflow-y: auto; padding: 22px; }
