/* One setting for every outline in the app: the theme's text colour at low strength, the rest see-through, so borders
   blend into whatever is behind them (light or dark themes) yet still show. Selected things use the accent the same way. */
:root { --soft-line: color-mix(in srgb, var(--text) 9%, transparent); --soft-line-accent: color-mix(in srgb, var(--accent) 32%, transparent); }

/* Egomini soft illustrated style: header, dock, shared components, Home and Roadmap */
:root {
  --radius: 22px; --radius-sm: 16px;
  --shadow-card: 0 8px 22px -14px rgba(120, 70, 40, .35);
}
#topBarTrack { display: none !important; }

/* ---- header ---- */
header.topbar { padding: 8px 0 10px; }
/* iOS leaves a stale black square where a sticky, translateZ(0) layer was hidden (display:none when a study screen opens from the Từ vựng tab).
   Drop the forced compositing layer; hidden states also fully detach it. */
header.topbar { -webkit-transform: none; transform: none; will-change: auto; }
/* Hidden while studying everywhere; hidden on list pages only on phones/tablets (below), never in the desktop sidebar. */
body[data-study="on"] header.topbar { display: none !important; position: static; transform: none; }
.topbar-row { gap: 10px; }
.brand { gap: 10px; min-width: 0; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 16px; flex-shrink: 0; display: block;
  background: #FFE2D6 url(/img/logo-mark.webp) 50% 50% / 74% auto no-repeat;
  border: 2px solid #fff; box-shadow: var(--shadow-card);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 19px; white-space: nowrap; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.brand-sub { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 12.5px; font-weight: 500; color: var(--text-dim); white-space: nowrap; }
.brand-sub svg { color: #6BAA4F; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.streak-pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; font-size: 14px; font-weight: 700; color: var(--text); background: var(--surface); box-shadow: var(--shadow-card); }
.streak-pill svg { color: var(--accent); }
#themeToggleBtn { width: 34px; height: 34px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow-card); }
@media (max-width: 1039px) { body[data-hdr="hidden"] header.topbar { display: none !important; position: static; transform: none; } }

/* ---- bottom dock ---- */
.dock { left: 12px; right: 12px; bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) - 12px)); max-width: 520px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 14px 34px -12px rgba(120, 70, 40, .38); padding: 8px; }
main#screen { padding-bottom: calc(92px + max(0px, env(safe-area-inset-bottom, 0px) - 12px)); }
.dock-item { position: relative; gap: 4px; padding: 6px 2px 10px; font-size: 10.5px; }
.dock-item.active::after { content: ''; position: absolute; bottom: 1px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

/* ---- shared components ---- */
.soft-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 10px; }
.sec-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.sec-head h3 svg { color: var(--accent); }
.sec-count { font-size: 13px; color: var(--text-dim); }
.page-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; }
.ph-back { display: flex; padding: 6px 6px 6px 0; background: none; border: 0; color: var(--text); cursor: pointer; }
.ph-icon { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); }
.ph-title { flex: 1; min-width: 0; }
.ph-title h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.ph-title p { margin: 3px 0 0; font-size: 13px; line-height: 1.35; color: var(--text-dim); }
.pill-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.pill-row::-webkit-scrollbar { display: none; }
.pill-row.sub { padding-top: 0; }
.pill-row.tools { overflow-x: visible; flex-wrap: wrap; padding-top: 0; }
.pill-row.tools .pill { flex: 1; justify-content: center; min-width: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 8px 14px; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-card);
}
.pill.active { background: var(--btn-bg, var(--accent)); color: var(--accent-ink); border-color: transparent; }
.pill.open { border-color: var(--accent); color: var(--accent); }
.pill.sm { padding: 6px 12px; font-size: 13px; }
.pill .n { font-size: 11px; opacity: .7; }
.empty-note { padding: 28px 12px; text-align: center; color: var(--text-dim); font-size: 14px; }
.ring-wrap { position: relative; flex-shrink: 0; }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 7; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; }
.ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; }

/* ---- home ---- */
.home-soft, .road-soft, .words-soft { max-width: 920px; }
.home-soft { display: flex; flex-direction: column; gap: 14px; }
.home-soft .sec-head { margin: 6px 0 -4px; }
.hero-banner {
  position: relative; overflow: hidden; min-height: 136px; padding: 18px 16px; border-radius: 24px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), color-mix(in srgb, var(--accent) 7%, var(--surface)));
  box-shadow: var(--shadow-card);
}
.hb-text { position: relative; z-index: 1; max-width: 60%; }
.hb-text h2 { margin: 0 0 8px; font-size: 21px; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; }
.hb-text p { display: flex; align-items: flex-end; gap: 4px; margin: 0; font-size: 13px; line-height: 1.4; color: var(--text-dim); }
.hb-text p svg { color: var(--accent); flex-shrink: 0; }
.hb-img { position: absolute; right: 10px; top: 50%; transform: translateY(-50%) scaleX(-1); height: 84%; max-height: 122px; width: auto; }
.road-soft .level-row, .words-soft .level-row, .home-soft .level-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 0; overflow: visible; }
.road-soft .level-chip, .words-soft .level-chip, .home-soft .level-chip { min-width: 0; padding: 10px 2px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-card); color: var(--text); }
.road-soft .level-chip .lc-code, .words-soft .level-chip .lc-code, .home-soft .level-chip .lc-code { font-size: 16.5px; }
.road-soft .level-chip .lc-sub, .words-soft .level-chip .lc-sub, .home-soft .level-chip .lc-sub { font-size: 10.5px; }
.road-soft .level-chip.active, .words-soft .level-chip.active, .home-soft .level-chip.active { background: var(--btn-bg, var(--accent)); color: var(--accent-ink); border-color: transparent; }
.progress-card { padding: 14px; }
.pc-top { display: flex; align-items: center; gap: 10px; }
.pc-num { flex: 1; min-width: 0; }
.pc-big { font-size: 27px; font-weight: 800; line-height: 1; letter-spacing: -.02em; white-space: nowrap; }
.pc-big span { font-size: 14.5px; font-weight: 700; color: var(--text-dim); }
.pc-sub { margin-top: 3px; font-size: 12.5px; line-height: 1.3; color: var(--text-dim); }
.pill-btn { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; padding: 7px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-family: var(--font-ui); font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-card); cursor: pointer; }
.pc-bar { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--text-dim); white-space: nowrap; }
.pc-track { flex: 1; height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.pc-fill { height: 100%; border-radius: 999px; background: var(--btn-bg, linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, white))); }
.cta-btn { width: 100%; padding: 15px; border-radius: 16px; font-size: 16px; }
.review-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.review-card.due { border-color: var(--accent); }
.review-card > svg { flex-shrink: 0; color: var(--accent); }
.rc-text { flex: 1; display: flex; flex-direction: column; font-size: 14px; }
.rc-text span { font-size: 12.5px; color: var(--text-dim); }
.rc-text em { font-style: normal; font-weight: 800; color: var(--text); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 10px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-card); }
.sc-tile { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 14px; background: var(--tile); }
.sc-tile img { width: 27px; height: 27px; object-fit: contain; }
.sc-num { font-size: 19px; font-weight: 800; line-height: 1.1; }
.sc-label { font-size: 11.5px; line-height: 1.2; color: var(--text-dim); }

@media (max-width: 400px) { .pill-btn > svg:first-child { display: none; } }

/* ---- roadmap ---- */
.road-hero { position: relative; display: flex; align-items: center; gap: 14px; overflow: hidden; padding: 16px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.road-hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 40%, color-mix(in srgb, var(--accent) 12%, transparent)); }
.rh-text { position: relative; z-index: 1; max-width: 54%; }
.rh-title { font-size: 18px; font-weight: 800; }
.rh-sub { margin: 2px 0 8px; font-size: 13px; color: var(--text-dim); }
.rh-img { position: absolute; right: 4px; bottom: 0; height: 100%; max-height: 112px; width: auto; }
.lesson-list { display: flex; flex-direction: column; gap: 12px; }
.lesson { display: flex; align-items: center; gap: 12px; padding: 12px; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-card); }
.ls-thumb { display: flex; align-items: center; justify-content: center; width: 54px; height: 54px; flex-shrink: 0; border-radius: 16px; background: var(--tile); }
.ls-thumb img { max-width: 78%; max-height: 78%; object-fit: contain; }
.ls-main { flex: 1; min-width: 0; }
.ls-top { display: flex; align-items: center; gap: 8px; }
.ls-num { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; background: var(--surface-2); color: var(--text-dim); font-size: 11px; font-weight: 800; }
.st-done .ls-num { background: var(--accent); color: var(--accent-ink); }
.st-progress .ls-num { background: var(--doing); color: var(--doing-ink); }
.ls-name { min-width: 0; flex: 1; }
.ls-title { font-size: 15.5px; font-weight: 800; line-height: 1.15; }
.ls-range { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--text-dim); }
.pill-st { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--text-dim); }
.pill-st.st-done { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.pill-st.st-progress { background: color-mix(in srgb, var(--doing) 20%, transparent); color: var(--doing); }
.ls-prog { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.ls-track { flex: 1; height: 7px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.ls-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.st-progress .ls-fill { background: var(--doing); }
.ls-list { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text-dim); cursor: pointer; }

@media (min-width: 1040px) {
  .hero-banner { min-height: 200px; padding: 30px 32px; }
  .hb-text h2 { font-size: 32px; }
  .hb-text p { font-size: 15px; }
  .hb-img { right: 24px; max-height: 190px; }
  .lesson-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .ph-title h1 { font-size: 32px; }
  .rh-img { max-height: 150px; right: 24px; }
  .road-hero { padding: 24px 28px; }
  .sc-num { font-size: 26px; }
}

/* no outlines on boxes: rely on soft shadows */
.soft-card, .stat-card, .lesson, .road-hero, .review-card, .review-card.due, .streak-pill,
#themeToggleBtn, .dock, .ls-list, .brand-logo { border-color: transparent; }
.pill.open { border-color: var(--accent); }
.ph-back, .top-mini-nav .progress-chip, .part-seg:not(.current), .lesson .ls-list, .word-list.soft { border-color: transparent; }

/* Global: no box outlines anywhere except the Từ vựng tab (.words-soft). State colors are re-asserted below. */
main#screen > :not(.words-soft), main#screen > :not(.words-soft) *,
.dock, .dock *, header.topbar *, .brand-logo { border-color: transparent; }
.part-seg { border-color: transparent; }
main#screen .theme-card.active, header.topbar .part-seg.current { border-color: var(--accent); }
main#screen .pill.open, main#screen .review-card.due { border-color: var(--accent); }
main#screen .slot { border-color: var(--soft-line); }
main#screen .slot.filled { border-color: var(--accent); }
main#screen .slot.wrong, main#screen .type-input.wrong { border-color: var(--coral); }
main#screen .type-input { border-color: var(--soft-line); }
main#screen .type-input.right { border-color: var(--mint); }
main#screen .type-input:focus { border-color: var(--accent); }
main#screen .set-row, main#screen .vol-row { border-top-color: color-mix(in srgb, var(--line) 60%, transparent); }
main#screen .btn-ghost { border-color: var(--soft-line); }
main#screen .pill:not(.active),
main#screen .pill-btn,
main#screen .level-chip:not(.active),
main#screen .btn-secondary,
main#screen .top-mini-nav .link-btn,
main#screen .stepper button,
main#screen .set-head .link-btn,
main#screen .ex-btn { border: 1px solid var(--soft-line); border-color: var(--soft-line); }
main#screen .ex-btn:hover { border-color: var(--accent); }
main#screen .pill.active,
main#screen .level-chip.active { border-color: transparent; }
main#screen .theme-card { border: 0; box-shadow: none; background: var(--surface-2); }
main#screen .theme-card.active { border: 0; box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }

.words-soft .level-row { margin: 0 0 12px; }
.ws-search { display: flex; gap: 8px; margin-bottom: 10px; }
.ws-search .ph-search { flex: 1; width: auto; padding: 10px 14px; }
.ws-search .filter-btn { flex-shrink: 0; padding: 10px 16px; }
.pill-row.wrap { flex-wrap: wrap; overflow-x: visible; }
.pill-row.wrap { gap: 6px; } .pill-row.wrap .pill.sm { padding: 6px 10px; }

.rh-img { transform: scaleX(-1); }
.road-soft .level-row { margin: 14px 0 6px; }
.lvl-tag { display: inline-flex; align-items: center; margin-right: 6px; padding: 2px 7px; border-radius: 999px; background: var(--btn-bg, var(--accent)); color: var(--accent-ink); font-size: 11px; font-weight: 800; }
main#screen .btn-logout { border: 1.5px solid #E5484D; color: #E5484D; background: var(--surface); }
#topProgress { display: inline-flex; align-items: center; white-space: nowrap; }
.streak-pill { flex-shrink: 0; white-space: nowrap; }
.brand-text { overflow: hidden; }
@media (max-width: 400px) {
  .brand-logo { width: 40px; height: 40px; border-radius: 14px; }
  .brand-name { font-size: 15.5px; }
  .brand-sub { font-size: 11.5px; }
  .streak-pill { padding: 6px 10px; }
  .streak-pill > svg { display: none; }
  .top-actions { gap: 6px; }
  .lvl-tag { margin-right: 5px; padding: 2px 6px; }
}

/* Desktop: center page content in the area beside the sidebar */
@media (min-width: 1040px) {
  main#screen { max-width: none; }
  .home-soft, .road-soft, .words-soft, .set-soft, .acc-soft { margin-left: auto; margin-right: auto; }
  main#screen:has(> .study-wrap) > .top-mini-nav { max-width: 780px; margin-left: auto; margin-right: auto; }
}

/* No text selection / long-press callouts in the app UI (form fields stay editable) */
html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, [contenteditable="true"] { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; user-drag: none; }

/* Double-tapping buttons must not zoom or scroll the page (still allows pan/pinch) */
*, *::before, *::after { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* level tag on stat cards (Account tab) */
.stat-card { position: relative; }
.sc-lvl { position: absolute; top: -9px; right: 12px; padding: 2px 9px; border-radius: 999px; background: var(--btn-bg, var(--accent)); color: var(--accent-ink); font-size: 10.5px; font-weight: 800; letter-spacing: .02em; }

/* Google sign-in button (own markup, pill-shaped) */
.g-btn { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; max-width: 380px; margin: 0 auto; padding: 13px 20px; border: 1px solid #DADCE0; border-radius: 999px; background: #fff; color: #3C4043; font-family: var(--font-ui); font-size: 15px; font-weight: 700; box-shadow: var(--shadow-card); cursor: pointer; }
.g-btn:active { transform: scale(.98); }
.g-btn:disabled { opacity: .7; cursor: default; }
main#screen .g-btn { border: 1.5px solid #D0D3D8; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }

.empty-mascot { display: block; height: 130px; width: auto; margin: 0 auto 10px; object-fit: contain; }

/* Search boxes keep a thin border so they stand out from the page (the rule above makes most soft borders transparent). */
.ph-search { border: 1px solid var(--soft-line); }
.ph-search:focus-within { border-color: var(--soft-line-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
/* Search boxes and filter buttons keep a visible border on every page (the global rule above clears borders elsewhere). */
main#screen .ph-search, main#screen .cat-fbtn, main#screen .ws-search .filter-btn { border: 1px solid var(--soft-line); }
main#screen .ph-search:focus-within, main#screen .cat-fbtn.open, main#screen .cat-fbtn:hover, main#screen .ws-search .filter-btn.open { border-color: var(--soft-line-accent); }
/* The open pack's card: a soft accent outline on every page (the global rule above clears plain borders). */
main#screen .pk-row.current { border: 1px solid var(--soft-line-accent); }
/* The app name in the top bar is never cut: it keeps its width, the progress chip next to it gives way */
.brand { flex-shrink: 0; }
.brand-text { overflow: visible; flex-shrink: 0; }
header.topbar .streak-pill { min-width: 0; flex-shrink: 1; }
/* Home banner: the text may use the whole width except what the mascot takes (plus a small gap), instead of a fixed 60%,
   so "chinh phục tiếng Anh!" stays on one line whenever there is room. Mascot ≈ 0.9 × its height wide. */
.hb-text { max-width: calc(100% - 118px); }
@media (min-width: 1040px) { .hb-text { max-width: calc(100% - 200px); } }
/* Home: the open pack's name on top of its progress card (tap to open its word list) */
.pc-pack { display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 14px; padding: 0 0 14px; border: 0; border-bottom: 1px solid var(--soft-line); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pc-pack .pk-tile { width: 44px; height: 44px; flex-shrink: 0; border-radius: 13px; font-size: 17px; }
.pc-pname { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pc-pname b { font-size: 16px; font-weight: 800; }
.pc-pname small { font-size: 12.5px; color: var(--text-dim); }
.pc-pack > svg { color: var(--text-dim); flex-shrink: 0; }
/* "Thêm gói học song song" on the home page: shaped exactly like the pack cards beside it (an empty slot for one more),
   with a + in place of the pack tile. */
main#screen .pk-addcard { width: 100%; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.pk-addtile { display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--accent); }
.pk-addcard .pk-main b { color: var(--text); }
/* Round back button in a page's title row (white with a soft shadow: it sits on the tinted page) */
.round-back { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); cursor: pointer; transition: transform .15s; }
.round-back:hover { color: var(--accent); }
.round-back:active { transform: scale(.94); }
/* Open pack: back button + "Gói trình độ CEFR · Egomini biên soạn" on one row above the pack header */
.pk-topbar { display: flex; align-items: center; gap: 12px; margin: 2px 0 14px; min-width: 0; }
.pk-topbar .pk-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* One header-box design for Trang chủ, Lộ trình and Thư viện — the roadmap's: white card, accent wash fading in from
   the right, 24px corners, soft shadow, mascot standing on the bottom edge. */
.hero-banner, .cat-hero { position: relative; overflow: hidden; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-card); }
.hero-banner::before, .cat-hero::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(100deg, transparent 40%, color-mix(in srgb, var(--accent) 12%, transparent)); }
.cat-hero > * { position: relative; z-index: 1; }
.hb-text, .hb-img { z-index: 1; }
.hb-img { top: auto; bottom: 0; transform: scaleX(-1); height: 100%; max-height: 122px; }
@media (min-width: 1040px) { .hb-img { max-height: 170px; } }
/* Stat card label (pack name): one line, never wider than the card; a long name scrolls sideways (marquee.js) */
.sc-lvl { max-width: calc(100% - 24px); white-space: nowrap; overflow: hidden; line-height: 1.5; }
.sc-lvl .mq { max-width: 100%; }
/* Every back button in a title row (Cài đặt sections, Lộ trình, …) uses the round white design of .round-back */
.ph-back { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); cursor: pointer; transition: transform .15s; }
.ph-back:hover { color: var(--accent); }
.ph-back:active { transform: scale(.94); }
.ph-back svg { width: 20px; height: 20px; stroke-width: 2.4; }
.top-mini-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
/* Home: the review card and the three stat cards. Phones: stacked as before. Desktop: one row of four. */
.home-stats { display: flex; flex-direction: column; gap: 14px; }
.home-stats .review-card, .home-stats .stat-row { margin: 0; }
@media (min-width: 1040px) {
  /* review + stats live in the left column now: review on top, the three stats below (two rows) */
  .home-stats.has-review .review-card { gap: 12px; }
  .home-stats.has-review .review-card .rc-text { min-width: 0; }
  .home-stats.has-review .review-card .btn { flex-shrink: 0; }
}
/* Home: open pack (left) and the packs learned alongside (right) side by side on desktop; on phones they stay in one
   column, the review and stat cards coming before the other packs. */
.home-split, .hs-main, .hs-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (max-width: 1039px) { .home-split { display: contents; } }
@media (min-width: 1040px) {
  .home-split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .hs-side .home-packs { grid-template-columns: 1fr; }
}
/* Desktop: the "other packs" column shows about three cards and scrolls inside when there are more, so both columns
   stay balanced. Phones keep the plain list (the page scrolls). */
@media (min-width: 1040px) {
  .hs-side .home-packs { flex: 1 1 0; min-height: 0; align-content: start; overflow-y: auto; overscroll-behavior: contain; padding: 4px 6px 10px 4px; margin: -4px -6px -10px -4px;
    scrollbar-width: thin; scrollbar-color: var(--soft-line) transparent; }
  .hs-side .home-packs::-webkit-scrollbar { width: 6px; }
  .hs-side .home-packs::-webkit-scrollbar-thumb { background: var(--soft-line); border-radius: 99px; }
}
/* Desktop home: the right column is exactly as tall as the left one (its own content doesn't size the row: contain),
   and the pack list fills it, scrolling inside when there are more packs. */
@media (min-width: 1040px) {
  .home-split { align-items: stretch; }
  .hs-side { contain: size; min-height: 0; }
}
/* Desktop home banner: title and tagline each on one line, a lower box and a smaller mascot */
@media (min-width: 1040px) {
  .hb-br { display: none; }
  .hero-banner { min-height: 0; padding: 24px 30px; }
  .hb-text { max-width: calc(100% - 160px); }
  .hb-text h2 { font-size: 28px; margin-bottom: 6px; }
  .hb-img { max-height: 124px; right: 28px; }
}
/* Home banner: "Bạn đang học gói …" line, and a bigger mascot on desktop so the box has more body */
.hb-now { margin-top: 10px; display: inline-block; max-width: 100%; padding: 6px 12px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--text); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.hb-now b { color: var(--accent); }
@media (min-width: 1040px) {
  .hero-banner { padding: 26px 30px; }
  .hb-text { max-width: calc(100% - 200px); }
  .hb-img { max-height: 168px; height: 100%; }
  .hb-now { font-size: 14px; }
}
/* Home: streak and 14-day activity cards at the bottom (same cards as Lịch sử học); side by side on desktop */
.home-history { display: flex; flex-direction: column; gap: 14px; }
.home-history .sp-banner, .home-history .set-card { margin: 0; }
.home-history .set-card .set-head { margin-bottom: 16px; }
/* Mobile home: drop the "Bạn đang học gói …" line and the 14-day activity card */
@media (max-width: 1039px) {
  .hb-now, .home-history .set-card { display: none; }
}
/* Desktop home: the other-packs list splits the column's height into five equal rows, so exactly five cards fill it
   (none cut off); more packs scroll. No mask on the scroller (repainting it on every scroll made scrolling stutter). */
@media (min-width: 1040px) {
  .hs-side .home-packs { grid-auto-rows: calc((100% - 4 * 12px) / 5); will-change: scroll-position; transform: translateZ(0); }
  .hs-side .home-packs > .pk-row { min-height: 0; padding-top: 8px; padding-bottom: 8px; }
}
/* Học bằng Gợi ý từ: phones reach it from the bottom of the home page (desktop has it in the sidebar) */
.home-hints { display: none; align-items: center; gap: 12px; width: 100%; margin-top: 14px; padding: 16px; text-align: left; font: inherit; color: var(--text); cursor: pointer; border: 0; }
.home-hints .hh-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.home-hints small { color: var(--text-dim); font-size: 13px; }
@media (max-width: 1039px) { .home-hints { display: flex; } }
