@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&display=swap');

:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1a282d;
  --muted: #5e6c70;
  --line: #dbe1df;
  --accent: #135d68;
  --accent-soft: #e5f1f0;
  --hero: #17323b;
  --hero-ink: #f6f5ef;
  --shadow: 0 18px 55px rgba(19, 42, 47, .07);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11191e;
  --surface: #1b282e;
  --text: #edf1ee;
  --muted: #a8b6b9;
  --line: #33444a;
  --accent: #9bd3dd;
  --accent-soft: #28434a;
  --hero: #0d242b;
  --hero-ink: #f6f5ef;
  --shadow: 0 18px 55px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: 'DM Sans', system-ui, sans-serif; font-size: 1rem; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1216px; margin: auto; padding: 0 28px; min-height: 76px; display: flex; align-items: center; gap: 36px; }
.wordmark { color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.08rem; letter-spacing: -.035em; white-space: nowrap; }
.wordmark span:last-child { font-weight: 400; color: var(--muted); }
.wordmark-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-right: 8px; border-radius: 7px; background: var(--accent); color: var(--surface); font-size: 1.24rem; vertical-align: middle; }
.header-inner nav { margin-left: auto; }
.header-inner nav a { color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 600; }
.header-inner nav a:hover, .site-footer a:hover { text-decoration: underline; }
.theme-toggle { border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 42px; height: 42px; border-radius: 50%; font-size: 1.2rem; }

.hero { position: relative; overflow: hidden; background: var(--hero); color: var(--hero-ink); }
.hero::before { content: ""; position: absolute; inset: 0; opacity: .25; background-image: linear-gradient(90deg, transparent 95%, #7cabb1 95%), linear-gradient(transparent 95%, #7cabb1 95%); background-size: 80px 80px; mask-image: linear-gradient(90deg, transparent 25%, #000); pointer-events: none; }
.hero::after { content: ""; position: absolute; width: 600px; height: 600px; border: 1px solid rgba(185, 222, 220, .22); border-radius: 50%; right: -170px; top: -240px; box-shadow: 0 0 0 95px rgba(185, 222, 220, .045), 0 0 0 190px rgba(185, 222, 220, .035); pointer-events: none; }
.hero-inner { position: relative; z-index: 1; max-width: 1216px; margin: auto; padding: clamp(72px, 10vw, 130px) 28px 86px; }
.eyebrow { margin: 0; font-size: .82rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.hero .eyebrow { color: #a9d7d7; }
.hero h1 { font-family: 'Newsreader', Georgia, serif; font-weight: 500; font-size: clamp(3.2rem, 8vw, 7.1rem); letter-spacing: -.055em; line-height: .98; max-width: 920px; margin: 24px 0 28px; }
.hero h1 em { color: #b4d6d0; font-weight: 400; }
.hero-lead { max-width: 660px; font-size: clamp(1.06rem, 2vw, 1.25rem); line-height: 1.6; color: #d3e2df; margin: 0 0 42px; }
.search-box { max-width: 760px; }
.search-box label { display: block; font-size: .9rem; font-weight: 700; margin-bottom: 12px; }
.search-control { display: flex; align-items: center; gap: 13px; min-height: 66px; padding: 0 19px; background: #fff; color: #17262b; border-radius: 13px; box-shadow: 0 18px 40px rgba(0, 0, 0, .15); }
.search-control:focus-within { outline: 3px solid #9bd3dd; outline-offset: 3px; }
.search-control input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #17262b; font-size: 1.05rem; }
.search-control input::placeholder { color: #6f7d80; }
.search-control button { border: 0; background: #e9f1f0; color: #174b55; padding: 8px 13px; border-radius: 8px; font-size: .86rem; font-weight: 700; }
.search-icon { display: block; width: 20px; height: 20px; border: 2px solid #456b70; border-radius: 50%; position: relative; flex: none; }
.search-icon::after { content: ""; width: 8px; height: 2px; background: #456b70; position: absolute; right: -6px; bottom: -3px; transform: rotate(45deg); border-radius: 2px; }
.search-hint { color: #bdd2d0; font-size: .88rem; margin: 12px 0 0; }

.library-section { padding: 76px 28px 110px; scroll-margin-top: 90px; }
.section-inner { max-width: 1160px; margin: auto; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 30px; }
.section-heading .eyebrow { color: var(--accent); }
.section-heading h2 { font-family: 'Newsreader', Georgia, serif; font-size: clamp(2.3rem, 5vw, 3.8rem); font-weight: 500; letter-spacing: -.045em; line-height: 1; margin: 10px 0 0; }
.section-heading > p { color: var(--muted); font-size: .92rem; margin: 0 0 4px; white-space: nowrap; }
.reading-list { display: grid; gap: 24px; }
.reading-card { display: grid; grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); gap: clamp(28px, 4vw, 54px); padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.book-cover { position: relative; display: flex; flex-direction: column; min-height: 360px; overflow: hidden; padding: 27px; background: #e9eeea; color: #17313a; border-radius: 10px; border: 1px solid #d2dcd8; }
.cover-rule { width: 52px; height: 5px; background: #24707a; border-radius: 8px; margin-bottom: 28px; }
.cover-kicker { color: #47717a; font-size: .75rem; text-transform: uppercase; letter-spacing: .18em; font-weight: 700; }
.book-cover strong { position: relative; z-index: 2; display: block; max-width: 255px; font-family: 'Newsreader', Georgia, serif; font-size: 2.65rem; font-weight: 500; letter-spacing: -.045em; line-height: 1.02; margin-top: 17px; }
.cover-blocks { display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 36px); gap: 3px; margin: auto 0 20px auto; transform: rotate(-11deg); opacity: .75; }
.cover-blocks i { border: 1px solid #31747a; }
.cover-blocks i:nth-child(2), .cover-blocks i:nth-child(5), .cover-blocks i:nth-child(9) { background: #b1d0cc; }
.cover-bottom { position: relative; z-index: 2; max-width: 210px; font-size: .85rem; line-height: 1.3; font-weight: 700; }
.card-content { padding: 12px 12px 10px 0; display: flex; flex-direction: column; align-items: start; }
.card-meta { display: flex; gap: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: .13em; font-size: .79rem; font-weight: 700; margin: 0 0 16px; }
.card-content h3 { font-family: 'Newsreader', Georgia, serif; font-size: clamp(2.2rem, 4vw, 3.7rem); font-weight: 500; line-height: 1.02; letter-spacing: -.045em; margin: 0 0 9px; }
.card-content h3 a { color: var(--text); text-decoration: none; }
.card-content h3 a:hover { color: var(--accent); text-decoration: underline; }
.card-subtitle { color: var(--text); font-size: 1.06rem; font-weight: 600; margin: 0 0 8px; }
.card-authors { color: var(--muted); font-size: .93rem; margin: 0 0 22px; }
.card-description { max-width: 570px; color: var(--muted); line-height: 1.65; margin: 0 0 22px; }
.topics { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 26px; }
.topics li { padding: 7px 10px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: .79rem; font-weight: 700; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-top: auto; }
.open-reader { display: inline-grid; place-items: center; min-height: 46px; padding: 10px 17px; background: var(--accent); color: var(--surface); border-radius: 9px; font-size: .89rem; font-weight: 700; text-decoration: none; }
.open-reader:hover { filter: brightness(1.1); }
.continue-reader { font-size: .87rem; font-weight: 700; text-decoration: none; }
.continue-reader:hover { text-decoration: underline; }
.page-matches { border-top: 1px solid var(--line); width: 100%; margin-top: 24px; padding-top: 16px; }
.page-matches p { font-size: .88rem; color: var(--muted); margin: 0 0 10px; }
.page-matches ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.page-matches a { display: block; color: var(--text); text-decoration: none; border-left: 3px solid var(--accent); padding: 6px 0 6px 11px; font-family: 'Newsreader', Georgia, serif; font-size: 1.05rem; line-height: 1.35; }
.page-matches a:hover { color: var(--accent); text-decoration: underline; }
.page-matches strong { display: block; font-family: 'DM Sans', system-ui, sans-serif; font-size: .76rem; color: var(--accent); margin-bottom: 3px; }
.empty-state { border: 1px dashed var(--line); border-radius: 15px; padding: 48px; text-align: center; }
.empty-state h3 { font-family: 'Newsreader', Georgia, serif; font-size: 2rem; font-weight: 500; margin: 0 0 8px; }
.empty-state p, .noscript-note { color: var(--muted); }
.site-footer { border-top: 1px solid var(--line); max-width: 1160px; padding: 25px 0 42px; margin: 0 auto; display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .85rem; }
.site-footer p { margin: 0; }
.site-footer a { text-decoration: none; font-weight: 700; }

@media (max-width: 720px) {
  .header-inner { padding: 0 18px; min-height: 64px; gap: 18px; }
  .header-inner nav { display: none; }
  .theme-toggle { margin-left: auto; }
  .hero-inner { padding: 65px 22px 70px; }
  .hero::after { right: -410px; }
  .hero h1 { max-width: 600px; }
  .library-section { padding: 55px 18px 80px; }
  .section-heading { align-items: start; flex-direction: column; }
  .reading-card { grid-template-columns: 1fr; padding: 17px; gap: 22px; }
  .book-cover { min-height: 270px; }
  .book-cover strong { font-size: 2.5rem; }
  .card-content { padding: 0 5px 8px; }
  .site-footer { margin: 0 18px; }
}

@media (max-width: 430px) {
  .wordmark span:last-child { display: none; }
  .hero h1 { font-size: 3.4rem; }
  .search-control { min-height: 59px; padding: 0 14px; }
  .search-control input { font-size: .95rem; }
  .site-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

html[data-theme="dark"] .search-control { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
html[data-theme="dark"] .search-control input { color: var(--text); }
html[data-theme="dark"] .search-control input::placeholder { color: var(--muted); }
html[data-theme="dark"] .search-control button { background: var(--accent-soft); color: var(--accent); }
html[data-theme="dark"] .search-icon { border-color: var(--accent); }
html[data-theme="dark"] .search-icon::after { background: var(--accent); }
html[data-theme="dark"] .book-cover { background: #26383d; color: #eaf0eb; border-color: #3a5559; }
html[data-theme="dark"] .cover-kicker { color: #a9d6d4; }
html[data-theme="dark"] .cover-rule { background: #9bd3dd; }
html[data-theme="dark"] .cover-blocks i { border-color: #75aeb2; }
html[data-theme="dark"] .cover-blocks i:nth-child(2),
html[data-theme="dark"] .cover-blocks i:nth-child(5),
html[data-theme="dark"] .cover-blocks i:nth-child(9) { background: #436a70; }
