:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e8eaee;
  --text: #14171f;
  --text-2: #5b6473;
  --text-3: #98a1b0;
  --brand: #1d4ed8;
  --brand-soft: #eef2ff;
  --ad: #b45309;
  --ad-bg: #fff7ed;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 31, .05);
  --shadow-md: 0 6px 20px rgba(20, 23, 31, .07);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Do NOT set overflow-x here. `overflow-x: hidden` turns the element into a scroll
     container (overflow-y becomes auto), which traps the page scroll inside .app-shell and
     makes the whole page unscrollable on both desktop and mobile. Horizontal overflow is
     contained per-element instead (see .card__body / .tab / .card--dense). */
  overflow-wrap: break-word;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* ---------------- Header ---------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.app-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px 9px;
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand__mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: grid;
  place-items: center;
  letter-spacing: -.5px;
}

.brand__name { font-size: 16.5px; font-weight: 750; letter-spacing: -.2px; }

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

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  border-radius: 50%;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:active { background: var(--line); }
.icon-btn.is-spinning svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Category tabs ---------------- */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 16px 10px;
  scroll-behavior: smooth;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: 6px 13px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: all .16s;
}
.tab:active { transform: scale(.96); }
.tab.is-active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

/* ---------------- Main area ---------------- */
.feed-wrap { padding: 14px 12px calc(28px + var(--safe-b)); }

.feed { display: flex; flex-direction: column; gap: 12px; }

/* Hero card */
.hero-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0f1115;
  min-height: 216px;
  display: flex;
  align-items: flex-end;
  box-shadow: var(--shadow-md);
}
.hero-card img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: .92;
}
.hero-card__scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,12,16,0) 32%, rgba(10,12,16,.86) 100%);
}
.hero-card__body { position: relative; padding: 16px; color: #fff; }
.hero-card__title {
  font-size: 19px;
  font-weight: 760;
  line-height: 1.34;
  margin: 6px 0 8px;
  letter-spacing: -.3px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* List card */
.card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  transition: transform .14s, box-shadow .14s;
  align-items: flex-start;
}
.card:active { transform: scale(.985); box-shadow: var(--shadow-md); }

.card__thumb {
  position: relative;          /* stacking context for the placeholder under the photo */
  flex: none;
  width: 96px; height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #eef1f5, #e2e6ec);
}
/* Placeholder sits underneath and disappears behind the real photo */
.card__ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  color: #b6bfcc;
  background: linear-gradient(135deg, #eef1f5, #e2e6ec);
  user-select: none;
}
.card__thumb img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

.card__body { min-width: 0; flex: 1 1 0; overflow: hidden; padding-top: 1px; }
.card__title {
  font-size: 15.2px;
  font-weight: 660;
  line-height: 1.42;
  letter-spacing: -.15px;
  overflow-wrap: anywhere;      /* long words/URLs must not break the card layout */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-3);
  min-width: 0;
}
.meta__source {
  color: var(--text-2);
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42%;
}
.meta__dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); flex: none; }
.meta__time { white-space: nowrap; }

/* Ad card */
.card--ad, .hero-card--ad {
  background: var(--ad-bg);
  border-color: #fed7aa;
}
.card--ad .card__title { color: #7c2d12; }
.hero-card--ad .hero-card__title { color: #fff; }

/* Dense mode: thumbnail-free text rows, fits roughly twice as many items at the same height */
.card--dense {
  padding: 11px 12px;
  gap: 0;
}
.card--dense .card__title {
  font-size: 14.6px;
  -webkit-line-clamp: 2;
}
.card--dense .meta { margin-top: 6px; }
.card--dense .ad-cta { margin-top: 5px; }

.ad-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .4px;
  background: #fed7aa;
  color: #7c2d12;
  flex: none;
}
.hero-card .ad-tag { background: rgba(255,255,255,.92); color: #7c2d12; }

.ad-cta {
  display: inline-block;
  margin-top: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ad);
}

/* Skeleton */
.skeleton { background: var(--surface); border-radius: var(--radius); padding: 10px; border: 1px solid var(--line); display: flex; gap: 12px; }
.skeleton__thumb { flex: none; width: 108px; height: 78px; border-radius: 10px; }
.skeleton__lines { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.sk-line { height: 12px; border-radius: 6px; }
.sk-line--sm { width: 38%; }
.sk-hero { height: 216px; border-radius: var(--radius); }
.sk { background: linear-gradient(90deg, #eceff3 25%, #f6f8fa 37%, #eceff3 63%); background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* States */
.state {
  text-align: center;
  padding: 42px 24px;
  color: var(--text-2);
}
.state__icon { font-size: 30px; margin-bottom: 10px; }
.state__title { font-size: 15.5px; font-weight: 700; color: var(--text); margin-bottom: 5px; }
.state__desc { font-size: 13.5px; line-height: 1.6; }
.state__btn {
  margin-top: 16px;
  padding: 9px 20px;
  border: 0; border-radius: 999px;
  background: var(--text); color: #fff;
  font-size: 14px; font-weight: 650;
  cursor: pointer;
}

.load-more { text-align: center; padding: 18px 0 6px; font-size: 13px; color: var(--text-3); }
.load-more__spinner {
  width: 18px; height: 18px;
  margin: 0 auto;
  border: 2px solid var(--line);
  border-top-color: var(--text-3);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* Footer */
.site-foot {
  padding: 20px 16px calc(24px + var(--safe-b));
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.7;
}
.site-foot a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }

/* Initial loading overlay */
.boot {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  z-index: 100;
  transition: opacity .3s;
}
.boot.is-hidden { opacity: 0; pointer-events: none; }
.boot__inner { text-align: center; }
.boot__mark {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 15px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff; font-size: 26px; font-weight: 800;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(29, 78, 216, .28);
}
.boot__text { font-size: 13px; color: var(--text-3); }

/* On desktop, narrow to phone width and center */
@media (min-width: 620px) {
  body { background: #eceef2; }
  .app-shell {
    max-width: 460px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    box-shadow: 0 0 0 1px rgba(20,23,31,.06), 0 20px 60px rgba(20,23,31,.10);
  }
  .app-header { max-width: 460px; }
}
