/* =====================================================================
   UI v2: responsive polish. Loaded AFTER style.css (delete the <link> in
   views/layouts/main.php to roll back). Breakpoints: phone <=560,
   tablet 561-992, laptop 993+, wide 1320+.
   ===================================================================== */
:root{--hdr-h:64px;--ring:rgba(22,119,255,.32)}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth;scroll-padding-top:calc(var(--hdr-h) + 12px)}
body{line-height:1.55;-webkit-font-smoothing:antialiased;overflow-wrap:break-word}
img{max-width:100%;height:auto} /* HTML width/height attributes must never stretch images (this was squashing product covers) */
:focus-visible{outline:3px solid var(--ring);outline-offset:2px;border-radius:6px}
.btn,.btn-o{transition:filter .15s,transform .1s,box-shadow .15s}.btn:active,.btn-o:active{transform:translateY(1px)}
.btn:focus-visible,.btn-o:focus-visible{outline-offset:3px}
.only-m{display:none}
@media(pointer:coarse){
  .btn,.btn-o{min-height:42px;display:inline-flex;align-items:center;justify-content:center;text-align:center}
  .btn.sm,.btn-o.sm{min-height:38px}
  .pager a{min-width:40px;min-height:40px;display:inline-flex;align-items:center;justify-content:center}
}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}*{transition:none!important;animation:none!important}}
@media(min-width:1320px){.wrap{max-width:1280px}.grid{grid-template-columns:repeat(5,1fr)}}
@media(max-width:560px){.wrap{padding:0 14px}.sec{padding-top:24px}}

/* ---------- Header: compact and tidy on phones/tablets ---------- */
@media(max-width:768px){
  .topbar{font-size:12px;padding:5px 0}
  .topbar .wrap{display:block}
  .topbar .wrap>span:first-child{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .tb-r{display:none}
  .hrow{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-areas:"burger brand act" "search search search";gap:8px 10px;padding:8px 14px;align-items:center}
  .burger{grid-area:burger;min-width:40px;min-height:40px;padding:8px}
  .brand{grid-area:brand;min-width:0}
  .hact{grid-area:act;margin-left:0;gap:6px}
  .sbox{grid-area:search;order:0;max-width:none;width:100%}
  .sbox input{font-size:16px;min-height:42px}
  .sbox button{min-width:48px}
  .brand{overflow:hidden}
  .bn{font-size:19px;white-space:nowrap;min-width:0;overflow:hidden;text-overflow:ellipsis}
  .bn small{display:none}
  .brand img{width:36px;height:36px}
  .hact .btn,.hact .btn-o{padding:6px 12px;font-size:13px;min-height:36px}
  .cart{display:inline-flex;align-items:center;justify-content:center;min-width:40px;min-height:40px;font-size:21px;padding:0}
  .nav{max-height:calc(100vh - var(--hdr-h));max-height:calc(100dvh - var(--hdr-h));overflow-y:auto;box-shadow:0 12px 24px rgba(11,31,75,.25)}
  .nav li>a{padding:14px 18px;font-size:16px;border-top:1px solid rgba(255,255,255,.08)}
  .nav .only-m{display:block}
  .nav .only-m a{background:rgba(255,255,255,.07);font-weight:700}
}
@media(max-width:480px){
  .hide-xs{display:none!important}
  .acc-btn .lb{display:none}
  .acc-btn .ic{font-size:18px;line-height:1}
  .acc-btn{padding:6px 10px!important}
  .bn{font-size:18px}
}
@media(min-width:481px){.acc-btn .ic{display:none}}
@media(max-width:430px){.is-in .bn{display:none}.bn{font-size:17px}}
@media(max-width:380px){.bn{font-size:16px}.hact{gap:2px}.hact .btn-o,.hact .btn{padding:6px 10px;font-size:12.5px}.hrow{gap:8px 6px;padding:8px 10px}.brand img{width:32px;height:32px}}
@media(max-width:340px){.bn{display:none}}

/* ---------- Shop: product cards + filters ---------- */
.pthumb{height:auto;aspect-ratio:4/3;object-fit:contain;padding:6px;background:linear-gradient(135deg,#eef4ff,#fff7e6)}
.pc{border:1px solid #edf1f9;transition:transform .15s,box-shadow .15s}
.pc:hover{box-shadow:0 8px 24px rgba(11,31,75,.14)}
.pb{padding:12px 12px 14px;gap:8px}
.pb h3{font-size:15px;line-height:1.35;min-height:2.7em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.pb h3 a:hover{color:var(--blue)}
.pr b{font-size:19px}
.pb .btn{width:100%}
.filters{background:#fff;padding:12px;border-radius:12px;box-shadow:var(--sh);gap:10px}
.filters select,.filters input{min-height:42px;font-size:15px}
.filters input:focus,.filters select:focus{outline:0;border-color:var(--blue);box-shadow:0 0 0 3px var(--ring)}
@media(max-width:700px){
  #ffilter{display:grid;grid-template-columns:1fr 1fr}
  #ffilter select{grid-column:1/-1;width:100%;font-size:16px}
  #ffilter input[type=number]{width:100%;font-size:16px}
  #ffilter .btn,#ffilter .btn-o{width:100%}
  .filters input,.filters select{font-size:16px}
}
.cat{border:1px solid #edf1f9;transition:transform .15s,box-shadow .15s}.cat:hover{transform:translateY(-2px);box-shadow:0 6px 18px rgba(22,119,255,.15)}
@media(max-width:560px){
  .pb{padding:10px}
  .pb h3{font-size:14px;-webkit-line-clamp:3}
  .pr b{font-size:17px}
  .pb .btn{font-size:13px;padding:9px 6px}
  .wlb{width:32px;height:32px}
  .cat{padding:11px;font-size:14px;gap:8px}
  .cat img{width:34px;height:34px}
  .hero .slide,.slide{padding:32px 0 40px}
  .slide p{font-size:16px}
  .hero .hbtns .btn{padding:11px 18px;font-size:15px}
}

/* ---------- MCQ hub + lists ---------- */
.mcq-search{width:100%;max-width:640px}.mcq-search input{min-width:0}
@media(min-width:481px){.mcq-search{flex-direction:row;align-items:stretch}.mcq-search .btn{width:auto;min-width:110px}}
@media(max-width:480px){.mcq-search{flex-direction:column}.mcq-search .btn{width:100%;min-height:46px}.mcq-hero{padding:28px 0 32px}}
.tools-grid{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}
.tcard{border:1px solid #edf1f9;transition:transform .15s,box-shadow .15s}
@media(min-width:561px) and (max-width:992px){.tools-grid:has(>.tcard:nth-child(4)):not(:has(>.tcard:nth-child(5))){grid-template-columns:repeat(2,minmax(0,1fr))}} /* exactly 4 cards: 2x2 instead of 3+1 */
@media(max-width:560px){
  .tools-grid{grid-template-columns:1fr;gap:12px}
  .tools-grid .tcard{display:grid;grid-template-columns:52px minmax(0,1fr);column-gap:14px;row-gap:3px;align-items:center;padding:14px 16px}
  .tools-grid .tcard .ticon{grid-row:1/4;font-size:30px;width:52px;height:52px;display:flex;align-items:center;justify-content:center;background:#f4f8ff;border-radius:14px}
  .tools-grid .tcard h3{font-size:16px;grid-column:2}
  .tools-grid .tcard p{grid-column:2;font-size:13.5px}
  .tools-grid .tcard .mc-meta{grid-column:2;justify-self:start}
  .tools-grid .tcard .btn{grid-column:1/-1;justify-self:stretch;margin-top:8px;width:100%}
  .mcards{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .mcard{padding:12px 13px}
  .mc-t{font-size:14.5px;line-height:1.35}
}

/* ---------- MCQ questions ---------- */
.mq-layout{display:grid;grid-template-columns:minmax(0,1fr);gap:0;align-items:start}
.mq-jump{margin:0 0 12px;padding:0;border:1px solid #edf1f9}
.mq-jump summary{cursor:pointer;font-weight:700;color:var(--navy);padding:12px 16px;list-style:none;display:flex;justify-content:space-between;align-items:center}
.mq-jump summary::-webkit-details-marker{display:none}
.mq-jump summary::after{content:"▾";color:var(--mut)}
.mq-jump[open] summary::after{content:"▴"}
.mq-jg{display:grid;grid-template-columns:repeat(auto-fill,minmax(40px,1fr));gap:6px;padding:0 14px 14px}
.mq-jg a{display:flex;align-items:center;justify-content:center;height:36px;border-radius:8px;background:#eef2fb;color:var(--navy);font:700 13px sans-serif}
.mq-jg a:hover{background:#dbe7ff}
.mq-jg a.ok{background:#22a559;color:#fff}.mq-jg a.bad{background:#d93025;color:#fff}
@media(min-width:1000px){
  .wrap.mqw{max-width:1200px}
  .mq-layout{grid-template-columns:minmax(0,1fr) 270px;grid-template-areas:"main side";gap:22px}
  .mq-main{grid-area:main;min-width:0}
  .mq-side{grid-area:side;position:sticky;top:calc(var(--hdr-h) + 14px);max-height:calc(100vh - var(--hdr-h) - 28px);overflow:auto}
  .mq-jump{margin:14px 0 0}
  .mq-jump summary{cursor:default;pointer-events:none}
  .mq-jump summary::after{display:none}
}
.mq{scroll-margin-top:calc(var(--hdr-h) + 62px);border:1px solid #edf1f9;padding:18px 22px}
.mq-q{font-size:18px;line-height:1.6}
.mq-opts li{padding:11px 14px;font-size:16px;line-height:1.45}
.mq-opts li:focus-visible{outline:3px solid var(--ring);outline-offset:1px}
.mq-ans summary{display:inline-flex;align-items:center;gap:6px;padding:9px 14px;border:1.5px solid #cfe0ff;border-radius:10px;background:#f4f8ff;list-style:none}
.mq-ans summary::-webkit-details-marker{display:none}
.mq-ans summary::before{content:"▸"}.mq-ans[open] summary::before{content:"▾"}
.mq-ans[open]>summary{margin-bottom:6px}
.mq-ans[open]{border-left:4px solid #22a559;padding-left:12px;margin-left:-2px}
.mq-exp{background:#f7f9fd;border-radius:10px;padding:10px 14px;margin-top:6px}
.mq-bar{top:calc(var(--hdr-h) + 8px)}
.mq-head{box-shadow:var(--sh)}
.mq-nav .btn,.mq-nav .btn-o{max-width:100%;text-align:left}
@media(max-width:560px){
  .mq{padding:14px 14px;margin:12px 0}
  .mq-q{font-size:16.5px;line-height:1.55}
  .mq-opts li{padding:11px 12px;gap:10px}
  .mq-head{padding:16px 16px}
  .mq-tests{width:100%}.mq-tests .btn{width:100%}.mq-tests .mut{width:100%}
  .mq-nav{flex-direction:column}.mq-nav .btn,.mq-nav .btn-o{width:100%}
  .mq-bar{font-size:13px;padding:8px 12px}
}

/* ---------- Vocabulary ---------- */
.vgrid{grid-template-columns:repeat(auto-fill,minmax(290px,1fr));gap:14px}
.vcard{padding:16px 18px;border:1px solid #edf1f9;display:flex;flex-direction:column;gap:7px;transition:transform .15s,box-shadow .15s}
.vcard:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(22,119,255,.14)}
.vhead{display:flex;align-items:center;justify-content:space-between;gap:8px}
.vcard h3{margin:0;font-size:20px;line-height:1.25;color:var(--blue);word-break:break-word}
.vspeak{flex:none;width:38px;height:38px;border-radius:50%;border:1px solid #d8e0ef;background:#fff;cursor:pointer;font-size:16px;line-height:1;padding:0}
.vspeak:hover,.vspeak.on{background:var(--blue);border-color:var(--blue)}
.vm{display:inline-block;align-self:flex-start;background:#fff6e0;border:1px solid #ffe2a1;color:#5b3d00;padding:4px 11px;border-radius:8px;font-weight:700;margin:0;line-height:1.5}
.vx{margin:0;font-size:14.5px;color:#44526e}
.vx b{color:var(--navy)}
.vx.vex{border-left:3px solid var(--blue);background:#f4f8ff;padding:8px 12px;border-radius:0 8px 8px 0;font-style:italic}
.vx.vex b{font-style:normal}
.filters.vsearch{display:flex;flex-wrap:nowrap}
.filters.vsearch input{flex:1;min-width:0}
@media(max-width:560px){.vgrid{grid-template-columns:1fr;gap:12px}.vcard{padding:14px 15px}.vcard h3{font-size:19px}}

/* ---------- Topic (English topics) page ---------- */
.tp-layout{display:grid;grid-template-columns:minmax(0,1fr);gap:20px;align-items:start}
@media(min-width:1000px){.tp-layout{grid-template-columns:minmax(0,1fr) 300px;gap:26px}.tp-side{position:sticky;top:calc(var(--hdr-h) + 14px)}}
.tp-art{--tp-fs:17px;padding:30px 34px;border:1px solid #edf1f9}
.tp-badge{display:inline-block;background:#e8f1ff;color:var(--blue);font:700 12px sans-serif;letter-spacing:.4px;padding:4px 11px;border-radius:20px;text-transform:uppercase}
.tp-head h1{margin:10px 0 12px;font-size:clamp(25px,4vw,36px);line-height:1.22;color:var(--navy)}
.tp-meta{display:flex;flex-wrap:wrap;gap:8px 16px;align-items:center;color:var(--mut);font-size:14px;padding-bottom:16px;border-bottom:1px solid #eef1f7}
.tp-tools{display:flex;gap:6px;margin-left:auto}
.tp-tools button,.tp-tools a{min-width:38px;height:36px;padding:0 10px;border-radius:9px;border:1px solid #d8e0ef;background:#fff;color:var(--navy);font:700 14px sans-serif;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
.tp-tools button:hover,.tp-tools a:hover{background:var(--blue);border-color:var(--blue);color:#fff}
.tp-body{font-size:var(--tp-fs);line-height:1.85;color:#26344f;margin-top:18px}
.tp-sp{display:block;height:.85em}
.tp-body b{color:var(--navy)}
.tp-sec{margin-top:30px}
.tp-sec h2{display:flex;align-items:center;gap:10px;margin:0;font-size:clamp(20px,2.6vw,25px);color:var(--navy)}
.tp-sec h2::before{content:"";width:5px;height:1.1em;border-radius:3px;background:var(--acc)}
.tp-sub .tp-body{background:#f7f9fd;border:1px solid #e6edf9;border-radius:12px;padding:14px 18px;margin-top:12px}
.tp-ex .tp-body{background:#f4f8ff;border-left:4px solid var(--blue);border-radius:0 12px 12px 0;padding:14px 18px;margin-top:12px}
.tp-pn{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:32px}
.tp-pn a{display:flex;flex-direction:column;gap:3px;padding:13px 15px;border:1px solid #e3e9f5;border-radius:12px;background:#fff}
.tp-pn a:hover{border-color:var(--blue);box-shadow:var(--sh)}
.tp-pn a.r{text-align:right;grid-column:2}
.tp-pn small{color:var(--mut)}.tp-pn span{font-weight:700;color:var(--navy);line-height:1.3}
.tp-more{padding:16px 18px;margin:0 0 16px;border:1px solid #edf1f9}
.tp-more h2{margin:0 0 8px;font-size:17px;color:var(--navy)}
.tp-more a.tl{display:block;padding:9px 0;border-bottom:1px solid #eef1f7;font-size:14.5px;line-height:1.4;color:var(--txt)}
.tp-more a.tl:last-of-type{border:0}.tp-more a.tl:hover{color:var(--blue)}
.tp-more .btn-o{width:100%;margin-top:10px}
@media(max-width:700px){.tp-art{padding:20px 16px}.tp-body{line-height:1.8}.tp-pn{grid-template-columns:1fr}.tp-pn a.r{grid-column:1;text-align:left}.tp-tools{margin-left:0}}
@media print{.topbar,.hdr,.footer,footer,.wa,.totop,.tp-side,.tp-pn,.tp-tools,.crumb{display:none!important}.tp-art{box-shadow:none;border:0;padding:0}.tp-body{font-size:12pt}}

/* ---------- Back to top ---------- */
.totop{position:fixed;left:14px;bottom:18px;z-index:40;width:44px;height:44px;border-radius:50%;border:0;background:var(--navy);color:#fff;font-size:20px;line-height:1;cursor:pointer;box-shadow:0 4px 14px rgba(11,31,75,.35);opacity:0;visibility:hidden;transform:translateY(8px);transition:opacity .2s,transform .2s,visibility .2s}
.totop.show{opacity:1;visibility:visible;transform:none}
@media(min-width:1000px){.totop{left:auto;right:84px}}

/* ---------- Product details, related, blog author box ---------- */
.pd-info{border:1px solid #edf1f9}.pd-info h2{margin:0 0 10px;font-size:clamp(20px,2.6vw,24px);color:var(--navy)}.pd-info h3{margin:20px 0 8px;font-size:17px;color:var(--navy)}
.pd-desc{line-height:1.8;color:#26344f;font-size:16px}
.pd-tbl{width:100%;border-collapse:collapse;font-size:15px}.pd-tbl th,.pd-tbl td{padding:9px 12px;border-bottom:1px solid #eef1f7;text-align:left;vertical-align:top}.pd-tbl th{width:38%;color:#556;font-weight:600;background:#f9fbff}.pd-tbl tr:last-child th,.pd-tbl tr:last-child td{border-bottom:0}
.pd-rel{margin:30px 0 10px}.pd-rel h2{margin:0 0 14px;color:var(--navy);font-size:clamp(20px,2.6vw,24px)}
.bp-author{display:flex;gap:14px;align-items:flex-start;margin-top:26px;padding:16px 18px;border:1px solid #e3e9f5;border-radius:14px;background:#f9fbff}
.bp-av{flex:none;width:46px;height:46px;border-radius:50%;background:var(--blue);color:#fff;font:800 20px sans-serif;display:flex;align-items:center;justify-content:center}
.bp-author p{margin:4px 0 8px;color:#44526e;line-height:1.6;font-size:15px}.bp-author a{font-weight:600;font-size:14px}
@media(max-width:560px){.pd-tbl th{width:44%}.bp-author{padding:14px}}



/* ---------- Blog post: tables scroll horizontally on mobile ---------- */
.bp-content .tbl-scroll{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;margin:1em 0;border:1px solid #e3e9f5;border-radius:10px}
.bp-content .tbl-scroll table{width:100%;min-width:640px;border-collapse:collapse;margin:0}
.bp-content .tbl-scroll th,
.bp-content .tbl-scroll td{white-space:normal;word-break:normal;overflow-wrap:normal;min-width:110px;vertical-align:top;padding:9px 12px;border:1px solid #eef1f7;text-align:left}
.bp-content .tbl-scroll th{background:#f4f8ff;color:var(--navy)}
