/* Top Hat Atlas website: one stylesheet for every page.

   The look (owner, 28 Nov 2026): modern and premium. Clean system type for
   headings and controls, generous space, soft depth. The home page is one
   dark stage for the books. The books' own typeface (Alegreya, SIL OFL,
   served from this site) is kept for reading the stories. */

@font-face { font-family: "Alegreya"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/Alegreya-Regular.5f7c2df530.woff") format("woff"); }
@font-face { font-family: "Alegreya"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("/assets/Alegreya-Italic.313b90780b.woff") format("woff"); }
@font-face { font-family: "Alegreya"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/assets/Alegreya-Bold.96a465381f.woff") format("woff"); }
@font-face { font-family: "Alegreya SC"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/AlegreyaSC-Regular.bd89ebff0f.woff") format("woff"); }

:root {
  --page: #fbfbfd;
  --grey: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-soft: #6e6e73;
  --ink-faint: #86868b;
  --hairline: rgba(0, 0, 0, 0.1);
  --dark: #0b0b0c;
  --dark-2: #161617;
  --on-dark: #f5f5f7;
  --on-dark-soft: #a1a1a6;
  --paper: #f8f4ea;
  --accent: #0071e3;
  --radius: 22px;
  --shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.28), 0 12px 24px -16px rgba(0, 0, 0, 0.12);
  --wide: 75rem;
  --text: 42rem;
  --header: 3.5rem;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --caps: "Alegreya SC", "Alegreya", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header) + 1rem); }
html.dark { background: var(--dark); color-scheme: dark; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font-family: var(--sans); font-size: 1.0625rem; line-height: 1.5; letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: clip;
}
html.dark body { background: var(--dark); color: var(--on-dark); }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px;
}
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; z-index: 60; background: var(--card); color: var(--ink); padding: 0.5rem 1rem; border-radius: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------------------------------------------------------------- type */

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.025em; line-height: 1.08; }
.display { font-size: clamp(2.2rem, 5.5vw, 3.6rem); }
.display.small { font-size: clamp(1.5rem, 3vw, 2rem); }
.headline { font-size: clamp(2.2rem, 5.6vw, 4.2rem); letter-spacing: -0.035em; line-height: 1.04; }
.eyebrow { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 0.8rem; }
html.dark .eyebrow { color: var(--on-dark-soft); }
.eyebrow a { text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.lead { font-size: clamp(1.15rem, 2vw, 1.4rem); line-height: 1.4; color: var(--ink-soft); max-width: 36rem; letter-spacing: -0.015em; }
.note { color: var(--ink-soft); font-size: 1rem; }
.fine { color: var(--ink-faint); font-size: 0.85rem; line-height: 1.45; }
.second-line { font-family: var(--serif); font-style: italic; font-size: 1.15rem; color: var(--ink-soft); margin: 0.6rem 0 1.8rem; letter-spacing: 0; }

/* ---------------------------------------------------------------- buttons */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font: inherit; font-size: 1.02rem; font-weight: 500; letter-spacing: -0.01em;
  color: #fff; background: var(--ink); border: 1px solid transparent; border-radius: 999px;
  padding: 0.75rem 1.4rem; min-height: 2.9rem; text-decoration: none; cursor: pointer;
  transition: transform 0.3s var(--ease), background 0.25s, color 0.25s;
}
.button:hover { background: #000; transform: scale(1.02); }
.button.light { background: #fff; color: var(--ink); }
.button.light:hover { background: #e8e8ed; }
.button.quiet, .button.ghost { background: transparent; color: var(--ink); border-color: rgba(0, 0, 0, 0.2); }
.button.quiet:hover, .button.ghost:hover { background: rgba(0, 0, 0, 0.05); }
.button.small { min-height: 2.3rem; padding: 0.4rem 1rem; font-size: 0.95rem; }
.button.wide { width: 100%; }
.button.danger { background: transparent; color: #c1271b; border-color: rgba(193, 39, 27, 0.5); }
.button.danger:hover { background: #c1271b; color: #fff; }
.button[disabled] { opacity: 0.5; cursor: wait; }
.text-link { font: inherit; font-weight: 500; color: var(--accent); background: none; border: 0; padding: 0.4rem 0; cursor: pointer; text-decoration: none; }
.text-link::after { content: " ›"; }
.text-link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- header */

.masthead {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: var(--header); padding: 0 clamp(16px, 3vw, 2.2rem);
  background: rgba(251, 251, 253, 0.74);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
html.dark .masthead { background: rgba(11, 11, 12, 0.72); color: var(--on-dark); border-bottom-color: rgba(255, 255, 255, 0.08); }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; font-size: 1.1rem; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.brand img { width: 1.85rem; height: auto; }
html.dark .brand img { filter: invert(1); }
.account-nav { display: flex; align-items: center; gap: 0.55rem; }
.nav-pill {
  display: inline-flex; align-items: center; height: 2.1rem; padding: 0 0.95rem; border-radius: 999px;
  font-size: 0.88rem; font-weight: 500; text-decoration: none; white-space: nowrap;
  border: 1px solid rgba(0, 0, 0, 0.16); transition: background 0.2s, border-color 0.2s;
}
.nav-pill:hover { background: rgba(0, 0, 0, 0.05); }
.nav-pill.solid { background: var(--ink); color: #fff; border-color: var(--ink); }
.nav-pill.solid:hover { background: #000; }
html.dark .nav-pill { border-color: rgba(255, 255, 255, 0.22); }
html.dark .nav-pill:hover { background: rgba(255, 255, 255, 0.1); }
html.dark .nav-pill.solid { background: #fff; color: var(--ink); border-color: #fff; }
html.dark .nav-pill.solid:hover { background: #e8e8ed; }
.nav-avatar { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; text-decoration: none; font-weight: 600; font-size: 0.95rem; background: linear-gradient(135deg, #5e5ce6, #bf5af2); color: #fff; }
@media (max-width: 30rem) {
  .brand span { display: none; }
  .nav-pill { padding: 0 0.8rem; font-size: 0.85rem; }
}
main { display: block; }

/* ---------------------------------------------------------------- footer */

.colophon { background: var(--grey); border-top: 1px solid var(--hairline); margin-top: 6rem; padding: 2.5rem 16px 3rem; text-align: center; color: var(--ink-soft); font-size: 0.85rem; }
.colophon p { margin: 0.35rem 0; }
.colophon a { text-decoration: none; }
.colophon a:hover { text-decoration: underline; }
.colophon-mark { font-weight: 600; color: var(--ink); font-size: 1rem; }
html.dark .colophon { background: var(--dark); border-top-color: rgba(255, 255, 255, 0.08); color: var(--on-dark-soft); margin-top: 0; }
html.dark .colophon-mark { color: var(--on-dark); }

.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.6rem 2rem; margin-bottom: 1.6rem; }
.section-head .note { margin: 0; max-width: 32rem; }

/* ================================================================ HOME (all dark) */

/* --- the books, turning */
.hero { position: relative; overflow: hidden; isolation: isolate; padding: clamp(1.2rem, 3.5vh, 2.4rem) 0 clamp(1.5rem, 5vh, 3rem); }
.hero-glow {
  position: absolute; z-index: -1; left: 50%; top: 55%; width: min(95vw, 1100px); aspect-ratio: 1.7;
  transform: translate(-50%, -50%); border-radius: 50%;
  background-color: #6b5a3e; filter: blur(120px); opacity: 0.5; transition: background-color 1.6s var(--ease);
}
.finder { max-width: 30rem; margin: 0 auto; padding: 0 16px; position: relative; z-index: 150; }
.finder-box { position: relative; }
.finder-icon { position: absolute; left: 1.05rem; top: 50%; width: 1.1rem; height: 1.1rem; transform: translateY(-50%); color: var(--on-dark-soft); pointer-events: none; z-index: 1; }
.finder input {
  width: 100%; font: inherit; font-size: 1rem; color: var(--on-dark);
  background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px;
  padding: 0.78rem 1.2rem 0.78rem 2.8rem; -webkit-appearance: none; appearance: none;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.finder input::placeholder { color: var(--on-dark-soft); }
.finder input:focus { outline: none; background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.35); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08); }
.finder-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 0.5rem); margin: 0; padding: 0.4rem; list-style: none;
  background: rgba(30, 30, 32, 0.9); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 18px;
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
}
.finder-results li { padding: 0.6rem 0.9rem; border-radius: 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; color: var(--on-dark); }
.finder-results li small { color: var(--on-dark-soft); white-space: nowrap; }
.finder-results li.is-active, .finder-results li:hover { background: rgba(255, 255, 255, 0.1); }

.carousel {
  --bw: clamp(230px, min(42vh, 34vw), 450px);
  --bh: calc(var(--bw) * 1.294);
  --bd: calc(var(--bw) * 0.06);
  position: relative; height: calc(var(--bh) + 4rem); margin-top: clamp(1rem, 3vh, 2rem);
  perspective: 2200px; perspective-origin: 50% 40%; overflow: hidden; touch-action: pan-y; outline: none; user-select: none; -webkit-user-select: none;
}
@media (max-width: 640px) { .carousel { --bw: min(66vw, 300px); } }
.carousel-track { list-style: none; margin: 0; padding: 0 16px; display: flex; gap: 1.5rem; overflow-x: auto; }
.carousel.is-3d .carousel-track { position: absolute; inset: 0; padding: 0; overflow: visible; transform-style: preserve-3d; display: block; }
.carousel.is-3d .book {
  --dim: 0;
  position: absolute; left: 50%; top: 1.2rem; width: var(--bw); margin-left: calc(var(--bw) / -2);
  transform-style: preserve-3d; filter: brightness(calc(1 - var(--dim) * 0.48)) saturate(calc(1 - var(--dim) * 0.15));
}
.carousel.is-3d .book.is-far { pointer-events: none; }
.book-link { display: block; position: relative; transform-style: preserve-3d; text-decoration: none; color: inherit; -webkit-user-drag: none; }
.book-link img { -webkit-user-drag: none; }
.book3d { display: block; position: relative; width: var(--bw); height: var(--bh); transform-style: preserve-3d; }
.book.nudge .book3d { animation: nudge 0.6s var(--ease); }
@keyframes nudge { 30% { transform: rotateY(-10deg) translateX(-6px); } 65% { transform: rotateY(6deg) translateX(4px); } }
.face { position: absolute; display: block; }
.face.front { inset: 0; width: 100%; height: 100%; object-fit: cover; transform: translateZ(calc(var(--bd) / 2)); border-radius: 2px 5px 5px 2px;
  box-shadow: inset 6px 0 8px -5px rgba(0, 0, 0, 0.35), 0 40px 80px -30px rgba(0, 0, 0, 0.9); }
.face.back { inset: 0; background: #d9cfb7; border-radius: 5px 2px 2px 5px; transform: rotateY(180deg) translateZ(calc(var(--bd) / 2)); }
.face.spine, .face.pages { top: 0; height: 100%; width: var(--bd); left: calc((var(--bw) - var(--bd)) / 2); }
.face.spine { background: linear-gradient(90deg, #c9bea4, #ece4d0 45%, #c4b89c); transform: rotateY(-90deg) translateZ(calc(var(--bw) / 2)); }
.face.pages { background: repeating-linear-gradient(90deg, #f6f1e4 0 1px, #d9d0bc 1px 2px); transform: rotateY(90deg) translateZ(calc(var(--bw) / 2 - 1px)); }
.face.top { left: 0; width: 100%; height: var(--bd); top: calc((var(--bh) - var(--bd)) / 2);
  background: repeating-linear-gradient(0deg, #f6f1e4 0 1px, #d9d0bc 1px 2px); transform: rotateX(90deg) translateZ(calc(var(--bh) / 2)); }
.carousel.is-3d .book::after {
  content: ""; position: absolute; left: 4%; right: 4%; top: calc(var(--bh) + 0.4rem); height: 2.4rem;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.75), transparent 70%); filter: blur(6px); transform: translateZ(-2px);
}
.book-cta {
  position: absolute; left: 50%; bottom: 1.1rem; transform: translate(-50%, 10px) translateZ(calc(var(--bd) / 2 + 2px));
  white-space: nowrap; font-size: 0.88rem; font-weight: 500; color: #fff; padding: 0.5rem 1rem; border-radius: 999px;
  background: rgba(20, 20, 22, 0.62); backdrop-filter: blur(14px) saturate(180%); -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.16); opacity: 0; transition: opacity 0.35s, transform 0.35s var(--ease); pointer-events: none;
}
.carousel:not(.is-3d) .book-cta { display: none; }
.book.is-current .book-link:hover .book-cta, .book.is-current .book-link:focus-visible .book-cta { opacity: 1; transform: translate(-50%, 0) translateZ(calc(var(--bd) / 2 + 2px)); }
@media (hover: none) { .book.is-current .book-cta { opacity: 1; transform: translate(-50%, 0) translateZ(calc(var(--bd) / 2 + 2px)); } }
.carousel-arrow {
  position: absolute; top: calc(1.2rem + var(--bh) / 2 - 1.4rem); z-index: 2000;
  width: 2.8rem; height: 2.8rem; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.12); color: #fff; cursor: pointer; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: background 0.25s, transform 0.25s var(--ease);
}
.carousel-arrow svg { width: 1.1rem; height: 1.1rem; }
.carousel-arrow:hover { background: rgba(255, 255, 255, 0.24); transform: scale(1.06); }
.carousel-arrow.prev { left: clamp(10px, 5vw, 4rem); }
.carousel-arrow.next { right: clamp(10px, 5vw, 4rem); }

/* --- drawings from the books, turning over one at a time */
.inside { max-width: 66rem; margin: 0 auto; padding: clamp(4rem, 12vh, 7rem) clamp(16px, 4vw, 3rem) clamp(2rem, 6vh, 4rem); }
.show-head { margin: 0 auto 2.6rem; text-align: center; }
.flip-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(0.8rem, 2.6vw, 1.8rem); perspective: 1800px; }
@media (max-width: 34rem) { .flip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.flip { aspect-ratio: 900 / 1306; }
.flip-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 1.3s cubic-bezier(0.45, 0.05, 0.25, 1); }
.flip-face {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; background: var(--paper);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 40px 70px -36px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.flip-face.back { transform: rotateY(180deg); }

/* --- the code on the back of every picture */
.qr-explain {
  max-width: var(--wide); margin: 0 auto; padding: clamp(4rem, 12vh, 8rem) clamp(16px, 4vw, 3rem) clamp(5rem, 14vh, 9rem);
  display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: clamp(2rem, 6vw, 5rem); align-items: center;
}
.qr-stage { --qx: 83%; --qy: 9%; position: relative; justify-self: center; width: min(100%, 26rem); border-radius: 6px; overflow: hidden; box-shadow: 0 60px 100px -45px rgba(0, 0, 0, 0.95); }
.qr-page { width: 100%; transform-origin: var(--qx) var(--qy); transition: transform 1.6s var(--ease) 0.2s; }
.qr-stage.is-in .qr-page { transform: scale(1.18); }
.qr-ring {
  position: absolute; left: var(--left); top: var(--top); width: var(--width); height: var(--height);
  border-radius: 10px; box-shadow: 0 0 0 3px #0a84ff, 0 0 0 9999px rgba(0, 0, 0, 0); pointer-events: none;
  transform: scale(2.2); transform-origin: 50% 50%; opacity: 0;
  transition: opacity 0.6s 1.2s, transform 1.6s var(--ease) 0.2s, box-shadow 1s 1.4s;
}
.qr-stage.is-in .qr-ring { opacity: 1; transform: scale(1.5); box-shadow: 0 0 0 3px #0a84ff, 0 0 0 9999px rgba(0, 0, 0, 0.45); animation: ring 2.4s ease-in-out 2.6s infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 7px rgba(10, 132, 255, 0.55), 0 0 0 9999px rgba(0, 0, 0, 0.45); } }
.qr-copy .headline { margin-bottom: 2rem; }
.qr-actions { margin: 0; }
@media (max-width: 760px) {
  .qr-explain { grid-template-columns: 1fr; text-align: center; }
}

/* ================================================================ SIGN IN AND WELCOME */

body[data-page="login"], body[data-page="signup"], body[data-page="welcome"] { background: var(--grey); }
body[data-page="login"] .colophon, body[data-page="signup"] .colophon, body[data-page="welcome"] .colophon { margin-top: 3rem; }
.auth { min-height: calc(100svh - var(--header) - 9rem); display: grid; place-items: center; padding: 3rem 16px 1rem; }
.auth-card {
  width: min(100%, 25rem); background: var(--card); border-radius: 28px; padding: 2.4rem clamp(1.4rem, 5vw, 2.2rem) 1.8rem;
  box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.04); text-align: center;
}
.auth-mark { width: 3.2rem; margin: 0 auto 1.1rem; }
.auth-card h1 { font-size: 1.65rem; letter-spacing: -0.03em; }
.auth-sub { color: var(--ink-soft); margin: 0.5rem 0 1.6rem; }
.auth-problem { background: #fff4e5; color: #8a4b00; border-radius: 12px; padding: 0.6rem 0.9rem; font-size: 0.92rem; margin: -0.4rem 0 1.2rem; }
.auth-buttons { display: grid; gap: 0.7rem; }
.auth-btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 0.7rem;
  height: 3.1rem; border-radius: 14px; font: inherit; font-size: 1.02rem; font-weight: 500; text-decoration: none; cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.16); background: #fff; color: var(--ink); transition: background 0.2s, transform 0.2s var(--ease);
}
.auth-btn:hover { background: #f5f5f7; }
.auth-btn:active { transform: scale(0.99); }
.auth-btn svg { position: absolute; left: 1.1rem; width: 1.25rem; height: 1.25rem; }
.auth-btn.apple { background: #000; color: #fff; border-color: #000; }
.auth-btn.apple:hover { background: #1d1d1f; }
.auth-btn.apple svg { width: 1.1rem; height: 1.3rem; top: 50%; transform: translateY(-58%); }
.auth-or { display: flex; align-items: center; gap: 0.8rem; color: var(--ink-faint); font-size: 0.85rem; margin: 0.4rem 0; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.auth-email { text-align: left; margin: 0.4rem 0 0; }
.auth-legal { margin: 1.6rem 0 0; }
.auth-legal a { color: var(--ink-soft); }
.welcome-form h1 { font-size: 1.6rem; }
.step-count { font-size: 0.8rem; font-weight: 600; color: var(--accent); margin: 0 0 0.6rem; letter-spacing: 0.02em; }
.birth { display: grid; grid-template-columns: 1.3fr 1fr; gap: 0.6rem; margin-bottom: 0.6rem; }
.welcome select, .welcome input[type="text"] {
  width: 100%; font: inherit; color: var(--ink); background: var(--grey); border: 1px solid transparent; border-radius: 12px;
  padding: 0.8rem 0.9rem; -webkit-appearance: none; appearance: none; margin-bottom: 0.8rem;
}
.welcome select:focus, .welcome input[type="text"]:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15); }
.pick-books { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; max-height: 19rem; overflow-y: auto; }
.pick { display: grid; gap: 0.3rem; cursor: pointer; font-size: 0.72rem; line-height: 1.2; color: var(--ink-soft); }
.pick input { position: absolute; opacity: 0; }
.pick img { border-radius: 4px; outline: 3px solid transparent; outline-offset: 2px; transition: outline-color 0.2s, transform 0.2s var(--ease); }
.pick input:checked + img { outline-color: var(--accent); transform: scale(0.96); }
.pick input:focus-visible + img { outline-color: rgba(0, 113, 227, 0.5); }
.child-stop .auth-sub { margin-bottom: 1.6rem; }

/* ================================================================ PORTFOLIO */

body[data-page="portfolio"] main > section { max-width: var(--wide); margin-left: auto; margin-right: auto; padding-left: clamp(16px, 4vw, 3rem); padding-right: clamp(16px, 4vw, 3rem); }
.folio-head { padding-top: 3rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2rem; }
.folio-stats { display: flex; flex-wrap: wrap; gap: clamp(1.2rem, 4vw, 3rem); align-items: center; }
.stat { display: grid; justify-items: center; text-align: center; }
.stat strong { font-size: clamp(2.2rem, 5vw, 3.2rem); font-weight: 700; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-soft); font-size: 0.85rem; margin-top: 0.3rem; }
.ring-stat { position: relative; width: 8.5rem; height: 8.5rem; align-content: center; }
.ring-stat svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-back, .ring-fill { fill: none; stroke-width: 8; }
.ring-back { stroke: rgba(0, 0, 0, 0.07); }
.ring-fill { --share: 0; stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--share)); transition: stroke-dashoffset 1.6s var(--ease); }
.ring-stat strong { font-size: 2.1rem; }
.ring-stat span { font-size: 0.72rem; max-width: 6rem; }
.folio-section { margin-top: 4rem; }
@media (max-width: 40rem) {
  .folio-stats { width: 100%; justify-content: space-between; gap: 0.6rem; }
  .ring-stat { width: 7.2rem; height: 7.2rem; }
  .ring-stat strong { font-size: 1.8rem; }
  .stat strong { font-size: 2rem; }
}
.medals { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 1rem; }
.medal-group { grid-column: 1 / -1; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-top: 1rem; }
.medal-group:first-child { margin-top: 0; }
.medal { display: grid; justify-items: center; text-align: center; gap: 0.2rem; padding: 1.1rem 0.8rem 1rem; border-radius: 20px; background: var(--card); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05); transition: transform 0.4s var(--ease), box-shadow 0.4s; }
.medal:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.medal svg { width: 4.4rem; height: auto; margin-bottom: 0.3rem; }
.medal:not(.is-earned) svg { filter: grayscale(1); opacity: 0.32; }
.medal.is-earned svg { filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.2)); animation: medal-in 0.9s var(--ease) both; }
@keyframes medal-in { from { transform: scale(0.6) rotate(-10deg); opacity: 0; } }
.medal strong { font-size: 0.95rem; font-weight: 600; line-height: 1.2; }
.medal span { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.3; }
.medal-progress { display: block; width: 70%; height: 4px; border-radius: 4px; background: rgba(0, 0, 0, 0.08); margin-top: 0.5rem; overflow: hidden; }
.medal-progress i { display: block; height: 100%; width: calc(var(--share, 0) * 100%); background: var(--accent); border-radius: 4px; }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 11rem), 1fr)); gap: 1rem; }
.gallery button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.gallery img { width: 100%; aspect-ratio: 0.75; object-fit: cover; border-radius: 14px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06); transition: transform 0.4s var(--ease); }
.gallery button:hover img { transform: scale(1.02); }
.gallery span { display: block; margin-top: 0.45rem; font-size: 0.9rem; font-weight: 500; }
.empty { color: var(--ink-soft); background: var(--grey); border-radius: 18px; padding: 1.4rem 1.6rem; margin: 0; }
.shelf-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1rem; }
.shelf-book a { display: grid; grid-template-columns: 4.4rem 1fr; grid-template-rows: auto auto 1fr; column-gap: 1rem; align-items: start; text-decoration: none; padding: 0.9rem; border-radius: 18px; background: var(--card); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05); transition: box-shadow 0.3s; }
.shelf-book a:hover { box-shadow: var(--shadow); }
.shelf-book img { grid-row: 1 / 4; border-radius: 3px; box-shadow: 0 8px 16px -10px rgba(0, 0, 0, 0.5); }
.shelf-title { font-weight: 600; font-size: 0.98rem; line-height: 1.25; }
.shelf-book .progress { margin: 0.4rem 0 0; }
.shelf-book.is-owned .shelf-title::after { content: "Your book"; margin-left: 0.5rem; font-size: 0.68rem; font-weight: 600; color: var(--accent); background: rgba(0, 113, 227, 0.1); border-radius: 999px; padding: 0.1rem 0.5rem; vertical-align: 0.15em; }
.shelf-medals { display: flex; gap: 0.35rem; margin-top: 0.5rem; }
.pip { width: 0.9rem; height: 0.9rem; border-radius: 50%; background: rgba(0, 0, 0, 0.08); }
.pip.bronze.is-earned { background: linear-gradient(135deg, #f6cfa8, #c27a3a 60%, #6e3b14); }
.pip.silver.is-earned { background: linear-gradient(135deg, #fff, #bfc5ce 60%, #646b75); }
.pip.gold.is-earned { background: linear-gradient(135deg, #fff1b0, #e0aa22 60%, #7c5a06); }
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 2rem 16px; background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.lightbox figure { margin: 0; max-width: min(92vw, 44rem); text-align: center; color: #fff; }
.lightbox img { max-height: 76vh; width: auto; margin: 0 auto; border-radius: 10px; }
.lightbox figcaption { margin-top: 1rem; display: grid; gap: 0.2rem; justify-items: center; }
.lightbox figcaption span { color: var(--on-dark-soft); font-size: 0.9rem; }
.lightbox .text-link { color: #6cb4ff; }
.lightbox-close { position: absolute; top: 1rem; right: 1.2rem; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 1.5rem; cursor: pointer; }

/* ---------------------------------------------------------------- progress */

.progress { display: flex; align-items: center; gap: 0.8rem; margin: 1rem 0; max-width: 26rem; }
.progress-bar { flex: 1; height: 4px; border-radius: 4px; background: rgba(0, 0, 0, 0.1); display: block; overflow: hidden; }
.progress-fill { display: block; height: 100%; width: calc(var(--share, 0) * 100%); background: var(--ink); transition: width 1.2s var(--ease); }
.progress-text { font-size: 0.82rem; font-weight: 500; white-space: nowrap; color: var(--ink-soft); }

/* ================================================================ BOOK PAGE */

.book-hero {
  max-width: var(--wide); margin: 3rem auto 0; padding: 0 clamp(16px, 4vw, 3rem);
  display: grid; grid-template-columns: minmax(0, 22rem) 1fr; gap: clamp(2rem, 6vw, 5rem); align-items: center;
}
.book-hero-cover { border-radius: 3px 7px 7px 3px; box-shadow: inset 7px 0 9px -6px rgba(0, 0, 0, 0.35), 0 50px 80px -36px rgba(0, 0, 0, 0.55); }
.book-hero .lead { margin: 1.2rem 0 1rem; }
.book-hero .book-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 1.6rem 0 0; }
.button.is-disabled { background: transparent; color: var(--ink-faint); border: 1px dashed rgba(0, 0, 0, 0.25); cursor: default; transform: none; }
@media (max-width: 44rem) {
  .book-hero { grid-template-columns: 1fr; text-align: center; }
  .book-hero-cover { width: 62%; margin: 0 auto; }
  .book-hero .book-actions { justify-content: center; }
  .book-hero .lead, .book-hero .progress { margin-left: auto; margin-right: auto; }
}
.plates { max-width: var(--wide); margin: 5rem auto 0; padding: 0 clamp(16px, 4vw, 3rem); }
.slots { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.6rem 1.2rem; grid-template-columns: repeat(auto-fill, minmax(min(44%, 11rem), 1fr)); }
.slot a { display: block; text-decoration: none; }
.slot-frame { position: relative; display: grid; place-items: center; align-content: center; gap: 0.35rem; aspect-ratio: 0.73; border-radius: 16px; background: var(--grey); overflow: hidden; color: var(--ink-faint); transition: transform 0.45s var(--ease), box-shadow 0.45s var(--ease); }
.slot a:hover .slot-frame { transform: translateY(-4px); box-shadow: var(--shadow); }
.slot-num { font-size: 2.4rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1; color: #c7c7cc; }
.lock { width: 1.2rem; height: 1.2rem; }
.slot-hint { font-size: 0.78rem; font-weight: 500; }
.slot-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: unveil 0.9s var(--ease); }
@keyframes unveil { from { opacity: 0; filter: blur(10px); transform: scale(1.04); } }
.slot.has-photo .slot-frame::after { content: "Coloured"; position: absolute; left: 0.55rem; bottom: 0.55rem; font-size: 0.72rem; font-weight: 600; background: rgba(20, 20, 22, 0.75); color: #fff; border-radius: 999px; padding: 0.2rem 0.6rem; }
.slot-name { display: block; margin-top: 0.6rem; line-height: 1.3; font-size: 0.95rem; font-weight: 500; }

/* ================================================================ PLATE PAGE */

.stage { position: sticky; top: var(--header); z-index: 0; overflow: clip; height: calc(100svh - var(--header)); min-height: 22rem; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem 16px 0.8rem; }
.plate-frame { position: relative; width: fit-content; max-width: 100%; border-radius: 6px; background: var(--paper); box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.55); filter: blur(calc(var(--p, 0) * 12px)); transform: scale(calc(1 + var(--p, 0) * 0.04)); }
.plate-frame img { width: auto; height: auto; max-width: 100%; max-height: max(16rem, calc(100svh - var(--header) - 5.4rem)); border-radius: 6px; }
.colour-layer { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; }
.plate-name { margin: 0.9rem 0 0; font-weight: 600; font-size: 1rem; text-align: center; opacity: calc(1 - var(--p, 0) * 2); }
.stage-veil { position: absolute; inset: 0; background: var(--page); opacity: calc(var(--p, 0) * 0.35); pointer-events: none; }
.paint-stroke { stroke-dasharray: 1; stroke-dashoffset: 1; animation: paint 4.4s cubic-bezier(0.45, 0.05, 0.55, 0.95) 0.9s forwards; }
@keyframes paint { to { stroke-dashoffset: 0; } }
.stage-status { position: absolute; left: 0; right: 0; bottom: 3.6rem; display: flex; justify-content: center; padding: 0 16px; opacity: calc(1 - var(--p, 0) * 2.5); z-index: 1; }
.stamp { background: rgba(255, 255, 255, 0.88); border-radius: 999px; padding: 0.75rem 1.6rem; text-align: center; backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); box-shadow: 0 24px 50px -22px rgba(0, 0, 0, 0.5); animation: stamp 0.8s var(--ease) both 0.3s; }
.stamp strong { display: block; font-weight: 600; font-size: clamp(1.25rem, 4vw, 1.6rem); letter-spacing: -0.02em; line-height: 1.15; }
.stamp span { display: block; color: var(--ink-soft); font-size: 0.9rem; }
@keyframes stamp { from { transform: translateY(24px) scale(0.94); opacity: 0; } }
.reading { position: relative; z-index: 1; max-width: calc(var(--text) + 5rem); margin: 0 auto 24svh; padding: 2.6rem clamp(1.3rem, 4.5vw, 3rem) 2rem; border-radius: 30px; background: rgba(255, 255, 255, 0.86); backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%); box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.4); }
.reading .display { font-size: clamp(2.2rem, 6vw, 3.6rem); }
.story { font-family: var(--serif); font-size: 1.2rem; line-height: 1.7; letter-spacing: 0; }
.story p { margin: 0 0 1.1em; }
.story p:first-child::first-letter { font-family: var(--caps); font-size: 3.4em; float: left; line-height: 0.82; padding: 0.07em 0.1em 0 0; }
.words-waiting .w { opacity: 0.1; transition: opacity 0.6s ease; transition-delay: calc(var(--i) * 22ms); }
.words-in .w { opacity: 1; }
.reading-now { background: rgba(0, 113, 227, 0.08); box-shadow: 0 0 0 0.4rem rgba(0, 113, 227, 0.08); border-radius: 6px; }
.capture { margin: 0 0 2.2rem; padding: 1.5rem 1.6rem 1.3rem; border-radius: var(--radius); background: var(--grey); display: grid; gap: 0.9rem; }
.capture h2 { font-size: 1.35rem; }
.capture-text p { margin: 0.4rem 0 0; color: var(--ink-soft); }
.capture-photo { margin: 0; }
.capture-photo img { width: 100%; max-height: 24rem; object-fit: contain; background: #fff; border-radius: 14px; }
.capture-photo figcaption { font-size: 0.85rem; font-weight: 500; color: var(--ink-soft); margin-top: 0.45rem; }
.capture-actions { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: center; }
.capture-take { position: relative; overflow: hidden; }
.capture-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.capture-status { margin: 0; min-height: 1.4em; }
.capture-status.error { color: #c1271b; }
.capture .fine { margin: 0; }
.after-story { position: relative; z-index: 1; background: var(--page); box-shadow: 0 0 0 100vmax var(--page); clip-path: inset(0 -100vmax); }
.after-story > section, .after-story > nav { max-width: calc(var(--text) + 5rem); margin: 0 auto; padding: 2.4rem clamp(16px, 3vw, 3rem) 0; }
.after-story h2 { margin-bottom: 1.3rem; }
.palette { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr)); }
.palette li { display: flex; align-items: center; gap: 0.75rem; }
.palette svg { flex: none; width: 2.8rem; height: 2.8rem; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.16)); }
.swatch-name { display: block; line-height: 1.2; font-weight: 500; }
.swatch-use { display: block; font-size: 0.88rem; color: var(--ink-soft); line-height: 1.25; }
.facts { padding-left: 1.3rem; margin: 0; }
.facts li { margin-bottom: 1rem; }
.sources { display: block; font-size: 0.82rem; color: var(--ink-faint); margin-top: 0.15rem; }
.sources a { color: var(--accent); text-decoration: none; word-break: break-word; }
.sources a:hover { text-decoration: underline; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.4rem; padding-top: 1.5rem !important; border-top: 1px solid var(--hairline); }
.pager a { text-decoration: none; max-width: 48%; }
.pager a:hover span { text-decoration: underline; }
.pager .next { text-align: right; margin-left: auto; }
.pager small { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; }

/* ================================================================ SMALL PAGES */

.locked { max-width: 38rem; margin: 0 auto; padding: 7rem 16px 2rem; text-align: center; }
.locked .lead { margin: 1rem auto 2rem; }
.locked-art .lock { width: 3rem; height: 3rem; margin: 0 auto 1.4rem; display: block; color: var(--ink-faint); }
.form-page { max-width: 34rem; margin: 0 auto; padding: 4rem 16px 0; }
.form-page .lead { margin: 1rem 0; }
.form-page.prose { max-width: var(--text); }
.form-page h2.display.small { margin: 2.8rem 0 0.4rem; }
.form-page ul { padding-left: 1.2rem; }
.form { display: grid; gap: 0.35rem; margin: 1.4rem 0; }
.form label { margin-top: 0.8rem; font-weight: 500; font-size: 0.92rem; }
.form label small { font-weight: 400; color: var(--ink-faint); }
.form input[type="email"], .form input[type="password"], .form input[type="text"] {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid rgba(0, 0, 0, 0.16); border-radius: 12px;
  padding: 0.8rem 1rem; width: 100%; transition: border-color 0.2s, box-shadow 0.2s;
}
.auth .form input[type="email"], .auth .form input[type="password"] { background: var(--grey); border-color: transparent; }
.form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15); background: #fff; }
.form .check { display: flex; gap: 0.7rem; align-items: flex-start; line-height: 1.35; font-weight: 400; font-size: 1rem; }
.form .check input { width: 1.2rem; height: 1.2rem; margin: 0.1rem 0 0; accent-color: var(--ink); flex: none; }
.form .button { justify-self: start; margin-top: 0.9rem; }
.form .button.wide { justify-self: stretch; }
.form-message { margin: 0.3rem 0 0; min-height: 1.4em; font-size: 0.92rem; }
.form-message.error { color: #c1271b; }

/* ---------------------------------------------------------------- motion and print */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-delay: 0s !important; }
  .plate-frame { filter: none; transform: none; }
  .paint-stroke { stroke-dashoffset: 0; }
}
@media print {
  .masthead nav, .pager, .colophon, .stage-status, .read-aloud, .capture { display: none; }
  .stage { position: static; height: auto; }
  body { background: #fff; }
}

/* ================================================================ ADVERTS (free accounts) */

.ad-wrap:empty { display: none; }
.after-story .ad-wrap, .plates + .ad-wrap, body[data-page="portfolio"] .ad-wrap { max-width: calc(var(--text) + 5rem); margin: 2.6rem auto 0; padding: 0 clamp(16px, 3vw, 3rem); }
.plates + .ad-wrap, body[data-page="portfolio"] .ad-wrap { max-width: var(--wide); }
.house-ad { border-radius: var(--radius); background: var(--grey); padding: 1.2rem 1.3rem 1.1rem; display: grid; gap: 1rem; }
.ad-label { margin: 0; font-size: 0.8rem; color: var(--ink-faint); display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; align-items: center; }
.ad-label span { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.7rem; border: 1px solid rgba(0, 0, 0, 0.2); border-radius: 4px; padding: 0.05rem 0.35rem; }
.ad-label a { color: var(--accent); text-decoration: none; }
.ad-books { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 0.8rem; }
.ad-book { display: flex; gap: 0.9rem; align-items: center; text-decoration: none; background: var(--card); border-radius: 16px; padding: 0.7rem; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05); transition: box-shadow 0.3s; }
.ad-book:hover { box-shadow: var(--shadow); }
.ad-book img { width: 3.4rem; border-radius: 2px; box-shadow: 0 8px 14px -8px rgba(0, 0, 0, 0.5); }
.ad-book strong { display: block; font-size: 0.95rem; }
.ad-book small { color: var(--ink-soft); font-size: 0.82rem; }
.ad-title { margin: 0 0 0.4rem; font-weight: 600; font-size: 0.9rem; }
.ad-supplies ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 0.4rem 1.2rem; }
.ad-supplies a { color: var(--accent); text-decoration: none; font-weight: 500; font-size: 0.92rem; }
.ad-supplies a:hover { text-decoration: underline; }
.ad-supplies small { display: block; color: var(--ink-soft); font-size: 0.8rem; line-height: 1.3; }
.ad-disclosure { margin: 0.6rem 0 0; font-size: 0.75rem; color: var(--ink-faint); }

/* ================================================================ PREMIUM EXTRAS */

.nav-avatar.is-premium { box-shadow: 0 0 0 2px var(--page), 0 0 0 4px #e0aa22; }
html.dark .nav-avatar.is-premium { box-shadow: 0 0 0 2px var(--dark), 0 0 0 4px #e0aa22; }
.plate-tools { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.reference img { width: 100%; max-width: 30rem; border-radius: 8px; box-shadow: var(--shadow); }
button.link { font: inherit; font-size: 0.82rem; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.premium-teaser { margin: 1rem 0 0; padding: 0.9rem 1.1rem; border-radius: 14px; background: linear-gradient(135deg, rgba(224, 170, 34, 0.12), rgba(191, 90, 242, 0.08)); color: var(--ink-soft); font-size: 0.95rem; }
.premium-teaser a { color: var(--ink); font-weight: 600; }

/* colourists */
.colourist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.7rem; }
.colourist { --c: #7d6bf2; display: grid; gap: 0.25rem; }
.colourist-pick { display: flex; align-items: center; gap: 0.6rem; font: inherit; text-align: left; cursor: pointer; padding: 0.6rem 1rem 0.6rem 0.7rem; border-radius: 999px; border: 1px solid rgba(0, 0, 0, 0.12); background: var(--card); color: var(--ink); }
.colourist-pick:disabled { cursor: default; }
.colourist.is-current .colourist-pick { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.colourist-dot { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--c); }
.colourist-pick strong { font-weight: 600; font-size: 0.95rem; }
.colourist-pick small { color: var(--ink-soft); font-size: 0.78rem; display: block; }
.colourist-tools { display: flex; gap: 0.8rem; padding-left: 1rem; }
.c-violet { --c: #7d6bf2; } .c-blue { --c: #3a86ff; } .c-teal { --c: #14a3a3; } .c-green { --c: #3aa655; }
.c-amber { --c: #e0a020; } .c-coral { --c: #ef6f5e; } .c-rose { --c: #e05a9c; } .c-slate { --c: #6c7a89; }
.colourist-add { max-width: 26rem; }
.inline-form { display: flex; gap: 0.5rem; }
.inline-form input { flex: 1; }
.inline-form .button { margin-top: 0 !important; }

/* certificates list */
.certificate-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: 0.8rem; }
.certificate-link { display: grid; gap: 0.15rem; padding: 1rem 1.1rem; border-radius: 16px; text-decoration: none; background: linear-gradient(135deg, #fff8e1, #fff); box-shadow: 0 0 0 1px rgba(224, 170, 34, 0.35); }
.certificate-link.is-locked { background: var(--grey); box-shadow: none; color: var(--ink-soft); }
.certificate-link span { font-size: 0.85rem; color: var(--ink-soft); }
.certificate-list .empty { grid-column: 1 / -1; }

/* account page */
.premium-box { background: var(--grey); border-radius: 18px; padding: 1rem 1.2rem; }
.premium-box p { margin: 0.3rem 0; }

/* the Premium page */
.premium-hero { text-align: center; padding: 4.5rem 16px 1rem; }
.premium-hero .lead { margin: 1rem auto 0; }
.premium-hero .headline { background: linear-gradient(120deg, #1d1d1f 20%, #a67c00 60%, #bf5af2); -webkit-background-clip: text; background-clip: text; color: transparent; }
.plans { max-width: 46rem; margin: 2.6rem auto 0; padding: 0 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 1rem; }
.plan { position: relative; background: var(--card); border-radius: 26px; padding: 1.8rem 1.6rem 1.6rem; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06); text-align: center; display: grid; gap: 0.4rem; align-content: start; }
.plan.best { box-shadow: 0 0 0 2px #e0aa22, var(--shadow); }
.plan h2 { font-size: 1.2rem; }
.price { margin: 0.3rem 0; color: var(--ink-soft); }
.price strong { display: block; font-size: 2.6rem; font-weight: 700; letter-spacing: -0.04em; color: var(--ink); }
.plan-note { margin: 0 0 0.6rem; color: #a67c00; font-size: 0.9rem; font-weight: 500; }
.plan-flag { position: absolute; top: -0.75rem; left: 50%; transform: translateX(-50%); margin: 0; background: #e0aa22; color: #fff; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; border-radius: 999px; padding: 0.2rem 0.75rem; }
.plan .button { margin-top: auto; }
.premium-state, .premium-message, .test-badge { text-align: center; max-width: 40rem; margin: 1rem auto 0; padding: 0 16px; }
.premium-state { font-size: 1.2rem; font-weight: 500; }
.test-badge { color: #8a4b00; }
.perks { max-width: 46rem; margin: 3rem auto 0; padding: 0 16px; }
.perks ul { list-style: none; margin: 0 0 1.4rem; padding: 0; display: grid; gap: 0.2rem; }
.perks li { display: grid; grid-template-columns: minmax(0, 14rem) 1fr; gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--hairline); }
.perks li strong { font-weight: 600; }
.perks li span { color: var(--ink-soft); }
@media (max-width: 34rem) { .perks li { grid-template-columns: 1fr; gap: 0.2rem; } }

/* the print and certificate pages */
.print-page { max-width: 52rem; margin: 0 auto; padding: 2.4rem 16px 0; text-align: center; }
.print-bar { margin-bottom: 1.6rem; }
.print-tools { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.8rem 1.4rem; margin: 0.6rem 0; }
.print-problem { background: #fff4e5; color: #8a4b00; border-radius: 12px; padding: 0.8rem 1rem; }
.print-plate { margin: 0 auto; max-height: 80vh; width: auto; box-shadow: var(--shadow); }
.print-plate:not([src]) { display: none; }
.certificate {
  position: relative; margin: 0 auto; max-width: 44rem; aspect-ratio: 1.414; padding: clamp(1.4rem, 5vw, 3rem);
  display: grid; align-content: center; justify-items: center; gap: 0.3rem; text-align: center;
  background: #fffdf6; color: #1b1a17; font-family: var(--serif); letter-spacing: 0;
  box-shadow: inset 0 0 0 10px #fffdf6, inset 0 0 0 12px #1b1a17, inset 0 0 0 16px #fffdf6, inset 0 0 0 17px #1b1a17, var(--shadow);
}
.cert-mark { width: 3.4rem; margin-bottom: 0.4rem; }
.cert-kicker { font-family: var(--caps); font-size: clamp(1.4rem, 4vw, 2.2rem); letter-spacing: 0.08em; margin: 0; }
.cert-line { font-style: italic; color: #5d584d; margin: 0.4rem 0 0; }
.cert-name { font-family: var(--caps); font-size: clamp(2rem, 7vw, 3.4rem); margin: 0.2rem 0; border-bottom: 1px solid #1b1a17; padding: 0 1.5rem 0.2rem; }
.cert-book { font-family: var(--caps); font-size: clamp(1.3rem, 4vw, 2rem); margin: 0.2rem 0; }
.cert-date, .cert-sign { margin: 0.6rem 0 0; font-size: 0.95rem; }
.cert-sign { font-family: var(--caps); letter-spacing: 0.1em; }
@media print {
  body[data-page="print"] .masthead, body[data-page="print"] .colophon, body[data-page="print"] .print-bar,
  body[data-page="certificate"] .masthead, body[data-page="certificate"] .colophon, body[data-page="certificate"] .print-bar { display: none !important; }
  .print-page { padding: 0; max-width: none; }
  .print-plate { max-height: 100vh; max-width: 100%; box-shadow: none; }
  .certificate { box-shadow: inset 0 0 0 10px #fffdf6, inset 0 0 0 12px #1b1a17, inset 0 0 0 16px #fffdf6, inset 0 0 0 17px #1b1a17; max-width: none; }
}
