@font-face { font-family: "Literata"; src: url("/fonts/literata.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/fonts/atkinson-next.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #0f1522; --page: #121826; --raise: #1a2234; --line: #273147;
  --ink: #e6e8ec; --muted: #9aa3b2; --faint: #6b7487;
  --pen: #8fb2ff; --hl: 255, 214, 64; --note: #ffe68f; --coral: #ff8a70;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --serif: "Literata", "Noto Serif", Georgia, serif;
  --sans: "Atkinson", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }
[hidden] { display: none !important; }

/* the lesson list: rotation, then topic, then lessons */
.page { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 26px) 18px calc(env(safe-area-inset-bottom) + 48px); }
.head h1 { font-family: var(--serif); font-size: 34px; font-weight: 650; letter-spacing: -.015em; margin: 0; }
.head h1 span, .area h2 span { background: linear-gradient(180deg, transparent 58%, rgba(var(--hl), .32) 58%, rgba(var(--hl), .18) 90%, transparent 90%); padding: 0 .06em; }
.sub { color: var(--muted); font-size: 15px; margin: 6px 0 18px; min-height: 1.3em; }
.search { display: flex; align-items: center; gap: 10px; background: var(--raise); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; }
.search:focus-within { border-color: var(--pen); }
.search svg { width: 20px; height: 20px; flex: none; stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink); font: 17px var(--sans); padding: 13px 0; }
.search input::placeholder { color: var(--faint); }

.area { margin-top: 38px; }
.area h2 { font-family: var(--serif); font-size: 27px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 4px; display: flex; align-items: baseline; gap: 10px; }
.area h2 small { font-family: var(--sans); font-size: 14px; font-weight: 400; color: var(--muted); }
.area h3 { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--pen); margin: 22px 0 6px; }
.empty { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--muted); margin: 10px 0 0; }

.lesson { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; padding: 10px 8px 10px 4px; margin: 0 -4px; border-radius: 14px;
  transition: background .2s, transform .15s var(--ease); }
.lesson:active { background: rgba(143, 178, 255, .09); transform: scale(.985); }
@media (hover: hover) { .lesson:hover { background: rgba(143, 178, 255, .06); } }
.lesson .cover { flex: none; width: 58px; height: 82px; border-radius: 5px; object-fit: cover; object-position: top; background: var(--page);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 10px 20px -10px rgba(0, 0, 0, .8), 0 2px 5px rgba(0, 0, 0, .4); }
.lesson .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.lesson .title { font-size: 17px; line-height: 1.3; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lesson .meta { font-size: 14px; color: var(--muted); }
.lesson .meta b { color: var(--note); font-weight: 600; }
.lesson .go { flex: none; width: 18px; height: 18px; stroke: var(--faint); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* lesson reader */
.viewer { position: fixed; inset: 0; background: #0b101a; display: flex; flex-direction: column; animation: open .3s var(--ease); z-index: 20; }
.vbar { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; background: rgba(11, 16, 26, .96); border-bottom: 1px solid #1b2333; }
.vbar #vClose { display: flex; align-items: center; gap: 4px; font-size: 15px; color: var(--pen); padding: 6px 8px; border-radius: 10px; }
.vbar #vClose svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.vbar #vTitle { flex: 1; min-width: 0; font-family: var(--serif); font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.vbar #vPage { font-size: 14px; color: var(--muted); min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.vscroll { flex: 1; overflow: auto; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.vpages { padding: 10px 6px 40px; transform-origin: 0 0; width: max-content; min-width: 100%; }
.vpage { position: relative; margin: 0 auto 10px; background: #121826; border-radius: 3px; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); overflow: hidden; }
.vpage canvas { display: block; width: 100%; height: 100%; }
.vloading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--muted); font-size: 15px; }

@keyframes open { from { opacity: 0; transform: scale(.97); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* sign in */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; overflow: auto; }
.login form { width: min(360px, 100%); }
.login h1 { font-family: var(--serif); font-size: 40px; margin: 0 0 6px; letter-spacing: -.01em; }
.login h1 span { background: linear-gradient(180deg, transparent 56%, rgba(var(--hl), .34) 56%, rgba(var(--hl), .2) 90%, transparent 90%); padding: 0 .08em; }
.login p { color: var(--muted); margin: 0 0 26px; font-size: 16px; }
.login input { width: 100%; background: var(--raise); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; font: 17px var(--sans); }
.login button { width: 100%; margin-top: 12px; border-radius: 14px; padding: 15px; font-weight: 700; font-size: 16px; background: var(--pen); color: #0f1522; }
.login .err { color: var(--coral); margin-top: 12px; min-height: 1.4em; font-size: 15px; }
