:root {
  --ink: #161210;
  --ink-soft: #3f3832;
  --paper: #f3eadc;
  --paper-2: #efe4d2;
  --card: #fbf6ec;
  --rule: #161210;
  --red: #b42318;
  --red-deep: #8a1c14;
  --gold: #b45309;
  --muted: #6b6258;
  --line: rgba(22, 18, 16, 0.12);
  --shadow: 0 18px 40px rgba(22, 18, 16, 0.12);
  --seal: #b42318;
  --chip: #efe4d2;
  --ok: #3f6b4a;
  --radius: 14px;
  --serif: "Sitka Text", "Cambria", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --sans: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: "Cascadia Mono", "Consolas", "Sarasa Gothic", ui-monospace, monospace;
}

[data-theme="night"] {
  --ink: #f4eadc;
  --ink-soft: #d7cbb8;
  --paper: #12100e;
  --paper-2: #1b1814;
  --card: #1e1a16;
  --rule: #f4eadc;
  --red: #e11d48;
  --red-deep: #fb7185;
  --gold: #fbbf24;
  --muted: #a89884;
  --line: rgba(244, 234, 220, 0.12);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --chip: #2a241e;
  --ok: #86efac;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(180, 35, 24, 0.08), transparent 50%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 23px,
      rgba(22, 18, 16, 0.025) 24px
    ),
    var(--paper);
  min-height: 100vh;
}

[data-theme="night"] body,
body[data-theme] {
  background:
    radial-gradient(1000px 420px at 80% -20%, rgba(225, 29, 72, 0.16), transparent 45%),
    var(--paper);
}

a { color: inherit; }
button, input { font-family: inherit; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 20;
  background: var(--red);
  color: #fff;
  padding: 8px 12px;
}

.ticker {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 28px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  overflow: hidden;
  white-space: nowrap;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fecaca;
  font-weight: 700;
  flex-shrink: 0;
}
.live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.clocks {
  display: flex;
  gap: 22px;
  overflow: auto;
  scrollbar-width: none;
}
.clocks::-webkit-scrollbar { display: none; }
.clocks b { color: #fca5a5; font-weight: 600; }

.masthead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  padding: 22px 28px 18px;
  border-bottom: 3px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.seal {
  width: 58px;
  height: 58px;
  border: 3px solid var(--seal);
  border-radius: 50%;
  color: var(--seal);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  transform: rotate(-8deg);
  background: color-mix(in srgb, var(--card) 80%, var(--red));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--seal) 35%, transparent);
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 42px;
  line-height: 0.95;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.brand small {
  display: block;
  margin-top: 4px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede {
  max-width: 520px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.lede strong { color: var(--red); font-weight: 700; }

.tools {
  display: flex;
  gap: 8px;
  align-items: center;
}
.icon-btn, .lang-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
}
.icon-btn:hover, .lang-btn:hover, .chip:hover { border-color: var(--ink); }
.lang-btn[aria-pressed="true"], .chip.is-on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.search-wrap {
  padding: 16px 28px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.search {
  position: relative;
}
.search input {
  width: 100%;
  height: 52px;
  border: 1.5px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 0 20px 0 48px;
  font-size: 16px;
  outline: none;
}
.search input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 25%, transparent); }
.search .slash {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 6px;
}

.stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.stats b { color: var(--ink); font-size: 18px; font-family: var(--serif); display: block; }

.filters {
  padding: 14px 28px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--ink);
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}

.desk {
  padding: 8px 28px 28px;
}

.kicker {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 18px 0 10px;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}
.kicker h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.04em;
}
.kicker span { color: var(--muted); font-size: 13px; }

.featured {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  width: 100%;
  box-shadow: 0 1px 0 rgba(22, 18, 16, 0.04);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  position: relative;
  overflow: hidden;
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--ink);
  outline: none;
}
.card.featured-card::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--red);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.flag {
  font-size: 28px;
  line-height: 1;
  filter: saturate(1.05);
}
.flag-wrap {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
}
.flag-img {
  width: 42px;
  height: 30px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--line);
  background: var(--chip);
  display: block;
}
.flag-fallback { display: none; font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.flag-img.is-off { display: none; }
.flag-img.is-off + .flag-fallback { display: inline; }
.drawer .flag-img { width: 56px; height: 40px; }
.card-marks {
  display: flex;
  align-items: center;
  gap: 8px;
}
.iso {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.12em;
}
.card h3 {
  margin: 10px 0 2px;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.03em;
}
.card .en { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.meta em { font-style: normal; color: var(--red); }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.drawer-bg {
  position: fixed;
  inset: 0;
  background: rgba(22, 18, 16, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}
.drawer-bg.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 100%);
  background: var(--card);
  color: var(--ink);
  z-index: 31;
  transform: translateX(104%);
  transition: transform 0.28s ease;
  box-shadow: -20px 0 50px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: none; }
.drawer header {
  padding: 22px 22px 12px;
  border-bottom: 2px solid var(--rule);
}
.drawer .flag { font-size: 40px; }
.drawer h2 {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 32px;
}
.drawer .sub { color: var(--muted); margin-top: 4px; }
.drawer-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.drawer-body {
  padding: 16px 22px 28px;
  overflow: auto;
  scrollbar-width: none;
}
.drawer-body::-webkit-scrollbar { display: none; }

#drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.source {
  display: block;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--paper);
}
.source:hover { border-color: var(--red); }
.source .type {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
}
.source b { display: block; margin: 4px 0 2px; font-size: 16px; }
.source small { color: var(--muted); word-break: break-all; }

.note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 16px;
}

footer {
  border-top: 3px solid var(--rule);
  padding: 22px 28px 40px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
footer b { color: var(--ink); }

.star {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  padding: 0;
}
.star.on { color: var(--gold); }

@media (max-width: 980px) {
  .masthead { grid-template-columns: 1fr; }
  .featured { grid-template-columns: repeat(2, 1fr); }
  .search-wrap { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}
@media (max-width: 640px) {
  .ticker, .masthead, .search-wrap, .filters, .desk, footer { padding-left: 16px; padding-right: 16px; }
  .brand h1 { font-size: 32px; }
  .featured, .grid { grid-template-columns: 1fr; }
}

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

@media print {
  .ticker, .tools, .search-wrap, .filters, .drawer, .drawer-bg { display: none !important; }
  .card { break-inside: avoid; }
}
