/* Anil Sir Chemistry — app styles */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --ink: #14202e;
  --muted: #5d6877;
  --line: #e3dfd6;
  --brand: #0f2a3f;
  --brand-2: #1d4a6b;
  --accent: #f0a23b;
  --accent-ink: #2a1a00;
  --ok: #18794e;
  --ok-bg: #e6f4ec;
  --err: #b42318;
  --err-bg: #fdecea;
  --info-bg: #e8f0f8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 32, 46, .06), 0 6px 18px rgba(20, 32, 46, .06);
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e151d; --surface: #16202b; --surface-2: #1c2834; --ink: #e8edf2; --muted: #9aa7b5;
    --line: #26323f; --brand: #3d7fb0; --brand-2: #5b9bcb; --accent: #f3ae52;
    --ok-bg: #12301f; --err-bg: #3a1714; --info-bg: #15283a; --ok: #5fd39a; --err: #ff8a7a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e151d; --surface: #16202b; --surface-2: #1c2834; --ink: #e8edf2; --muted: #9aa7b5;
  --line: #26323f; --brand: #3d7fb0; --brand-2: #5b9bcb; --accent: #f3ae52;
  --ok-bg: #12301f; --err-bg: #3a1714; --info-bg: #15283a; --ok: #5fd39a; --err: #ff8a7a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand b { font-family: "Sora", "Noto Sans", sans-serif; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: .4em 0 .5em; }
h2 { font-size: 1.2rem; margin: 0 0 .6em; }
h3 { font-size: 1rem; margin: 0 0 .3em; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.ic { width: 20px; height: 20px; flex: none; vertical-align: -4px; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 560px; }
.page { padding: 12px 0 calc(var(--tabbar-h) + 32px); min-height: 70vh; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.clamp1, .clamp2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp1 { -webkit-line-clamp: 1; }
.clamp2 { -webkit-line-clamp: 2; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-in { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.05; }
.brand small { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.topnav { display: none; gap: 4px; margin-left: 12px; }
.topnav a { color: var(--muted); padding: 8px 12px; border-radius: 10px; font-weight: 500; }
.topnav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.topnav a.on { color: var(--ink); background: var(--surface-2); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--ink); cursor: pointer; font-size: 18px; }
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.avatar { background: var(--brand); color: #fff; font-weight: 600; border-radius: 50%; }
.avatar:hover { background: var(--brand-2); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent; background: var(--brand); color: #fff; font: 600 .95rem "Noto Sans", sans-serif; cursor: pointer; transition: transform .08s, background .15s; text-decoration: none; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .85rem; border-radius: 10px; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--err); }
.btn-block { display: flex; width: 100%; }

/* Flash */
.flash { padding: 12px 14px; border-radius: 12px; margin: 10px 0; font-size: .95rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--err-bg); color: var(--err); }
.flash-info { background: var(--info-bg); color: var(--ink); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 20px; }
.card.pad + .card.pad { margin-top: 16px; }

/* Hero */
.hero { background: radial-gradient(1200px 400px at 80% -20%, #1d4a6b 0%, transparent 60%), var(--brand); color: #fff; margin: -12px 0 8px; }
.hero { --brand: #0f2a3f; }
.hero-in { display: grid; gap: 24px; padding: 40px 16px 44px; align-items: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--accent); margin: 0; font-weight: 600; }
.hero h1 { font-size: clamp(1.9rem, 6vw, 3rem); margin: .25em 0 .35em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.lead { font-size: 1.05rem; color: inherit; opacity: .85; max-width: 560px; margin: 0 0 1.2em; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.hero .btn-ghost:hover { background: rgba(255,255,255,.1); }
.hero-art { color: rgba(255,255,255,.85); display: none; }
.hero-art svg { width: 100%; max-width: 320px; margin-left: auto; }

/* Sections */
.sec { margin: 28px 0; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sec-head h2 { margin: 0; }
.sec-head a { font-weight: 600; font-size: .9rem; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hscroll { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 16px 10px; margin: 0 -16px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex: none; }
.hscroll.cards > .pcard { width: 168px; }
.why { display: grid; gap: 12px; }
.why .card.pad + .card.pad { margin-top: 0; }
.why p { margin: .3em 0 0; font-size: .92rem; }

/* Product card */
.pcard { display: flex; flex-direction: column; overflow: hidden; color: var(--ink); transition: transform .12s, box-shadow .12s; }
.pcard:hover { text-decoration: none; transform: translateY(-2px); }
.pcover { position: relative; aspect-ratio: 3 / 4; background: var(--surface-2); }
.pcover img { width: 100%; height: 100%; object-fit: cover; }
.type-course .pcover, .type-paper .pcover { aspect-ratio: 4 / 3; }
.ptype { position: absolute; left: 8px; top: 8px; background: rgba(15, 42, 63, .88); color: #fff; font-size: .68rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.ptype.inline { position: static; display: inline-block; background: var(--surface-2); color: var(--muted); }
.pbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pbody h3 { font-size: .92rem; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pbody p { margin: 0; }
.price-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.price { font-weight: 700; font-family: "Sora", sans-serif; }
.price.free { color: var(--ok); }
.mrp { color: var(--muted); font-size: .82rem; }
.off { color: var(--ok); font-size: .78rem; font-weight: 600; }
.price-row.big .price { font-size: 1.7rem; }
.price-row.big { margin-bottom: 12px; padding: 0; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); }
.tag .ic { width: 14px; height: 14px; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }

/* Continue reading */
.cont { display: flex; gap: 12px; align-items: center; padding: 10px; width: 270px; color: var(--ink); }
.cont:hover { text-decoration: none; }
.cont img { width: 52px; height: 68px; object-fit: cover; border-radius: 8px; }
.cont div { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }

/* Store */
.store-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.store-head h1 { margin-bottom: 0; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; height: 44px; flex: 1; font: inherit; color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 16px 14px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .87rem; font-weight: 500; white-space: nowrap; }
.chip:hover { text-decoration: none; border-color: var(--brand-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.count { opacity: .7; margin-left: 2px; }
.empty { text-align: center; padding: 40px 20px; }

/* Product detail */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .9rem; margin: 6px 0 10px; }
.pdetail { display: grid; gap: 20px; }
.pd-cover { overflow: hidden; max-width: 320px; width: 70%; margin: 0 auto; }
.pd-info h1 { margin-top: .3em; }
.facts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.facts li { padding-left: 24px; position: relative; color: var(--muted); }
.facts li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); }
.buybox { display: grid; gap: 10px; }
.buybox p { margin: 0; }
.prose { line-height: 1.7; }
.prose h3 { margin-top: 1.2em; }

/* Lessons */
.lessons { overflow: hidden; padding: 0; }
.lsec { padding: 12px 16px 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.lrow { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink); font-size: .92rem; }
a.lrow:hover { background: var(--surface-2); text-decoration: none; }
.lrow.on { background: var(--info-bg); font-weight: 600; }
.lrow.locked { color: var(--muted); }
.lnum { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .75rem; flex: none; }

/* Course player */
.course { display: grid; gap: 16px; }
.player { overflow: hidden; aspect-ratio: 16 / 9; background: #000; }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.novideo { height: 100%; display: grid; place-content: center; text-align: center; color: #aab; }
.novideo .ic { width: 48px; height: 48px; margin: 0 auto; }
.ltitle { font-size: 1.25rem; }
.lactions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.upsell { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.upsell .btn { margin-left: auto; }

/* Forms */
.form { display: grid; gap: 14px; margin: 16px 0; }
.form label { display: grid; gap: 6px; font-weight: 500; font-size: .92rem; }
.form input, .form select, .form textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand-2) 40%, transparent); border-color: var(--brand-2); }
.form textarea { min-height: 140px; resize: vertical; }
.form .check { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.form .check input { width: 20px; height: 20px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.auth { margin-top: 16px; }
.auth h1 { margin-top: .4em; }
.checklist { list-style: none; padding: 0; display: grid; gap: 6px; }
.checklist .ok { color: var(--ok); }
.checklist .bad { color: var(--err); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.tbl-wrap { overflow-x: auto; }

/* Library */
.libgrid { display: grid; gap: 12px; }
.librow { display: flex; gap: 14px; padding: 12px; align-items: center; }
.librow img { width: 64px; height: 84px; object-fit: cover; border-radius: 8px; flex: none; }
.librow .grow { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

/* Footer + tab bar */
.foot { border-top: 1px solid var(--line); padding: 28px 0 calc(var(--tabbar-h) + 28px); background: var(--surface); }
.foot-in { display: grid; gap: 16px; margin-bottom: 12px; }
.foot p { margin: .4em 0 0; font-size: .9rem; }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .9rem; }
.foot-links a { color: var(--muted); }
.tabbar { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar-h); color: var(--muted); font-size: .68rem; font-weight: 500; }
.tabbar a:hover { text-decoration: none; }
.tabbar a .ic { width: 22px; height: 22px; }
.tabbar a.on { color: var(--brand-2); }
.tabbar a.on .ic { stroke-width: 2.3; }
.wa-fab { position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 41; width: 52px; height: 52px; border-radius: 50%; background: #25d366; color: #fff; display: grid; place-items: center; box-shadow: var(--shadow); }
.wa-fab .ic { width: 28px; height: 28px; }

/* Reader */
.reader-body { overflow: hidden; background: #2b2f36; }
.reader { position: fixed; inset: 0; display: flex; flex-direction: column; background: #2b2f36; color: #e8edf2; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.rbar { display: flex; align-items: center; gap: 4px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: #1d2127; }
.rbar .icon-btn { color: #e8edf2; }
.rbar .icon-btn:hover { background: rgba(255,255,255,.08); }
.rtitle { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; padding: 0 6px; }
.rtitle b { font-size: .92rem; font-family: "Sora", sans-serif; }
.rtitle span { color: #9aa7b5; }
.sample-banner { background: var(--accent); color: var(--accent-ink); text-align: center; padding: 8px; font-size: .88rem; font-weight: 500; }
.sample-banner a { color: inherit; text-decoration: underline; font-weight: 700; }
.rpages { position: relative; flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 24px; overscroll-behavior: contain; }
.rpage { position: relative; margin: 0 auto 12px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.35); overflow: hidden; }
.rpage canvas { display: block; position: relative; z-index: 1; }
.rwm { position: absolute; inset: 0; z-index: 2; pointer-events: none; background-repeat: repeat; }
.rnum { position: absolute; z-index: 0; inset: 0; display: grid; place-items: center; color: #bbb; font: 600 2rem "Sora", sans-serif; }
.reader.night .rpage { background: #111; }
.reader.night .rpage canvas { filter: invert(.92) hue-rotate(180deg); }
.rloading { color: #c9d1da; text-align: center; padding: 80px 20px; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--accent); margin: 0 auto 12px; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #1d2127; }
.rfoot .btn-ghost { color: #e8edf2; border-color: #3a414b; }
.rfoot .btn-ghost:hover { background: rgba(255,255,255,.08); }
.jump { display: flex; align-items: center; gap: 6px; color: #9aa7b5; font-size: .9rem; }
.jump input { width: 64px; height: 34px; border-radius: 8px; border: 1px solid #3a414b; background: #2b2f36; color: #fff; text-align: center; font: inherit; }
@media print { body * { display: none !important; } body::after { content: "Printing is disabled for eBooks."; display: block; } }

/* Admin */
.admin-nav { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 12px; margin: 0 -16px 8px; scrollbar-width: none; }
.admin-nav a { flex: none; padding: 8px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-size: .9rem; font-weight: 500; }
.admin-nav a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.admin-nav a:hover { text-decoration: none; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { padding: 16px; }
.stat b { display: block; font: 700 1.5rem "Sora", sans-serif; }
.stat span { color: var(--muted); font-size: .85rem; }
.thumb { width: 40px; height: 52px; object-fit: cover; border-radius: 6px; }
.badge { display: inline-block; font-size: .7rem; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: #fff4e0; color: #8a5300; }
.inline-form { display: inline; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .why { grid-template-columns: repeat(3, 1fr); }
  .store-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .search { width: 340px; }
  .libgrid { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .foot-in { grid-template-columns: 1fr auto; align-items: start; }
}
@media (min-width: 900px) {
  :root { --tabbar-h: 0px; }
  .tabbar { display: none; }
  .topnav { display: flex; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero-in { grid-template-columns: 1.3fr 1fr; padding: 64px 16px; }
  .hero-art { display: block; }
  .hscroll.cards > .pcard { width: 210px; }
  .pdetail { grid-template-columns: 320px 1fr; gap: 36px; align-items: start; }
  .pd-cover { width: 100%; margin: 0; position: sticky; top: 80px; }
  .buybox { max-width: 400px; }
  .course { grid-template-columns: 1fr 340px; align-items: start; }
  .cside { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
  .page { padding-bottom: 48px; }
  .foot { padding-bottom: 28px; }
  .wa-fab { bottom: 24px; }
}
