:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f4f6f8);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #101114);
  --muted: var(--tg-theme-hint-color, #747b86);
  --accent: var(--tg-theme-button-color, #168acd);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #168acd);
  --border: rgba(127,127,127,.2);
  --radius: 22px;
  --shadow: 0 10px 30px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app { min-height: 100vh; padding-bottom: 84px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 60px;
  padding: env(safe-area-inset-top) 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -.7px;
  flex: 1;
}
.top-actions { display: flex; gap: 8px; }
.icon-btn, .tool-btn, .nav-item {
  border: 0;
  background: transparent;
  color: var(--text);
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 20px;
}
.search-panel {
  position: sticky;
  top: 60px;
  z-index: 15;
  padding: 12px 16px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.primary-btn {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-top: 10px; }
.chip {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.view { width: min(760px, 100%); margin: 0 auto; padding: 16px; }
.hero { padding: 22px 4px 8px; }
.hero .eyebrow {
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
}
.hero h1 {
  margin: 7px 0 8px;
  font-size: clamp(30px, 7vw, 46px);
  line-height: 1.02;
  letter-spacing: -1.6px;
}
.hero p { color: var(--muted); margin: 0; font-size: 16px; }
.feed { display: grid; gap: 14px; margin-top: 18px; }
.card {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}
.card-body { padding: 14px 15px 16px; }
.card-meta { color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -.45px;
}
.card p { color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.load-more {
  width: 100%;
  margin: 18px 0;
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.article-view { padding-top: 8px; }
.article-image {
  width: calc(100% + 32px);
  margin-left: -16px;
  max-height: 480px;
  object-fit: cover;
  display: block;
}
.article-meta {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  margin-top: 18px;
}
.article-title {
  font-size: clamp(30px, 7.5vw, 52px);
  line-height: 1.04;
  letter-spacing: -1.5px;
  margin: 8px 0 16px;
}
.article-toolbar { display: flex; gap: 10px; margin: 0 0 18px; }
.tool-btn {
  padding: 10px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
}
.article-body { font-size: 18px; line-height: 1.68; }
.article-body p { margin: 0 0 1.15em; }
.article-body h2, .article-body h3 { line-height: 1.2; margin: 1.7em 0 .7em; }
.article-body img {
  width: calc(100% + 16px);
  margin: 10px -8px 18px;
  height: auto;
  border-radius: 16px;
}
.article-body a { color: var(--link); }
.article-body blockquote {
  margin: 20px 0;
  padding: 4px 0 4px 16px;
  border-left: 4px solid var(--accent);
  color: var(--muted);
}
.article-footer { padding: 22px 0; }
.wide-btn { width: 100%; padding: 14px; }
.related-section { margin-top: 14px; }
.related-section h2 { font-size: 22px; }
.compact .card {
  display: grid;
  grid-template-columns: 120px 1fr;
  min-height: 90px;
}
.compact .card img { width: 120px; height: 100%; aspect-ratio: auto; }
.compact .card-body { padding: 10px 12px; }
.compact .card p { display: none; }
.compact .card h2 { font-size: 15px; }
.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(760px, 100%);
  padding: 7px 12px calc(7px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3,1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav-item {
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--muted);
  padding: 5px 0;
}
.nav-item span { font-size: 20px; line-height: 1; }
.nav-item small { font-size: 11px; }
.nav-item.active { color: var(--accent); }
.skeleton-card { padding: 10px 0; }
.skeleton {
  border-radius: 14px;
  background: var(--surface);
}
.skeleton.media { height: 220px; margin: -8px -16px 20px; border-radius: 0; }
.skeleton.line { height: 18px; margin: 12px 0; width: 78%; }
.skeleton.line.wide { height: 36px; width: 96%; }
.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 15px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .feed:not(.compact) { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero { padding-top: 34px; }
}
