/* 搞钱雷达 · 暗色、移动优先、零依赖。系统字体栈，不外链任何资源。 */

:root {
  --bg: #0b0d10;
  --bg-soft: #10141a;
  --surface: #151a22;
  --surface-2: #1b212b;
  --line: #262e3a;
  --line-soft: #1e242e;
  --text: #e9eef5;
  --text-dim: #aab4c2;
  --muted: #7d8896;
  --red: #ff3b30;
  --red-deep: #ff5a4f;
  --amber: #ffb020;
  --green: #38d39f;
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
    'Source Han Sans SC', 'Noto Sans CJK SC', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

/* 防横向滚动的第 1 道：全局盒模型 + 文本断行 + 根元素裁剪 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden; /* 第 2 道：任何溢出都不产生横向滚动条 */
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--amber);
  text-decoration: none;
}

p,
h1,
h2,
h3,
ul,
ol,
dl,
dd,
dt {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* 第 3 道：所有正文块强制断行，长 URL / 长英文不撑破容器 */
.view,
.card,
.block__body,
.opp__line,
.ai__text,
.act__title,
.list__body,
.hero__caption,
.headline,
.subline {
  overflow-wrap: anywhere;
  word-break: break-word;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------- 骨架 ------------------------------- */

.boot-note {
  padding: 24px 16px;
  color: var(--muted);
  font-size: 14px;
}

.boot-note--warn {
  color: var(--amber);
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 20%, var(--surface-2) 42%, var(--surface) 64%);
  background-size: 220% 100%;
  animation: shimmer 1.35s linear infinite;
}

.skeleton--hero {
  height: 148px;
  margin-bottom: var(--gap);
}

.skeleton--line {
  height: 20px;
  margin-bottom: 12px;
  border-radius: 8px;
}

.skeleton--card {
  height: 116px;
  margin-bottom: var(--gap);
}

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

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
  * {
    transition: none !important;
  }
}

/* ------------------------------- 布局外壳 ------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 13, 16, 0.92);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
}

.topbar__brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: none;
}

.topbar__meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#main {
  display: block;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

.view {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.view > * {
  min-width: 0; /* 第 4 道：flex 子项允许收缩 */
}

/* 底部导航：5 个格子用 flex:1 平分，永不溢出 */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(16, 20, 26, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.tab {
  flex: 1 1 0;
  min-width: 0; /* 关键：不加这行，中文标签会把导航撑宽 */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 4px 2px;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  border-top: 2px solid transparent;
}

.tab[aria-current='page'] {
  color: var(--red);
  border-top-color: var(--red);
  font-weight: 700;
}

body[data-session='guest'] .tabbar,
body[data-session='guest'] .topbar__meta {
  display: none;
}

body[data-session='guest'] #main {
  padding-bottom: 24px;
}

/* ------------------------------- 今日 · 英雄数字 ------------------------------- */

.hero {
  padding: 20px 18px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #1a1013 0%, var(--surface) 62%);
}

.hero--hot {
  border-left-color: var(--red);
  background: linear-gradient(180deg, #2a0f11 0%, var(--surface) 70%);
}

.hero--warn {
  border-left-color: var(--amber);
  background: linear-gradient(180deg, #241a08 0%, var(--surface) 70%);
}

.hero__kicker {
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--text-dim);
}

.hero__figure {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 2px 0 6px;
}

/* 用 clamp + vw 让数字在 320px 到桌面宽度都不会溢出容器 */
.hero__number {
  font-size: clamp(56px, 21vw, 104px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}

.hero--warn .hero__number {
  color: var(--amber);
}

.hero__unit {
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 700;
  color: var(--red-deep);
}

.hero--warn .hero__unit {
  color: var(--amber);
}

.hero__caption {
  font-size: 14px;
  color: var(--text-dim);
}

.headline {
  font-size: clamp(20px, 5.4vw, 26px);
  line-height: 1.32;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subline {
  font-size: 15px;
  color: var(--text-dim);
  margin-top: -6px;
}

/* ------------------------------- 统计 ------------------------------- */

.stats {
  display: flex;
  gap: 10px;
}

.stats--tight {
  gap: 8px;
}

.stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat__label {
  font-size: 12px;
  color: var(--muted);
}

.stat__value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat__value--sm {
  font-size: 14px;
  font-weight: 600;
  color: var(--amber);
}

/* ------------------------------- 卡片 ------------------------------- */

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card > * {
  min-width: 0;
}

.card--action {
  border-color: #3a2026;
  background: linear-gradient(180deg, #1b1114 0%, var(--surface) 60%);
}

.card--error {
  border-color: #43242a;
}

.card__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.card__title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.card__title--opp {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
}

.card__body {
  font-size: 14px;
  color: var(--text-dim);
}

.card__why {
  font-size: 13px;
  color: var(--text-dim);
}

.card__key {
  display: inline-block;
  min-width: 4.6em;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.score {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------- 徽标 / 标签 / 药丸 ------------------------------- */

.badge {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.badge--s {
  background: #4a1116;
  border-color: #7d1a22;
  color: #ff8f86;
}

.badge--a {
  background: #43290a;
  border-color: #6d4410;
  color: #ffc561;
}

.badge--b {
  background: #10263a;
  border-color: #1b4262;
  color: #7cc4ff;
}

.badge--c {
  color: var(--muted);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.tag--soft {
  color: var(--amber);
  border-color: #3d2f13;
}

.tag--todo {
  color: var(--amber);
}

.tag--done {
  color: var(--green);
}

.tag--skipped {
  color: var(--muted);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}

.pill--low {
  color: var(--green);
}

.pill--medium {
  color: var(--amber);
}

.pill--high {
  color: var(--red-deep);
}

/* ------------------------------- 按钮 ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px; /* 拇指可点 */
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn--primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
}

.btn--done {
  background: #14301f;
  border-color: #1f5138;
  color: var(--green);
  cursor: default;
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.42;
  cursor: not-allowed;
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
}

/* ------------------------------- 表单 ------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field--inline {
  flex: 1 1 0;
}

.field__label {
  font-size: 13px;
  color: var(--text-dim);
}

.input {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px; /* 16px 防止 iOS 聚焦时页面缩放 */
  appearance: none;
}

.input::placeholder {
  color: #5f6a78;
}

.input--select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 20px, calc(100% - 12px) 20px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filters__row {
  display: flex;
  gap: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  min-height: 34px;
}

.chip--on {
  border-color: var(--red);
  color: #fff;
  background: #35111a;
  font-weight: 600;
}

.chips--static {
  gap: 6px;
}

/* ------------------------------- 说明文字 ------------------------------- */

.note {
  font-size: 13px;
  color: var(--text-dim);
  min-height: 1em;
}

.note:empty {
  min-height: 0;
}

.note--ok {
  color: var(--green);
}

.note--bad {
  color: var(--red-deep);
}

.note--muted {
  color: var(--muted);
}

.count {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.count__hint {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 18px 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

/* ------------------------------- 标题 ------------------------------- */

.page-title {
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dim);
  margin-top: 4px;
}

.lede {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: -6px;
}

.crumb {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.crumb a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ------------------------------- 列表 ------------------------------- */

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list__item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.list__link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 14px;
  color: var(--text);
  min-width: 0;
}

.list__top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.list__title {
  font-size: 15px;
  font-weight: 700;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list__body {
  font-size: 13px;
  color: var(--text-dim);
}

.list__meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------- 行动条目 ------------------------------- */

.act {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.act__main {
  flex: 1 1 190px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.act__title {
  font-size: 15px;
  font-weight: 600;
}

.act__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.act__ops {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

/* ------------------------------- 行业详情 ------------------------------- */

.block {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.block__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--amber);
}

.block__body {
  font-size: 14px;
  color: var(--text);
}

.opp {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.opp__summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  min-width: 0;
}

.opp__summary::-webkit-details-marker {
  display: none;
}

.opp__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opp__score {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--amber);
}

.opp__body {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.opp__line {
  font-size: 13px;
  color: var(--text-dim);
}

.opp__key {
  display: inline-block;
  min-width: 5.6em;
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------- 设置 · 键值表 ------------------------------- */

.kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kv__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 13px;
}

.kv__row:last-child {
  border-bottom: 0;
}

.kv__row dt {
  color: var(--muted);
}

.kv__row dd {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ------------------------------- AI 输出 ------------------------------- */

.ai {
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.ai__text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}

/* ------------------------------- 口令页 ------------------------------- */

.login {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 20px 24px;
  margin-top: 6vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.login__title {
  font-size: clamp(28px, 8vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login__title::after {
  content: '';
  display: block;
  width: 46px;
  height: 4px;
  margin-top: 10px;
  background: var(--red);
  border-radius: 2px;
}

.login__lead {
  font-size: 14px;
  color: var(--text-dim);
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login__points {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.login__points li {
  position: relative;
  padding-left: 14px;
  font-size: 13px;
  color: var(--muted);
}

.login__points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
}

/* ------------------------------- 窄屏微调 ------------------------------- */

@media (max-width: 359px) {
  .view {
    padding: 12px;
  }
  .hero {
    padding: 16px 14px 14px;
  }
  .tab {
    font-size: 12px;
  }
  .filters__row {
    flex-direction: column;
  }
}

@media (min-width: 600px) {
  .view {
    padding: 22px 20px;
  }
  .card__head {
    align-items: center;
  }
}
