/* board.css - shared "catalogue board" chrome for quiz / mocks / sheets.
   Tokens, atmosphere, dashboard card (ring + featured + action), search + subject
   pills, stats button + stats modal + histogram, cover cards. quiz.html carries its
   own inline copy of the same rules; keep them in step (or migrate quiz.html onto
   this file). Light by default; :root[data-theme="dark"] works on pages with a toggle. */
:root {
  color-scheme: light;
  --qb-ground: #F1ECEE;
  --qb-ground-edge: #E5DCE0;
  --qb-surface: #FFFFFF;
  --qb-ink: #1A1B26;
  --qb-ink-soft: #55505C;
  --qb-ink-faint: #8B8590;
  --qb-hair: rgba(26,27,38,0.13);
  --qb-hair-soft: rgba(26,27,38,0.07);
  --qb-pink: #C65170;
  --qb-wine: #501B29;
  --qb-pink-ink: #7C2740;
  --qb-good: #2F8F63;
  --qb-line-green: #06C755;
  --qb-shadow: 0 1px 2px rgba(26,27,38,0.06), 0 12px 26px -10px rgba(80,27,41,0.20);
  --qb-lift: 0 2px 8px rgba(26,27,38,0.10), 0 30px 54px -14px rgba(80,27,41,0.34);
  --s-eng: #C65170; --s-tgat1: #3B8C88; --s-tgat2: #B77E30;
  --s-tgat3: #5B6BB0; --s-social: #AF5E3D; --s-thai: #8A5A86; --s-other: #6C6A78;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --qb-ground: #131319;
  --qb-ground-edge: #0C0C11;
  --qb-surface: #1E1F2B;
  --qb-ink: #ECE9F0;
  --qb-ink-soft: #A9A3B1;
  --qb-ink-faint: #726C7B;
  --qb-hair: rgba(255,255,255,0.12);
  --qb-hair-soft: rgba(255,255,255,0.06);
  --qb-pink: #E2718C;
  --qb-wine: #C65170;
  --qb-pink-ink: #F1A9B9;
  --qb-good: #55BE8F;
  --qb-shadow: 0 1px 2px rgba(0,0,0,0.45), 0 14px 30px -10px rgba(0,0,0,0.6);
  --qb-lift: 0 3px 10px rgba(0,0,0,0.5), 0 34px 60px -16px rgba(0,0,0,0.72);
  --s-eng: #E2718C; --s-tgat1: #5BB4AF; --s-tgat2: #D6A155;
  --s-tgat3: #8A98D8; --s-social: #D08663; --s-thai: #B587B0; --s-other: #9C97AB;
}
.qb-atmos { position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: radial-gradient(120% 80% at 50% -8%, var(--qb-ground) 0%, var(--qb-ground) 44%, var(--qb-ground-edge) 100%); }
.qb-atmos svg { position: absolute; top: -70px; left: 50%; width: 1500px; transform: translateX(-50%); }
.qb-grain { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E"); }


/* ===== DASHBOARD CARD: progress ring + featured set + statistics ===== */
.qb-dash { display: grid; grid-template-columns: auto 1fr auto; align-items: stretch;
  background: var(--qb-surface); border: 1px solid var(--qb-hair); border-radius: 18px;
  box-shadow: var(--qb-shadow); overflow: hidden; }
.qb-dash:has(.featured-section.is-collapsed) { grid-template-columns: 1fr 1fr; }
.qb-dash-ring, .qb-dash-stats { display: flex; align-items: center; gap: 12px; background: none; border: 0;
  font: inherit; color: var(--qb-ink); cursor: pointer; text-align: left; padding: 18px 22px; transition: background .15s; }
.qb-dash-ring:hover, .qb-dash-stats:hover { background: var(--qb-hair-soft); }
.qb-dash-ring:focus-visible, .qb-dash-stats:focus-visible { outline: 2px solid var(--qb-pink); outline-offset: -3px; }
.qb-dash-ring { border-right: 1px solid var(--qb-hair-soft); }
.qb-dash-stats { border-left: 1px solid var(--qb-hair-soft); flex-direction: column; justify-content: center;
  gap: 6px; padding: 18px 26px; font-weight: 700; font-size: 12px; }
.qb-dash-stats svg { width: 22px; height: 22px; color: var(--qb-pink-ink); }
.qb-ring-svg { width: 56px; height: 56px; flex-shrink: 0; position: relative; }
.qb-ring-svg svg { width: 100%; height: 100%; display: block; }
.qb-ring-svg b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: 'Space Mono', ui-monospace, monospace; font-size: 15px; color: var(--qb-ink); }
.qb-ring-txt { display: flex; flex-direction: column; gap: 2px; }
.qb-ring-txt strong { font-family: 'Prompt', sans-serif; font-size: 13px; font-weight: 700; line-height: 1.2; }
.qb-ring-txt span { font-size: 11px; color: var(--qb-ink-faint); line-height: 1.3; }
.qb-dash-stats[aria-pressed="true"] { background: color-mix(in srgb, var(--qb-pink) 10%, transparent); }
.qb-dash-ring[aria-pressed="true"] { background: color-mix(in srgb, var(--qb-pink) 10%, transparent); }
.qb-dash-ring[aria-pressed="true"] .qb-ring-txt span { color: var(--qb-pink-ink); font-weight: 700; }
.qb-dash { margin-bottom: 14px; }
.qb-dash [id$="ImgWrap"] { display: flex; flex-shrink: 0; }
.qb-dash .featured-img, .qb-dash .featured-img-placeholder { display: block; margin: 0; }
.qb-dash .featured-text { margin: 0; }
.qb-dash .featured-section { align-content: center; background: none; border-radius: 0; padding: 18px 20px 18px; margin: 0; min-height: 0; }
.qb-dash .featured-section::after { display: none; }
.qb-dash .featured-section::before { content: 'แนะนำ'; position: static; display: block; flex-basis: 100%;
  font-size: 10px; letter-spacing: .12em; color: var(--qb-pink-ink); opacity: 1; font-family: 'Prompt', sans-serif; font-weight: 700; }
.qb-dash .featured-section { flex-wrap: wrap; row-gap: 8px; }
.qb-dash .featured-skeleton { inset: 10px; background: linear-gradient(90deg, var(--qb-hair-soft) 25%, var(--qb-hair) 37%, var(--qb-hair-soft) 63%); background-size: 400% 100%; }
.qb-dash .featured-name { color: var(--qb-ink); font-size: 15px; }
.qb-dash .featured-subject { color: var(--qb-ink-soft); }
.qb-dash .featured-desc { display: none; }
.qb-dash .featured-code { background: color-mix(in srgb, var(--qb-good) 14%, transparent); color: var(--qb-good);
  font-family: 'Space Mono', ui-monospace, monospace; letter-spacing: 0; }
.qb-dash .featured-cover { box-shadow: none; border: 1px solid var(--qb-hair); }
.qb-dash .featured-btn { background: var(--qb-ink); color: var(--qb-ground); box-shadow: none; padding: 10px 18px; }
@media (max-width: 640px) {
  .qb-dash, .qb-dash:has(.featured-section.is-collapsed) { grid-template-columns: 1fr 1fr; }
  .qb-dash-ring { grid-column: 1; grid-row: 1; padding: 14px 16px; border-bottom: 1px solid var(--qb-hair-soft); }
  .qb-dash-stats { grid-column: 2; grid-row: 1; flex-direction: row; justify-content: center; padding: 14px 16px;
    border-bottom: 1px solid var(--qb-hair-soft); font-size: 13px; }
  .qb-dash .featured-section { grid-column: 1 / -1; grid-row: 2; padding: 14px 16px 16px; }
  .qb-dash:has(.featured-section.is-collapsed) .qb-dash-ring, .qb-dash:has(.featured-section.is-collapsed) .qb-dash-stats { border-bottom: 0; }
  .qb-ring-svg { width: 46px; height: 46px; } .qb-ring-svg b { font-size: 13px; }
}


.qb-tools { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.qb-tools .catalogue-search { margin: 0; padding: 11px 14px 11px 38px; border-radius: 12px; border: 1px solid var(--qb-hair);
  background: var(--qb-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B8590' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px 50% / 16px; color: var(--qb-ink); }
.qb-pills { display: flex; gap: 8px; overflow-x: auto; padding: 2px 1px 4px; scrollbar-width: none; }
.qb-pills::-webkit-scrollbar { display: none; }
.qb-pill { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--qb-hair);
  background: var(--qb-surface); color: var(--qb-ink-soft); border-radius: 999px; padding: 6px 13px; font: inherit;
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.qb-pill i { font-style: normal; font-family: 'Space Mono', ui-monospace, monospace; font-size: 11px; color: var(--qb-ink-faint); }
.qb-pill:hover { border-color: var(--qb-ink-faint); }
.qb-pill.on { background: var(--qb-ink); border-color: var(--qb-ink); color: var(--qb-ground); }
.qb-pill.on i { color: inherit; opacity: .7; }
.qb-pill:focus-visible { outline: 2px solid var(--qb-pink); outline-offset: 2px; }


.qb-statbtn { display: inline-flex; align-items: center; gap: 5px; background: none; border: 1px solid var(--qb-hair); color: var(--qb-ink-soft);
  border-radius: 999px; padding: 5px 11px 5px 9px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.qb-statbtn svg { width: 12px; height: 12px; }
.qb-statbtn:hover { background: var(--qb-hair-soft); color: var(--qb-ink); }
.qb-statbtn:focus-visible { outline: 2px solid var(--qb-pink); outline-offset: 2px; }
@media (max-width: 480px) { .qb-statbtn { font-size: 0; gap: 0; padding: 7px; } .qb-statbtn svg { width: 14px; height: 14px; } }
.qb-sm { position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; padding: 18px;
  background: rgba(19,19,25,.5); backdrop-filter: blur(4px); }
.qb-sm.open { display: flex; }
.qb-sm-card { width: 100%; max-width: 420px; max-height: 90vh; overflow: auto; background: var(--qb-surface); color: var(--qb-ink);
  border: 1px solid var(--qb-hair); border-radius: 20px; padding: 20px 20px 22px; box-shadow: var(--qb-lift); animation: qbSmIn .22s cubic-bezier(.2,.7,.2,1); }
@keyframes qbSmIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.qb-sm-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.qb-sm-title { flex: 1; font-family: 'Prompt', sans-serif; font-weight: 700; font-size: 16px; line-height: 1.3; }
.qb-sm-x { background: var(--qb-hair-soft); border: 0; border-radius: 50%; width: 30px; height: 30px; cursor: pointer; color: var(--qb-ink-soft); font-size: 18px; line-height: 1; }
.qb-sm-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.qb-sm-kpi { background: var(--qb-hair-soft); border-radius: 12px; padding: 11px 12px; }
.qb-sm-kpi b { display: block; font-family: 'Space Mono', ui-monospace, monospace; font-size: 22px; line-height: 1.1; }
.qb-sm-kpi span { font-size: 11px; color: var(--qb-ink-faint); }
.qb-sm-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
.qb-sm-sec { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--qb-pink-ink); margin-bottom: 10px; font-family: 'Prompt', sans-serif; }
.qb-hist { display: flex; align-items: flex-end; gap: 4px; height: 110px; margin-bottom: 4px; }
.qb-hist-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.qb-hist-col i { font-style: normal; font-size: 9px; color: var(--qb-ink-faint); font-family: 'Space Mono', ui-monospace, monospace; }
.qb-hist-bar { width: 100%; border-radius: 4px 4px 2px 2px; background: color-mix(in srgb, var(--qb-pink) 45%, transparent); min-height: 2px;
  transform-origin: bottom; animation: qbBar .5s cubic-bezier(.2,.7,.2,1) both; }
.qb-hist-col.me .qb-hist-bar { background: var(--qb-pink); }
@keyframes qbBar { from { transform: scaleY(0); } }
.qb-hist-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--qb-ink-faint); font-family: 'Space Mono', ui-monospace, monospace; margin-bottom: 18px; }
.qb-or-more { display: flex; flex-direction: column; gap: 9px; }
.qb-or-row { display: grid; grid-template-columns: 76px 1fr 38px; align-items: center; gap: 10px; font-size: 12.5px; }
.qb-or-row em { font-style: normal; font-family: 'Space Mono', ui-monospace, monospace; text-align: right; font-weight: 700; }
.qb-or-track { height: 8px; border-radius: 5px; background: var(--qb-hair); overflow: hidden; }
.qb-or-fill { height: 100%; border-radius: 5px; background: var(--qb-ink); transition: width .5s cubic-bezier(.2,.7,.2,1); }
.qb-sm-you { margin-top: 14px; font-size: 12.5px; color: var(--qb-ink-soft); }
.qb-sm-you b { color: var(--qb-pink-ink); }
.qb-sm-empty { text-align: center; color: var(--qb-ink-faint); font-size: 13px; padding: 26px 8px; }



.qb-sharebtn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex-shrink: 0; padding: 0; background: none;
  border: 1px solid var(--qb-hair); border-radius: 50%; color: var(--qb-ink-soft); cursor: pointer; transition: background .15s, color .15s; }
.qb-sharebtn svg { width: 13px; height: 13px; }
.qb-sharebtn .ic-ok { display: none; }
.qb-sharebtn:hover { background: var(--qb-hair-soft); color: var(--qb-ink); }
.qb-sharebtn:focus-visible { outline: 2px solid var(--qb-pink); outline-offset: 2px; }
.qb-sharebtn.done { color: var(--qb-good); border-color: var(--qb-good); }
.qb-sharebtn.done .ic-share { display: none; }
.qb-sharebtn.done .ic-ok { display: block; }

/* ---- cover cards (mocks / sheets): keep the uploaded cover, standardize the frame ---- */
.bd-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px 18px; }
.bd-card { display: flex; flex-direction: column; gap: 10px; cursor: pointer; position: relative; background: none; border: 0; padding: 0; text-align: left; font: inherit; color: inherit; }
.bd-card:focus-visible { outline: 2px solid var(--qb-pink); outline-offset: 4px; border-radius: 14px; }
.bd-cover { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--qb-hair); background: var(--qb-surface);
  box-shadow: var(--qb-shadow); aspect-ratio: 210 / 297; transition: box-shadow .25s ease, transform .3s cubic-bezier(.2,.7,.2,1); }
.bd-card:hover .bd-cover { box-shadow: var(--qb-lift); transform: translateY(-3px); }
.bd-cover img, .bd-cover .bd-ph { width: 100%; height: 100%; object-fit: cover; display: flex; align-items: center; justify-content: center; color: var(--qb-ink-faint); }
.bd-stamp { position: absolute; right: 8px; bottom: 8px; font-family: 'Space Mono', ui-monospace, monospace; font-weight: 700; font-size: 13px;
  color: var(--qb-good); background: color-mix(in srgb, var(--qb-surface) 90%, transparent); border: 1.5px solid var(--qb-good); border-radius: 7px; padding: 2px 6px; line-height: 1.2; }
.bd-body { display: flex; flex-direction: column; gap: 3px; padding: 0 2px; }
.bd-type { display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; color: var(--qb-ink-faint); letter-spacing: .02em; }
.bd-type i { width: 7px; height: 7px; border-radius: 50%; background: var(--sc, var(--qb-ink-faint)); flex-shrink: 0; }
.bd-name { font-size: 13px; font-weight: 600; line-height: 1.32; color: var(--qb-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.64em; }
.bd-date { font-size: 10.5px; color: var(--qb-ink-faint); }
.bd-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.bd-actions .qb-statbtn { padding: 5px 11px 5px 9px; font-size: 12px; gap: 5px; }
.bd-actions-l { display: flex; align-items: center; gap: 6px; }
.bd-go { font-family: 'Prompt', sans-serif; font-size: 12px; font-weight: 700; color: var(--qb-pink-ink); }
.bd-card:hover .bd-go { text-decoration: underline; }
@media (max-width: 640px) { .bd-card .bd-go { display: none; } .bd-actions { justify-content: flex-start; } }
.bd-empty { grid-column: 1 / -1; text-align: center; color: var(--qb-ink-faint); font-size: 13px; padding: 30px 8px; }
@media (max-width: 900px) { .bd-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .bd-grid { grid-template-columns: repeat(2, 1fr); gap: 18px 12px; } }
.bd-section { margin-top: 6px; }

/* ---- "latest" highlight (two newest items, above the search bar) ---- */
.bd-latest { position: relative; background: linear-gradient(135deg, color-mix(in srgb, var(--qb-pink) 11%, var(--qb-surface)) 0%, var(--qb-surface) 70%);
  border: 1px solid color-mix(in srgb, var(--qb-pink) 30%, var(--qb-hair)); border-radius: 16px; padding: 11px 14px 6px; box-shadow: var(--qb-shadow); }
.bd-latest-head { display: flex; align-items: center; gap: 8px; font-family: 'Prompt', sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--qb-pink-ink); margin-bottom: 4px; }
.bd-latest-head i { width: 6px; height: 6px; border-radius: 50%; background: var(--qb-pink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--qb-pink) 22%, transparent); }
.bd-latest-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 0; background: none; border: 0; border-top: 1px dashed color-mix(in srgb, var(--qb-pink) 25%, var(--qb-hair)); font: inherit; color: inherit; text-align: left; cursor: pointer; }
.bd-latest-row:first-of-type { border-top: 0; }
.bd-latest-row:focus-visible { outline: 2px solid var(--qb-pink); outline-offset: 2px; border-radius: 8px; }
.bd-latest-thumb { flex: 0 0 34px; height: 44px; border-radius: 6px; overflow: hidden; border: 1px solid var(--qb-hair); background: var(--qb-hair-soft); display: flex; align-items: center; justify-content: center; }
.bd-latest-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bd-latest-glyph { flex: 0 0 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-family: 'Space Mono', ui-monospace, monospace; font-weight: 700; font-size: 11px; color: var(--sc); background: color-mix(in srgb, var(--sc) 14%, transparent); }
.bd-latest-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bd-latest-title { font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--qb-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-latest-meta { font-size: 11.5px; color: var(--qb-ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-latest-new { flex-shrink: 0; font-family: 'Prompt', sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .04em; color: #fff; background: var(--qb-pink); border-radius: 999px; padding: 2px 9px; }
.bd-latest-go { flex-shrink: 0; font-family: 'Prompt', sans-serif; font-size: 12px; font-weight: 700; color: var(--qb-pink-ink); }
.bd-latest-row:hover .bd-latest-go { text-decoration: underline; }
.qb-tools > .bd-latest { margin-bottom: 2px; }

/* mock stats modal: answer-key sections */
.qb-sm-card.wide { max-width: 480px; }
.qb-sm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 16px; }
.qb-chip { font-size: 11px; font-weight: 600; color: var(--qb-ink-soft); background: var(--qb-hair-soft); border-radius: 999px; padding: 3px 10px; }
.bd-cat { margin-bottom: 12px; }
.bd-cat-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.bd-cat-name { font-size: 13px; font-weight: 600; color: var(--qb-ink); }
.bd-cat-meta { font-family: 'Space Mono', ui-monospace, monospace; font-size: 11px; color: var(--qb-ink-faint); white-space: nowrap; }
.bd-cat-bar { position: relative; height: 8px; border-radius: 5px; background: var(--qb-hair); }
.bd-cat-fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--qb-ink); transition: width .5s cubic-bezier(.2,.7,.2,1); }
.bd-cat-fill.mix { background: color-mix(in srgb, var(--qb-ink) 35%, transparent); }
.bd-cat-me { position: absolute; top: -3px; width: 3px; height: 14px; border-radius: 2px; background: var(--qb-pink); transform: translateX(-1px); }
.bd-cat-sub { font-size: 11px; color: var(--qb-ink-faint); margin-top: 4px; }
.bd-legend { display: flex; gap: 14px; font-size: 11px; color: var(--qb-ink-faint); margin: -2px 0 12px; }
.bd-legend b { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--qb-ink); vertical-align: -1px; margin-right: 5px; }
.bd-legend b.me { width: 3px; height: 12px; background: var(--qb-pink); border-radius: 2px; margin-right: 6px; }
.bd-hard { display: flex; flex-direction: column; gap: 6px; }
.bd-hard-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--qb-ink-soft); }
.bd-hard-row em { font-style: normal; flex: 0 0 52px; font-family: 'Space Mono', ui-monospace, monospace; font-weight: 700; color: var(--qb-ink); }
.bd-hard-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-hard-row b { font-family: 'Space Mono', ui-monospace, monospace; color: var(--qb-pink-ink); }
.qb-sm-sec + .qb-sm-sec, .bd-block + .bd-block { margin-top: 18px; }
.bd-note { font-size: 11.5px; color: var(--qb-ink-faint); margin-top: 6px; line-height: 1.5; }
