:root {
  color-scheme: light;
  font: 16px/1.55 "Segoe UI", system-ui, sans-serif;
  color: #162e48;
  background: #f5f9fd;
  --ink: #162e48;
  --muted: #4a647e;
  --blue: #155fbb;
  --blue-dark: #104b96;
  --sky: #e8f4ff;
  --line: #cedeed;
  --paper: #fff;
  --amber: #f5ad22;
  --green: #286746;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 290px; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; }
button, input, select { font: inherit; }
a { color: var(--blue-dark); text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
svg { flex: none; vertical-align: middle; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.15; }
h1 { font-size: clamp(2rem, 5.5vw, 3.4rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.45rem, 3.25vw, 2rem); letter-spacing: -.02em; }
h3 { font-size: 1.35rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #ad6500; outline-offset: 4px; }
.wrap { width: min(1112px, calc(100% - 48px)); margin-inline: auto; }
.skip { position: absolute; top: 8px; left: 8px; z-index: 3; transform: translateY(-150%); background: white; padding: 8px 12px; }
.skip:focus { transform: none; }

.site-header { background: #fcfeff; border-bottom: 1px solid var(--line); }
.header-inner { width: min(1112px, calc(100% - 48px)); min-height: 70px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.2rem; font-weight: 750; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; background: #1968c7; color: white; border-radius: 11px; font-size: 1.44rem; line-height: 1; }
.header-inner nav { display: flex; align-items: center; gap: 6px; }
.header-inner nav a { color: var(--muted); font-weight: 640; padding: 8px 13px; border-radius: 9px; }
.header-inner nav a:hover, .header-inner nav [aria-current] { color: var(--blue-dark); background: var(--sky); }
.site-footer { min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(1112px, calc(100% - 48px)); margin: 0 auto; border-top: 1px solid var(--line); color: var(--muted); font-size: .92rem; }
.site-footer a:hover { text-decoration: underline; }
.button { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: fit-content; min-height: 46px; padding: 9px 17px; border: 1px solid transparent; border-radius: 11px; font-weight: 690; line-height: 1.28; text-align: center; }
.button svg { width: 20px; height: 20px; }
.primary { color: #fff; background: var(--blue); }
.primary:hover:not(:disabled) { background: var(--blue-dark); }
.secondary { background: white; color: var(--blue-dark); border-color: var(--line); }
.secondary:hover:not(:disabled), .text-button:hover { background: var(--sky); }
.text-button { appearance: none; min-height: 41px; border: 0; border-radius: 8px; background: transparent; color: var(--blue-dark); font-weight: 650; padding: 6px 8px; text-align: left; }
.loading, .empty-state { padding: 65px 0; }
.loading { text-align: center; color: var(--muted); }
.empty-state p, .empty-state a { margin-top: 19px; }
.muted, .status { color: var(--muted); }
.status { font-size: .94rem; margin-top: 9px; }
.status:empty { display: none; }
.error-text { color: #a62940; }

.hero { min-height: 475px; display: grid; grid-template-columns: minmax(265px, .9fr) minmax(0, 1.1fr); align-items: center; gap: clamp(24px, 5vw, 68px); padding: 51px 0 44px; }
.hero h1 { font-size: clamp(3.25rem, 7.8vw, 6.6rem); line-height: .99; letter-spacing: -.057em; }
.grade { margin: 0 0 13px; font-weight: 700; color: var(--blue-dark); }
.hero-description { max-width: 370px; font-size: clamp(1rem, 1.8vw, 1.15rem); color: var(--muted); margin: 21px 0 24px; }
.hero-figure { margin: 0; align-self: center; justify-self: stretch; }
.paper-preview { display: block; position: relative; aspect-ratio: 1.47; overflow: hidden; background: #f0f3f4; border: 9px solid #dcebf7; border-radius: 24px; box-shadow: 0 7px 0 #d0e1ef; }
.paper-preview img { display: block; width: 100%; height: auto; }
.hint-box { position: absolute; left: 54%; top: 24%; width: 13%; height: 15%; border: 2px solid var(--amber); border-radius: 10px; background: #ffc34326; }
.hint-sound { position: absolute; left: 58%; top: 17%; display: grid; place-items: center; width: 25px; height: 25px; color: var(--ink); background: #ffdf84; border-radius: 50%; }
.hint-sound svg { width: 17px; height: 17px; }
.hero-figure figcaption { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--muted); font-size: .9rem; margin-top: 17px; }
.hero-figure figcaption svg { width: 18px; height: 18px; }
.home-lessons { padding: 27px 0 68px; border-top: 1px solid var(--line); }
.home-lessons h2 { margin-bottom: 21px; }
.lesson-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.lesson-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; background: white; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); padding: 14px; min-height: 85px; }
.lesson-card:hover { border-color: #77ace0; background: #fafdff; }
.lesson-number { display: grid; place-items: center; border-radius: 11px; background: var(--sky); color: var(--blue-dark); font-size: 1.45rem; font-weight: 760; width: 47px; height: 47px; }
.lesson-card:nth-child(3n+2) .lesson-number { color: var(--green); background: #e2f4e7; }
.lesson-card:nth-child(3n+3) .lesson-number { color: #815000; background: #fff2cb; }
.lesson-card strong, .lesson-card small { display: block; }
.lesson-card small { color: var(--muted); font-size: .86rem; }
.lesson-card > svg { color: var(--blue); width: 21px; }

.reader { padding: 27px 0 29px; }
.reader-top { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.reader-top h1 { font-size: clamp(1.75rem, 4.6vw, 2.75rem); }
.reader-top p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); margin-top: 8px; font-size: .9rem; }
.reader-top p svg { width: 16px; height: 16px; }
.page-switch { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.page-switch a { display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 9px; min-width: 44px; height: 43px; color: var(--blue-dark); font-weight: 750; padding: 0 7px; }
.page-switch a:hover { border-color: var(--blue); }
.page-switch a[aria-current] { background: var(--blue); color: #fff; border-color: var(--blue); }
.reader-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 13px 13px 0 0; background: white; }
.segmented, .zoom-buttons { display: flex; min-width: 0; gap: 4px; }
.segmented button, .zoom-buttons button { border: 0; color: var(--blue-dark); background: transparent; min-height: 42px; min-width: 42px; border-radius: 8px; }
.segmented button { padding: 4px 10px; font-weight: 650; font-size: .92rem; }
.segmented button[aria-pressed="true"], .zoom-buttons button:hover { background: var(--sky); }
.zoom-buttons svg { width: 18px; height: 18px; }
.viewport { position: relative; height: min(72dvh, 790px); min-height: 305px; padding: 12px; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom; background: #dceaf5; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 13px 13px; cursor: grab; }
.viewport.dragging, .viewport.dragging .hotspot { cursor: grabbing; }
.reading-paper { position: relative; margin-inline: auto; background: #fff; border-radius: 3px; box-shadow: 0 2px 10px #24415b20; user-select: none; }
.reading-paper img, .marking-paper img { display: block; width: 100%; height: auto; pointer-events: none; }
.hotspots, .marks { position: absolute; inset: 0; pointer-events: none; }
.hotspot, .marks span { position: absolute; border: 2px solid transparent; border-radius: clamp(4px, 1vw, 12px); padding: 0; background: transparent; pointer-events: auto; touch-action: inherit; }
.hotspot.active, .marks span { border-color: #ae6d06; background: #fbc55047; }
@media (hover: hover) { .hotspot:hover { border-color: #936820; background: #fbc55027; } }
.hotspot:focus-visible { outline-offset: 0; }
.reader-status { min-height: 1.5em; }

.donate-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); gap: clamp(24px, 7vw, 92px); align-items: start; padding-top: clamp(34px, 7vw, 78px); padding-bottom: 66px; }
.donate-symbol { display: grid; place-items: center; height: 53px; width: 53px; border-radius: 17px; background: #fff1c9; color: #8b4d06; margin-bottom: 20px; }
.donate-symbol svg { width: 22px; height: 22px; }
.donate-copy p { margin-top: 18px; max-width: 430px; color: var(--muted); font-size: 1.08rem; }
.checkout, .panel { background: #fff; border: 1px solid var(--line); border-radius: 17px; padding: clamp(15px, 3vw, 27px); }
.checkout form { display: grid; gap: 12px; }
.checkout h2 { font-size: clamp(1.35rem, 3vw, 1.8rem); margin-bottom: 5px; }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.amounts button { min-height: 44px; border: 1px solid var(--line); border-radius: 9px; color: var(--blue-dark); font-weight: 680; background: #fff; }
.amounts button[aria-pressed="true"] { border-color: var(--blue); background: var(--sky); }
label { color: var(--ink); font-weight: 620; }
input:not([type="checkbox"]), select { display: block; width: 100%; max-width: 100%; height: 44px; border-radius: 8px; border: 1px solid #bbcee0; background: #fcfeff; color: var(--ink); padding: 7px 10px; }
input[type="file"] { line-height: 1.85; font-size: .9rem; }
label > input:not([type="checkbox"]), label > select { margin-top: 4px; }
.checkout form .primary { width: 100%; margin-top: 5px; }
.checkout .qr { width: min(250px, 100%); height: auto; display: block; margin: 11px auto; }
.bank-links, .checkout-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 15px; }
.bank-links a { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; }
.payment-complete { text-align: center; padding: 14px; }
.payment-complete > svg { color: var(--green); width: 44px; height: 44px; margin-bottom: 10px; }

.admin-login { padding: 58px 0; }
.admin-login .panel { max-width: 430px; margin-top: 25px; display: grid; gap: 12px; }
.admin-layout { padding: 30px 0 50px; }
.admin-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 23px; }
.admin-heading p { margin-top: 6px; color: var(--muted); }
.admin-workspace { display: grid; grid-template-columns: minmax(175px, 240px) minmax(0, 1fr); gap: 15px; align-items: start; }
.admin-side { display: grid; gap: 12px; padding: 16px; }
.admin-side h2 { font-size: 1.25rem; }
#admin-readings { display: grid; gap: 5px; }
#admin-readings button, .item-list button { display: flex; align-items: center; justify-content: space-between; gap: 5px; text-align: left; width: 100%; min-height: 43px; padding: 6px 8px; color: var(--ink); background: #fff; border: 1px solid transparent; border-radius: 7px; overflow: hidden; }
#admin-readings button:hover, #admin-readings button[aria-pressed=true], .item-list button:hover, .item-list button[aria-pressed=true] { background: var(--sky); border-color: var(--line); }
#admin-readings small { display: block; color: var(--muted); font-size: .81rem; }
.pill { padding: 2px 5px; border-radius: 5px; color: #6a3f22; background: #f8eadd; font-size: .72rem; font-weight: 700; }
.pill.on { color: var(--green); background: #e0f3e7; }
.lesson-settings { padding: 16px; margin-bottom: 12px; }
.lesson-settings form { display: flex; flex-wrap: wrap; align-items: end; gap: 11px; }
.lesson-settings form > label:first-child { flex: 1 1 180px; }
.checkbox { display: flex; align-items: center; align-self: end; gap: 5px; min-height: 45px; }
.checkbox input { accent-color: var(--blue); width: 16px; height: 16px; }
.item-workspace { padding: 18px; }
.item-head, .detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-head h2 { font-size: 1.3rem; }
.filters { display: grid; grid-template-columns: minmax(80px, .6fr) 1fr; gap: 10px; margin: 18px 0 12px; }
.item-grid { display: grid; grid-template-columns: minmax(122px, .66fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.item-list { display: grid; align-content: start; gap: 2px; max-height: 450px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; padding: 5px; }
.item-list button > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.item-list small { flex: none; color: var(--muted); font-size: .76rem; }
.item-list svg { width: 16px; height: 16px; }
.item-detail { display: grid; gap: 12px; padding: 12px; border-radius: 10px; background: #f5f9fd; min-width: 0; }
.item-detail h3 { overflow-wrap: anywhere; }
.detail-heading small { color: var(--muted); }
.clip-info, .edit-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.clip-info span { font-size: .86rem; color: var(--muted); }
.generation-form, .upload-form, .new-reading { display: grid; gap: 9px; }
.upload-form { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 3px; }
.new-reading { max-width: 540px; }
.marking-paper { position: relative; max-width: 100%; cursor: crosshair; touch-action: none; }
.marks span { pointer-events: none; }

@media (max-width: 750px) {
  .hero { min-height: auto; gap: 23px; }
  .lesson-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-workspace { grid-template-columns: 1fr; }
  #admin-readings { grid-template-columns: repeat(auto-fit, minmax(123px, 1fr)); }
}
@media (max-width: 545px) {
  .wrap, .header-inner, .site-footer { width: calc(100% - 28px); }
  .header-inner { min-height: 64px; }
  .brand { gap: 6px; font-size: 1.03rem; }
  .brand-mark { width: 33px; height: 33px; }
  .header-inner nav { gap: 1px; }
  .header-inner nav a { padding: 7px 6px; font-size: .9rem; }
  .hero, .donate-layout { grid-template-columns: 1fr; }
  .hero { padding: 35px 0 25px; }
  .hero h1 { font-size: clamp(3.3rem, 13vw, 4.4rem); }
  .hero-description { margin-top: 15px; }
  .hero-figure { margin-top: 7px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .home-lessons { padding-bottom: 36px; }
  .reader { padding-top: 18px; }
  .reader-top { align-items: start; gap: 5px; }
  .reader-top p { font-size: .82rem; gap: 4px; }
  .page-switch { gap: 4px; }
  .page-switch a { min-width: 32px; height: 38px; }
  .reader-toolbar { padding-inline: 4px; }
  .segmented, .zoom-buttons { gap: 1px; }
  .segmented button { padding-inline: 7px; }
  .zoom-buttons button { min-width: 38px; }
  .viewport { height: 66dvh; }
  .donate-layout { padding-bottom: 42px; }
  .item-grid { grid-template-columns: 1fr; }
  .item-list { max-height: 190px; }
}
