/* ============================================================
   BRIGHT NEWS — Editorial Light Edition
   Off-white + warm-black + accent gold. Source Serif 4 + IBM Plex.
   Dark mode via [data-theme="dark"] on :root.
   ============================================================ */

:root {
  /* Light (default) */
  --bg: #faf7f2;
  --bg-elev: #ffffff;
  --bg-sunk: #f3eee6;
  --ink: #1a1612;
  --ink-2: #443c33;
  --ink-3: #7a6f62;
  --ink-4: #b3a999;
  --rule: #e8e0d2;
  --rule-strong: #d6cab5;
  --gold: #b8893a;
  --gold-soft: #e9d6a8;
  --gold-bg: #f5ecd6;

  --tag-business: #2f5d50;
  --tag-tech: #3a4ea8;
  --tag-politics: #a8423a;
  --tag-lifestyle: #8a5a2b;

  --maxw: 1280px;
  --gutter: 32px;
  --radius: 4px;

  --t-display: 'Source Serif 4', 'Sarabun', Georgia, serif;
  --t-sans: 'IBM Plex Sans Thai', 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --t-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

html[data-theme="dark"] {
  --bg: #14110d;
  --bg-elev: #1c1812;
  --bg-sunk: #0e0c09;
  --ink: #f3ebda;
  --ink-2: #d3c8b0;
  --ink-3: #9a8e76;
  --ink-4: #5e553f;
  --rule: #2a241b;
  --rule-strong: #3b3325;
  --gold: #d9b974;
  --gold-soft: #6b522b;
  --gold-bg: #2a2113;

  --tag-business: #6fb09a;
  --tag-tech: #8198de;
  --tag-politics: #d98079;
  --tag-lifestyle: #c79b6e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--t-sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.25s ease, color 0.25s ease;
}

/* ============ Top utility bar ============ */
.topbar {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky; top: 0; z-index: 30;
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  font-family: var(--t-mono);
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  flex-wrap: wrap;
}
.topbar-left { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.topbar-right { display: flex; gap: 14px; align-items: center; }
.topbar-sep { color: var(--ink-4); }
.topbar a { color: var(--ink-3); text-decoration: none; }
.topbar a:hover { color: var(--ink); }
#topbar-headlines, #topbar-rounds { font-weight: 500; color: var(--ink-2); }

/* ============ Masthead ============ */
.masthead {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 36px var(--gutter) 20px;
  text-align: center;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.mast-eyebrow {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 14px;
}
.mast-eyebrow .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold); margin: 0 8px 1px;
  vertical-align: middle;
}
.mast-title {
  font-family: var(--t-display);
  font-weight: 700;
  font-size: clamp(40px, 7vw, 84px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.mast-rule { width: 60px; height: 3px; background: var(--gold); margin: 14px auto 12px; }
.mast-tagline {
  font-family: var(--t-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.mast-meta {
  margin-top: 18px;
  display: flex; justify-content: center; gap: 26px;
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  flex-wrap: wrap;
}
.mast-meta b { color: var(--ink); font-weight: 500; }

/* corner brand mark */
.mast-mark {
  position: absolute; left: var(--gutter); top: 36px;
  display: flex; align-items: center; gap: 10px;
}
.mast-mark .glyph {
  width: 36px; height: 36px;
  border: 1.5px solid var(--ink); border-radius: 4px;
  display: grid; place-items: center;
  font-family: var(--t-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  background: var(--bg-elev);
}
.mast-mark-text { text-align: left; line-height: 1.1; }
.mast-mark-est {
  font-family: var(--t-mono); font-size: 10px; letter-spacing: 0.18em;
  color: var(--ink-3); text-transform: uppercase;
}
.mast-mark-vol {
  font-family: var(--t-display); font-size: 14px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink);
}
@media (max-width: 720px) {
  .mast-mark { position: static; justify-content: center; margin-bottom: 14px; }
}

/* ============ Nav ============ */
.navbar {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky; top: 41px; z-index: 25;
}
.navbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; align-items: stretch; justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.nav-rounds, .nav-cats {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.nav-rounds {
  padding: 10px 0;
  border-right: 1px solid var(--rule);
  padding-right: 24px;
}
.nav-cats { padding: 10px 0; flex: 1; }
.nav-search {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
}
.nav-search input {
  background: transparent;
  border: 1px solid var(--rule);
  padding: 7px 12px 7px 32px;
  font-family: var(--t-sans);
  font-size: 13px;
  color: var(--ink);
  border-radius: var(--radius);
  width: 200px;
  outline: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237a6f62' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m21 21-3.5-3.5'/></svg>");
  background-repeat: no-repeat;
  background-position: 10px center;
  transition: border-color 0.15s ease;
}
.nav-search input:focus { border-color: var(--gold); }
.nav-search input::placeholder { color: var(--ink-4); }

@media (max-width: 720px) {
  .nav-rounds { border-right: 0; padding-right: 0; }
  .nav-search input { width: 100%; }
  .nav-search { width: 100%; }
}

.pill {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  font-family: var(--t-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
}
.pill:hover { background: var(--bg-sunk); color: var(--ink); }
.pill[aria-pressed="true"] {
  background: var(--ink); color: var(--bg);
}
.pill .pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.7;
}
.pill.cat[aria-pressed="false"] .pill-dot { opacity: 0.9; }
.cat-business .pill-dot { background: var(--tag-business); }
.cat-tech .pill-dot { background: var(--tag-tech); }
.cat-politics .pill-dot { background: var(--tag-politics); }
.cat-lifestyle .pill-dot { background: var(--tag-lifestyle); }

/* ============ Layout grid ============ */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px var(--gutter) 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 48px;
}
@media (max-width: 960px) {
  .page { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  /* minmax(0, 1fr) forces the column to start at 0 and shrink to viewport.
     Plain "1fr" = "minmax(auto, 1fr)" lets long content (Thai compound words,
     URLs in placeholders) push the column wider than viewport on small screens. */
}

/* ============ Section header ============ */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
  margin-bottom: 28px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-head h2 {
  margin: 0;
  font-family: var(--t-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.section-head .meta {
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ============ Card / Article ============ */
.article {
  cursor: pointer;
  position: relative;
}
.article .img-wrap {
  position: relative;
  aspect-ratio: 16/10;
  background: var(--bg-sunk);
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.article .img-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.4s ease;
}
.article:hover .img-wrap img { transform: scale(1.03); }
.article .img-wrap .ph {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, rgba(0,0,0,0.04) 14px 15px),
    var(--bg-sunk);
  display: grid; place-items: center;
  color: var(--ink-3);
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 16px;
  line-height: 1.5;
}
html[data-theme="dark"] .article .img-wrap .ph {
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, rgba(255,255,255,0.04) 14px 15px),
    var(--bg-sunk);
}

/* Bookmark star */
.bookmark-btn {
  position: absolute;
  top: 10px; right: 10px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--rule);
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-2);
  z-index: 2;
  transition: all 0.15s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
html[data-theme="dark"] .bookmark-btn {
  background: rgba(28, 24, 18, 0.9);
}
.bookmark-btn:hover {
  color: var(--gold);
  border-color: var(--gold-soft);
  transform: scale(1.06);
}
.bookmark-btn[aria-pressed="true"] {
  color: var(--gold);
  border-color: var(--gold);
}
.bookmark-btn[aria-pressed="true"] svg { fill: var(--gold); }

.article .meta-row {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.article .cat-tag { color: var(--ink); font-weight: 600; }
.article .cat-tag.business { color: var(--tag-business); }
.article .cat-tag.tech { color: var(--tag-tech); }
.article .cat-tag.politics { color: var(--tag-politics); }
.article .cat-tag.lifestyle { color: var(--tag-lifestyle); }
.article .meta-row .sep {
  width: 3px; height: 3px; background: var(--ink-4); border-radius: 50%;
}
.article .round-chip {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--gold);
  font-weight: 600;
}
.article .round-chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
}
.article h3 {
  font-family: var(--t-display);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-wrap: pretty;
}
.article p.dek {
  color: var(--ink-2);
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.6;
  text-wrap: pretty;
}
.article .source {
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  display: inline-flex; align-items: center; gap: 4px;
}
.article .source::after { content: "↗"; color: var(--ink-4); }

/* Hero */
.hero { margin-bottom: 40px; }
.hero .img-wrap { aspect-ratio: 16/9; margin-bottom: 22px; }
.hero h3 {
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.05;
  margin-bottom: 16px;
  text-wrap: balance;
}
.hero p.dek {
  font-size: 18px;
  line-height: 1.6;
  max-width: 70ch;
}

/* Sub-grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 48px;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--rule);
}
.grid-2 h3 { font-size: 24px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px 32px;
  row-gap: 40px;
}
.grid-3 h3 { font-size: 18px; }
.grid-3 .article p.dek { font-size: 14px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-3 { grid-template-columns: 1fr; } }

/* Round divider */
.round-divider {
  margin: 56px 0 32px;
  display: flex; align-items: center; gap: 20px;
}
.round-divider .label {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 10px;
  white-space: nowrap;
}
.round-divider .label .icon {
  width: 14px; height: 14px; display: inline-flex;
}
.round-divider .line {
  flex: 1; height: 1px; background: var(--rule-strong);
}
.round-divider .count {
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
}

/* ============ Sidebar ============ */
aside.sidebar { position: relative; }
.side-block { margin-bottom: 40px; }
.side-head {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  display: flex; justify-content: space-between; align-items: center;
}
.side-head .dot {
  width: 6px; height: 6px; background: var(--gold); border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.side-list { list-style: none; margin: 0; padding: 0; }
.side-item {
  display: flex; gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.side-item:hover { opacity: 0.65; }
.side-item:last-child { border-bottom: 0; }
.side-item .num {
  font-family: var(--t-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--ink-4);
  min-width: 24px;
  line-height: 1.3;
}
.side-item .body { flex: 1; min-width: 0; }
.side-item .body .meta {
  font-family: var(--t-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.side-item .body h4 {
  font-family: var(--t-display);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.35;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.005em;
}

/* Brief box */
.brief-box {
  background: var(--gold-bg);
  border: 1px solid var(--gold-soft);
  padding: 22px;
  border-radius: var(--radius);
}
.brief-box .eyebrow {
  font-family: var(--t-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 10px;
}
.brief-box h4 {
  font-family: var(--t-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 12px;
  line-height: 1.2;
  color: var(--ink);
}
.brief-box p {
  font-size: 14px;
  color: var(--ink-2);
  margin: 0 0 14px;
  line-height: 1.55;
}
.brief-box .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-top: 1px solid var(--gold-soft);
  padding-top: 14px;
}
.brief-box .stat .n {
  font-family: var(--t-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brief-box .stat .l {
  font-family: var(--t-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Sources pills */
.sources-list {
  display: flex; flex-wrap: wrap; gap: 6px 8px;
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.sources-list .src-pill {
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg-elev);
  white-space: nowrap;
}

/* Archive list */
.archive-list {
  list-style: none;
  margin: 0; padding: 0;
}
.archive-date {
  border-bottom: 1px solid var(--rule);
}
.archive-date:last-child { border-bottom: 0; }
.archive-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0;
  cursor: pointer;
  text-align: left;
  font-family: var(--t-sans);
  color: var(--ink);
  transition: opacity 0.15s ease;
}
.archive-toggle:hover { opacity: 0.7; }
.archive-chev {
  font-family: var(--t-mono);
  color: var(--ink-3);
  width: 12px;
  font-size: 11px;
}
.archive-date-label {
  font-family: var(--t-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -0.005em;
  flex: 1;
}
.archive-date-meta {
  font-family: var(--t-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.archive-items {
  list-style: none;
  margin: 0 0 12px 20px;
  padding: 0;
  border-left: 1px solid var(--rule);
}
.archive-item {
  padding: 10px 0 10px 14px;
  cursor: pointer;
  transition: opacity 0.15s ease;
  display: block;
}
.archive-item:hover { opacity: 0.65; }
.archive-item-meta {
  display: block;
  font-family: var(--t-mono);
  font-size: 9px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.archive-item-meta .cat-tag.business { color: var(--tag-business); }
.archive-item-meta .cat-tag.tech { color: var(--tag-tech); }
.archive-item-meta .cat-tag.politics { color: var(--tag-politics); }
.archive-item-meta .cat-tag.lifestyle { color: var(--tag-lifestyle); }
.archive-item-title {
  display: block;
  font-family: var(--t-display);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.archive-loading {
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  padding: 10px 0 10px 14px;
}

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 17, 13, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: grid; place-items: start center;
  overflow-y: auto;
  padding: 40px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 6px;
  width: 100%;
  max-width: 760px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
  transform: translateY(8px);
  transition: transform 0.25s ease;
  overflow: hidden;
  position: relative;
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-img {
  width: 100%;
  aspect-ratio: 16/8;
  background: var(--bg-sunk);
  object-fit: cover;
  display: block;
}
.modal-img-wrap {
  position: relative;
  aspect-ratio: 16/8;
  background: var(--bg-sunk);
  overflow: hidden;
}
.modal-img-ph {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, rgba(0,0,0,0.04) 14px 15px),
    var(--bg-sunk);
  display: grid; place-items: center;
  color: var(--ink-3);
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}
html[data-theme="dark"] .modal-img-ph {
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, rgba(255,255,255,0.04) 14px 15px),
    var(--bg-sunk);
}
.modal-body { padding: 32px 40px 36px; }
.modal-meta {
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 14px;
  display: flex; gap: 12px; align-items: center;
  flex-wrap: wrap;
}
.modal-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-4); }
.modal-meta .round-tag { color: var(--gold); font-weight: 600; }
.modal-meta .cat-tag { font-weight: 600; }
.modal-meta .cat-tag.business { color: var(--tag-business); }
.modal-meta .cat-tag.tech { color: var(--tag-tech); }
.modal-meta .cat-tag.politics { color: var(--tag-politics); }
.modal-meta .cat-tag.lifestyle { color: var(--tag-lifestyle); }
.modal h2 {
  font-family: var(--t-display);
  font-weight: 700;
  font-size: clamp(28px, 3.5vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 18px;
  text-wrap: balance;
  color: var(--ink);
}
.modal .dek {
  font-size: 18px;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0 0 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
  text-wrap: pretty;
}
.modal .body-text {
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
}
.modal .body-text p { margin: 0 0 18px; }
.modal .body-text strong { color: var(--ink); font-weight: 600; }
.modal .body-text .pull {
  font-family: var(--t-display);
  font-style: italic;
  font-size: 20px;
  color: var(--gold);
  border-left: 3px solid var(--gold);
  padding: 4px 0 4px 18px;
  margin: 24px 0;
  line-height: 1.4;
}
.modal .body-text ul {
  padding-left: 20px;
  margin: 0 0 18px;
}
.modal .body-text li { margin-bottom: 8px; }
.modal-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--rule);
  font-family: var(--t-mono);
  font-size: 12px;
  color: var(--ink-3);
  flex-wrap: wrap;
  gap: 12px;
}
.modal-footer a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
}
.modal-footer a:hover { text-decoration: underline; }
.modal-footer .actions {
  display: flex; gap: 8px; align-items: center;
}
.modal-footer .modal-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s ease;
}
.modal-footer .modal-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.modal-footer .modal-btn.is-active {
  border-color: var(--gold);
  color: var(--gold);
}
.modal-footer .modal-btn.is-active svg { fill: var(--gold); }

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--rule);
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink);
  z-index: 2;
  font-size: 20px;
  line-height: 1;
  transition: background 0.15s ease;
}
html[data-theme="dark"] .modal-close { background: rgba(28, 24, 18, 0.92); }
.modal-close:hover { background: var(--bg); }

@media (max-width: 600px) {
  .modal-body { padding: 24px 22px 28px; }
  .modal-backdrop { padding: 20px 12px; }
}

/* ============ Theme toggle button ============ */
.theme-toggle {
  appearance: none; background: transparent;
  border: 1px solid var(--rule);
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink-2);
  transition: all 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--rule-strong); }
.theme-toggle svg { width: 14px; height: 14px; }

/* ============ No-result + loading ============ */
.no-result {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-3);
  font-family: var(--t-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px;
  color: var(--ink-3);
  font-family: var(--t-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  gap: 16px;
}
.loading-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--rule);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--tag-politics);
  font-family: var(--t-mono);
  font-size: 13px;
}
.error-state code {
  background: var(--bg-sunk);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* ============ Footer ============ */
footer.site-foot {
  border-top: 1px solid var(--rule);
  padding: 32px var(--gutter);
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 20px;
  font-family: var(--t-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
}
footer.site-foot a { color: var(--ink-3); text-decoration: none; cursor: pointer; }
footer.site-foot a:hover { color: var(--ink); }
footer.site-foot b { color: var(--ink); font-weight: 600; }
.foot-links { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-family: var(--t-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Selection ============ */
::selection { background: var(--gold); color: var(--bg); }

/* ============ Animations ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.article, .grid-2, .grid-3, .hero, .section-head, .round-divider {
  animation: fadeUp 0.35s ease both;
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   Mobile responsive — Phase 4.5
   Iterates on existing 720px/600px breakpoints with phone-specific
   fixes for topbar, stats, nav pills, and touch targets.
   Desktop view (>=1024px) is unchanged — every rule lives inside a
   @media (max-width: ...) query.
   ============================================================ */

/* Prevent any element from causing horizontal scroll at root.
   Belt-and-suspenders against absolute-positioned mast-mark + long
   pill labels overflowing on narrow viewports. */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Long Thai compound words / inline URLs without spaces can push card width
   beyond column width. break-word allows breaking inside words at the last
   resort (only when no other break point is available). */
.article h3,
.article p.dek,
.article .source,
.modal h2,
.modal .dek,
.modal .body-text,
.side-item .body h4,
.archive-item-title,
.brief-box h4,
.brief-box p {
  overflow-wrap: break-word;
  word-break: break-word; /* legacy WebKit fallback */
}

/* Placeholder label inside .img-wrap can have long URL — let it wrap */
.article .img-wrap .ph,
.modal-img-ph {
  overflow-wrap: anywhere; /* anywhere = even mid-URL if needed */
}

/* Tablet portrait + small landscape (=600px and below) ============== */
@media (max-width: 600px) {
  /* Long source labels (e.g., "Thailand Business News / Manila Times PR")
     overflow viewport because of white-space: nowrap. Allow wrapping at
     phone widths — slightly less compact but no overflow. */
  .sources-list .src-pill {
    white-space: normal;
    max-width: 100%;
    word-break: break-word;
  }

  /* Mast-meta stats: stack vertically center-aligned (consistent with all 3) */
  .mast-meta {
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
    margin-top: 14px;
  }

  /* Round pills: horizontal scroll instead of wrapping to 2 lines.
     Hide scrollbar visually (still scrollable via touch). */
  .nav-rounds {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* leave room so last pill isn't flush with viewport edge */
    padding-right: 12px;
    /* visual hint: subtle fade on right edge so users know it scrolls */
    mask-image: linear-gradient(to right, black calc(100% - 18px), transparent);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 18px), transparent);
  }
  .nav-rounds::-webkit-scrollbar { display: none; }

  /* Same treatment for category pills */
  .nav-cats {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-right: 12px;
    mask-image: linear-gradient(to right, black calc(100% - 18px), transparent);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 18px), transparent);
  }
  .nav-cats::-webkit-scrollbar { display: none; }

  /* Touch target minimums (Apple HIG / Material) — 44x44 logical px */
  .pill {
    min-height: 44px;
    padding: 10px 16px;
  }
  .theme-toggle {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  .theme-toggle svg {
    width: 16px;
    height: 16px;
  }
  .bookmark-btn {
    width: 40px;
    height: 40px;
  }
}

/* Phone portrait (<= 480px) ========================================= */
@media (max-width: 480px) {
  /* Topbar: 2-line stack — Line 1: date + อัปเดต, Line 2: counts + theme toggle */
  .topbar-inner {
    flex-wrap: wrap;
    row-gap: 6px;
    padding: 10px 16px;
    gap: 10px;
  }
  .topbar-left {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
    /* let date wrap before อัปเดต if needed at very small widths */
  }
  .topbar-right {
    width: 100%;
    justify-content: space-between; /* counts on left, theme toggle pushed to right */
    gap: 8px;
  }

  /* Compact masthead spacing */
  .masthead {
    padding: 28px 16px 16px;
  }
  .mast-eyebrow {
    font-size: 10px;
    letter-spacing: 0.16em;
  }
  .mast-tagline {
    font-size: 11px;
    letter-spacing: 0.18em;
  }

  /* Tighten container paddings — keep 16px floor (per Phase 4.5 spec) */
  .page {
    padding: 24px 16px 64px;
    gap: 24px;
  }
  footer.site-foot {
    padding: 24px 16px;
    gap: 12px;
  }
  .navbar-inner {
    padding: 0 16px;
    gap: 12px;
  }

  /* Modal — already has 600px breakpoint at 22px; keep it. */
}

/* Very small phones (iPhone SE 320px guard) ========================= */
@media (max-width: 375px) {
  /* Topbar-left has 5 spans:
     [date] [sep] [อัปเดต ...] [sep] [HEADLINES]
     Hide the อัปเดต group (3rd + 4th) — info not critical at this size. */
  .topbar-left > span:nth-child(3),
  .topbar-left > span:nth-child(4) {
    display: none;
  }

  /* Even tighter container padding floor */
  .topbar-inner { padding: 8px 14px; gap: 8px; }
  .masthead { padding: 24px 14px 12px; }
  .mast-title { font-size: clamp(34px, 11vw, 48px); }
  .page { padding: 20px 14px 56px; }
  footer.site-foot { padding: 20px 14px; }
  .navbar-inner { padding: 0 14px; }
}
