/* The public library pages (/thu-vien/**, built by scripts/build-library.mjs): the landing page's
   look (Mali, teal and amber on paper) for long bilingual reading. */
@font-face { font-family: Mali; src: url("/assets/mali-light.woff2") format("woff2"), url("/assets/mali-light.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Mali; src: url("/assets/mali-medium.woff2") format("woff2"), url("/assets/mali-medium.ttf") format("truetype"); font-weight: 600; font-display: swap; }
:root { --ink: #143d39; --muted: #53706d; --teal: #007f74; --teal-dark: #005a51; --mint: #d4fffb; --mint-soft: #ecfbf9; --paper: #fbfefd; --white: #fff; --amber: #f4b942; --amber-soft: #fff5dc; --line: #c5dedb; --shadow: 0 18px 50px rgba(0, 75, 69, 0.1); }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Mali, system-ui, sans-serif; font-size: 16px; line-height: 1.7; overflow-x: clip; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--teal-dark); }
h1, h2, h3, h4, p { margin-top: 0; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
.skip { position: absolute; left: 16px; top: -80px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; text-decoration: none; }
.skip:focus { top: 16px; }
.shell { width: min(1080px, calc(100% - 32px)); margin-inline: auto; }

/* header / footer */
.site-header { padding: 14px 0; background: var(--white); border-bottom: 1px solid var(--line); }
.site-nav { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.brand img { width: 40px; height: 40px; border-radius: 11px; }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { color: var(--muted); font-size: 14px; text-decoration: none; }
.nav-links a:hover { color: var(--teal); }
.nav-links .nav-app { padding: 9px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; white-space: nowrap; }
.nav-links .nav-app:hover { background: var(--teal-dark); color: #fff; }
main { padding-bottom: 72px; }
.site-footer { padding: 36px 0 40px; background: var(--white); border-top: 1px solid var(--line); }
.footer-sections { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 24px; font-size: 14px; }
.footer-sections a { color: var(--ink); text-decoration: none; }
.footer-sections a:hover { color: var(--teal); text-decoration: underline; }
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { color: inherit; }

/* breadcrumb and headings */
.crumbs ol { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 18px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.crumbs li + li::before { content: "›"; margin-right: 8px; color: var(--line); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--teal); }
.lesson-head, .section-head { margin: 26px 0 26px; }
.kicker { margin-bottom: 8px; color: var(--teal-dark); font-size: 14px; }
.kicker a { text-decoration: none; }
.kicker .free { padding: 2px 9px; border-radius: 999px; background: var(--mint); font-size: 12px; font-weight: 600; }
h1 { margin-bottom: 10px; font-size: clamp(30px, 5vw, 48px); font-weight: 600; line-height: 1.15; letter-spacing: -0.035em; }
.subtitle { margin: 0; color: var(--muted); font-size: 19px; }
.lead { max-width: 720px; color: var(--muted); font-size: 18px; }
.meta { color: var(--muted); font-size: 14px; }
.app-button { display: inline-flex; align-items: center; gap: 10px; min-height: 50px; padding: 12px 20px; border-radius: 14px; background: var(--teal); color: #fff; font-weight: 600; text-decoration: none; }
.app-button:hover { background: var(--teal-dark); }
.store-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.store-button { display: inline-flex; align-items: center; gap: 10px; min-height: 50px; padding: 7px 16px; border-radius: 14px; background: var(--ink); color: #fff; text-decoration: none; }
.store-button:hover { background: var(--teal-dark); }
.store-button svg { width: 24px; height: 24px; flex: 0 0 auto; }
.store-button small, .store-button strong { display: block; line-height: 1.2; }
.store-button small { font-size: 9px; opacity: 0.78; }
.store-button strong { font-size: 15px; }

/* a lesson */
.lesson { max-width: 760px; }
.listen { margin: 0 0 22px; padding: 14px 18px; border-radius: 18px; background: var(--mint-soft); border: 1px solid var(--line); }
.listen figcaption { margin-bottom: 8px; color: var(--teal-dark); font-size: 14px; font-weight: 600; }
.listen audio { width: 100%; }
.lang-toggle { display: inline-flex; margin: 0 0 22px; padding: 4px; border-radius: 999px; background: #e8f2f1; }
.lang-toggle[hidden] { display: none; }
.lang-toggle button { padding: 8px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 600 13px Mali, system-ui, sans-serif; cursor: pointer; }
.lang-toggle button[aria-pressed="true"] { background: #fff; color: var(--teal-dark); box-shadow: 0 3px 12px rgba(0, 70, 65, 0.1); }
.pair { margin: 0 0 22px; }
.pair p { margin: 0; }
.pair p[lang="en"] { font-size: 18.5px; line-height: 1.75; }
.vi { color: var(--teal-dark); }
.pair .vi, .lines .vi { margin-top: 6px; padding-left: 14px; border-left: 3px solid var(--amber); font-size: 15.5px; }
.en-only .vi, .en-only .vi-vi { display: none; }
.sides { display: grid; gap: 30px; }
.side h2 { margin-bottom: 12px; color: var(--teal-dark); font-size: 18px; }
.side p { margin-bottom: 14px; }
.side[lang="en"] p { font-size: 18px; }
@media (min-width: 960px) { .lesson:has(.sides) { max-width: 1080px; } .sides { grid-template-columns: 1fr 1fr; gap: 44px; } }
.cut-note { margin: 4px 0 0; padding-top: 36px; background: linear-gradient(180deg, rgba(251, 254, 253, 0), var(--paper) 70%); color: var(--muted); font-style: italic; position: relative; margin-top: -34px; }
.vocab { margin-top: 36px; }
.vocab h2, .more h2 { margin-bottom: 12px; font-size: 22px; letter-spacing: -0.02em; }
.vocab table { width: 100%; border-collapse: collapse; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; font-size: 15px; }
.vocab th { padding: 10px 14px; background: var(--mint-soft); color: var(--teal-dark); text-align: left; }
.vocab td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.vocab td:first-child { width: 46%; }
.ipa { color: var(--muted); font-size: 13px; }
.cta { margin: 40px 0 32px; padding: 28px; border-radius: 24px; background: var(--amber-soft); border: 1px solid #f3dca4; }
.cta h2 { margin-bottom: 8px; font-size: 24px; letter-spacing: -0.02em; }
.cta p { color: #3f5a56; }
.cta-more { background: var(--mint-soft); border-color: var(--line); }

/* grammar lessons */
.theory { font-size: 16.5px; }
.theory p { margin: 0 0 10px; }
.theory h2, .theory h3, .theory h4 { margin: 26px 0 10px; color: var(--teal-dark); font-size: 21px; line-height: 1.35; }
.theory .sec { margin: 26px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--teal-dark); font-size: 14px; letter-spacing: 0.03em; }
.theory .sub { margin: 18px 0 6px; font-size: 17.5px; font-weight: 600; }
.theory .label { margin: 10px 0 4px; color: var(--muted); font-size: 14px; font-weight: 600; }
.theory .formula { margin: 6px 0 14px; padding: 12px 14px; border-radius: 14px; background: var(--mint); color: #00413a; font-weight: 600; text-align: center; }
.theory ul, .theory ol { margin: 0 0 14px; padding-left: 22px; }
.theory li { margin: 4px 0; }
.theory li::marker { color: var(--teal); }
.theory u { text-decoration: none; background: linear-gradient(transparent 62%, var(--mint) 0); color: var(--teal-dark); font-weight: 600; }
.theory table { display: block; max-width: 100%; overflow-x: auto; margin: 0 0 16px; border-collapse: collapse; font-size: 15px; }
.theory td, .theory th { padding: 8px 10px; border: 1px solid var(--line); vertical-align: top; }
.theory tr:first-child td { background: var(--mint-soft); font-weight: 600; }

/* comics */
.summary { margin-bottom: 10px; }
.cast { color: var(--muted); font-size: 14px; }
.comic-page { margin: 0 0 38px; }
.comic-page img { width: 100%; max-width: 560px; border-radius: 16px; box-shadow: var(--shadow); }
.lines { margin: 18px 0 0; padding: 0; list-style: none; }
.line { margin: 0 0 14px; }
.line p { margin: 0; }
.line p[lang="en"] { font-size: 17.5px; }
.line.narration p[lang="en"] { font-style: italic; }
.who { display: inline-block; margin-bottom: 2px; padding: 1px 10px; border-radius: 999px; background: var(--mint); color: var(--teal-dark); font-size: 12px; font-weight: 600; }

/* related lessons */
.next-prev { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 760px; }
.next-prev a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--ink); text-decoration: none; }
.next-prev a:last-child:not(:first-child) { text-align: right; }
.next-prev a:hover { border-color: var(--teal); }
.next-prev small { display: block; color: var(--muted); font-size: 12px; }
.next-prev span { font-weight: 600; line-height: 1.35; }
.more { max-width: 760px; margin-top: 34px; }
.more ul { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; margin: 0 0 14px; padding: 0; list-style: none; }
.more li a { font-weight: 600; text-decoration: none; }
.more li a:hover { text-decoration: underline; }
.more li span { display: block; color: var(--muted); font-size: 14px; }
.see-all { font-weight: 600; }

/* section and hub pages */
.lesson-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.lesson-list a { display: flex; align-items: center; gap: 16px; padding: 14px 6px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.lesson-list a:hover { background: var(--mint-soft); }
.lesson-list .n { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--mint); color: var(--teal-dark); font-size: 13px; font-weight: 600; }
.lesson-list .t { flex: 1; min-width: 0; }
.lesson-list strong { display: block; font-weight: 600; line-height: 1.35; }
.lesson-list small { display: block; color: var(--muted); font-size: 14px; }
.badge { flex: 0 0 auto; padding: 3px 10px; border-radius: 999px; background: var(--amber-soft); color: #7a5300; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 22px 18px; margin: 0; padding: 0; list-style: none; }
.cover-grid a { display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none; }
.cover-grid img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 14px; background: #efe6d2; box-shadow: var(--shadow); margin-bottom: 6px; }
.cover-title { font-weight: 600; line-height: 1.3; }
.cover-sub { color: var(--muted); font-size: 13px; }
.cover-grid .badge { align-self: flex-start; }
.hub-head { display: flex; align-items: center; gap: 28px; }
.hub-mam { flex: 0 0 auto; width: 150px; }
.shelves { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.shelves a { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: #fff; color: var(--ink); text-decoration: none; transition: border-color 0.2s, transform 0.2s; }
.shelves a:hover { border-color: var(--teal); transform: translateY(-2px); }
.shelves strong { font-size: 19px; line-height: 1.3; }
.shelves span { color: var(--muted); font-size: 15px; }
.shelves small { margin-top: auto; color: var(--teal-dark); font-weight: 600; }
.shelves .app-only a { border-style: dashed; background: transparent; }

@media (max-width: 860px) {
  .nav-links a:not(.nav-app) { display: none; }
}
@media (max-width: 620px) {
  .brand span { font-size: 14px; }
  h1 { font-size: 30px; }
  .lead { font-size: 17px; }
  .pair p[lang="en"] { font-size: 17.5px; }
  .hub-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .hub-mam { width: 110px; }
  .more ul, .next-prev { grid-template-columns: 1fr; }
  .next-prev a:last-child:not(:first-child) { text-align: left; }
  .cover-grid { grid-template-columns: repeat(2, 1fr); gap: 18px 14px; }
  .cta { padding: 22px 18px; }
  .footer-row { flex-direction: column; align-items: flex-start; }
  .badge { display: none; }
}
@media (prefers-reduced-motion: reduce) { .shelves a { transition: none; } }
