:root {
  --green: #1E5B4A; --green-dark: #123B30; --green-soft: #E3F4EC; --green-line: #A8CBB9;
  --ink: #1B2430; --ink-2: #3D4652; --muted: #5B6470; --line: #E3E6E0; --line-2: #CDD2CA;
  --bg: #F6F7F4; --card: #FFFFFF; --chip: #F1F3EF;
  --yellow: #F5C542; --yellow-ink: #2B2100; --yellow-soft: #FFF8E1; --yellow-line: #F0DC9A;
  --free-bg: #CDEBDD; --free-fg: #0F4A31; --buy-bg: #FFE7A3; --buy-fg: #4A3500; --mem-bg: #D9E2F7; --mem-fg: #1F3577;
  --radius: 16px;
  --font: 'Noto Sans Thai', system-ui, sans-serif; --display: 'Mitr', 'Noto Sans Thai', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.6; }
a { color: var(--green); } a:hover { color: var(--green-dark); }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; line-height: 1.3; margin: 0; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid #2F6FB5; outline-offset: 2px; }

/* buttons */
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--green); color: #fff; } .btn-primary:hover { background: var(--green-dark); color: #fff; }
.btn-yellow { background: var(--yellow); color: var(--yellow-ink); } .btn-yellow:hover { color: var(--yellow-ink); filter: brightness(.96); }
.btn-outline { background: #fff; color: var(--green); border-color: var(--green); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line-2); }
.btn-dark { background: var(--ink); color: #fff; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* header */
.site-header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; gap: 12px 28px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--green); display: grid; place-items: center; }
.brand-name { font-family: var(--display); font-size: 21px; font-weight: 500; }
.main-nav { display: flex; gap: 4px 22px; flex: 1 1 auto; flex-wrap: wrap; }
.main-nav a { color: var(--ink); text-decoration: none; padding: 10px 0; }
.main-nav a[aria-current="page"] { color: var(--green); font-weight: 700; }
.header-actions { display: flex; gap: 10px; align-items: center; }
@media (max-width: 760px) { .main-nav { display: none; } .header-actions .btn { padding: 8px 12px; } }

.promo { background: var(--yellow); color: var(--yellow-ink); text-align: center; font-size: 15px; padding: 9px 16px; }
.promo a { color: var(--yellow-ink); font-weight: 700; }

/* hero */
.hero { background: var(--green); color: #fff; }
.hero .wrap { padding-top: 64px; padding-bottom: 72px; display: flex; flex-direction: column; gap: 20px; }
.hero .tag { align-self: flex-start; background: var(--yellow); color: var(--yellow-ink); font-weight: 600; font-size: 14px; padding: 6px 12px; border-radius: 999px; }
.hero h1 { font-size: clamp(30px, 5vw, 52px); max-width: 760px; }
.hero p { margin: 0; font-size: clamp(16px, 2vw, 19px); color: #D6E7E0; max-width: 620px; }
.search { display: flex; gap: 8px; background: #fff; padding: 7px; border-radius: 14px; max-width: 640px; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 17px; padding: 10px 12px; color: var(--ink); background: transparent; }

/* sections */
.section { padding: 48px 0 8px; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.section-head h2 { font-size: clamp(22px, 3vw, 30px); }

/* level tabs */
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.level-btn { font: inherit; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 72px; border-radius: 14px; background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.level-btn .dot { width: 12px; height: 38px; border-radius: 6px; flex: none; }
.level-btn b { font-family: var(--display); font-weight: 500; font-size: 18px; display: block; }
.level-btn small { font-size: 14px; opacity: .85; }
.level-btn[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (max-width: 760px) {
  .levels { display: flex; overflow-x: auto; scrollbar-width: none; }
  .level-btn { flex: none; min-height: 48px; padding: 8px 14px; border-radius: 999px; }
  .level-btn .dot { width: 10px; height: 10px; } .level-btn small { display: none; } .level-btn b { font-size: 15px; }
}
.filters { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip-row > span { font-weight: 600; font-size: 15px; min-width: 76px; }
.chip { font: inherit; font-size: 15px; padding: 8px 15px; min-height: 42px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (max-width: 760px) { .chip-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .chip-row > span { display: none; } .chip { flex: none; } }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
.card { text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.card:hover { color: var(--ink); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(27,36,48,.10); }
.card-thumb { position: relative; aspect-ratio: 5 / 4; background: #EEF2EF; display: grid; place-items: center; overflow: hidden; }
.card-thumb img { width: 62%; height: 88%; object-fit: cover; object-position: top; border-radius: 4px; box-shadow: 0 6px 16px rgba(27,36,48,.14); background: #fff; }
.card-thumb .paper { width: 52%; height: 80%; background: #fff; border-radius: 4px; box-shadow: 0 6px 16px rgba(27,36,48,.12); }
.badge { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 8px; display: inline-block; }
.card-thumb .badge { position: absolute; top: 10px; left: 10px; }
.badge-free { background: var(--free-bg); color: var(--free-fg); }
.badge-buy { background: var(--buy-bg); color: var(--buy-fg); }
.badge-member { background: var(--mem-bg); color: var(--mem-fg); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-title { font-family: var(--display); font-size: 17px; line-height: 1.45; }
.card-tags { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--ink-2); }
.card-tags span { background: var(--chip); padding: 3px 8px; border-radius: 6px; }
@media (max-width: 560px) { .card-title { font-size: 15px; } .card-body { padding: 10px 12px 12px; } }

.bundle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
@media (max-width: 560px) { .bundle-grid { grid-template-columns: 1fr; } }
.bundle-card { flex-direction: row; align-items: center; padding: 16px; gap: 6px; }
.bundle-card .card-body { padding: 0 0 0 10px; }
.bundle-stack { position: relative; flex: none; width: 92px; height: 108px; }
.bundle-stack span { position: absolute; width: 74px; height: 96px; border-radius: 6px; background: var(--c); }
.bundle-stack span:nth-child(1) { left: 18px; top: 0; opacity: .35; transform: rotate(8deg); }
.bundle-stack span:nth-child(2) { left: 9px; top: 4px; opacity: .6; transform: rotate(3deg); }
.bundle-stack span:nth-child(3) { left: 0; top: 10px; color: #fff; font-family: var(--display); font-size: 13px; display: flex; align-items: flex-end; padding: 8px; box-shadow: 0 6px 16px rgba(27,36,48,.18); }
.empty { background: #fff; border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 40px 20px; text-align: center; color: var(--muted); }

/* steps + member band */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.step-n { width: 42px; height: 42px; border-radius: 50%; background: var(--green); color: #fff; font-family: var(--display); font-size: 19px; display: grid; place-items: center; margin-bottom: 8px; }
.band { background: var(--ink); color: #fff; border-radius: 20px; padding: 36px; display: flex; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: space-between; }
.band p { color: #C9D0D8; margin: 8px 0 0; }

.site-footer { border-top: 1px solid var(--line); background: #fff; margin-top: 56px; }
.site-footer .wrap { padding-top: 28px; padding-bottom: 28px; display: flex; flex-wrap: wrap; gap: 12px 28px; justify-content: space-between; font-size: 14px; color: var(--muted); }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }

/* worksheet page */
.ws-layout { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; padding-top: 20px; }
.ws-viewer { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.ws-aside { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.viewer-stage { background: #E9ECE6; border-radius: 18px; padding: 28px; display: grid; place-items: center; }
.page { position: relative; width: 100%; max-width: 520px; aspect-ratio: 210 / 297; background: #fff; border-radius: 6px; box-shadow: 0 12px 32px rgba(27,36,48,.14); overflow: hidden; }
.page img { width: 100%; height: 100%; object-fit: contain; }
.page.locked .fake { position: absolute; inset: 0; padding: 9%; display: flex; flex-direction: column; gap: 14px; filter: blur(6px); }
.page.locked .fake span { height: 12px; background: #E3E6E0; border-radius: 6px; }
.lock-card { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(246,247,244,.4); }
.lock-card > div { background: #fff; border-radius: 16px; padding: 22px 26px; box-shadow: 0 10px 30px rgba(27,36,48,.18); text-align: center; max-width: 280px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.thumb { flex: none; font: inherit; font-weight: 600; min-width: 48px; height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.thumb[aria-current="true"] { background: var(--green); color: #fff; border-color: var(--green); }
.thumb.is-locked { color: var(--muted); }
.box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-list li { display: flex; gap: 10px; }
.check-list li::before { content: '✓'; color: var(--green); font-weight: 700; }
.price-big { font-family: var(--display); font-size: 34px; }
.notice { background: var(--yellow-soft); border: 1px solid var(--yellow-line); color: var(--buy-fg); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.buybar { display: none; }
@media (max-width: 760px) {
  .viewer-stage { padding: 16px; margin: 0 -20px; border-radius: 0; }
  .buybar { display: flex; position: sticky; bottom: 0; z-index: 15; background: #fff; border-top: 1px solid var(--line); padding: 12px 20px 20px; margin: 16px -20px 0; gap: 12px; align-items: center; box-shadow: 0 -6px 18px rgba(27,36,48,.06); }
  .buybar .btn { flex: 1; }
}

.stars { display: flex; gap: 4px; }
.star { font: inherit; font-size: 28px; line-height: 1; width: 44px; height: 44px; border: 0; background: none; color: #B07D00; cursor: pointer; border-radius: 8px; }

/* pricing */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.plan { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 26px; display: flex; flex-direction: column; gap: 16px; position: relative; }
.plan.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.plan.dark .muted { color: #C9D0D8; }
.plan .ribbon { position: absolute; top: -13px; left: 26px; background: var(--yellow); color: var(--yellow-ink); font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 999px; }
.plan.dark .check-list li::before { color: var(--yellow); }
.toggle { display: inline-flex; gap: 4px; background: #E9ECE6; padding: 4px; border-radius: 12px; }
.toggle button { font: inherit; font-weight: 600; border: 0; border-radius: 9px; padding: 9px 18px; min-height: 42px; background: transparent; color: var(--ink-2); cursor: pointer; }
.toggle button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(27,36,48,.12); }
details.faq { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; }
details.faq summary { cursor: pointer; font-weight: 600; }

/* library */
.lib-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.lib-big { font-family: var(--display); font-size: 26px; }
.lib-layout { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.lib-tabs { flex: 1 1 200px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.lib-tab { font: inherit; text-align: left; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 14px; min-height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--ink); }
.lib-tab .count { font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--chip); }
.lib-tab[aria-current="page"] { background: var(--green); color: #fff; font-weight: 600; }
.lib-tab[aria-current="page"] .count { background: rgba(255,255,255,.2); }
.lib-main { flex: 999 1 600px; min-width: 0; }
.lib-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 14px; }
.lib-thumb { flex: none; width: 60px; height: 80px; border-radius: 6px; background: #E7F0FB; overflow: hidden; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.lib-info { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lib-files { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) {
  .lib-summary { display: flex; overflow-x: auto; scrollbar-width: none; }
  .lib-summary > .box { flex: none; min-width: 150px; padding: 12px 14px; }
  .lib-big { font-size: 19px; }
  .lib-tabs { flex-direction: row; overflow-x: auto; scrollbar-width: none; flex-basis: 100%; padding: 6px; }
  .lib-tab { flex: none; border-radius: 999px; }
  .lib-files { width: 100%; } .lib-files .btn { flex: 1; }
}

/* admin */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.admin-tabs button { font: inherit; font-weight: 600; cursor: pointer; padding: 10px 16px; min-height: 44px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); }
.admin-tabs button[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; min-width: 360px; }
.bar { flex: 1; min-width: 4px; background: var(--green); border-radius: 3px 3px 0 0; }

/* forms (admin) */
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea { font: inherit; font-weight: 400; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink); min-height: 44px; }
.field textarea { min-height: 90px; resize: vertical; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 720px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #EEF0EC; vertical-align: top; }
th { color: var(--muted); font-size: 14px; font-weight: 600; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; }
