/* ============ TOKENS ============ */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #191613;
  --muted: #6f6960;
  --faint: #97918a;
  --line: #e7e2d9;
  --chip-bg: #f1ede5;
  --accent: #a61e2e;          /* đỏ son */
  --accent-ink: #ffffff;
  --good: #0e7a5f;
  --shadow: 0 1px 3px rgba(25, 22, 19, 0.07);

  --c-moinhat: #a61e2e;
  --c-phapluat: #a61e2e;
  --c-vanban: #3e5ba9;
  --c-dautu: #0e7a5f;
  --c-nganhang: #b4690e;
  --c-thegioi: #6b4ea0;
  --c-chinhtri: #545e75;

  --radius: 14px;
  --pad: 16px;
  --serif: Charter, 'Bitstream Charter', 'Palatino Linotype', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151210;
    --surface: #1f1b18;
    --ink: #efeae2;
    --muted: #a49c90;
    --faint: #7d766c;
    --line: #322d28;
    --chip-bg: #292420;
    --accent: #e05b50;
    --accent-ink: #1c0f0d;
    --good: #4fb596;
    --shadow: none;
    --c-moinhat: #e05b50;
    --c-phapluat: #e05b50;
    --c-vanban: #7c97e0;
    --c-dautu: #4fb596;
    --c-nganhang: #e0a04d;
    --c-thegioi: #a98bd9;
    --c-chinhtri: #98a4c0;
  }
}
:root[data-theme='light'] {
  --bg: #fbfaf7; --surface: #ffffff; --ink: #191613; --muted: #6f6960;
  --faint: #97918a; --line: #e7e2d9; --chip-bg: #f1ede5;
  --accent: #a61e2e; --accent-ink: #ffffff; --good: #0e7a5f;
  --shadow: 0 1px 3px rgba(25, 22, 19, 0.07);
  --c-moinhat: #a61e2e; --c-phapluat: #a61e2e; --c-vanban: #3e5ba9;
  --c-dautu: #0e7a5f; --c-nganhang: #b4690e; --c-thegioi: #6b4ea0; --c-chinhtri: #545e75;
}
:root[data-theme='dark'] {
  --bg: #151210; --surface: #1f1b18; --ink: #efeae2; --muted: #a49c90;
  --faint: #7d766c; --line: #322d28; --chip-bg: #292420;
  --accent: #e05b50; --accent-ink: #1c0f0d; --good: #4fb596; --shadow: none;
  --c-moinhat: #e05b50; --c-phapluat: #e05b50; --c-vanban: #7c97e0;
  --c-dautu: #4fb596; --c-nganhang: #e0a04d; --c-thegioi: #a98bd9; --c-chinhtri: #98a4c0;
}

/* ============ BASE ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.wrap { max-width: 560px; margin: 0 auto; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
h1, h2, h3, h4 { text-wrap: balance; margin: 0; }
.serif { font-family: var(--serif); }
[hidden] { display: none !important; }

/* ============ HEADER ============ */
header.app {
  padding: 12px var(--pad) 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-mark { width: 30px; height: 30px; flex: 0 0 auto; }
.logo em { color: var(--accent); font-style: normal; }
.updated { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.3; }
.icon-btn {
  min-width: 40px; min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; color: var(--muted);
}
.icon-btn:active { background: var(--chip-bg); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.spin svg { animation: none; } }

/* search */
.search { padding: 0 var(--pad) 10px; }
.search input {
  width: 100%; min-height: 42px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  padding: 8px 14px; font-size: 15px;
}
.search input::placeholder { color: var(--faint); }

/* ============ CHIP BAR ============ */
.chips {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px var(--pad) 10px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--chip-bg);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tc, var(--accent)); }
.chip[aria-selected='true'] { background: var(--tc, var(--accent)); color: #fff; }
:root[data-theme='dark'] .chip[aria-selected='true'],
.chip[aria-selected='true'].on-dark { color: #16130f; }
.chip[aria-selected='true'] .dot { background: currentColor; }

/* ============ NEWS LIST ============ */
main { min-height: 60vh; }
.section-desc { padding: 12px var(--pad) 0; font-size: 13px; color: var(--muted); }

.card, .hero-card {
  display: block;
  position: relative;
  padding: 14px var(--pad);
  border-bottom: 1px solid var(--line);
}
.hero-card .img {
  aspect-ratio: 16/9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--chip-bg);
  margin-bottom: 10px;
}
.hero-card .img img, .card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-card h3 { font-family: var(--serif); font-size: 20px; line-height: 1.32; font-weight: 700; padding-right: 40px; }
.hero-card p { margin: 7px 0 0; color: var(--muted); font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.card { display: flex; gap: 12px; align-items: flex-start; }
.card .body { flex: 1; min-width: 0; padding-right: 34px; }
.card h4 { font-family: var(--serif); font-size: 16.5px; line-height: 1.38; font-weight: 650; }
.card .thumb {
  flex: 0 0 88px; aspect-ratio: 4/3;
  border-radius: 10px; overflow: hidden;
  background: var(--chip-bg);
}
.meta { margin-top: 6px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meta .src { font-weight: 600; color: var(--tc, var(--accent)); }
.meta .tpc {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--tc, var(--accent));
  border: 1px solid currentColor;
  padding: 1px 6px; border-radius: 4px;
}
.save-btn {
  position: absolute; top: 10px; right: 8px;
  min-width: 40px; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
}
.hero-card .save-btn { top: auto; bottom: 6px; }
.save-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.save-btn.saved { color: var(--accent); }
.save-btn.saved svg { fill: currentColor; }

.more-btn {
  display: block; width: calc(100% - var(--pad) * 2);
  margin: 14px auto;
  min-height: 46px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface);
  font-weight: 600; font-size: 14.5px; color: var(--muted);
}

/* ============ RATES ============ */
.rates-head { padding: 16px var(--pad) 6px; }
.rates-head h2 { font-family: var(--serif); font-size: 21px; }
.rates-head .note { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.rates-scroll { overflow-x: auto; padding: 8px 0 4px; }
table.rates {
  border-collapse: collapse;
  width: 100%; min-width: 520px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
table.rates th, table.rates td {
  padding: 9px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.rates th { color: var(--muted); font-size: 12px; font-weight: 700; }
table.rates th:first-child, table.rates td:first-child {
  text-align: left;
  position: sticky; left: 0;
  background: var(--bg);
  font-weight: 600;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis;
}
table.rates th.sortable { cursor: pointer; }
table.rates th[aria-sort] { color: var(--accent); }
table.rates td.top { color: var(--good); font-weight: 700; }
.rates-empty { padding: 28px var(--pad); color: var(--muted); font-size: 14.5px; text-align: center; }

/* ============ SAVED / SOURCES / STATES ============ */
.view-title { padding: 16px var(--pad) 4px; font-family: var(--serif); font-size: 21px; }
.empty {
  padding: 44px var(--pad); text-align: center; color: var(--muted); font-size: 14.5px;
}
.empty svg { width: 40px; height: 40px; stroke: var(--faint); fill: none; stroke-width: 1.5; margin-bottom: 10px; }
.src-group { padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.src-group h3 { font-size: 15px; display: flex; gap: 8px; align-items: center; }
.src-group h3 .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tc); }
.src-group ul { margin: 8px 0 0; padding: 0 0 0 17px; color: var(--muted); font-size: 14px; }
.src-group li { margin: 3px 0; }
.about { padding: 16px var(--pad); color: var(--muted); font-size: 13.5px; line-height: 1.6; }

.offline-note {
  margin: 10px var(--pad) 0;
  padding: 9px 12px;
  background: var(--chip-bg); border-radius: 10px;
  font-size: 13px; color: var(--muted);
}

/* skeleton */
.skel { padding: 14px var(--pad); border-bottom: 1px solid var(--line); }
.skel .b { height: 14px; border-radius: 6px; background: var(--chip-bg); margin: 8px 0; }
.skel .b.w60 { width: 60%; }

/* ============ BOTTOM NAV ============ */
nav.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom .inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
nav.bottom button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  min-height: 54px;
}
nav.bottom button[aria-selected='true'] { color: var(--accent); }
nav.bottom svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
