:root {
  --paper: #f7f3ec; --card: #fffdf9; --ink: #1f2320; --muted: #6b6f69; --line: #e4ddd0;
  --accent: #1d4d3f; --accent-2: #2e6b58; --gold: #c8912f; --err: #a33a2c; --ok: #2f6d3a;
  --r: 12px; --serif: 'Fraunces', Georgia, serif; --sans: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--accent); }
h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; }
img { max-width: 100%; display: block; }

.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-in, .foot-in, .wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 16px; align-items: center; font-size: .95rem; }
.top nav a:not(.btn) { color: var(--ink); text-decoration: none; }
.wrap { padding-top: 32px; padding-bottom: 56px; min-height: 70vh; }

.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: .65rem 1.3rem;
  font: 600 .95rem var(--sans); text-decoration: none; cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-sm { padding: .4rem 1rem; font-size: .85rem; color: #fff !important; }
.btn-block { width: 100%; padding: .85rem; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

.hero { text-align: center; max-width: 680px; margin: 8px auto 40px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--gold); font-weight: 600; margin: 0 0 8px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); }
.lead { color: var(--muted); font-size: 1.08rem; }
.steps { list-style: none; padding: 0; margin: 24px 0 0; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; font-size: .9rem; }
.steps li { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px 6px 6px; display: flex; align-items: center; gap: 8px; }
.steps b { background: var(--accent); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.cover { aspect-ratio: 3/4; background: var(--accent); display: grid; place-items: center; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover span { color: #f3e9d6; font-family: var(--serif); font-size: 1.4rem; padding: 24px; text-align: center; }
.card-body { padding: 16px; display: flex; flex-direction: column; flex: 1; }
.card h2 { font-size: 1.15rem; }
.author { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }
.desc { font-size: .92rem; color: #454942; margin: 0 0 16px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; }
.owned { color: var(--ok); font-weight: 600; font-size: .9rem; }

.auth { max-width: 420px; margin: 24px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; }
.muted { color: var(--muted); }
.form label { display: block; font-size: .85rem; font-weight: 600; margin: 16px 0 6px; }
.form input, .form textarea { width: 100%; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }
.form input:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form .btn { margin-top: 20px; }
.otp { font-size: 1.6rem !important; letter-spacing: .5em; text-align: center; }
.resend { text-align: center; margin-top: 16px; font-size: .9rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.alert { background: #fbf3df; border: 1px solid #ecd9a8; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: .92rem; }
.alert-err { background: #fbe9e6; border-color: #efc2ba; color: var(--err); }
.alert-ok { background: #e7f3e8; border-color: #bcdcc0; color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.page-head { margin-bottom: 24px; }
.list { display: grid; gap: 12px; }
.list-item { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 16px; text-decoration: none; color: var(--ink); }
.list-item h2 { font-size: 1.05rem; margin: 0; }
.list-item p { margin: 0; font-size: .85rem; }
.thumb { width: 56px; aspect-ratio: 3/4; background: var(--accent); border-radius: 6px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; font-size: .85rem; color: var(--muted); }
.stats span { display: block; font-family: var(--serif); font-size: 1.6rem; color: var(--ink); font-weight: 600; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 24px; }
.panel h2 { font-size: 1.2rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.inline { display: flex; gap: 8px; align-items: center; margin: 0; }
.small-input { width: 80px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.mono { font-family: ui-monospace, monospace; font-size: .8rem; }

.prose { max-width: 720px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; }

.foot { border-top: 1px solid var(--line); padding: 24px 0; font-size: .85rem; color: var(--muted); }
.foot nav { display: flex; gap: 16px; flex-wrap: wrap; }
.foot a { color: var(--muted); }

/* ---------- Reader ---------- */
.reader-body { background: #3a3d3a; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.rbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #1f2320; color: #eee; font-size: .9rem; }
.rbar a { color: #eee; text-decoration: none; white-space: nowrap; }
.rtitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--serif); }
.rctl { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.rctl button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid #555; background: #2c302c; color: #fff; font-size: 1.1rem; cursor: pointer; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px 8px 64px; overflow-x: auto; }
.page { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.35); flex: none; pointer-events: none; }
.page canvas { display: block; }
.hidden-pages { filter: blur(24px); }
.shield { position: fixed; inset: 0; background: rgba(20,22,20,.92); display: grid; place-items: center; z-index: 20; color: #fff; text-align: center; }
.shield[hidden] { display: none; }
.reader-body .empty { color: #ddd; }
@media print { body * { display: none !important; } body::after { content: 'Printing is disabled.'; display: block; padding: 40px; } }
@media (max-width: 480px) { .rback { font-size: 0; } .rback::before { content: '←'; font-size: 1.2rem; } }
