/* ==========================================================================
   Burke Hedges Library — design system
   Navy #1C2B4A · Gold #E8B840 · Cream. Large type and 48px targets for older readers.
   ========================================================================== */

:root {
	--navy: #1C2B4A;
	--navy-2: #283b62;
	--gold: #E8B840;
	--gold-deep: #b98a14;

	--bg: #ffffff;
	--surface: #ffffff;
	--surface-2: #f6f7f9;
	--ink: #1b2230;
	--ink-2: #475063;
	--muted: #6b7384;
	--line: #e6e8ec;
	--focus: #2563eb;
	--ok: #127a3c;
	--ok-bg: #dcf3e4;
	--warn: #8a5b00;
	--warn-bg: #fff1cc;
	--bad: #a3271c;
	--bad-bg: #fde4e1;
	--accent: var(--navy);
	--accent-ink: #ffffff;
	--shadow: 0 1px 2px rgba(28, 43, 74, .06), 0 8px 24px rgba(28, 43, 74, .08);
	--radius: 16px;
	--radius-sm: 10px;

	--f-ui: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--f-display: "Cormorant Garamond", Georgia, serif;
	--f-read: "Literata", Georgia, "Times New Roman", serif;

	color-scheme: light;
}

:root[data-theme="night"] {
	--bg: #10151f;
	--surface: #171e2b;
	--surface-2: #1c2433;
	--ink: #e9ecf2;
	--ink-2: #c3c9d4;
	--muted: #98a1b2;
	--line: #2a3446;
	--focus: #8fb4ff;
	--accent: var(--gold);
	--accent-ink: #111826;
	--ok-bg: #133524; --ok: #7fe0a2;
	--warn-bg: #3a2c08; --warn: #ffd57a;
	--bad-bg: #3d1714; --bad: #ff9c92;
	--shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
	color-scheme: dark;
}

:root[data-theme="sepia"] {
	--bg: #f1e7d3;
	--surface: #f8f0de;
	--surface-2: #f3e8d2;
	--ink: #3b2f22;
	--ink-2: #5a4a37;
	--muted: #7a6a55;
	--line: #e0d2b6;
}

:root[data-theme="contrast"] {
	--bg: #000000;
	--surface: #000000;
	--surface-2: #0b0b0b;
	--ink: #ffffff;
	--ink-2: #ffffff;
	--muted: #e8e8e8;
	--line: #ffffff;
	--focus: #ffd400;
	--accent: #ffd400;
	--accent-ink: #000000;
	--shadow: none;
	color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 18px/1.55 var(--f-ui);
	-webkit-font-smoothing: antialiased;
	min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; color: var(--ink); }
h1 { font: 700 clamp(30px, 5vw, 42px)/1.12 var(--f-display); letter-spacing: -.01em; }
h2 { font-size: 22px; }
h3 { font-size: 19px; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 1000; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; text-decoration: none; }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }
.fine { font-size: 15px; color: var(--muted); }
.center { text-align: center; }
.lead { font-size: 19px; color: var(--ink-2); max-width: 46ch; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); margin: 0 0 8px; }
:root[data-theme="night"] .eyebrow, :root[data-theme="contrast"] .eyebrow { color: var(--gold); }
.kbd { font: 600 14px var(--f-ui); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; }

/* ---------- buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; padding: 10px 20px; border-radius: 12px; border: 2px solid transparent;
	font-weight: 700; font-size: 17px; text-decoration: none; cursor: pointer;
	transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink-2); }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-ghost { background: transparent; border: 0; color: var(--ink-2); font-weight: 600; cursor: pointer; }
.btn-lg { min-height: 56px; font-size: 18px; }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; pointer-events: none; }
.link { background: none; border: 0; padding: 6px 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 600; }
.link-danger { color: var(--bad); }

/* ---------- forms ---------- */
.form { display: grid; gap: 18px; margin-top: 18px; }
.field { display: grid; gap: 8px; font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); }
.field input, .share__input, .members__search, .search input, textarea {
	width: 100%; min-height: 56px; padding: 12px 16px; border-radius: 12px;
	border: 2px solid var(--line); background: var(--surface); font-size: 19px; color: var(--ink);
}
.field input:focus, textarea:focus, .search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.pin-input { letter-spacing: .35em; font-variant-numeric: tabular-nums; font-size: 24px !important; }
.pin-wrap { position: relative; }
.pin-wrap .btn-ghost { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
.form-error { background: var(--bad-bg); color: var(--bad); padding: 12px 14px; border-radius: 10px; margin: 0; font-weight: 600; }
.notice { background: var(--ok-bg); color: var(--ok); padding: 12px 14px; border-radius: 10px; margin: 0; }

/* ---------- switch ---------- */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 8px 0; font-size: 16px; }
.switch input { position: absolute; opacity: 0; }
.switch__ui { flex: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; }
.switch__ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .switch__ui { background: var(--accent); }
.switch input:checked + .switch__ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__ui { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.shell { max-width: 1120px; margin: 0 auto; padding: 32px 20px 80px; }
.shell--narrow { max-width: 720px; }
.section-title { font: 600 15px var(--f-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 40px 0 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }

/* ---------- brand & top bar ---------- */
.brand { display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; text-decoration: none; }
.brand__logo { display: block; width: 168px; height: auto; max-width: none; }
.brand__library { margin-left: 64px; margin-top: -2px; color: var(--muted); font-size: 10px; line-height: 1; letter-spacing: .28em; text-transform: uppercase; }
.auth .brand__logo { width: min(245px, 70vw); }
.auth .brand__library { margin-left: 92px; font-size: 12px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar__inner { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topnav { display: flex; gap: 4px; }
.topnav a { text-decoration: none; font-weight: 600; padding: 10px 14px; border-radius: 10px; color: var(--ink-2); }
.topnav a:hover { background: var(--surface-2); }
.topnav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -3px 0 var(--gold); }
@media (max-width: 560px) { .topbar .brand { width: 46px; overflow: hidden; } .topbar .brand__logo { width: 145px; } .topbar .brand__library { display: none; } .topnav a { padding: 10px; font-size: 16px; } }

/* ---------- auth screens ---------- */
.page-auth { background: var(--bg); }
:root[data-theme="night"] .auth__art { background: linear-gradient(160deg, #1C2B4A, #0c1528); }
:root[data-theme="night"] .auth__quote { color: #fff; }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth__art {
	background:
		radial-gradient(ellipse at 25% 15%, rgba(232, 184, 64, .22), transparent 55%),
		linear-gradient(160deg, #fbf8f1 0%, #f4efe3 100%);
	border-right: 1px solid var(--line);
	position: relative; display: flex; align-items: flex-end; padding: 56px;
}
.auth__art::before { content: ""; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M0 60h120M60 0v120' stroke='%231C2B4A' stroke-opacity='.05'/%3E%3C/svg%3E"); }
.auth__quote { position: relative; color: var(--navy); max-width: 30ch; }
.auth__quote p { font: 600 clamp(30px, 3.4vw, 46px)/1.15 var(--f-display); margin-bottom: 16px; }
.auth__quote span { color: var(--gold-deep); letter-spacing: .18em; text-transform: uppercase; font-size: 14px; font-weight: 700; }
.auth__panel { display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(20px, 6vw, 80px); gap: 28px; }
.auth__card { max-width: 480px; width: 100%; padding: 32px; }
.auth__switch { margin-top: 16px; text-align: center; }
.help { color: var(--muted); font-size: 16px; }
.done { text-align: center; padding: 12px 0; }
.done__icon { font-size: 44px; width: 84px; height: 84px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--gold); }
@media (max-width: 860px) {
	.auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
	.auth__art { min-height: 0; padding: 28px 22px; }
	.auth__art:empty { display: none; }
	.auth__quote p { font-size: 26px; }
	.auth__panel { justify-content: flex-start; padding-top: 28px; }
	.auth__card { padding: 24px 20px; }
}

/* ---------- library ---------- */
.hello { padding: 12px 0 4px; }
.continue__card {
	display: grid; grid-template-columns: 110px 1fr auto; gap: 22px; align-items: center;
	background: linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff;
	border-radius: 22px; padding: 20px; text-decoration: none; box-shadow: var(--shadow);
	transition: transform .15s;
}
.continue__card:hover { transform: translateY(-2px); }
.continue__card h3 { color: #fff; font: 700 26px/1.2 var(--f-display); margin: 0 0 12px; }
.continue__card .eyebrow { color: var(--gold); }
.continue__cover { width: 110px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.continue__meta { margin: 10px 0 0; color: #cfd6e4; font-size: 16px; }
.continue__play { width: 72px; height: 72px; border-radius: 50%; background: var(--gold); color: var(--navy); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(232, 184, 64, .45); }
.meter { height: 8px; border-radius: 999px; background: rgba(127, 127, 127, .25); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--gold); border-radius: inherit; width: 0; transition: width .4s; }
@media (max-width: 600px) {
	.continue__card { grid-template-columns: 76px 1fr; }
	.continue__cover { width: 76px; }
	.continue__play { grid-column: 1 / -1; width: 100%; height: 56px; border-radius: 14px; }
	.continue__card h3 { font-size: 22px; }
}
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; }
.book-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; text-decoration: none; transition: transform .15s, box-shadow .15s; }
.book-card:hover { transform: translateY(-3px); }
.book-card__art { background: linear-gradient(160deg, #1C2B4A, #0f1a30); padding: 26px 26px 0; display: flex; justify-content: center; }
.book-card__art img { width: 62%; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px 6px 0 0; box-shadow: 0 -4px 26px rgba(0,0,0,.4); }
.book-card__body { padding: 20px 22px 22px; display: grid; gap: 10px; flex: 1; }
.book-card__body h3 { font: 700 25px/1.15 var(--f-display); margin: 0; }
.book-card__sub { color: var(--ink-2); font-size: 16px; margin: 0; }
.book-card__meta { color: var(--muted); font-size: 15px; display: flex; gap: 12px; flex-wrap: wrap; }
.book-card__cta { margin-top: 6px; }
.book-card.skeleton { min-height: 420px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.tips__list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tips__list li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; color: var(--ink-2); }
.tips__list strong { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- licence (owner) ---------- */
.licence { margin-bottom: 40px; }
.licence__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.licence__head h2 { font: 700 30px var(--f-display); margin: 0 0 4px; }
.licence__dates { color: var(--muted); margin: 0; }
.status-pill { padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 15px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.status-pill[data-s="grace"] { background: var(--warn-bg); color: var(--warn); }
.status-pill[data-s="expired"], .status-pill[data-s="suspended"], .status-pill[data-s="refunded"] { background: var(--bad-bg); color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 6px; }
.stat__n { font: 700 32px/1 var(--f-display); color: var(--ink); }
.stat__l { color: var(--muted); font-size: 15px; }
@media (max-width: 800px) { .stats { grid-template-columns: 1fr 1fr; } }
.share__row { display: flex; gap: 10px; flex-wrap: wrap; }
.share__input { flex: 1 1 300px; font-family: ui-monospace, Consolas, monospace; font-size: 15px !important; }
.share__tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.members__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.members__head h3 { margin: 0; }
.members__search { max-width: 320px; min-height: 48px; font-size: 16px; }
.people { list-style: none; padding: 0; margin: 0; }
.people li { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; color: var(--ink-2); }
.people__name { font-weight: 700; }
.people__meta { color: var(--muted); font-size: 15px; }
.people__tag { font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }
.awaiting { background: var(--warn-bg); border-radius: 12px; padding: 12px 16px; margin: 8px 0 12px; }
.awaiting h4 { margin: 4px 0; color: var(--warn); }
.renew { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.renew__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- account ---------- */
.devices { list-style: none; padding: 0; margin: 0 0 16px; }
.devices li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }

/* ---------- toasts ---------- */
.toast-region { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000; display: grid; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 14px 18px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; animation: toast-in .2s ease-out; pointer-events: auto; }
.toast--bad { background: var(--bad); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle; opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print { body * { display: none !important; } body::before { content: "Printing is not available for licensed books."; display: block; padding: 40px; font: 20px sans-serif; } }
