:root {
  --jade: #0E6B5C;
  --jade-deep: #084B41;
  --on-jade: #FFFFFF;
  --marigold: #F0A91B;
  --bg: #E9EFEB;
  --surface: #FFFFFF;
  --surface-2: #F1F5F2;
  --ink: #15231F;
  --muted: #55655F;
  --line: #D5DFD9;
  --t-cuoc-song: #B4560F;
  --t-lich-su-dia-ly: #A5302A;
  --t-du-lich: #0B7285;
  --t-tieng-viet: #2F7D32;
  --t-nhiep-anh: #5B4BA8;
  --t-ngoai-ngu: #1F5FA8;
  --t-van-tho-nhac: #9C2F73;
  --scrim: rgba(8, 20, 18, .55);
  --top-h: 56px;
  --tab-h: 62px;
  --page-w: 1048px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --bar-h: calc(var(--tab-h) + var(--safe-b));
  --sheet-h: 0px;
  --ui: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, sans-serif;
  --read: "Literata", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --jade: #49C2AB;
    --jade-deep: #8FE0CF;
    --on-jade: #06302A;
    --bg: #101A18;
    --surface: #1A2724;
    --surface-2: #24332F;
    --ink: #E7F0EC;
    --muted: #A3B4AD;
    --line: #2F403B;
    --t-cuoc-song: #F0A35E;
    --t-lich-su-dia-ly: #F08A80;
    --t-du-lich: #5CC6D8;
    --t-tieng-viet: #7FCB83;
    --t-nhiep-anh: #B5A9F2;
    --t-ngoai-ngu: #8AB8F0;
    --t-van-tho-nhac: #F08CC8;
    --scrim: rgba(0, 0, 0, .65);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--ui);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; touch-action: manipulation; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
svg { display: block; }
:focus-visible {
  outline: 2.5px solid var(--jade-deep);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--marigold);
  border-radius: 6px;
}
main:focus, h1:focus, .sheet:focus { outline: none; box-shadow: none; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; left: 8px; top: -80px; z-index: 100; background: var(--surface); padding: 10px 14px; border-radius: 8px; }
.skip:focus { top: calc(8px + var(--safe-t)); }

.t-cuoc-song { --c: var(--t-cuoc-song); }
.t-lich-su-dia-ly { --c: var(--t-lich-su-dia-ly); }
.t-du-lich { --c: var(--t-du-lich); }
.t-tieng-viet { --c: var(--t-tieng-viet); }
.t-nhiep-anh { --c: var(--t-nhiep-anh); }
.t-ngoai-ngu { --c: var(--t-ngoai-ngu); }
.t-van-tho-nhac { --c: var(--t-van-tho-nhac); }

/* Thanh trên */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 10px 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; min-height: 44px; min-width: 0; }
.mark { width: 32px; height: 32px; flex: none; }
.wordmark { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-size: 18px; letter-spacing: -.015em; color: var(--jade-deep); white-space: nowrap; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; background: var(--surface-2); color: var(--ink);
}
.icon-btn svg { width: 22px; height: 22px; }

/* Thanh tab dưới (điện thoại, máy tính bảng) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: calc(var(--tab-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 0; min-height: var(--tab-h); padding: 4px 1px;
  color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center;
}
.nav svg { width: 24px; height: 24px; flex: none; }
.nav .lbl-long { display: none; }
.nav a[aria-current] { color: var(--jade); font-weight: 700; }
.nav a[aria-current] svg { fill: color-mix(in srgb, var(--jade) 18%, transparent); }

/* Khung */
.shell { display: block; }
.side { display: none; }
main { min-width: 0; }

/* Đầu trang chủ: ảnh bìa, avatar, tên trang */
.hero { container-type: inline-size; background: var(--surface); margin-bottom: 8px; }
.cover { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.cover:focus-visible { outline-offset: -4px; box-shadow: inset 0 0 0 6px var(--marigold); border-radius: 0; }
.cover-slide { position: absolute; inset: 0; }
.cover-slide[hidden] { display: none; }
.cover-slide > svg { width: 100%; height: 100%; }
.cover-slide figcaption {
  position: absolute; left: 12px; top: 12px; max-width: calc(100% - 24px);
  padding: 4px 10px; background: #FFFFFF; color: #15231F; border-radius: 2px;
  font-size: 13px; font-weight: 700; line-height: 1.3; box-shadow: 3px 3px 0 var(--marigold);
}
.cover-edge { position: absolute; top: 0; bottom: 0; width: 24%; display: flex; align-items: center; padding: 0 8px; }
.cover-edge.prev { left: 0; justify-content: flex-start; }
.cover-edge.next { right: 0; justify-content: flex-end; }
.cover-edge span {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, .88); color: #15231F; box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
}
.cover-edge svg { width: 22px; height: 22px; }
.cover-edge:focus-visible { box-shadow: none; outline: none; }
.cover-edge:focus-visible span { outline: 2.5px solid var(--jade-deep); box-shadow: 0 0 0 5px var(--marigold); }
.cover-dots {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  display: flex; padding: 0 6px; border-radius: 999px; background: rgba(8, 20, 18, .45);
}
.cover-dots button { display: grid; place-items: center; width: 26px; height: 26px; }
.cover-dots button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .6); }
.cover-dots button[aria-current]::before { width: 10px; height: 10px; background: #FFFFFF; }

.hero-info {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: 12px 14px;
  padding: 0 16px 14px;
}
.hero-avatar {
  position: relative; z-index: 2;
  width: 28.125cqw; height: 28.125cqw; margin-top: -9.375cqw;
  border-radius: 50%; border: 4px solid var(--surface); background: var(--surface); overflow: hidden;
}
.hero-avatar svg { width: 100%; height: 100%; }
.hero-text { min-width: 0; padding-bottom: 4px; }
.hero-title { font-size: clamp(21px, 6vw, 30px); font-weight: 700; letter-spacing: -.015em; line-height: 1.2; text-wrap: balance; }
.hero-tagline { margin-top: 3px; color: var(--muted); font-size: 14px; font-style: italic; line-height: 1.4; }
.hero-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }

/* Nút phụ */
.btn-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 14px;
}
.btn-soft svg { width: 20px; height: 20px; flex: none; color: var(--jade); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 46px; padding: 0 18px; border-radius: 10px;
  background: var(--jade); color: var(--on-jade); font-weight: 700;
}
.btn svg { width: 19px; height: 19px; }

/* Hàng chuyên đề */
.shelf {
  display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto;
  background: var(--surface); margin-bottom: 8px;
  scrollbar-width: none; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scroll-padding-left: 12px;
}
.shelf::-webkit-scrollbar { display: none; }
.shelf-item {
  position: relative; flex: 0 0 88px; height: 112px; overflow: hidden;
  border-radius: 10px; scroll-snap-align: start; background: var(--surface-2);
}
.shelf-item svg { width: 100%; height: 76px; }
.shelf-item span {
  position: absolute; left: 0; right: 0; bottom: 0; height: 36px; padding: 0 4px;
  display: grid; place-items: center; text-align: center;
  background: var(--c); color: #fff; font-weight: 700; font-size: 12px; line-height: 1.15;
}
@media (prefers-color-scheme: dark) { .shelf-item span { color: #10201C; } }

/* Thẻ bài */
.feed { display: grid; gap: 8px; }
.post { background: var(--surface); }
.post-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.avatar { width: 32px; height: 32px; flex: none; display: block; }
.who { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.3; }
.who-topic { position: relative; color: var(--c); font-weight: 700; font-size: 15px; }
.who-topic::after { content: ""; position: absolute; inset: -10px -10px -4px; }
.who span { color: var(--muted); font-size: 13px; }
.post-link { display: block; }
.post-link h2 { padding: 0 14px; font-size: 18px; line-height: 1.38; font-weight: 700; letter-spacing: -.005em; text-wrap: pretty; }
.post-link p { padding: 4px 14px 10px; color: var(--muted); text-wrap: pretty; }

.scene { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); }
.scene > svg, .scene > img { width: 100%; height: 100%; }
.scene > img, .cover-slide > img, .mini-img > img, .tile-img > img, .tl-img > img, .photo-tile > img, .hero-avatar > img, .photo-view > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.scene figcaption {
  position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 24px);
  display: flex; flex-direction: column; padding: 5px 10px;
  background: #FFFFFF; color: #15231F; border-radius: 2px;
  font-size: 13px; font-weight: 700; line-height: 1.3;
  box-shadow: 3px 3px 0 var(--marigold);
}
.scene figcaption span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene figcaption small { font-weight: 400; color: #55655F; font-size: 12px; font-variant-numeric: tabular-nums; }

.post-actions { display: flex; align-items: center; gap: 2px; padding: 3px 6px; border-top: 1px solid var(--line); }
.act {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 12px; border-radius: 8px;
  color: var(--muted); font-weight: 600; font-size: 13px;
  transition: transform .08s ease-out;
}
.act svg { width: 20px; height: 20px; flex: none; }
.act.is-on { color: var(--jade); }
.act.is-on svg { fill: currentColor; }
.act-read { margin-left: auto; color: var(--jade); font-weight: 700; }

/* Phản hồi khi chạm */
.act:active, .chip:active, .btn:active, .btn-soft:active, .icon-btn:active, .seg a:active, .nav a:active { transform: scale(.96); }
.chip, .btn, .btn-soft, .icon-btn, .seg a, .nav a { transition: transform .08s ease-out; }
.post-link, .mini, .tile, .tl-card, .place-list a, .sheet-list a, .topic-list a, .facts a, .title-list a, .row-link { transition: background-color .08s linear .06s; }
.post-link:active, .place-list a:active, .sheet-list a:active, .topic-list a:active, .facts a:active, .tl-card:active, .tile:active, .title-list a:active, .row-link:active { background-color: var(--surface-2); }
.shelf-item:active, .photo-tile:active { opacity: .85; }

@media (hover: hover) {
  .act:hover, .nav a:hover { background: var(--surface-2); }
  .post-link:hover h2, .title-list a:hover span:last-child { color: var(--jade); }
}

/* Đầu trang con */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding: 14px 14px 10px; background: var(--surface); }
.page-head h1 { font-size: 23px; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 999px; }
.seg a { position: relative; display: inline-flex; align-items: center; min-height: 38px; padding: 0 13px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg a::after { content: ""; position: absolute; inset: -6px 0; }
.seg a[aria-current] { background: var(--jade); color: var(--on-jade); }

/* Trang chuyên đề */
.topic-hero { display: flex; align-items: center; gap: 14px; padding: 14px; margin-bottom: 8px; background: var(--surface); border-left: 5px solid var(--c); }
.topic-hero-img { width: 112px; height: 76px; flex: none; overflow: hidden; border-radius: 8px; }
.topic-hero-img svg { width: 100%; height: 100%; }
.topic-hero-text { min-width: 0; }
.topic-hero h1 { font-size: 21px; font-weight: 700; line-height: 1.25; text-wrap: balance; }
.topic-hero p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.empty-block { display: grid; justify-items: center; gap: 14px; padding: 28px 18px; background: var(--surface); text-align: center; color: var(--muted); }
.other-topics { margin-top: 8px; padding: 14px 0 6px; background: var(--surface); }
.other-topics h2 { padding: 0 14px 8px; font-size: 18px; font-weight: 700; }

/* Bản đồ */
.map-wrap { background: var(--surface); padding: 0 12px 12px; }
.map-svg { width: 100%; height: auto; background: color-mix(in srgb, var(--t-du-lich) 11%, var(--surface)); border-radius: 8px; cursor: pointer; }
.grid line { stroke: color-mix(in srgb, var(--muted) 38%, transparent); stroke-width: 1; stroke-dasharray: 2 6; }
.map-axis { fill: var(--muted); font: 600 27px var(--ui); }
.map-sea { fill: var(--t-du-lich); font: 700 34px var(--ui); }
.map-isl { fill: var(--ink); font: 600 30px var(--ui); }
.isl-dot { fill: var(--ink); }
.pin-dot { fill: var(--c); stroke: var(--surface); stroke-width: 3; }
.pin.is-active .pin-dot { stroke: var(--marigold); stroke-width: 6; }
.place-list { margin-top: 8px; background: var(--surface); }
.place-list a, .sheet-list a { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.place-list a.is-active { background: var(--surface-2); }
.place-list a > span:last-child, .sheet-list a > span:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.32; }
.place-list strong, .sheet-list strong { font-weight: 700; }
.place-list small, .sheet-list small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; }

.sheet {
  position: fixed; z-index: 35;
  left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r));
  bottom: calc(var(--bar-h) + 8px);
  max-height: calc(100dvh - var(--bar-h) - var(--top-h) - var(--safe-t) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 10px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 28px rgba(8, 40, 34, .28);
  animation: rise .2s ease-out;
}
.sheet h2 { padding-right: 48px; min-height: 40px; display: flex; align-items: center; font-size: 15px; font-weight: 700; }
.sheet .mini { padding-right: 46px; }
.sheet-list a { padding-left: 2px; padding-right: 2px; }
.sheet-list li:last-child a { border-bottom: 0; }
.sheet-close { position: absolute; top: 8px; right: 8px; z-index: 1; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }

/* Thẻ nhỏ */
.mini { display: flex; align-items: center; gap: 11px; min-height: 64px; }
.mini-img { width: 76px; height: 58px; flex: none; overflow: hidden; border-radius: 6px; }
.mini-img svg { width: 100%; height: 100%; }
.mini-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.32; }
.mini-text strong { font-size: 15px; font-weight: 600; }
.mini-text small { color: var(--muted); font-size: 13px; }

/* Bộ lọc */
.chips { position: relative; display: flex; gap: 7px; padding: 4px 14px 12px; overflow-x: auto; background: var(--surface); scrollbar-width: none; overscroll-behavior-x: contain; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chips.sticky { position: sticky; top: calc(var(--top-h) + var(--safe-t)); z-index: 20; border-bottom: 1px solid var(--line); padding-top: 6px; padding-bottom: 8px; }
.chip {
  position: relative; flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip::after { content: ""; position: absolute; inset: -3px 0; }
.chip[aria-current] { background: var(--jade); color: var(--on-jade); }

/* Dòng thời gian */
.timeline { position: relative; padding: 16px 14px 8px 34px; }
.timeline::before { content: ""; position: absolute; left: 19px; top: 18px; bottom: 16px; width: 3px; background: var(--line); border-radius: 2px; }
.timeline li { position: relative; padding-bottom: 18px; }
.timeline li::before {
  content: ""; position: absolute; left: -22px; top: 3px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--c); border: 3px solid var(--bg);
}
.tl-year { display: block; margin-bottom: 6px; color: var(--ink); font-weight: 700; font-size: 15px; }
.tl-card { display: flex; overflow: hidden; background: var(--surface); border-radius: 10px; min-height: 92px; }
.tl-img { width: 104px; flex: none; }
.tl-img svg { width: 100%; height: 100%; }
.tl-text { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 10px 12px; line-height: 1.32; min-width: 0; }
.tl-text strong { font-weight: 700; text-wrap: pretty; }
.tl-text small { color: var(--muted); font-size: 13px; }

/* Khám phá */
.search {
  position: relative; display: flex; align-items: center; padding: 0 14px 10px;
  background: var(--surface); color: var(--muted);
}
.search svg { position: absolute; left: 26px; top: 13px; width: 20px; height: 20px; pointer-events: none; }
.search input {
  width: 100%; height: 46px; padding: 0 14px 0 41px;
  font: 400 16px var(--ui); color: var(--ink);
  background: var(--surface-2); border: 1.5px solid var(--muted); border-radius: 999px;
  -webkit-appearance: none; appearance: none;
}
.search input:focus { outline: none; border-color: var(--jade); box-shadow: 0 0 0 2px var(--jade); }
.search input::placeholder { color: var(--muted); opacity: 1; }
.count { padding: 8px 14px 0; color: var(--muted); font-size: 13px; }
.grid-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 8px; }
.tile { display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border-radius: 10px; }
.tile-img { display: block; aspect-ratio: 4 / 3; }
.tile-img svg { width: 100%; height: 100%; }
.tile-text { display: flex; flex-direction: column; gap: 3px; padding: 9px 10px 11px; line-height: 1.32; }
.tile-text strong { font-size: 15px; font-weight: 600; text-wrap: pretty; }
.tile-text em { font-style: normal; font-weight: 700; font-size: 13px; color: var(--c); }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.empty a { color: var(--jade); font-weight: 700; }

/* Ảnh */
.album { margin-bottom: 8px; padding: 14px 12px; background: var(--surface); }
.album h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 2px 10px; font-size: 18px; font-weight: 700; }
.album h2 small { color: var(--muted); font-size: 13px; font-weight: 400; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.photo-tile { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 4px; background: var(--surface-2); }
.photo-tile > svg { width: 100%; height: 100%; }
.photo-mark { display: grid; place-items: center; width: 100%; height: 100%; }
.photo-mark svg { width: 70%; height: 70%; }

/* Giới thiệu */
.panel { margin-top: 8px; padding: 14px 16px; background: var(--surface); }
.panel:first-child { margin-top: 0; }
.about-head { display: grid; justify-items: start; gap: 4px; }
.avatar.avatar-xl { width: 88px; height: 88px; border-radius: 50%; }
.about-head h1 { margin-top: 6px; font-size: 23px; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
.bio { color: var(--muted); font-style: italic; max-width: 52ch; }
.counts { display: flex; gap: 26px; margin: 10px 0; }
.counts div { display: flex; flex-direction: column-reverse; }
.counts dd { font-size: 18px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.counts dt { color: var(--muted); font-size: 13px; }
.about-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel h2, .related h2, .sources h2 { font-size: 18px; font-weight: 700; margin-bottom: 7px; line-height: 1.35; }
.panel p { max-width: 62ch; }
.topic-list a { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.topic-list small { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 13px; }
.row-link { display: flex; align-items: center; gap: 10px; min-height: 48px; color: var(--jade); font-weight: 600; border-radius: 8px; }
.row-link svg { width: 22px; height: 22px; flex: none; }

/* Trang đọc */
.reader { background: var(--surface); }
.reader-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: calc(var(--tab-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--surface); border-top: 1px solid var(--line);
}
.reader-bar .act { flex-direction: column; gap: 3px; min-height: var(--tab-h); padding: 4px 2px; border-radius: 0; font-size: 12px; line-height: 1.2; }
.reader-bar .act svg { width: 24px; height: 24px; }
.reader .scene { aspect-ratio: 16 / 9; }
.reader-body { padding: 16px 16px 8px; }
.reader-body h1 { font-size: clamp(24px, 7vw, 27px); line-height: 1.3; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 7px; color: var(--muted); font-size: 13px; }
.byline-topic { position: relative; color: var(--c); font-weight: 700; }
.byline-topic::after { content: ""; position: absolute; inset: -12px -8px; }
.reader-body > p.lede { margin-top: 15px; max-width: 66ch; font: 600 clamp(18px, 4.9vw, 19px)/1.58 var(--read); text-wrap: pretty; }
.prose { max-width: 66ch; font: 400 clamp(17px, 4.6vw, 18px)/1.68 var(--read); }
.prose > * { margin-top: 15px; }
.prose p { text-wrap: pretty; }
.prose h2, .prose h3, .prose h4 { margin-top: 26px; font-family: var(--ui); font-weight: 700; line-height: 1.3; text-wrap: balance; }
.prose h2 { font-size: 21px; }
.prose h3 { font-size: 18px; }
.prose h4 { font-size: 16px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: 6px; }
.prose blockquote {
  margin-left: 0; margin-right: 0; padding: 12px 16px; border-left: 4px solid var(--jade); border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--jade) 9%, var(--surface));
}
.prose blockquote > * + * { margin-top: 8px; }
.prose img { display: block; width: 100%; height: auto; margin: 0 auto; border-radius: 8px; background: var(--surface-2); }
.prose img.img-m { width: 70%; }
.prose img.img-s { width: 45%; }
.prose a { color: var(--jade); text-decoration: underline; text-underline-offset: 3px; }
.prose figure figcaption { margin-top: 6px; color: var(--muted); font: 400 13px/1.4 var(--ui); text-align: center; }
.video { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.body-status { margin-top: 18px; padding: 16px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 15px; }
.body-status .btn { margin-top: 10px; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 22px; }
.pager > :last-child { justify-self: end; }
.pager-status { color: var(--muted); font-size: 13px; font-weight: 600; text-align: center; }
.facts { display: grid; gap: 8px; margin-top: 22px; }
.facts a { display: flex; align-items: center; gap: 11px; min-height: 58px; padding: 8px 13px; background: var(--surface-2); border-radius: 10px; font-weight: 600; }
.facts svg { width: 22px; height: 22px; color: var(--jade); flex: none; }
.facts span { display: flex; flex-direction: column; line-height: 1.3; }
.facts small { color: var(--muted); font-weight: 400; font-size: 13px; }
.sources { margin-top: 22px; }
.sources li { padding: 6px 0; }
.sources a { color: var(--jade); text-decoration: underline; text-underline-offset: 3px; }
.page-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 24px 0 8px; }
.page-nav .btn-soft { flex-direction: column; gap: 3px; min-height: 58px; padding: 6px 4px; font-size: 13px; text-align: center; line-height: 1.2; }
.related { display: grid; gap: 8px; margin-top: 12px; padding: 14px 16px 20px; border-top: 8px solid var(--bg); }

/* Chân trang */
.site-footer { padding: 18px 16px calc(var(--bar-h) + var(--sheet-h) + 20px); color: var(--muted); font-size: 13px; text-align: center; }
.site-footer p + p { margin-top: 2px; }

/* Hộp thoại */
.modal {
  width: 100%; max-width: 100%; max-height: min(88dvh, 720px);
  margin: auto 0 0; padding: 0 0 var(--safe-b);
  border: 0; border-radius: 16px 16px 0 0;
  background: var(--surface); color: var(--ink);
  overscroll-behavior: contain;
}
.modal[open] { animation: rise .2s ease-out; }
.modal::backdrop { background: var(--scrim); }
.modal-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 18px; font-weight: 700; line-height: 1.3; min-width: 0; }
.modal-body { padding: 6px 18px 22px; }
.modal-body p { margin-top: 8px; max-width: 62ch; }
.modal-body h3 { margin-top: 18px; font-size: 15px; font-weight: 700; }
.photo-view { aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); }
.photo-view > svg { width: 100%; height: 100%; }
.photo-view .photo-mark svg { width: 46%; height: 46%; }
.photo-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 12px 18px 16px; color: var(--muted); font-size: 13px; }

/* Toast */
.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(var(--bar-h) + 14px);
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 8px;
  background: var(--ink); color: var(--surface); font-weight: 600; font-size: 13px;
  transition: opacity .16s, transform .16s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Điện thoại và máy tính bảng: trang đọc chỉ giữ thanh thao tác ở đáy */
@media (max-width: 1023.98px) {
  body[data-view="article"] .topbar,
  body[data-view="article"] .nav { display: none; }
  body[data-view="article"] .reader { padding-top: var(--safe-t); }
}

/* Màn hình rộng hơn điện thoại: cột giữa, bo góc */
@media (min-width: 640px) {
  .prose img.img-left { float: left; width: 45%; margin: 4px 18px 10px 0; }
  .prose img.img-right { float: right; width: 45%; margin: 4px 0 10px 18px; }
  .prose::after { content: ""; display: block; clear: both; }
  #hero, .shell { max-width: 680px; margin-left: auto; margin-right: auto; }
  #hero { padding-top: 12px; }
  .hero, .shelf, .post, .page-head, .panel, .reader, .place-list, .album, .topic-hero, .empty-block, .other-topics { border-radius: 12px; }
  .hero { overflow: hidden; }
  .shell { padding-top: 12px; }
  #hero:not(:empty) + .shell { padding-top: 0; }
  .feed { gap: 12px; }
  .post { overflow: hidden; }
  .page-head { border-radius: 12px 12px 0 0; }
  .map-wrap { border-radius: 0 0 12px 12px; }
  .chips:not(.sticky):not(.wrap) { border-radius: 0 0 12px 12px; }
  .grid-list { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 12px 0; gap: 12px; }
  .reader { overflow: clip; }
  .reader-body { padding: 22px 30px 10px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .related { padding: 18px 30px 24px; }
  .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal { width: min(560px, calc(100vw - 32px)); margin: auto; border-radius: 14px; padding-bottom: 0; }
}

/* Máy tính: menu ngang, ảnh bìa, 2 cột theo góp ý */
@media (min-width: 1024px) {
  .topbar { padding: 0 max(20px, calc((100vw - var(--page-w)) / 2)); gap: 16px; }
  .nav {
    position: static; display: flex; gap: 2px; margin-left: auto;
    min-height: 0; padding: 0; background: none; border: 0;
  }
  .nav a { flex-direction: row; gap: 8px; min-height: 42px; padding: 0 12px; border-radius: 8px; font-size: 14px; }
  .nav svg { width: 20px; height: 20px; }
  .nav .lbl-long { display: inline; }
  .nav .lbl-short { display: none; }
  .nav a[aria-current] { background: color-mix(in srgb, var(--jade) 12%, transparent); }

  #hero, .shell { max-width: var(--page-w); }
  #hero { padding-top: 20px; }
  .hero { margin-bottom: 20px; }
  .hero-info { grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 20px; padding: 0 28px 22px; }
  .hero-avatar { border-width: 6px; }
  .hero-title { font-size: 34px; }
  .hero-tagline { font-size: 17px; }
  .hero-actions { grid-column: auto; padding-bottom: 6px; }

  .shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; padding-top: 20px; }
  .side {
    display: grid; gap: 14px; position: sticky; top: calc(var(--top-h) + 20px);
    max-height: calc(100dvh - var(--top-h) - 40px); overflow-y: auto; overscroll-behavior: contain;
  }
  .side-card { padding: 15px 16px; background: var(--surface); border-radius: 12px; }
  .side-card h2 { margin-bottom: 8px; font-size: 18px; font-weight: 700; }
  .title-list { display: grid; }
  .title-list a { display: flex; align-items: flex-start; gap: 10px; padding: 7px 4px; border-radius: 6px; font-size: 14px; font-weight: 600; line-height: 1.35; }
  .title-list .dot { width: 9px; height: 9px; margin-top: 6px; }
  .side-card .topic-list a { min-height: 38px; font-size: 14px; }
  .photo-grid.mini { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .side-more { display: inline-flex; align-items: center; min-height: 40px; margin-top: 4px; color: var(--jade); font-weight: 700; font-size: 14px; }

  main { padding-bottom: 8px; }
  .reader-bar {
    position: sticky; top: var(--top-h); bottom: auto; z-index: 20;
    display: flex; align-items: center; min-height: 0;
    padding: 4px 8px; border-top: 0; border-bottom: 1px solid var(--line);
  }
  .reader-bar .act { flex-direction: row; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
  .reader-bar .act svg { width: 20px; height: 20px; }
  .reader-bar .act:first-child { margin-right: auto; }
  .reader-body { padding: 26px 40px 10px; }
  .reader-body h1 { font-size: 32px; }
  .page-nav .btn-soft { flex-direction: row; min-height: 48px; font-size: 14px; }
  .related { padding: 18px 40px 24px; }
  .chips.sticky { top: var(--top-h); }
  .sheet { left: auto; right: 24px; bottom: 24px; width: 360px; max-height: calc(100dvh - var(--top-h) - 48px); }
  .toast { bottom: 26px; }
  .site-footer { padding: 24px 16px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .act:active, .chip:active, .btn:active, .btn-soft:active, .icon-btn:active, .seg a:active, .nav a:active { transform: none; }
}

/* Thích, Không thích, Trả lời */
.react { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.react-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.react-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  transition: transform .08s ease-out;
}
.react-btn svg { width: 20px; height: 20px; flex: none; }
.react-btn b { min-width: 1ch; font-variant-numeric: tabular-nums; color: var(--muted); }
.react-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--jade) 14%, var(--surface)); border-color: var(--jade); color: var(--jade); }
.react-btn[aria-pressed="true"] svg { fill: color-mix(in srgb, var(--jade) 25%, transparent); }
.react-btn[aria-pressed="true"] b { color: var(--jade); }
.react-btn:active { transform: scale(.96); }
.react-btn:disabled { opacity: .7; }
.react h2 { display: flex; align-items: center; gap: 8px; margin-top: 22px; font-size: 18px; font-weight: 700; }
.react h2 svg { width: 22px; height: 22px; color: var(--jade); }
.react h2 small { color: var(--muted); font-weight: 600; font-size: 14px; }
.react-note { margin-top: 10px; color: var(--muted); font-size: 14px; }
.link-btn { color: var(--jade); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.replies { display: grid; gap: 10px; margin-top: 12px; }
.reply { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); }
.reply-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 14px; }
.reply-head time { color: var(--muted); font-size: 12px; }
.reply-body { margin-top: 4px; white-space: pre-line; overflow-wrap: anywhere; font: 400 16px/1.55 var(--read); }
.reply-form { margin-top: 16px; display: grid; gap: 10px; }
.rf-field { display: grid; gap: 5px; }
.rf-field span { font-weight: 600; font-size: 14px; }
.rf-field input, .rf-field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: 400 16px/1.45 var(--ui);
}
.rf-field input { min-height: 46px; }
.rf-field textarea { resize: vertical; min-height: 96px; }
.rf-field input:focus, .rf-field textarea:focus { outline: 2px solid var(--jade); outline-offset: 0; border-color: var(--jade); box-shadow: none; }
.rf-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.rf-msg:empty { display: none; }
.rf-msg { padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.rf-msg[data-kind="error"] { background: color-mix(in srgb, #B3261E 12%, var(--surface)); }
.rf-msg[data-kind="ok"] { background: color-mix(in srgb, var(--jade) 14%, var(--surface)); }
.rf-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.rf-foot small { flex: 1 1 240px; color: var(--muted); font-size: 13px; line-height: 1.4; }
