/* KPCambodianmathematics — site styles
   Identity taken from the logo: royal purple ring, gold lettering, drafting tools on graph paper.
   One bold element: the grade "ruler" on the home page. Everything else stays quiet. */

/* ================================================================ tokens */
:root {
  --bg: #f6f5fb;
  --bg-2: #efedf7;
  --surface: #ffffff;
  --surface-2: #f2f0f9;
  --ink: #1d1830;
  --ink-2: #463f5e;
  --ink-3: #6b6485;
  --line: #e3dfee;
  --line-2: #cdc6df;
  --grid: rgba(75, 42, 156, .07);
  --brand: #2a1659;
  --primary: #4b2a9c;
  --primary-strong: #3a1f7d;
  --primary-soft: #ece6fa;
  --gold: #d9a21b;
  --gold-strong: #b98808;
  --gold-soft: #fbf1d6;
  --on-gold: #2a1659;
  --red: #c7362f;
  --red-soft: #fbe7e5;
  --green: #1f8a5b;
  --green-soft: #e2f4ea;
  --g7: #2b5db8; --g8: #1f8a5b; --g9: #6a3fb5; --g10: #c7362f; --g11: #a86b0c; --g12: #0e7490;
  /* names used by older stylesheets (lesson.css, kp-teacher.css, construct.css) */
  --teal: var(--primary); --teal-strong: var(--primary-strong); --teal-soft: var(--primary-soft);
  --amber: var(--gold-strong); --amber-soft: var(--gold-soft);
  --blue: #2b5db8; --blue-soft: #e4ecf9; --violet: #6a3fb5; --violet-soft: #eee7fa;
  --rose: var(--red); --rose-soft: var(--red-soft); --slate: #4a5670; --slate-soft: #e9ecf2;
  --header-bg: rgba(255, 255, 255, .92);
  --shadow-sm: 0 1px 2px rgba(42, 22, 89, .06);
  --shadow: 0 10px 28px -14px rgba(42, 22, 89, .28);
  --shadow-lg: 0 24px 56px -22px rgba(42, 22, 89, .38);
  --radius: 14px;
  --radius-sm: 10px;
  --wrap: 1160px;
  --header-h: 68px;
  --font: 'Kantumruy Pro', 'Noto Sans Khmer', 'Khmer OS Siemreap', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121020; --bg-2: #171428; --surface: #1b1830; --surface-2: #231f3c;
    --ink: #ece9f7; --ink-2: #c4bedA; --ink-3: #9790b3; --line: #2e2948; --line-2: #3d3760;
    --grid: rgba(183, 156, 245, .06);
    --primary: #b79cf5; --primary-strong: #cdb8ff; --primary-soft: #2c2350;
    --gold: #e8b93a; --gold-strong: #e8b93a; --gold-soft: #3a2e12;
    --red: #f08a82; --red-soft: #3c1d1c; --green: #5fcf9a; --green-soft: #173528;
    --g7: #7fa6ec; --g8: #5fcf9a; --g9: #b79cf5; --g10: #f08a82; --g11: #e8b93a; --g12: #5cc4dc;
    --blue: #7fa6ec; --blue-soft: #1c2a45; --violet: #b79cf5; --violet-soft: #2c2350; --slate: #a9b3c9; --slate-soft: #232838;
    --header-bg: rgba(18, 16, 32, .9);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35); --shadow: 0 12px 30px -12px rgba(0, 0, 0, .6); --shadow-lg: 0 28px 60px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121020; --bg-2: #171428; --surface: #1b1830; --surface-2: #231f3c;
  --ink: #ece9f7; --ink-2: #c4beda; --ink-3: #9790b3; --line: #2e2948; --line-2: #3d3760;
  --grid: rgba(183, 156, 245, .06);
  --primary: #b79cf5; --primary-strong: #cdb8ff; --primary-soft: #2c2350;
  --gold: #e8b93a; --gold-strong: #e8b93a; --gold-soft: #3a2e12;
  --red: #f08a82; --red-soft: #3c1d1c; --green: #5fcf9a; --green-soft: #173528;
  --g7: #7fa6ec; --g8: #5fcf9a; --g9: #b79cf5; --g10: #f08a82; --g11: #e8b93a; --g12: #5cc4dc;
  --blue: #7fa6ec; --blue-soft: #1c2a45; --violet: #b79cf5; --violet-soft: #2c2350; --slate: #a9b3c9; --slate-soft: #232838;
  --header-bg: rgba(18, 16, 32, .9);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35); --shadow: 0 12px 30px -12px rgba(0, 0, 0, .6); --shadow-lg: 0 28px 60px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ================================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.85; font-weight: 400;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-strong); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.5; font-weight: 700; color: var(--ink); }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 16px; background: var(--brand); color: #fff; border-radius: 8px; }
.skip:focus { top: 10px; color: #fff; }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 16px; height: 16px; }
.nowrap { white-space: nowrap; }
.muted, .note { color: var(--ink-3); font-size: 14.5px; }

/* ================================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 8px 22px; border-radius: 12px; border: 1.5px solid transparent;
  font: inherit; font-size: 16px; font-weight: 600; line-height: 1.4; text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn .ic { width: 19px; height: 19px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); color: #fff; }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-primary:hover { color: #160f2c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) .btn-primary:hover { color: #160f2c; } }
.btn-gold, .btn-amber { background: var(--gold); color: var(--on-gold); }
.btn-gold:hover, .btn-amber:hover { background: var(--gold-strong); color: var(--on-gold); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { min-height: 38px; padding: 5px 15px; font-size: 14.5px; border-radius: 10px; }
.text-link { font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* ================================================================ header */
.site-header { position: sticky; top: 0; z-index: 50; height: var(--header-h); border-bottom: 1px solid var(--line); }
.site-header::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--header-bg); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.header-inner { display: flex; align-items: center; gap: 20px; height: 100%; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); flex: none; }
.brand img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--gold-soft); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: 17.5px; letter-spacing: -.01em; color: var(--brand); }
:root[data-theme="dark"] .brand-text b { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-text b { color: var(--ink); } }
.brand-text small { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.main-nav { flex: 1; display: flex; justify-content: flex-end; }
.nav-list { display: flex; align-items: center; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav-item { position: relative; }
.nav-link {
  display: inline-flex; align-items: center; gap: 5px; padding: 8px 13px; border: 0; border-radius: 10px;
  background: none; color: var(--ink-2); font: inherit; font-size: 15.5px; font-weight: 500; cursor: pointer; text-decoration: none;
}
.nav-link:hover, .nav-item.open > .nav-link { background: var(--surface-2); color: var(--ink); }
.nav-item.current > .nav-link { color: var(--primary); font-weight: 700; }
.nav-link .chev { width: 15px; height: 15px; transition: transform .2s; }
.nav-item.open > .nav-link .chev { transform: rotate(180deg); }
.menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 60; min-width: 340px;
  padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .15s, transform .15s, visibility .15s;
}
.menu::before { content: ''; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.nav-item.open > .menu { opacity: 1; visibility: visible; transform: none; }
.menu-grades { display: grid; grid-template-columns: 1fr 1fr; min-width: 420px; left: 50%; right: auto; transform: translate(-50%, 6px); }
.nav-item.open > .menu-grades { transform: translate(-50%, 0); }
.menu a { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.menu a:hover { background: var(--surface-2); }
.menu .mi { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.menu .mi .ic { width: 20px; height: 20px; }
.menu .mt { display: block; font-weight: 600; font-size: 15px; line-height: 1.5; }
.menu .md { display: block; font-size: 13px; line-height: 1.55; color: var(--ink-3); }
.menu .grade-num { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px; font-weight: 700; font-size: 19px; color: #fff; background: var(--c); }
.menu .menu-all { justify-content: center; margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; font-size: 14.5px; font-weight: 600; color: var(--primary); }
.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}
.menu-toggle { display: none; }
.menu-toggle .i-close { display: none; }
body.nav-open .menu-toggle .i-menu { display: none; }
body.nav-open .menu-toggle .i-close { display: block; }
.nav-mobile-cta { display: none; }

/* grade colours */
.g7 { --c: var(--g7); } .g8 { --c: var(--g8); } .g9 { --c: var(--g9); } .g10 { --c: var(--g10); } .g11 { --c: var(--g11); } .g12 { --c: var(--g12); }
.fg { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; flex: none; border-radius: 8px; background: var(--c, var(--primary)); color: #fff; font-weight: 700; font-size: 15px; line-height: 1; }
:root[data-theme="dark"] .fg, :root[data-theme="dark"] .menu .grade-num { color: #121020; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fg, :root:not([data-theme="light"]) .menu .grade-num { color: #121020; } }

/* ================================================================ sections */
main { display: block; }
.section { padding: 80px 0; }
.section-tight { padding: 48px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { max-width: 720px; margin: 0 0 32px; }
.section-head h2, .split-2 h2 { font-size: clamp(25px, 3vw, 32px); }
.section-head p, .split-2 .sub { margin: 8px 0 0; color: var(--ink-2); font-size: 17px; }
.more { margin: 28px 0 0; }
.eyebrow { display: inline-block; margin-bottom: 10px; font-size: 14.5px; font-weight: 600; color: var(--primary); }
.lead { color: var(--ink-2); font-size: 18.5px; }

/* ================================================================ home hero + ruler */
.home-hero {
  position: relative; padding: 64px 0 56px; border-bottom: 1px solid var(--line);
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px; background-position: -1px -1px;
}
.home-hero h1 { max-width: 820px; font-size: clamp(32px, 4.6vw, 52px); line-height: 1.4; letter-spacing: -.01em; color: var(--brand); }
:root[data-theme="dark"] .home-hero h1 { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .home-hero h1 { color: var(--ink); } }
.home-hero .lead { max-width: 640px; margin: 16px 0 0; }
.finder { position: relative; max-width: 640px; margin: 28px 0 0; }
.finder-ic { position: absolute; left: 16px; top: 15px; color: var(--ink-3); }
.finder input {
  width: 100%; height: 54px; padding: 0 18px 0 50px; border-radius: 14px; border: 1.5px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16.5px; box-shadow: var(--shadow-sm);
}
.finder input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.finder-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; }
.finder-list a { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; line-height: 1.5; }
.finder-list a:hover, .finder-list a.on { background: var(--surface-2); }
.finder-list b { display: block; font-weight: 600; font-size: 15.5px; }
.finder-list small { display: block; color: var(--ink-3); font-size: 13px; }
.finder-list .none { padding: 12px; color: var(--ink-3); font-size: 15px; }

.ruler {
  position: relative; display: grid; grid-template-columns: repeat(6, 1fr); margin: 40px 0 0;
  background: var(--surface); border: 1.5px solid var(--brand); border-radius: 6px; overflow: hidden; box-shadow: var(--shadow);
}
:root[data-theme="dark"] .ruler { border-color: var(--line-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ruler { border-color: var(--line-2); } }
/* millimetre ticks along the top edge, like a drafting ruler */
.ruler::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 14px; pointer-events: none;
  background-image:
    repeating-linear-gradient(90deg, var(--ink-3) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(90deg, var(--ink-2) 0 1px, transparent 1px 50px);
  background-size: 100% 7px, 100% 14px; background-repeat: no-repeat;
  opacity: .55;
}
.rule-cell {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; padding: 26px 20px 18px;
  border-left: 1.5px solid var(--line-2); color: var(--ink); text-decoration: none; transition: background .15s;
}
.rule-cell:first-child { border-left: 0; }
.rule-cell:hover { background: color-mix(in srgb, var(--c) 9%, var(--surface)); color: var(--ink); }
.rule-num { font-size: clamp(44px, 5.6vw, 72px); font-weight: 700; line-height: 1.15; color: var(--c); letter-spacing: -.02em; }
.rule-lbl { margin-top: 4px; font-weight: 600; font-size: 15.5px; }
.rule-sub { color: var(--ink-3); font-size: 13.5px; }
.rule-cell::after { content: ''; position: absolute; left: 20px; right: 20px; bottom: 0; height: 4px; border-radius: 4px 4px 0 0; background: var(--c); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
.rule-cell:hover::after, .rule-cell:focus-visible::after { transform: scaleX(1); }
.ruler.small { max-width: 640px; margin: 26px auto; }
.ruler.small .rule-cell { align-items: center; padding: 20px 8px 12px; }
.ruler.small .rule-num { font-size: 36px; }
.hero-facts { margin: 18px 0 0; color: var(--ink-3); font-size: 15px; }

/* ================================================================ role portal: users (student, teacher) | admin */
.portal-sec { padding-top: 56px; }
.portal { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: stretch; }
.portal-t { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--ink-3); }
.portal-users { padding: 22px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.portal-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.role { display: flex; flex-direction: column; align-items: flex-start; padding: 22px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.role h4, .portal-admin h4 { margin: 12px 0 4px; font-size: 22px; }
.role p, .portal-admin p { margin: 0 0 12px; color: var(--ink-2); font-size: 15.5px; line-height: 1.75; }
.role .btn, .portal-admin .btn { margin-top: auto; }
.role-i { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.role-student .role-i { background: var(--gold-soft); color: var(--gold-strong); }
.role-links { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 2px; }
.role-links a { font-weight: 600; font-size: 15px; text-decoration: none; }
.role-links a:hover { text-decoration: underline; }
.role-links a::before { content: '›'; margin-right: 8px; color: var(--ink-3); }
.portal-admin { display: flex; flex-direction: column; align-items: flex-start; padding: 22px; border-radius: 18px; background: var(--brand); color: #e9e4f8; }
.portal-admin .portal-t { color: #b9addb; }
.portal-admin h4 { color: #fff; }
.portal-admin p { color: #cfc6ea; }
.portal-admin .role-i { background: rgba(255, 255, 255, .1); color: var(--gold); }
@media (max-width: 960px) { .portal { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .portal-pair { grid-template-columns: 1fr; } .portal-users { padding: 14px; } }

/* ================================================================ home blocks */
.split-2 { display: grid; grid-template-columns: .85fr 1.15fr; gap: 56px; align-items: start; }
.feature-list { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 32px; margin: 0; padding: 0; list-style: none; }
.feature-list li { display: flex; gap: 14px; align-items: flex-start; }
.feature-list .ic { width: 26px; height: 26px; margin-top: 4px; color: var(--primary); }
.feature-list b { display: block; font-size: 17px; }
.feature-list span { display: block; color: var(--ink-2); font-size: 15.5px; line-height: 1.75; }

.link-list { display: grid; gap: 8px 22px; margin: 0; padding: 0; list-style: none; }
.link-list.cols-2 { grid-template-columns: repeat(2, 1fr); }
.link-list.cols-3 { grid-template-columns: repeat(3, 1fr); }
.link-list a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; color: var(--ink); text-decoration: none; line-height: 1.55; }
.link-list a:hover { background: var(--surface); border-color: var(--line); }
.section-alt .link-list a:hover { background: var(--bg); }
.link-list b { display: block; font-weight: 600; font-size: 15.5px; }
.link-list small { display: block; color: var(--ink-3); font-size: 13.5px; }
.link-list .n { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 8px; background: color-mix(in srgb, var(--c, var(--primary)) 12%, transparent); color: var(--c, var(--primary)); font-weight: 700; font-size: 15px; }

.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.tool { display: flex; flex-direction: column; gap: 6px; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: border-color .15s; }
.tool:hover { border-color: var(--primary); color: var(--ink); }
.tool-i { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 8px; border-radius: 12px; background: var(--gold-soft); color: var(--gold-strong); }
.tool b { font-size: 18px; }
.tool > span:last-child { color: var(--ink-2); font-size: 15.5px; line-height: 1.75; }

.contact-band { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 32px; padding: 32px 36px; border-radius: 18px; background: var(--brand); color: #e9e4f8; }
.contact-band h2 { color: #fff; font-size: clamp(22px, 2.6vw, 28px); }
.contact-band p { margin: 6px 0 0; max-width: 620px; color: #cfc6ea; }

/* ================================================================ inner pages */
.page-hero {
  position: relative; padding: 40px 0 34px; border-bottom: 1px solid var(--line); background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
}
.page-hero > .wrap { position: relative; }
.page-hero h1 { font-size: clamp(28px, 3.6vw, 40px); }
.page-hero .lead { max-width: 720px; margin: 10px 0 0; font-size: 18px; }
.page-hero .hero-actions { margin-top: 22px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; font-size: 14px; color: var(--ink-3); }
.crumbs li + li::before { content: '/'; margin-right: 6px; color: var(--line-2); }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--primary); text-decoration: underline; }
.grade-hero { display: flex; align-items: center; gap: 24px; }
.grade-badge { display: grid; place-items: center; width: 58px; height: 58px; flex: none; border-radius: 14px; background: var(--c, var(--primary)); color: #fff; font-size: 28px; font-weight: 700; }
.grade-hero .grade-badge { width: 92px; height: 92px; border-radius: 20px; font-size: 46px; }
.grade-hero .level { display: block; font-size: 15px; font-weight: 600; color: var(--c); }
:root[data-theme="dark"] .grade-badge { color: #121020; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .grade-badge { color: #121020; } }

.gtabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.gtab { display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 500; font-size: 15px; }
.gtab:hover { border-color: var(--c); color: var(--ink); }
.gtab .fg { min-width: 28px; height: 28px; font-size: 14px; }
.pgrade { padding: 8px 0 36px; border-bottom: 1px solid var(--line); margin-bottom: 36px; scroll-margin-top: calc(var(--header-h) + 12px); }
.pgrade:last-child { border-bottom: 0; }
.pgrade h2 { display: flex; align-items: center; gap: 12px; font-size: 26px; margin-bottom: 8px; }
.pgrade h3 { margin: 18px 0 8px; font-size: 16.5px; color: var(--ink-2); }

.level-label { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; font-size: 16px; font-weight: 700; color: var(--ink-2); }
.level-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.chapters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.chapters:empty { display: none; }
.chapter {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: border-color .15s;
}
.chapter:hover { border-color: var(--c, var(--primary)); color: var(--ink); }
.chapter .n { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: color-mix(in srgb, var(--c, var(--primary)) 13%, transparent); color: var(--c, var(--primary)); font-weight: 700; }
.chapter b { display: block; font-weight: 600; font-size: 15.5px; line-height: 1.6; }
.chapter small { display: block; color: var(--ink-3); font-size: 13.5px; line-height: 1.6; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card { display: flex; flex-direction: column; padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
a.card { transition: border-color .15s; }
a.card:hover { border-color: var(--primary); color: var(--ink); }
.card .ci { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 10px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.card h3 { font-size: 17.5px; }
.card p { margin: 4px 0 0; color: var(--ink-2); font-size: 15px; line-height: 1.7; }
.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grade-card { display: flex; flex-direction: column; padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.grade-card:hover { border-color: var(--c); color: var(--ink); }
.grade-top { display: flex; align-items: center; justify-content: space-between; }
.grade-card h3 { margin-top: 14px; font-size: 20px; }
.grade-card p { margin: 4px 0 12px; color: var(--ink-2); font-size: 15px; }
.grade-card .topics { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.grade-card .go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--c); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; border-radius: var(--radius); background: var(--line); border: 1px solid var(--line); }
.stat { padding: 20px; background: var(--surface); }
.stat b { display: block; font-size: 28px; line-height: 1.3; }
.stat span { color: var(--ink-3); font-size: 14.5px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.8; white-space: nowrap; }
.chip-live { background: var(--green-soft); color: var(--green); }
.chip-soon { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }
.callout { display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px; border-radius: var(--radius); background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); color: var(--ink); }
.callout .ic { color: var(--gold-strong); margin-top: 4px; }
.callout p { margin: 0; color: var(--ink-2); font-size: 15.5px; }
.report { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 28px 0 8px; padding: 16px 18px; border-radius: 14px; background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); color: var(--ink); line-height: 1.7; }
.report-i { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--gold); color: var(--on-gold); }
.report-t { flex: 1 1 260px; display: flex; flex-direction: column; }
.report-t span { color: var(--ink-2); font-size: 14.5px; }

.prose { max-width: 760px; }
.prose h2 { margin: 34px 0 10px; font-size: 23px; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--ink-2); }
.prose ul { padding-left: 1.3em; }
.steps-line { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0; padding: 0; list-style: none; counter-reset: st; }
.steps-line li { position: relative; padding: 46px 22px 0 0; counter-increment: st; }
.steps-line li::before { content: counter(st, khmer); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; z-index: 1; }
.steps-line li::after { content: ''; position: absolute; left: 34px; right: 0; top: 17px; height: 2px; background: var(--line-2); }
.steps-line li:last-child::after { display: none; }
.steps-line b { display: block; font-size: 17px; }
.steps-line span { display: block; color: var(--ink-2); font-size: 15px; line-height: 1.75; }
.link-plain { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 32px; padding: 0; list-style: none; }
.sitemap-cols { columns: 3 280px; column-gap: 36px; }
.sitemap-cols section { break-inside: avoid; margin-bottom: 26px; }
.sitemap-cols h2 { font-size: 19px; margin-bottom: 4px; }
.sitemap-cols ol { margin: 0; padding-left: 1.6em; font-size: 15px; line-height: 1.8; }
.center-block { text-align: center; max-width: 720px; }
.big-404 { margin: 0; font-size: 96px; font-weight: 700; line-height: 1.2; color: var(--gold); }

/* ================================================================ footer: Khmer skyline on royal purple */
.site-footer { position: relative; margin-top: 150px; padding: 40px 0 26px; background: var(--brand); color: #d9d1f0; }
:root[data-theme="dark"] .site-footer { background: #0d0a1c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-footer { background: #0d0a1c; } }
/* Phnom Bakheng · sugar palms · Angkor Wat · Banteay Srei, standing on the footer */
.site-footer::before {
  content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: clamp(70px, 11vw, 150px); pointer-events: none;
  background: var(--brand);
  -webkit-mask: var(--k-skyline) center bottom / auto 100% repeat-x; mask: var(--k-skyline) center bottom / auto 100% repeat-x;
}
:root[data-theme="dark"] .site-footer::before { background: #0d0a1c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-footer::before { background: #0d0a1c; } }
/* gold kbach band along the top edge of the footer */
.site-footer::after {
  content: ''; position: absolute; left: 0; right: 0; top: 10px; height: 14px; background: var(--gold); opacity: .9; pointer-events: none;
  -webkit-mask: var(--k-band) left top / 35px 14px repeat-x; mask: var(--k-band) left top / 35px 14px repeat-x;
}
.site-footer .wrap { position: relative; padding-top: 22px; }
.footer-grid { display: grid; grid-template-columns: minmax(290px, 1.5fr) repeat(4, minmax(0, 1fr)); gap: 32px; }
.site-footer .brand { color: #fff; }
.site-footer .brand-text b { color: #fff; }
.site-footer .brand-text small { color: #b9addb; }
.site-footer .brand img { box-shadow: 0 0 0 2px var(--gold); }
.footer-brand p { margin: 14px 0 12px; max-width: 320px; color: #cfc6ea; font-size: 14.5px; line-height: 1.8; }
.tg-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; text-decoration: none; }
.site-footer .tg-link { color: var(--gold); }
.site-footer .tg-link:hover { color: #fff; }
.tg-link .ic { width: 18px; height: 18px; }
.footer-col h4 { margin-bottom: 10px; font-size: 15px; color: var(--gold); }
.footer-col ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.footer-col a { color: #d9d1f0; text-decoration: none; font-size: 14.5px; }
.footer-col a:hover { color: #fff; text-decoration: underline; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 40px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, .14); color: #b9addb; font-size: 13.5px; }
.footer-bottom p { margin: 0; }
.site-footer :focus-visible { outline-color: var(--gold); }

/* ================================================================ Khmer ornaments */
/* kbach fringe hanging under the header, like the edge of a lintel */
.site-header::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 10px; background: var(--gold); pointer-events: none; opacity: .85;
  -webkit-mask: var(--k-band) left top / 25px 10px repeat-x; mask: var(--k-band) left top / 25px 10px repeat-x;
  transform: scaleY(-1);
}
/* Angkor Wat and sugar palms rising behind the home hero */
.home-hero { overflow: hidden; }
.home-hero > .wrap { position: relative; z-index: 1; }
.home-hero::after {
  content: ''; position: absolute; right: max(0px, calc((100vw - var(--wrap)) / 2 - 40px)); top: 36px; width: min(36vw, 470px); aspect-ratio: 3 / 1; pointer-events: none;
  background: var(--primary); opacity: .13;
  -webkit-mask: var(--k-angkor) right bottom / contain no-repeat; mask: var(--k-angkor) right bottom / contain no-repeat;
}
/* kbach scroll in the corner of inner page titles */
.page-hero { overflow: hidden; }
.page-hero::after, .tp-hero::after {
  content: ''; position: absolute; right: 18px; top: 14px; width: 120px; height: 120px; pointer-events: none;
  background: var(--gold); opacity: .45; transform: scaleX(-1);
  -webkit-mask: var(--k-corner) center / contain no-repeat; mask: var(--k-corner) center / contain no-repeat;
}
.tp-hero { position: relative; overflow: hidden; }
/* lotus ornament: a divider and a mark before section titles */
.lotus-rule { display: flex; align-items: center; gap: 14px; max-width: 360px; margin: 0 auto 30px; color: var(--gold-strong); }
.lotus-rule::before, .lotus-rule::after { content: ''; flex: 1; height: 1px; background: currentColor; opacity: .5; }
.lotus-rule i, .lotus-mark { display: inline-block; width: 34px; height: 28px; background: currentColor;
  -webkit-mask: var(--k-lotus) center / contain no-repeat; mask: var(--k-lotus) center / contain no-repeat; }
.lotus-mark { width: 26px; height: 22px; margin-right: 10px; vertical-align: -2px; color: var(--gold-strong); }
.big-404 + h1 { margin-top: 0; }
/* kbach band on the dark panels (Admin card, contact band) */
.portal-admin, .contact-band { position: relative; overflow: hidden; }
.portal-admin::after, .contact-band::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: var(--gold); opacity: .55; pointer-events: none;
  -webkit-mask: var(--k-band) left bottom / 30px 12px repeat-x; mask: var(--k-band) left bottom / 30px 12px repeat-x;
}
.portal-admin::before {
  content: ''; position: absolute; right: -10px; top: -10px; width: 130px; height: 130px; background: var(--gold); opacity: .18; pointer-events: none;
  -webkit-mask: var(--k-corner) center / contain no-repeat; mask: var(--k-corner) center / contain no-repeat; transform: scaleX(-1);
}
.portal-admin > *, .contact-band > * { position: relative; }

/* ================================================================ responsive */
@media (max-width: 1080px) {
  .nav-link { padding: 8px 9px; font-size: 15px; }
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .home-hero::after { opacity: .07; top: auto; bottom: 0; width: 80vw; }
  :root { --header-h: 62px; }
  .menu-toggle { display: grid; }
  .main-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0; z-index: 45; display: block;
    padding: 12px 16px 40px; overflow-y: auto; background: var(--bg);
    opacity: 0; visibility: hidden; transition: opacity .18s, visibility .18s;
  }
  html.nav-open { overflow: hidden; }
  body.nav-open .main-nav { opacity: 1; visibility: visible; }
  .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
  .nav-item { border-bottom: 1px solid var(--line); }
  .nav-link { width: 100%; justify-content: space-between; padding: 15px 6px; font-size: 17px; font-weight: 600; color: var(--ink); border-radius: 0; }
  .nav-link:hover, .nav-item.open > .nav-link { background: none; }
  .menu, .menu-grades {
    position: static; min-width: 0; display: none; padding: 0 0 12px; border: 0; border-radius: 0; box-shadow: none; background: none;
    opacity: 1; visibility: visible; transform: none !important; transition: none;
  }
  .menu::before { display: none; }
  .nav-item.open > .menu { display: block; }
  .nav-item.open > .menu-grades { display: grid; grid-template-columns: 1fr 1fr; }
  .nav-mobile-cta { display: grid; gap: 10px; margin-top: 22px; }
  .hide-sm { display: none; }
  .ruler { grid-template-columns: repeat(3, 1fr); }
  .rule-cell:nth-child(4) { border-left: 0; }
  .rule-cell:nth-child(n+4) { border-top: 1.5px solid var(--line-2); }
  .split-2 { grid-template-columns: 1fr; gap: 28px; }
  .chapters, .cards, .grades, .tools, .link-list.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .steps-line { grid-template-columns: 1fr 1fr; gap: 26px 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 60px 0; }
}
@media (max-width: 640px) {
  body { font-size: 16.5px; }
  .wrap { padding: 0 16px; }
  .brand-text small { display: none; }
  .brand-text b { font-size: 15.5px; }
  .home-hero { padding: 40px 0 36px; }
  .rule-cell { padding: 22px 14px 14px; }
  .rule-lbl { font-size: 14px; }
  .feature-list, .chapters, .cards, .grades, .tools, .link-list.cols-2, .link-list.cols-3, .steps-line { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .contact-band { padding: 26px 22px; }
  .grade-hero .grade-badge { width: 64px; height: 64px; font-size: 32px; border-radius: 16px; }
  .menu-grades { grid-template-columns: 1fr !important; }
}
@media print {
  .site-header::after, .site-footer::before, .site-footer::after,
  .site-header, .site-footer, .skip, .no-print { display: none !important; }
  body { background: #fff; }
}

/* ================================================================ real photographs (static/img/photos/*, see build_site_from_template.PHOTOS) */
.home-hero, .page-hero, .tp-hero, .site-footer { --photo: none; }
.home-hero { background-image: linear-gradient(90deg, var(--bg) 30%, color-mix(in srgb, var(--bg) 70%, transparent) 62%, color-mix(in srgb, var(--bg) 35%, transparent)), var(--photo), linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: auto, cover, 28px 28px, 28px 28px; background-position: 0 0, right center, -1px -1px, -1px -1px; }
.page-hero { background-image: linear-gradient(90deg, var(--surface) 40%, color-mix(in srgb, var(--surface) 55%, transparent)), var(--photo), linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: auto, cover, 28px 28px, 28px 28px; background-position: 0 0, right center, 0 0, 0 0; }
.site-footer { background-image: linear-gradient(color-mix(in srgb, var(--brand) 92%, transparent), color-mix(in srgb, var(--brand) 80%, transparent)), var(--photo); background-size: cover; background-position: center; }

/* ---------- About: biography, timeline, documents ---------- */
.section-title { font-size: clamp(23px, 2.6vw, 29px); margin: 0 0 18px; }
.section-title::before { content: ""; display: inline-block; width: 22px; height: 22px; margin-right: 10px; vertical-align: -3px; background: var(--gold); -webkit-mask: var(--k-lotus) center/contain no-repeat; mask: var(--k-lotus) center/contain no-repeat; }
.bio-card { position: relative; display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 36px; align-items: start; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px); box-shadow: var(--shadow); overflow: hidden; }
.bio-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: var(--gold); -webkit-mask: var(--k-band) left bottom/auto 12px repeat-x; mask: var(--k-band) left bottom/auto 12px repeat-x; opacity: .85; }
.bio-photo { display: block; border-radius: var(--radius); overflow: hidden; border: 4px solid var(--gold-soft); box-shadow: 0 0 0 1px var(--gold), var(--shadow); aspect-ratio: 4 / 5; }
.bio-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.bio-photo:hover img { transform: scale(1.03); }
.bio-text h2 { margin: 0; font-size: clamp(28px, 3.4vw, 38px); }
.bio-latin { display: block; font-size: 17px; font-weight: 500; color: var(--ink-3); letter-spacing: .02em; }
.bio-role { margin: 8px 0 16px; font-weight: 600; color: var(--primary); }
.bio-text > p { color: var(--ink-2); }
.bio-facts { list-style: none; padding: 0; margin: 20px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bio-facts li { padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); border-left: 3px solid var(--gold); }
.bio-facts b { display: block; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.bio-facts span { color: var(--ink); font-weight: 600; }
.bio-text .btn + .btn { margin-left: 8px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 26px; position: relative; max-width: 860px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--gold), var(--primary)); }
.timeline li { position: relative; padding: 0 0 22px 18px; }
.timeline li::before { content: ""; position: absolute; left: -26px; top: 5px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--gold); }
.timeline li:first-child::before { background: var(--gold); }
.tl-year { display: inline-block; font-size: 13.5px; font-weight: 700; color: var(--on-gold); background: var(--gold-soft); padding: 2px 10px; border-radius: 99px; margin-bottom: 4px; }
:root[data-theme="dark"] .tl-year { color: var(--gold); }
.timeline b { display: block; color: var(--ink); }
.timeline small { color: var(--ink-3); font-size: 14.5px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; margin: 18px 0 22px; }
.doc-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s; display: flex; flex-direction: column; }
.doc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.doc-card a { display: block; height: 200px; background: var(--surface-2); padding: 10px; }
.doc-card img { width: 100%; height: 100%; object-fit: contain; display: block; }
.doc-card figcaption { padding: 12px 14px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; flex: 1; }
.doc-card figcaption b { font-size: 15px; line-height: 1.5; color: var(--ink); }
.doc-card figcaption small { color: var(--ink-3); font-size: 13.5px; }
.doc-year { margin-top: auto; padding-top: 6px; font-size: 13px; font-weight: 700; color: var(--gold-strong); }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 94vh; }
.lightbox::backdrop { background: rgba(14, 8, 34, .86); }
.lightbox img { display: block; max-width: 96vw; max-height: 84vh; border-radius: 8px; box-shadow: var(--shadow-lg); }
.lb-cap { color: #fff; text-align: center; margin: 10px 0 0; font-weight: 600; }
.lb-close { position: fixed; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; cursor: pointer; display: grid; place-items: center; }
.lb-close .ic { width: 22px; height: 22px; }
@media (max-width: 760px) {
  .bio-card { grid-template-columns: 1fr; padding: 18px; gap: 20px; }
  .bio-photo { max-width: 280px; margin: 0 auto; }
  .bio-facts { grid-template-columns: 1fr; }
  .bio-text .btn + .btn { margin: 8px 0 0; }
}
.doc-group { display: flex; align-items: center; gap: 10px; margin: 26px 0 0; font-size: 19px; color: var(--primary); }
.doc-group span { font-size: 13px; font-weight: 700; color: var(--on-gold); background: var(--gold-soft); border-radius: 99px; padding: 1px 10px; }
:root[data-theme="dark"] .doc-group span { color: var(--gold); }
.doc-group::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.bio-skills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.bio-skills span { font-size: 13.5px; font-weight: 600; padding: 4px 12px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }

/* ---------- Books shop ---------- */
.book-card { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 36px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.book-card + .book-card { margin-top: 24px; }
.book-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: var(--gold); -webkit-mask: var(--k-band) left bottom/auto 12px repeat-x; mask: var(--k-band) left bottom/auto 12px repeat-x; opacity: .85; }
.book-cover { position: relative; display: block; align-self: start; border-radius: 6px 12px 12px 6px; overflow: hidden; box-shadow: -6px 0 0 -2px var(--primary-strong), var(--shadow-lg); transition: transform .3s; }
.book-cover:hover { transform: translateY(-4px) rotate(-.6deg); }
.book-cover img { display: block; width: 100%; height: auto; }
.book-badge { position: absolute; top: 12px; right: 12px; background: var(--red); color: #fff; font-weight: 800; font-size: 13px; padding: 3px 10px; border-radius: 6px; letter-spacing: .05em; }
.book-info h2 { margin: 0; font-size: clamp(28px, 3.4vw, 40px); }
.book-en { margin: 4px 0 14px; color: var(--ink-3); font-weight: 600; letter-spacing: .02em; }
.book-info > p { color: var(--ink-2); }
.book-points { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.book-points li { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); }
.book-points .ic { flex: none; width: 18px; height: 18px; margin-top: 4px; color: var(--green); }
.book-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.book-meta div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; border-left: 3px solid var(--gold); }
.book-meta dt { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.book-meta dd { margin: 0; font-weight: 700; color: var(--ink); }
.book-buy { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px dashed var(--line-2); }
.book-price { margin: 0 12px 0 0; font-size: 30px; font-weight: 800; color: var(--primary); }
.book-price small { font-size: 16px; color: var(--ink-3); font-weight: 600; }
.buy-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; counter-reset: s; }
.buy-steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.buy-steps b { display: block; margin: 10px 0 4px; color: var(--ink); }
.buy-steps p { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.step-n { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: var(--on-gold); font-weight: 800; font-size: 17px; }
.redeem-box { max-width: 760px; margin: 0 auto; padding: 26px; border-radius: calc(var(--radius) + 4px); background: linear-gradient(135deg, var(--primary-soft), var(--gold-soft)); border: 1px solid var(--line-2); }
.redeem-box h2 { margin: 0 0 6px; display: flex; gap: 10px; align-items: center; }
.redeem-box h2 .ic { width: 26px; height: 26px; color: var(--green); }
.rd-form { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.rd-form textarea { flex: 1 1 320px; min-height: 76px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 13px/1.5 ui-monospace, Consolas, monospace; resize: vertical; word-break: break-all; }
.rd-msg { margin: 12px 0 0; min-height: 1.5em; color: var(--ink-2); }
.rd-msg.ok { color: var(--green); font-weight: 600; }
.rd-msg.bad { color: var(--red); }
.order-dlg { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border: 0; border-radius: 18px; padding: 24px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.order-dlg::backdrop { background: rgba(14, 8, 34, .7); }
.order-dlg h2 { margin: 0; font-size: 24px; }
.order-dlg .book-price { font-size: 22px; margin: 4px 0 16px; }
.dlg-x { position: absolute; top: 10px; right: 10px; background: var(--surface-2); color: var(--ink); }
.od-oid { padding: 12px 14px; border-radius: 10px; background: var(--gold-soft); border: 1px dashed var(--gold); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.od-oid b { font: 700 18px/1.2 ui-monospace, Consolas, monospace; color: var(--on-gold); letter-spacing: .03em; }
:root[data-theme="dark"] .od-oid b { color: var(--gold); }
.qr-tabs { display: flex; gap: 6px; margin: 10px 0; }
.qr-tabs button { flex: 1; padding: 8px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2); font: inherit; font-weight: 600; cursor: pointer; }
.qr-tabs button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
:root[data-theme="dark"] .qr-tabs button.on { color: #160f2c; }
.qr-pane { margin: 0; text-align: center; }
.qr-pane img { max-width: 100%; max-height: 52vh; border-radius: 12px; box-shadow: var(--shadow); }
.qr-pane figcaption { margin-top: 6px; color: var(--ink-3); font-size: 14px; }
#od-tg-text { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px; resize: none; }
@media (max-width: 860px) {
  .book-card { grid-template-columns: 1fr; padding: 18px; gap: 20px; }
  .book-cover { max-width: 300px; margin: 0 auto; }
  .book-points, .book-meta { grid-template-columns: 1fr 1fr; }
  .buy-steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) { .buy-steps, .book-points { grid-template-columns: 1fr; } }
.bk-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 14px; align-items: end; }
.bk-out textarea { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px; }
#bk-sales { margin-top: 14px; }
