:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #22252a;
  --muted: #979da6;
  --line: #eceded;
  --accent: #ef3b2d;
  --accent-2: #ff7a1c;
  --accent-weak: #ffebe8;
  --green: #2f8f63;
  --shadow: 0 1px 2px rgba(30, 34, 40, 0.04), 0 6px 16px -14px rgba(30, 34, 40, 0.35);
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

:root[data-theme='dark'] {
  --bg: #121110;
  --surface: #1c1b18;
  --surface-2: #232220;
  --text: #ece9e2;
  --muted: #8f8a7f;
  --line: #2c2a26;
  --accent: #ff5a44;
  --accent-2: #ff8a3d;
  --accent-weak: #3a1f1a;
  --green: #6fbf99;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -20px rgba(0, 0, 0, 0.9);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #121110;
    --surface: #1c1b18;
    --surface-2: #232220;
    --text: #ece9e2;
    --muted: #8f8a7f;
    --line: #2c2a26;
    --accent: #ff6b45;
    --accent-weak: #3a2119;
    --green: #6fbf99;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -20px rgba(0, 0, 0, 0.9);
  }
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image: none;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Noto Sans SC',
    'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

input {
  font: inherit;
  color: inherit;
}

img {
  display: block;
}

.page {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 16px 14px calc(34px + var(--safe-b));
  overflow-x: hidden;
}

/* ---------- 顶部品牌 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 14px;
}

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

.logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 21px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(145deg, #f0703f, #d9411d);
  box-shadow: 0 6px 16px -8px rgba(217, 65, 29, 0.8);
}

.brand-text h1 {
  margin: 0;
  font-size: 18.5px;
  font-weight: 500;
  letter-spacing: 0.4px;
}

.sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: transform 0.15s ease, color 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  color: var(--text);
}

.icon-btn.is-spinning svg {
  animation: spin 0.9s linear infinite;
}

.i-moon {
  display: none;
}

:root[data-theme='dark'] .i-sun {
  display: none;
}

:root[data-theme='dark'] .i-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .i-sun {
    display: none;
  }
  :root:not([data-theme='light']) .i-moon {
    display: block;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 粘性工具栏 ---------- */
.sticky-tools {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0;
  padding: 6px 0 4px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.tabs {
  display: inline-flex;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  flex: 0 0 auto;
  font-weight: 400;
  color: var(--muted);
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.tab.is-active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab-count {
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--accent-weak);
  color: var(--accent);
}

.search-row {
  margin-top: 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 43px;
  padding: 0 13px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14.5px;
  color: var(--text);
}

.search input::placeholder {
  color: var(--muted);
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.clear-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  background: var(--surface-2);
}

.chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding: 1px 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 400;
}

.chip.is-star.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- 列表元信息 ---------- */
.feed-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 2px 10px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dot {
  opacity: 0.5;
}

/* ---------- 卡片 ---------- */
.feed {
  display: grid;
  gap: 12px;
}

.card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.32s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card.is-read .title,
.card.is-read .post-text {
  color: var(--muted);
}

.card.is-read {
  opacity: 0.78;
}

/* 好价卡片 */
.deal {
  display: flex;
  gap: 12px;
  padding: 12px 11px;
  align-items: center;
}

.deal-media {
  position: relative;
  flex: 0 0 70px;
  width: 70px;
  height: 70px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.deal-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.deal-media .ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
  background: linear-gradient(140deg, var(--surface-2), color-mix(in srgb, var(--accent) 10%, var(--surface-2)));
}

.deal-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 70px;
  justify-content: center;
  padding-right: 30px;
}

.title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price {
  margin-top: 0;
  font-size: 15.5px;
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mall {
  padding: 0 5px;
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* 酷安卡片 */
.post {
  padding: 11px 12px 9px;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(145deg, #67a889, #2c7a5b);
  flex: 0 0 auto;
}

.author {
  color: var(--text);
  font-weight: 400;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-text {
  margin: 9px 0 0;
  font-size: 14.8px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-text.is-open {
  -webkit-line-clamp: unset;
}

.expand {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--accent);
}

.post-pics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.post-pics.one {
  grid-template-columns: minmax(0, 1fr);
  max-width: 70%;
}

.post-pics img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: var(--surface-2);
}

.post-pics.one img {
  aspect-ratio: 4 / 3;
}

.post-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.open-link {
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 400;
}

.star {
  position: absolute;
  top: 6px;
  right: 5px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: 0.75;
  transition: transform 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.star svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.star:active {
  transform: scale(0.85);
}

.star.on {
  color: #e0a33a;
  opacity: 1;
}

.star.on svg {
  fill: #e0a33a;
  stroke: #e0a33a;
}

/* ---------- 骨架屏 ---------- */
.sk {
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 12px;
  display: flex;
  gap: 12px;
}

.sk-box,
.sk-line {
  background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--line) 55%, var(--surface-2)) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}

.sk-box {
  width: 94px;
  height: 94px;
  border-radius: 14px;
  flex: 0 0 auto;
}

.sk-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 3px;
}

.sk-line {
  height: 12px;
}

.sk-line.w60 {
  width: 60%;
}

.sk-line.w40 {
  width: 40%;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

/* ---------- 空态 / 底部 ---------- */
.empty {
  padding: 54px 12px;
  text-align: center;
  color: var(--muted);
}

.empty .emoji {
  font-size: 34px;
  filter: grayscale(0.2);
}

.empty p {
  margin: 12px 0 0;
  font-size: 14px;
}

.empty button {
  margin-top: 16px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13.5px;
}

.sentinel {
  height: 1px;
}

.loading-more {
  display: grid;
  place-items: center;
  padding: 18px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.end-note {
  text-align: center;
  padding: 20px 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.footer {
  margin: 26px 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.9;
}

.footer p {
  margin: 0;
}

.tiny {
  opacity: 0.75;
}

/* ---------- 浮动件 ---------- */
.to-top {
  position: fixed;
  right: 14px;
  bottom: calc(22px + var(--safe-b));
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 40;
  animation: rise 0.25s ease both;
}

.new-pill {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 24px -10px rgba(221, 82, 48, 0.6);
  z-index: 45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + var(--safe-b));
  transform: translate(-50%, 12px);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  color: #fff;
  background: rgba(28, 26, 22, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: 80vw;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 620px) {
  .deal-media {
    flex-basis: 70px;
    width: 70px;
    height: 70px;
  }
  .title {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 五源标签：小屏可横向滑动 ---------- */
.tabs {
  display: flex;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
}

/* ---------- 第二排筛选（价格 / 时间 / 排序） ---------- */
.chips-filters {
  align-items: center;
  margin-top: 2px;
  -webkit-mask-image: none;
  mask-image: none;
}

.f-label {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--muted);
}

.f-sep {
  flex: 0 0 auto;
  width: 1px;
  height: 15px;
  margin: 0 3px;
  background: var(--line);
}

.chip-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ---------- 线报卡片 ---------- */
/* 线报卡片：两行，标签+标题一行，价格+商城+时间一行 */
.link {
  padding: 12px 12px 11px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

.link-row .title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 14.5px;
  line-height: 1.3;
  -webkit-line-clamp: 1;
}

.link-row .star {
  position: static;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin-left: 2px;
}

.link-row .star svg {
  width: 14px;
  height: 14px;
}

.src-tag {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--accent);
  background: var(--accent-weak);
}

.src-tag.xianbaoku {
  color: #2f7d5c;
  background: rgba(47, 125, 92, 0.12);
}

.src-tag.manmanbuy,
.src-tag.meidebi {
  color: #b4682a;
  background: rgba(180, 104, 42, 0.13);
}

.src-tag.gwdang {
  color: #c0453b;
  background: rgba(192, 69, 59, 0.11);
}

.cat-tag {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.kind-tag {
  flex: 0 0 auto;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
}

.link-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.link-foot .price {
  margin-top: 0;
  font-size: 15px;
}

.link-foot .price.none {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.link-foot time {
  margin-left: auto;
  white-space: nowrap;
}

.link-foot .open-link {
  flex: 0 0 auto;
}

/* 好价卡片里价格、品类、商城、时间同排 */
.price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.price-row .price {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price-row .mall,
.price-row .kind-tag {
  flex: 0 0 auto;
}

.price-row time {
  margin-left: auto;
  white-space: nowrap;
}

/* 品类 chip 上的条数 */
.chip-num {
  margin-left: 4px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chip.is-active .chip-num {
  color: rgba(255, 255, 255, 0.75);
}

@media (max-width: 420px) {
  /* 窄屏上把频道分类标签藏起来，优先保证标题能看完 */
  .link-row .cat-tag {
    display: none;
  }
  .link-foot time {
    display: none;
  }
}

@media (max-width: 480px) {
  .tab {
    padding: 7px 12px;
    font-size: 13px;
  }
  .tab-count {
    font-size: 10px;
    padding: 1px 5px;
  }
}

