/* smzdh-lite 前端样式
   设计取向（参考 Emil Kowalski 的 design-eng 原则）：
   - 入场动画一律 ease-out 自定义曲线，时长 <300ms，绝不 ease-in
   - 入场元素从 scale(0.96)+opacity 开始，不从 0 缩放凭空出现
   - 可按压元素 :active scale(0.97)，transition 只写具体属性不用 all
   - 边框用半透明色 + 柔和阴影分层，不用生硬实线
   - hover 只做轻微上浮，高频操作不加重动画；尊重 prefers-reduced-motion
*/
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --radius: 16px;
  --accent: #2f9e63;
  --accent-strong: #1d7a48;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f3;
  --bg-grad: radial-gradient(1200px 500px at 80% -10%, rgba(47, 158, 99, 0.12), transparent 60%), #f3f6f3;
  --surface: #ffffff;
  --surface-2: #eef3ee;
  --text: #14211a;
  --text-2: #51665a;
  --text-3: #85988b;
  --border: rgba(20, 40, 28, 0.09);
  --shadow: 0 1px 2px rgba(16, 40, 25, 0.05), 0 8px 24px rgba(16, 40, 25, 0.06);
  --shadow-hover: 0 2px 4px rgba(16, 40, 25, 0.06), 0 16px 40px rgba(16, 40, 25, 0.1);
  --chip-bg: #ffffff;
  --score-high-bg: #e5f5ea; --score-high: #157347;
  --score-mid-bg: #fdf3d8; --score-mid: #8a6d1a;
  --score-low-bg: #eceff0; --score-low: #5d6b62;
  --warn-bg: #fdf6e3; --warn-border: rgba(190, 140, 20, 0.35); --warn-text: #7a5b12;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f0b;
  --bg-grad: radial-gradient(1200px 500px at 80% -10%, rgba(47, 158, 99, 0.16), transparent 60%), #0a0f0b;
  --surface: #121a14;
  --surface-2: #182219;
  --text: #e9f2ec;
  --text-2: #a7bcae;
  --text-3: #74897a;
  --border: rgba(210, 240, 220, 0.09);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.45);
  --chip-bg: #141d16;
  --score-high-bg: rgba(34, 197, 94, 0.16); --score-high: #7ee2a8;
  --score-mid-bg: rgba(234, 179, 8, 0.15); --score-mid: #f2d06b;
  --score-low-bg: rgba(148, 163, 153, 0.15); --score-low: #a6b5ab;
  --warn-bg: rgba(120, 84, 10, 0.25); --warn-border: rgba(224, 164, 88, 0.4); --warn-text: #eec987;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-grad);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 240ms ease, color 240ms ease;
}
a { color: inherit; text-decoration: none; }
.page { max-width: 1100px; margin: 0 auto; padding: 0 20px calc(40px + env(safe-area-inset-bottom)); }

/* 头部：吸顶毛玻璃 */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 4px 14px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #35b06d, #1d7a48);
  box-shadow: 0 6px 16px rgba(29, 122, 72, 0.35);
}
.brand-text h1 { margin: 0; font-size: 19px; letter-spacing: 0.01em; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.freshness {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2);
  border: 1px solid var(--border); background: var(--surface);
  padding: 6px 11px; border-radius: 999px; box-shadow: var(--shadow);
}
.freshness .dot { width: 7px; height: 7px; border-radius: 50%; background: #3ecf6f; animation: pulse 2.4s ease-in-out infinite; }
.freshness.stale { color: var(--warn-text); border-color: var(--warn-border); background: var(--warn-bg); }
.freshness.stale .dot { background: #e0a458; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; font-size: 16px; box-shadow: var(--shadow);
  transition: transform 160ms var(--ease-out), color 160ms ease, background-color 240ms ease;
}
.theme-toggle:active { transform: scale(0.92); }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* 统计条 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 18px 0 4px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  animation: rise 320ms var(--ease-out) both;
}
.stat:nth-child(2) { animation-delay: 40ms; }
.stat:nth-child(3) { animation-delay: 80ms; }
.stat:nth-child(4) { animation-delay: 120ms; }
.stat .num { display: block; font-size: 26px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 12px; color: var(--text-3); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.alert {
  margin-top: 14px; padding: 11px 14px; font-size: 13px;
  border: 1px solid var(--warn-border); background: var(--warn-bg); color: var(--warn-text);
  border-radius: 12px; animation: rise 260ms var(--ease-out) both;
}
.hidden { display: none; }

/* 筛选区 */
.filters { padding: 16px 0 6px; display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 2px; }
.chip {
  flex: none; cursor: pointer; font-size: 13px; padding: 7px 13px; border-radius: 999px;
  background: var(--chip-bg); color: var(--text-2); border: 1px solid var(--border);
  transition: transform 160ms var(--ease-out), background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.chip:hover { color: var(--text); }
.chip:active { transform: scale(0.95); }
.chip.active { background: var(--accent-strong); border-color: transparent; color: #fff; box-shadow: 0 6px 14px rgba(29, 122, 72, 0.3); }
.tools { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.search {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 0 12px; box-shadow: var(--shadow); min-width: 240px; flex: 0 1 320px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search-icon { color: var(--text-3); font-size: 16px; }
.search input {
  border: none; outline: none; background: transparent; color: var(--text);
  font-size: 14px; padding: 10px 0; width: 100%;
}
.search input:focus-visible { outline: none; }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track {
  width: 38px; height: 22px; border-radius: 999px; flex: none; position: relative;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background-color 180ms ease;
}
.toggle .thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-3);
  transition: transform 220ms var(--ease-out), background-color 180ms ease;
}
.toggle input:checked + .track { background: var(--accent-strong); }
.toggle input:checked + .track .thumb { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

/* 羊毛卡片 */
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; padding: 14px 0 8px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 9px;
  animation: rise 340ms var(--ease-out) both;
  transition: transform 180ms var(--ease-out), box-shadow 180ms ease, background-color 240ms ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card-top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.score { font-weight: 800; font-size: 13px; border-radius: 8px; padding: 3px 9px; font-variant-numeric: tabular-nums; }
.s-high { background: var(--score-high-bg); color: var(--score-high); }
.s-mid { background: var(--score-mid-bg); color: var(--score-mid); }
.s-low { background: var(--score-low-bg); color: var(--score-low); }
.cat { border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; color: var(--text-2); }
.src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-top time { margin-left: auto; flex: none; }
.card h3 { margin: 0; font-size: 16.5px; line-height: 1.5; font-weight: 650; }
.card h3 a { transition: color 140ms ease; }
.card h3 a:hover { color: var(--accent-strong); }
.summary { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.65; flex: 1; }
.card-bottom { display: flex; flex-direction: column; gap: 9px; margin-top: 2px; }
.value { color: var(--accent-strong); font-weight: 700; font-size: 13px; min-width: 0; line-height: 1.55; overflow-wrap: anywhere; }
.card-actions { display: flex; align-items: center; gap: 10px; min-height: 22px; }
.code {
  background: var(--score-high-bg); color: var(--score-high); border: 1px solid var(--border);
  border-radius: 9px; padding: 5px 10px; cursor: pointer; font-size: 12px; font-weight: 600; flex: none; white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.code:active { transform: scale(0.95); }
.go { margin-left: auto; flex: none; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--accent-strong); transition: transform 160ms var(--ease-out); padding-top: 1px; }
.go:hover { transform: translateX(2px); }
.empty { color: var(--text-3); padding: 48px 0; text-align: center; font-size: 14px; grid-column: 1 / -1; }

/* 来源状态与页脚 */
.sources { padding: 18px 0 8px; }
.sources h2 { font-size: 14px; margin: 0 0 10px; color: var(--text-2); }
.sources ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.sources li { display: flex; gap: 9px; align-items: center; color: var(--text-2); flex-wrap: wrap; }
.sources b { color: var(--text); font-weight: 600; }
.sources time { color: var(--text-3); margin-left: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: #34c759; }
.dot.bad { background: #e0564b; }
footer { padding: 20px 0 8px; color: var(--text-3); font-size: 12px; border-top: 1px solid var(--border); }

button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand-text p { display: none; }
  .freshness { padding: 5px 9px; font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .freshness .dot { animation: none; }
}

/* 投票按钮 */
.votes { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.vote { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 20px; background: transparent; color: var(--text-3); font-size: 12px; cursor: pointer; transition: all 150ms ease; }
.vote b { font-weight: 600; min-width: 0; }
.vote b:empty { display: none; }
.vote:hover { border-color: var(--accent); color: var(--text); }
.vote-up.active { background: #e8f5e9; border-color: #34c759; color: #1b7a2e; }
.vote-down.active { background: #fdecea; border-color: #e0564b; color: #b3261e; }
[data-theme="dark"] .vote-up.active { background: rgba(52,199,89,.15); color: #4cd964; }
[data-theme="dark"] .vote-down.active { background: rgba(224,86,75,.15); color: #ff6b62; }
