* { box-sizing: border-box; }
:root {
  --ink: #261e3c; --muted: #605873; --violet: #5341a1; --deep: #302359;
  --lime: #dcf58e; --line: #e4dfec; --lav: #f0ebfa; --paper: #faf8f5;
  --white: #fff; --green: #315b45; --radius: 18px;
}
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.65 "Leelawadee UI", Tahoma, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 3px solid #8768d4; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(32px, 4vw, 55px); line-height: 1.23; letter-spacing: -.02em; }
h2 { font-size: clamp(23px, 2.4vw, 30px); line-height: 1.35; }
h3 { font-size: 17px; line-height: 1.45; }
img { display: block; max-width: 100%; height: auto; }
.shell { width: min(1280px, calc(100% - 64px)); margin-inline: auto; }
.header { background: white; border-bottom: 1px solid var(--line); }
.nav { display: flex; align-items: center; gap: 28px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 12px; font-size: 25px; letter-spacing: -.045em; }
.brand img { width: 42px; border-radius: 11px; }
.nav a:not(.brand) { display: flex; align-items: center; min-height: 40px; color: var(--muted); font-weight: 700; }
.nav a:not(.brand):hover, .nav a[aria-current] { color: var(--violet); }
.nav a[aria-current]:not(.orders-link) { box-shadow: 0 2px var(--violet); }
.orders-link { margin-left: auto; padding: 4px 15px; border: 1px solid var(--line); border-radius: 12px; }
.skip { position: absolute; left: 12px; top: -100px; padding: 8px 13px; background: white; z-index: 10; }
.skip:focus { top: 8px; }
.btn, .outline, .chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 15px; border: 1px solid transparent; border-radius: 10px;
  font-weight: 700; line-height: 1.4; text-align: center;
}
.btn { background: var(--violet); color: white; }
.btn:hover { background: var(--deep); }
.btn.lime { color: var(--deep); background: var(--lime); }
.btn.lime:hover { background: #cbe879; }
.outline, .chip { background: white; border-color: var(--line); color: var(--deep); }
.outline:hover, .chip:hover { border-color: #a48fcb; }
.chip { padding-inline: 12px; font-size: 14px; }
.chip.active, .chip[aria-pressed=true] { background: var(--violet); border-color: var(--violet); color: white; }
.muted { color: var(--muted); }
.eyebrow { color: var(--violet); font-weight: 700; font-size: 13px; }
.loading, .error-page { padding: 42px 0; min-height: 42vh; }
.panel, .side { background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.library { margin-top: 26px; padding-bottom: 48px; }
.hero {
  display: flex; align-items: center; position: relative; isolation: isolate; overflow: hidden;
  border-radius: 22px; padding: clamp(22px, 4vw, 54px);
  background: linear-gradient(115deg, #302359, #4d3680 77%, #57418c);
  color: white;
}
.hero:not(.featured) { padding-block: 25px; }
.hero:not(.featured) h1 { font-size: clamp(29px, 3.8vw, 39px); }
.hero-content { position: relative; z-index: 1; width: min(100%, 575px); }
.hero h1 { font-size: clamp(32px, 3.65vw, 48px); text-wrap: balance; }
.hero p { margin-top: 12px; color: #f1eaff; font-size: clamp(15px, 1.5vw, 19px); }
.search { display: flex; align-items: stretch; gap: 7px; margin-top: 17px; background: white; border-radius: 13px; padding: 6px; }
.search-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding-left: 10px; }
.search-icon { flex: 0 0 14px; height: 14px; border: 2px solid var(--violet); border-radius: 50%; position: relative; }
.search-icon::after { content: ""; position: absolute; width: 6px; height: 2px; background: var(--violet); right: -5px; bottom: -2px; transform: rotate(45deg); }
.search input { width: 100%; min-width: 0; padding: 7px; border: 0; border-radius: 5px; color: var(--ink); }
.hero-links { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; margin-top: 16px; }
.hero-links > a:not(.btn) { font-weight: 700; padding: 5px 2px; }
.hero-links > a:not(.btn):hover { text-decoration: underline; }
.fan { position: absolute; inset: 0 0 0 auto; width: 44%; pointer-events: none; }
.fan::before { content: ""; position: absolute; inset: 12% 7% -45%; border-radius: 50%; background: #745aaf; opacity: .54; }
.fan img {
  position: absolute; width: 39%; left: 14%; top: 18%;
  border: 4px solid white; border-radius: 6px; box-shadow: 0 15px 26px #1f123d62;
  transform: rotate(-15deg);
}
.fan img:nth-child(2) { left: 47%; top: 20%; transform: rotate(16deg); }
.fan img:nth-child(3) { left: 29%; top: 9%; transform: rotate(-2deg); }
.grade-bar { display: flex; align-items: center; gap: 16px; margin-block: 18px 24px; padding: 11px 14px; background: white; border: 1px solid var(--line); border-radius: 15px; }
.grade-bar strong { flex-shrink: 0; }
.levels { display: flex; flex-wrap: wrap; gap: 7px; }
.levels .chip { min-width: 48px; }
.catalog { display: grid; grid-template-columns: 215px minmax(0, 1fr); gap: 25px; align-items: start; }
.side { display: grid; gap: 13px; padding: 16px; }
.side label { display: block; margin-bottom: 4px; font-weight: 700; }
.field, .side select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #d5ccdf; border-radius: 9px; padding: 7px 10px; background: white; color: var(--ink); }
.free-filter { display: flex; align-items: center; gap: 8px; min-height: 43px; padding: 6px 8px; border-radius: 9px; background: #f0f6e6; color: var(--green); font-size: 14px; font-weight: 700; }
.free-filter:hover { background: #e4f0d5; }
.check { display: grid; place-items: center; width: 18px; height: 18px; flex: 0 0 18px; border: 1px solid #648172; border-radius: 4px; background: white; }
.free-filter[aria-current] .check { color: white; background: var(--green); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 15px; }
.toolbar p { margin-top: 3px; font-size: 14px; }
.view-switch { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--lav); border-radius: 11px; }
.view-switch .chip { border-color: transparent; background: transparent; min-height: 35px; }
.view-switch .chip.active, .view-switch .chip[aria-pressed=true] { background: white; color: var(--deep); box-shadow: 0 1px 3px #30235930; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 12px 0 16px; }
.reset, .source { color: var(--violet); text-decoration: underline; text-underline-offset: 3px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 15px; }
.card:hover { border-color: #a98bcb; }
.thumb { display: flex; justify-content: center; align-items: flex-start; position: relative; height: clamp(155px, 16vw, 215px); overflow: hidden; padding-top: 17px; background: #eae3f6; }
.card:nth-child(4n+2) .thumb { background: #e6efde; }
.card:nth-child(4n+3) .thumb { background: #f2e8dc; }
.card:nth-child(4n+4) .thumb { background: #e4edf4; }
.thumb img { width: 70%; max-width: 158px; border-radius: 4px; box-shadow: 0 8px 17px #31225035; }
.badge { display: inline-block; color: var(--green); background: #e9f4e3; padding: 3px 8px; border-radius: 7px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.thumb .badge { position: absolute; top: 9px; left: 9px; background: #f4faed; }
.card-info { display: flex; flex: 1; flex-direction: column; gap: 5px; padding: 13px 13px 8px; min-width: 0; }
.card h3 { overflow-wrap: anywhere; }
.card h3 a:hover { text-decoration: underline; }
.card .eyebrow, .card .muted { font-size: 12px; }
.card-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; border-top: 1px solid var(--line); padding-top: 3px; margin-top: auto; font-size: 13px; font-weight: 700; }
.card-bottom a { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; color: var(--violet); }
.card-bottom a:hover { text-decoration: underline; }
.pages { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 18px; font-size: 14px; }
.book-group { overflow: hidden; margin-bottom: 13px; background: white; border: 1px solid var(--line); border-radius: 14px; }
.book-group > h3 { background: var(--lav); padding: 12px 15px; }
.textbook-reference { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 12px 15px; background: var(--lav); }
.textbook-reference .muted { margin-top: 3px; font-size: 13px; }
.textbook-reference .outline { flex-shrink: 0; max-width: 100%; font-size: 14px; }
.product-title .textbook-reference { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; }
.book-row { display: grid; grid-template-columns: 105px minmax(0, 1fr) 90px 86px; align-items: center; gap: 9px; min-height: 49px; padding: 9px 15px; border-top: 1px solid var(--line); }
.book-row:hover { background: #f7f2fc; }
.book-row span { font-size: 13px; color: var(--muted); }
.book-row span:last-child:not(.badge) { color: var(--violet); }
.product-page { max-width: 1090px; padding-bottom: 44px; }
.crumb { margin: 17px 0 13px; color: var(--muted); font-size: 14px; }
.crumb a { color: var(--violet); }
.product-title { margin-bottom: 19px; }
.product-title h1 { margin: 4px 0; font-size: clamp(30px, 4vw, 46px); }
.product-jump { display: none; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 21px; align-items: start; }
.viewer { background: #eee9f5; overflow: hidden; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 7px; padding: 10px 14px; background: white; border-bottom: 1px solid var(--line); }
.preview-link { display: block; width: min(370px, calc(100% - 42px)); margin: 19px auto 8px; background: white; border-radius: 4px; box-shadow: 0 10px 26px #3122502a; }
.preview-link img { width: 100%; aspect-ratio: 210 / 297; object-fit: contain; }
.viewer-caption { padding-bottom: 11px; text-align: center; color: var(--muted); font-size: 13px; }
.details { padding: 17px; }
.purchase { padding: 15px; background: var(--lav); border-radius: 12px; }
.details .price { font-size: 27px; font-weight: 800; line-height: 1.35; }
.details section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 14px; }
.details ul { padding-left: 22px; margin: 5px 0 0; }
.details .btn, .details .outline { width: 100%; margin-top: 10px; }
.note, .error { font-size: 14px; margin-top: 8px; }
.error { color: #84212d; }
.error:empty { margin: 0; }
.chapter-list { padding: 16px; margin-top: 20px; }
.chapter-list nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 16px; }
.chapter-list a { border-radius: 8px; padding: 8px; }
.chapter-list a:hover { background: var(--paper); }
.chapter-list a[aria-current] { background: var(--lav); color: var(--deep); font-weight: 700; }
.offer { padding: 20px; }
.offer p { margin-top: 6px; }
.offer .actions { margin-bottom: 0; }
.bundles, .orders { padding: 28px 0 52px; min-height: 64vh; }
.bundles .toolbar, .bundles .grid { margin-top: 18px; }
.bundle-hero { background: var(--deep); color: white; border-radius: 18px; padding: 23px; margin-top: 15px; }
.bundle-hero p { color: #eee4fb; margin-top: 8px; }
.bundle-hero .btn { margin-top: 13px; }
.order-list { display: grid; gap: 12px; margin: 15px 0; }
.order { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 13px 16px; }
.order strong { display: block; }
.order .muted, .recovery-code { font-size: 13px; }
.orders .intro { margin-top: 6px; }
.footer { padding: 18px 0; border-top: 1px solid var(--line); background: white; font-size: 14px; color: var(--muted); }
.footer .shell, .store-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 16px; }
.footer a:hover { text-decoration: underline; }
.recover-form { max-width: 600px; margin: 24px 0; }
.recover-form h2 { font-size: 20px; }
.recover-form .field { flex: 1 1 190px; }
.recovery-code { margin-top: 8px; }
.recovery-code summary { cursor: pointer; color: var(--violet); }
.recovery-code input { width: min(640px, 100%); margin-top: 6px; }
.policy-copy { margin-top: 12px; max-width: 800px; }
.policy-copy div { white-space: pre-wrap; margin-top: 20px; }

@media (max-width: 1150px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero.featured .hero-content { width: 55%; }
}
@media (max-width: 850px) {
  .shell { width: calc(100% - 38px); }
  .catalog { grid-template-columns: 170px minmax(0, 1fr); gap: 14px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book-row { grid-template-columns: 72px minmax(0, 1fr) 75px; }
  .print-info { display: none; }
}
@media (max-width: 640px) {
  .shell { width: calc(100% - 26px); }
  .nav { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 2px 8px; padding: 6px 0; }
  .brand { grid-column: span 2; margin: 0; font-size: 22px; }
  .brand img { width: 34px; }
  .nav a:not(.brand) { min-height: 35px; justify-content: center; font-size: 14px; }
  .orders-link { grid-area: 1 / 3; margin: 0 0 0 auto; padding-inline: 8px; }
  .library { margin-top: 13px; }
  .hero, .hero:not(.featured) { border-radius: 16px; padding: 18px 13px; }
  .hero.featured .hero-content { width: 100%; }
  .hero p { margin-top: 7px; }
  .fan { display: none; }
  .search { margin-top: 12px; }
  .search input { font-size: 16px; }
  .search input::placeholder { font-size: 13px; }
  .search .btn { padding-inline: 10px; }
  .hero-links { gap: 6px 13px; }
  .grade-bar { display: block; margin-block: 12px; padding: 9px 10px; }
  .levels { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 5px; margin-top: 6px; }
  .levels .chip { padding-inline: 2px; min-width: 0; min-height: 38px; }
  .catalog { grid-template-columns: minmax(0,1fr); }
  .side { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
  .side section { flex: 1 1 120px; min-width: 0; }
  .side .free-filter { align-self: end; }
  .side select { font-size: 16px; }
  .toolbar { margin-bottom: 10px; }
  .grid { gap: 10px; }
  .card-info { padding: 9px 9px 5px; }
  .card h3 { font-size: 16px; }
  .thumb { height: 152px; }
  .detail-grid, .chapter-list nav { grid-template-columns: minmax(0,1fr); }
  .product-jump { display: inline-flex; margin-top: 9px; }
  .details { padding: 12px; }
  .preview-link { width: min(300px, calc(100% - 36px)); }
  .book-row { grid-template-columns: 52px minmax(0, 1fr) 66px; gap: 6px; padding-inline: 8px; }
  .book-row span, .book-row strong { font-size: 13px; }
}
@media (max-width: 360px) {
  .orders-link { padding-inline: 5px; }
  .thumb { height: 125px; }
  .viewer-head .chip { padding-inline: 7px; }
}
