/* ============================================================
   Tiện Ích Hub — design system (đổi giao diện 18/11/2026)
   Tổng hợp từ web công cụ nước ngoài: sạch tối giản kiểu iLovePDF
   (nền trắng, thẻ trắng đều, bóng đổ rất nhẹ, khoảng trắng lớn) +
   thẻ hạng mục đặc màu kiểu TinyWow + hàng xếp hạng kiểu
   Product Hunt. Nhấn xanh dương #1e8fe0, CTA Ủng hộ cam #f59e0b.
   Bố cục: khôi phục bản trước đợt 1 (hero + xếp hạng ở đầu trang,
   Điểm báo là mục chính, rồi lưới công cụ, Ủng hộ cuối trang).
   Mobile-first: không tràn ngang ở 390px.
   Dark mode qua [data-theme="dark"] trên <html>.
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --hero-bg: #f4f9fd;
  --surface: #ffffff;
  --ink: #1a2027;
  --muted: #64748b;
  --line: #e5e7eb;
  --line-soft: #eef2f7;
  --accent: #1e8fe0;
  --accent-dark: #1770b8;
  --accent-soft: #e8f4fd;
  --amber: #f59e0b;
  --amber-dark: #d97706;
  --warn: #b45309;
  --good: #15803d;
  --bad: #b91c1c;
  --shadow: 0 10px 25px -5px rgba(30, 136, 229, 0.15);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.05);
  --note-bg: #fff7d6;
  --error-bg: #fdecea;
  --focus: #7cc0ff;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 20px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-soft: #16283f;
  --hero-bg: #16283f;
  --surface: #1e293b;
  --ink: #e9f1f8;
  --muted: #94a3b8;
  --line: #334155;
  --line-soft: #26334a;
  --accent: #4da3e8;
  --accent-dark: #7cc0ff;
  --accent-soft: #1d3a57;
  --amber: #f59e0b;
  --amber-dark: #e8a33d;
  --warn: #e8a33d;
  --good: #4ade80;
  --bad: #f87171;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
  --note-bg: #2a2410;
  --error-bg: #3a1a18;
  --focus: #7cc0ff;
}

/* ---------- Nền tảng ---------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
}

img, canvas, svg, video { max-width: 100%; height: auto; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3, h4 { line-height: 1.3; overflow-wrap: break-word; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; min-width: 0; }
.main { padding-top: 8px; padding-bottom: 16px; min-width: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: var(--bad); font-weight: 700; }
p.error {
  background: var(--error-bg);
  border: 1px solid var(--bad);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}

.brand {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand span { color: var(--accent); }

.header-actions { display: flex; gap: 8px; align-items: center; }

.theme-toggle,
.nav-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover,
.nav-toggle:hover { background: var(--bg-soft); }

.site-nav { display: none; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  display: block;
}
.site-nav a:hover { background: var(--bg-soft); color: var(--ink); }
.site-nav a.nav-active { background: var(--accent-soft); color: var(--accent-dark); }

.site-header.nav-open .site-nav {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 8px 16px 16px;
  gap: 4px;
}

@media (min-width: 720px) {
  .nav-toggle { display: none; }
  .site-nav { display: flex; gap: 4px; align-items: center; }
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 32px 0;
}
.footer-inner { display: flex; flex-direction: column; gap: 8px; }
.footer-inner p { margin: 0; }
.footer-brand { font-weight: 700; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer-nav a { color: var(--ink); font-weight: 600; text-decoration: none; }
.footer-nav a:hover { text-decoration: underline; }

/* ---------- Hero / section ---------- */

.hero {
  padding: 40px 24px 28px;
  margin-top: 16px;
  background: var(--hero-bg);
  border-radius: var(--radius-lg);
  text-align: center;
  position: relative;
  isolation: isolate;
}
.hero h1 { font-size: 2.5rem; font-weight: 800; line-height: 1.15; margin: 0 0 12px; }
.hero-sub { color: var(--muted); font-size: 1.05rem; margin: 0 auto 20px; max-width: 60ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
@media (min-width: 720px) {
  .hero h1 { font-size: 3rem; }
  .hero { padding: 48px 32px 32px; }
}

/* Ánh sáng hero đi theo chuột (JS cập nhật --mx/--my). */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: var(--radius-lg);
  background: radial-gradient(
    360px circle at var(--mx, 50%) var(--my, 40%),
    rgba(255, 255, 255, 0.55),
    rgba(186, 230, 253, 0.25) 45%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
}
.hero:hover::after,
.hero:focus-within::after { opacity: 0.15; }

.section { margin: 40px 0; }
.section > h2 {
  margin: 0 0 16px;
  font-size: 1.75rem;
  font-weight: 700;
}

.support-banner {
  margin: 24px 0;
  padding: 20px 24px;
  background: var(--amber);
  color: #1a2027;
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.support-banner p { margin: 0; flex: 1 1 260px; }
.support-banner .btn {
  background: #fff;
  color: #1a2027;
  border-color: #fff;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.support-banner .btn:hover { background: #fff7e6; }

/* ---------- Nút bấm ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--bg-soft); border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-ghost { background: transparent; }
.btn-ghost:active { transform: none; }

.btn-small { padding: 4px 10px; font-size: 0.875rem; }
.copy-btn { padding: 6px 12px; font-size: 0.9rem; }

/* ---------- Lưới ---------- */

.grid-2, .grid-3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Ô tìm kiếm + chip lọc ---------- */

.search-input {
  width: 100%;
  padding: 12px 16px;
  font: inherit;
  font-size: 1rem;
  border: 1px solid #d6d6df;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  margin-bottom: 12px;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30, 143, 224, 0.15); outline: none; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.chip {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
button.chip { cursor: pointer; }
button.chip:hover { background: var(--bg-soft); }
.chip-active,
button.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
/* Chip đang chọn mà rê chuột qua vẫn giữ nền xanh (như tab). */
.chip-active:hover,
button.chip[aria-pressed="true"]:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* ---------- Thẻ công cụ (kiểu iLovePDF) ---------- */

.catalog-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  will-change: transform;
}
.catalog-card:hover,
.catalog-card.is-touched {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}
.catalog-card:active { transform: translateY(0); box-shadow: var(--shadow-card); }
/* Ô icon pastel theo hạng mục (màu nền nhạt, giữ nguyên cả dark mode). */
.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: #e8f4fd;
  font-size: 1.5rem;
  line-height: 1;
}
.catalog-card[data-category="tai-chinh"] .card-icon { background: #dbeafe; }
.catalog-card[data-category="van-phong"] .card-icon { background: #ede9fe; }
.catalog-card[data-category="suc-khoe"] .card-icon { background: #d1fae5; }
.catalog-card[data-category="hoc-tap"] .card-icon { background: #fce7f3; }
.catalog-card[data-category="nha-bep"] .card-icon { background: #ffedd5; }
.catalog-card[data-category="du-lich"] .card-icon { background: #cffafe; }
.catalog-card[data-category="mua-sam"] .card-icon { background: #fee2e2; }
.catalog-card[data-category="doi-song"] .card-icon { background: #ecfccb; }
.catalog-card[data-category="dev-web"] .card-icon { background: #e0e7ff; }
.catalog-card[data-category="github"] .card-icon { background: #e5e7eb; }
.catalog-card[data-category="hang-ngay"] .card-icon { background: #fef3c7; }
.card-title { margin: 0; font-size: 1.125rem; font-weight: 600; }
.card-desc { margin: 0; color: var(--muted); font-size: 0.875rem; flex: 1 1 auto; overflow-wrap: break-word; }
.card-cat {
  align-self: flex-start;
  border: none;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.8rem;
  padding: 4px 10px;
}

/* ---------- Trang công cụ ---------- */

.breadcrumb { margin: 16px 0 0; }
.breadcrumb a { color: var(--muted); font-weight: 600; text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }

.tool-page-head { margin: 12px 0 4px; }
.tool-page-head h1 { margin: 0 0 8px; font-weight: 800; }
.tool-page-head p { margin: 0 0 12px; max-width: 70ch; }

/* ---------- Khối công cụ (class cho worker công cụ) ---------- */

.tool-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin: 16px 0;
}
.tool-panel > :first-child { margin-top: 0; }
.tool-panel > :last-child { margin-bottom: 0; }

.tool-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tool-head h1, .tool-head h2 { margin: 0; }

.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field input[type="email"],
.field input[type="url"],
.field input[type="password"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid #d6d6df;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30, 143, 224, 0.15); outline: none; }
.field textarea { min-height: 96px; resize: vertical; }
.field input[type="checkbox"],
.field input[type="radio"] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.field .hint { font-size: 0.875rem; color: var(--muted); margin-top: 4px; }

.result {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 16px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  overflow-wrap: break-word;
}
.result-row + .result-row { border-top: 1px dashed var(--line-soft); }
.result-row span { min-width: 0; }
.result-row strong { text-align: right; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  /* Điện thoại: hàng kết quả xếp dọc (nhãn trên, giá trị dưới) để
     con số không bị ép hẹp tới mức gãy dòng giữa chừng. */
  .result-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .result-row strong { text-align: left; }
}

.tbl { width: 100%; border-collapse: collapse; margin: 12px 0; }
.tbl th, .tbl td { border: 1px solid var(--line-soft); padding: 8px 10px; text-align: left; overflow-wrap: break-word; }
.tbl th { background: var(--bg-soft); }
@media (max-width: 640px) {
  .tbl { display: block; overflow-x: auto; }
}

.note {
  background: var(--note-bg);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 12px 0;
}
.note p { margin: 0; }

/* Tabs — dùng cho cả trang chủ (xếp hạng, Điểm báo) và bên trong công cụ */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tab {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { background: var(--bg-soft); }
.tab-active { background: var(--accent); border-color: var(--accent); color: #fff; }
/* Tab đang chọn mà rê chuột qua vẫn giữ nền xanh (không bị luật :hover
   ghi đè thành nền nhạt + chữ trắng khó đọc). */
.tab-active:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.tab-panel[hidden] { display: none; }

/* Thống kê nhanh trong công cụ */
.stat {
  text-align: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.stat-num { font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 0.875rem; }

/* ---------- Khối công cụ — mở rộng (worker C, 18/11) ----------
   Chuẩn trải nghiệm dùng chung, học theo web công cụ nước ngoài
   (iLovePDF/TinyWow): kết quả chính nổi bật + nút chép, hàng nút gọn,
   lỗi nêu rõ từng ô, đơn vị trong ô nhập, trạng thái bận rõ ràng. */

/* Hàng nút của công cụ (Tính + Điền ví dụ + Đặt lại): xếp ngang, tự
   xuống dòng; trên điện thoại mỗi nút chiếm trọn một hàng cho dễ bấm. */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
@media (max-width: 480px) {
  .btn-row .btn { flex: 1 1 100%; }
}

/* Kết quả nổi bật: con số chính to, rõ — đặt đầu khối .result. */
.result-hero { text-align: center; padding: 16px 12px 8px; }
.result-hero-label { font-weight: 700; color: var(--muted); margin: 0 0 4px; }
.result-hero-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--accent-dark);
  overflow-wrap: break-word;
}
.result-hero-sub { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; }
@media (max-width: 480px) {
  .result-hero-value { font-size: 1.6rem; }
}

/* Hàng nút dưới kết quả (Chép kết quả, Tải ảnh…): căn giữa, gọn. */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

/* Lỗi theo từng ô nhập: viền đỏ + dòng chữ đỏ ngay dưới ô
   (UH.markFieldError thêm, UH.clearFieldErrors gỡ). */
.field input.field-error,
.field select.field-error,
.field textarea.field-error {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}
.field-msg { color: var(--bad); font-size: 0.875rem; font-weight: 600; margin: 4px 0 0; }

/* Đơn vị trong ô nhập: "₫", "kWh", "%/năm" nằm gọn bên phải ô. */
.input-unit { position: relative; display: block; }
.input-unit input { padding-right: 56px; }
.input-unit .unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
}

/* Trạng thái bận của nút (UH.setBusy/UH.withBusy thêm): spinner xoay +
   mờ nhẹ, chống bấm đúp. Tắt nhấp nháy khi prefers-reduced-motion
   (luật chung cuối file đã tắt mọi animation). */
.btn.is-busy { opacity: 0.75; pointer-events: none; }
.btn.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: uh-spin 0.7s linear infinite;
}
@keyframes uh-spin { to { transform: rotate(360deg); } }

/* Link "bỏ qua tới nội dung" (template.js): ẩn cho tới khi focus. */
.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 300;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 0 0 12px 12px;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; color: #fff; }

/* ---------- Giá trị dữ liệu (app.js render vào dải hôm nay) ---------- */

.today-value { font-size: 1.3rem; font-weight: 800; line-height: 1.3; overflow-wrap: break-word; }
.today-source { margin: 8px 0 0; }
.coin-price-vnd { color: var(--muted); font-size: 0.875rem; overflow-wrap: break-word; }
.coin-change { font-weight: 700; font-size: 0.9rem; }
.coin-change.up { color: var(--good); }
.coin-change.down { color: var(--bad); }
.gold-prices { display: flex; flex-wrap: wrap; gap: 8px 32px; }
.gold-price span { display: block; color: var(--muted); font-size: 0.875rem; }
.gold-price b { font-size: 1.15rem; overflow-wrap: break-word; }

/* ---------- Điểm báo ---------- */

.news-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}
.news-card h4 { margin: 0 0 8px; font-size: 1.02rem; }
.news-card h4 a { color: var(--ink); text-decoration: none; overflow-wrap: break-word; }
.news-card h4 a:hover { color: var(--accent); text-decoration: underline; }
.news-summary { margin: 0 0 8px; color: var(--muted); overflow-wrap: break-word; }
.news-meta { margin: 0; font-size: 0.85rem; color: var(--muted); }
.news-why { font-style: italic; color: var(--muted); }

/* Tin nổi bật: nền xanh nhạt, nhãn "Tin nổi bật" màu nhấn. */
.news-featured { background: var(--accent-soft); }
.news-featured-tag {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-dark);
}
.news-featured h3 { margin: 0 0 8px; font-size: 1.25rem; }
.news-featured h3 a { color: var(--ink); text-decoration: none; overflow-wrap: break-word; }
.news-featured h3 a:hover { color: var(--accent); text-decoration: underline; }

/* Trang lưu trữ Điểm báo theo ngày: danh sách tin. */
.news-list { display: grid; gap: 12px; }
.news-list .news-card { margin-bottom: 0; }

/* ---------- Bảng xếp hạng (kiểu Product Hunt: hàng ngang, không bóng đổ) ---------- */

/* Bảng xếp hạng nằm trong vùng hero: panel trắng nổi bật ở đầu trang. */
.hero-ranking {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  text-align: left;
}
.hero-ranking h2 { margin: 0 0 12px; font-size: 1.4rem; }
/* Tiêu đề Bảng xếp hạng không gãy giữa cụm từ trên màn hình hẹp. */
#ranking h2 { white-space: nowrap; }

.rank-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 8px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 8px;
}
.rank-row:last-child { border-bottom: none; }
.rank-row:hover { background: var(--bg-soft); }
.rank-num {
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1.2;
  min-width: 36px;
  text-align: center;
  flex: 0 0 auto;
  color: var(--muted);
}
.rank-1 .rank-num { color: #d97706; }
.rank-2 .rank-num { color: #64748b; }
.rank-3 .rank-num { color: #b45309; }
.rank-body { min-width: 0; flex: 1 1 auto; }
.rank-body h4 { margin: 0 0 4px; font-size: 1rem; }
.rank-body h4 a { color: var(--ink); text-decoration: none; overflow-wrap: break-word; }
.rank-body h4 a:hover { color: var(--accent); text-decoration: underline; }
.rank-desc { margin: 0 0 4px; color: var(--muted); font-size: 0.925rem; overflow-wrap: break-word; }
.rank-meta { margin: 0; font-size: 0.85rem; color: var(--muted); }
/* Pill ★ số sao ở cuối hàng (điểm xếp hạng trực quan). */
.rank-pill {
  flex: 0 0 auto;
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}
.hot-chip {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 8px;
}

/* ---------- Dải dữ liệu hôm nay (trên Điểm báo) ---------- */

.section-strips { margin: 32px 0; }
.strip-date { margin: 0 0 12px; font-size: 0.95rem; font-weight: 600; }
.strip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 960px) { .strip-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.strip-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 16px;
  min-width: 0;
  /* Chừa chiều cao tối thiểu để trang không nhảy hình khi dữ liệu về (CLS). */
  min-height: 160px;
}
.strip-label { margin: 0; font-size: 1rem; }
.strip-body { flex: 1 1 auto; min-width: 0; }
.strip-body > :first-child { margin-top: 0; }
.strip-body > :last-child { margin-bottom: 0; }
.strip-fng { margin: 0; }
.strip-link { margin: 0; }
.strip-link a { font-weight: 700; text-decoration: none; }
.strip-link a:hover { text-decoration: underline; }
@media (max-width: 640px) {
  /* Điện thoại: dải cuộn ngang để trang không quá dài. */
  .strip-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .strip-card { flex: 0 0 240px; scroll-snap-align: start; min-height: 150px; }
}

/* ---------- Thẻ hạng mục đặc màu (kiểu TinyWow, trang /cong-cu/) ---------- */

.cat-heading { margin: 28px 0 12px; font-size: 1.4rem; }
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
@media (min-width: 640px) { .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .cat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--cat-color, #2563eb);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: #fff;
  min-width: 0;
  min-height: 150px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); filter: brightness(1.04); }
.cat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-size: 1.35rem;
  line-height: 1;
}
.cat-count {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}
.cat-name { margin: 0; font-size: 1.125rem; font-weight: 700; color: #fff; }
.cat-featured { margin: 0; color: rgba(255, 255, 255, 0.88); font-size: 0.875rem; overflow-wrap: break-word; flex: 1 1 auto; padding-right: 28px; }
.cat-arrow {
  position: absolute;
  right: 16px;
  bottom: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

/* ---------- Ủng hộ / QR ---------- */

.qr-wrap { text-align: center; margin: 20px 0; }
.qr-wrap canvas {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  box-sizing: content-box;
}
.amount-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.amount-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.amount-btn[aria-pressed="true"]:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* ---------- Trang văn bản (Điều khoản / Chính sách) ---------- */

.legal h2 { margin-top: 32px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.legal h3 { margin-top: 24px; }
.legal ul, .legal ol { padding-left: 22px; }
.legal li { margin-bottom: 6px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Hero: ô tìm kiếm lớn + chip gợi ý ---------- */

.hero-search-wrap { position: relative; max-width: 640px; margin: 0 auto 12px; text-align: left; }
.hero-search {
  width: 100%;
  padding: 16px 20px;
  font: inherit;
  font-size: 1.05rem;
  border: 1px solid #d6d6df;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.hero-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30, 143, 224, 0.15); outline: none; }
.hero-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
}
.hero-search-results[hidden] { display: none; }
.hero-search-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
}
.hero-search-item:last-child { border-bottom: none; }
.hero-search-item:hover { background: var(--accent-soft); }
.hero-search-name { font-weight: 700; overflow-wrap: break-word; }
.hero-search-cat { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.hero-search-empty { margin: 0; padding: 12px 14px; color: var(--muted); }

.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; justify-content: center; }
.hero-chips .chip { text-decoration: none; }

/* Ô tìm kiếm trang /cong-cu/ nổi bật hơn. */
.search-input-large { font-size: 1.05rem; padding: 14px 18px; box-shadow: var(--shadow-sm); }

/* ---------- Thanh nav dưới (chỉ điện thoại ≤768px) ---------- */

.bottom-nav { display: none; }
@media (max-width: 768px) {
  body { padding-bottom: 64px; }
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--line);
    min-height: 56px;
  }
  .bottom-nav a {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    min-width: 0;
  }
  .bottom-nav a.bottom-nav-active { background: var(--accent-soft); color: var(--accent-dark); }
  .toast { bottom: 76px; }
}

/* ---------- Sơ đồ trang trong footer ---------- */

.footer-sitemap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 12px 0 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.footer-sitemap-col h3 { margin: 0 0 8px; font-size: 1rem; }
.footer-sitemap-col a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  padding: 2px 0;
  overflow-wrap: break-word;
}
.footer-sitemap-col a:hover { color: var(--accent); text-decoration: underline; }
@media (min-width: 720px) {
  .footer-sitemap { flex-direction: row; gap: 48px; }
  .footer-sitemap-col { flex: 1 1 0; min-width: 0; }
}

/* ---------- Chuyển cảnh mượt cho nút bấm / link ---------- */

.btn,
.chip,
.tab,
.site-nav a,
.footer-nav a,
.breadcrumb a,
.theme-toggle,
.nav-toggle,
.amount-btn {
  transition: color 0.2s ease, background-color 0.2s ease,
    border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ---------- Linh vật ---------- */

.mascot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mascot svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Linh vật trong hero: ~96px, nằm dưới hàng chip gợi ý, trên bảng xếp hạng. */
.mascot-hero {
  width: 96px;
  height: 96px;
  margin-top: 16px;
}

/* Linh vật góc trang: cố định góc dưới-phải, ~64px.
   z-index 150: trên header sticky (100), dưới toast (200) nên
   không che thông báo; bottom 24px để không đè lên toast. */
.mascot-corner {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  z-index: 150;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(18, 40, 62, 0.18);
  padding: 6px;
}

.mascot-corner:hover {
  box-shadow: 0 8px 22px rgba(18, 40, 62, 0.24);
}

/* Tay vẫy: xoay quanh vai (góc dưới-trái của nhóm tay). */
.mascot-arm {
  transform-box: fill-box;
  transform-origin: 20% 85%;
}

/* Vẫy tay: xoay nhẹ ±15°, chạy 1 lần 0.9s rồi dừng. */
.mascot.waving .mascot-arm {
  animation: mascot-wave 0.9s ease-in-out 1;
}

@keyframes mascot-wave {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-15deg); }
  50% { transform: rotate(12deg); }
  75% { transform: rotate(-8deg); }
  100% { transform: rotate(0deg); }
}

/* Nhảy nhẹ: lên 6px rồi về chỗ cũ, 0.5s, chạy 1 lần. */
.mascot.jumping {
  animation: mascot-jump 0.5s ease 1;
}

@keyframes mascot-jump {
  0% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

@media (max-width: 600px) {
  .mascot-corner {
    width: 48px;
    height: 48px;
    right: 12px;
    bottom: 16px;
  }

  /* Trên điện thoại linh vật hero thu nhỏ còn ~64px. */
  .mascot-hero {
    width: 64px;
    height: 64px;
  }

  /* Điện thoại: hero + panel xếp hạng gọn lại để hàng xếp hạng đủ rộng. */
  .hero { padding: 32px 16px 24px; }
  .hero-ranking { padding: 16px; }

  /* Hàng xếp hạng trên điện thoại: pill ★ xuống dòng dưới nội dung
     (không chen ngang làm hẹp cột chữ). */
  .rank-row { flex-wrap: wrap; }
  .rank-body { flex: 1 1 calc(100% - 48px); }
  .rank-pill { margin-left: 48px; align-self: flex-start; }
}

/* ---------- Khung xương (skeleton) + noscript ---------- */

/* Khung xám mờ lúc dải dữ liệu chưa có dữ liệu; app.js thay toàn bộ
   innerHTML khi dữ liệu về nên skeleton tự biến mất. Dùng --line-soft
   nên tự hợp cả sáng/tối; tắt nhấp nháy khi prefers-reduced-motion. */
.skeleton {
  background: var(--line-soft);
  border-radius: 8px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
.skeleton-value { height: 2rem; width: 55%; margin-bottom: 8px; }
.skeleton-line { height: 1rem; width: 85%; margin-bottom: 8px; }
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Khối <noscript>: thông báo + danh sách link gọn tới toàn bộ công cụ. */
.noscript-notice {
  background: var(--note-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 12px auto;
}
.noscript-notice p { margin: 0 0 8px; }
.noscript-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.875rem;
}

/* Nội dung giới thiệu + FAQ của 12 công cụ chính + câu "vì sao đáng đọc". */
.tool-intro { font-size: 1.05rem; line-height: 1.6; margin: 0 0 1.25rem; }
.tool-faq { margin-top: 2rem; }
.tool-faq h2 { font-size: 1.15rem; margin-bottom: 0.75rem; }
.tool-faq details { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; margin-bottom: 0.5rem; background: var(--surface); }
.tool-faq summary { cursor: pointer; font-weight: 600; }
.tool-faq details p { margin: 0.5rem 0 0.25rem; }
.tool-disclaimer { margin-top: 1.5rem; }

/* ---------- Tôn trọng người dùng nhạy cảm với chuyển động ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  /* Tắt luôn hiệu ứng nâng thẻ + ánh sáng hero. */
  .catalog-card:hover,
  .catalog-card.is-touched,
  .catalog-card:active,
  .cat-card:hover {
    transform: none;
  }

  .hero::after {
    display: none;
  }

  .mascot {
    cursor: default;
  }

  .skeleton { animation: none; }
}
