/* 脉搏 Pulse — 设计令牌 + 版式。
   双主题跟随系统；图表用色全部来自经过 CVD 校验的参考调色板。
   文字永远穿墨色（ink），身份色只落在图形标记上。 */

:root {
  color-scheme: light;
  /* 面与墨 */
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --scrim: rgba(11, 11, 11, 0.42);
  /* 状态（固定，不随主题换义） */
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;
  --delta-good: #006300;
  /* 项目身份色（分类槽 1/2/3/7） */
  --c-flt: #2a78d6;
  --c-jx: #eb6834;
  --c-sg: #1baf7a;
  --c-job: #4a3aa7;
  /* 机票走势的顺序蓝阶（浅→深 = 11/19→11/23） */
  --blue-250: #86b6ef;
  --blue-350: #5598e7;
  --blue-450: #2a78d6;
  --blue-550: #1c5cab;
  --blue-700: #0d366b;
  /* 字 */
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  /* 动 */
  --press: 90ms cubic-bezier(0.2, 0, 0.4, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --scrim: rgba(0, 0, 0, 0.55);
    --delta-good: #0ca30c;
    --c-flt: #3987e5;
    --c-jx: #d95926;
    --c-sg: #199e70;
    --c-job: #9085e9;
    /* 深底上的顺序蓝阶（不深于 600） */
    --blue-250: #b7d3f6;
    --blue-350: #86b6ef;
    --blue-450: #5598e7;
    --blue-550: #3987e5;
    --blue-700: #1c5cab;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--c-flt); outline-offset: 2px; border-radius: 6px; }

/* ---------- 页头 ---------- */

.hdr { padding: 6px 2px 14px; }
.hdr-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hdr-brand { display: flex; align-items: center; gap: 10px; }
.hdr-name { font-size: 22px; font-weight: 700; letter-spacing: 0.01em; }
.hdr-pulse { width: 64px; height: 20px; overflow: visible; }
.hdr-pulse path {
  fill: none; stroke: var(--c-flt); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.hdr-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.hdr-sub { margin-top: 2px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.hdr-sub button { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* 加载时描画一次心电线 */
@media (prefers-reduced-motion: no-preference) {
  .hdr-pulse path { stroke-dasharray: 200; stroke-dashoffset: 200; animation: pulse-draw 900ms cubic-bezier(0.3, 0, 0.2, 1) 120ms forwards; }
  @keyframes pulse-draw { to { stroke-dashoffset: 0; } }
}

/* ---------- 状态点 ---------- */

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.serious { background: var(--serious); }
.dot.crit { background: var(--crit); }
.dot.idle { background: var(--baseline); }
@media (prefers-reduced-motion: no-preference) {
  .dot.breath { animation: breath 4s ease-in-out infinite; }
  @keyframes breath { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
}

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

.cards { display: grid; gap: 12px; }

.card {
  display: block; width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 18px;
  padding: 16px 16px 14px;
  transition: transform var(--press);
}
.card:active { transform: scale(0.985); }

.card-eyebrow { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.card-eyebrow .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.card-eyebrow .name { font-weight: 600; color: var(--ink); }
.card-eyebrow .state { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.card-eyebrow .chev { color: var(--muted); font-size: 15px; margin-left: 2px; }

.card-hero { margin-top: 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-hero .v { font-size: 32px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.card-hero .u { font-size: 14px; color: var(--ink-2); }
.card-hero .delta { font-size: 13px; font-weight: 600; }
.delta.down { color: var(--delta-good); }
.delta.up { color: var(--serious); }
.delta.flat { color: var(--muted); }

.card-viz { margin-top: 10px; }
.card-sub { margin-top: 8px; font-size: 13px; color: var(--muted); }
.card-sub b { color: var(--ink-2); font-weight: 600; }

/* 骨架屏 */
.skel { height: 128px; border-radius: 18px; border: 1px solid var(--ring); background: var(--surface); position: relative; overflow: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--grid), transparent);
    animation: shimmer 1.4s ease infinite; }
  @keyframes shimmer { to { transform: translateX(100%); } }
}

/* 错误横幅 */
.banner { border: 1px solid var(--ring); background: var(--surface); border-radius: 12px;
  padding: 10px 14px; font-size: 13px; color: var(--ink-2); margin-bottom: 12px;
  display: flex; gap: 8px; align-items: center; }

/* ---------- 图表通用 ---------- */

.viz svg { display: block; width: 100%; height: auto; }
.viz text { font-family: var(--font); }
.axis-t { font-size: 10px; fill: var(--muted); }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--baseline); stroke-width: 1; }

/* 图例芯片（可点选隐藏系列） */
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.legend .chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--ring); border-radius: 999px; padding: 3px 10px; transition: opacity var(--press); }
.legend .chip .key { width: 12px; height: 3px; border-radius: 2px; }
.legend .chip[aria-pressed="false"] { opacity: 0.38; }

/* 十字线提示 */
.viz-wrap { position: relative; }
.viz-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--ring);
  border-radius: 10px; padding: 6px 10px; font-size: 12px; color: var(--ink-2); box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  white-space: nowrap; z-index: 3; display: none; }
.viz-tip .t { color: var(--muted); }
.viz-tip .row { display: flex; align-items: center; gap: 6px; }
.viz-tip .row .key { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.viz-tip .row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 周打卡点 */
.weeks { display: flex; align-items: center; gap: 7px; }
.weeks .wk { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.weeks .wk.on { background: var(--c-job); }
.weeks .wk.off { background: none; border: 1.5px solid var(--baseline); }
.weeks .wk.miss { background: none; border: 1.5px solid var(--serious); }
.weeks .wk.now { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c-job); }
.weeks .lbl { font-size: 11px; color: var(--muted); margin-left: 4px; }

/* ---------- 详情 sheet ---------- */

.sheet-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; opacity: 0; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto;
  height: calc(100dvh - 48px - env(safe-area-inset-top));
  background: var(--page);
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.22);
  overscroll-behavior: contain;
  touch-action: none;
}
.sheet-grab { flex: none; padding: 10px 0 4px; display: grid; place-items: center; cursor: grab; }
.sheet-grab::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--baseline); }
.sheet-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 4px 18px 12px; }
.sheet-head .swatch { width: 12px; height: 12px; border-radius: 4px; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.sheet-head .sub { margin-left: auto; font-size: 12px; color: var(--muted); }
.sheet-head .close { margin-left: 4px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--ring);
  color: var(--ink-2); font-size: 14px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 2px 16px calc(28px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch; touch-action: pan-y; }

/* sheet 内容区块 */
.sec { background: var(--surface); border: 1px solid var(--ring); border-radius: 16px; padding: 14px 14px 12px; margin-top: 12px; }
.sec h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.sec h3 .cnt { color: var(--muted); font-weight: 500; }
.footnote { margin: 14px 4px 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* 统计行（一排小数字） */
.statrow { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.stat { text-align: center; padding: 6px 0; }
.stat .v { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 1px; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--ink-2); }

/* 列表行 */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-top: 1px solid var(--grid); min-height: 44px; }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t1 { font-size: 14px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.row .t1 .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t2 { font-size: 12px; color: var(--muted); margin-top: 1px; }
.row .end { text-align: right; flex: none; }
.row .end .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row .end .s { font-size: 11px; color: var(--muted); }

.tag { display: inline-block; font-size: 11px; color: var(--ink-2); border: 1px solid var(--ring);
  border-radius: 6px; padding: 0 6px; line-height: 18px; flex: none; }
.badge-est { color: var(--muted); font-size: 11px; border: 1px dashed var(--baseline); border-radius: 6px; padding: 0 5px; line-height: 17px; }

/* 头像圆（用邀请称呼首字） */
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 15px; font-weight: 650; color: #fff; }

/* 求职职位卡 */
.jobcard { border-top: 1px solid var(--grid); padding: 12px 2px; }
.jobcard:first-of-type { border-top: 0; }
.jobcard .top { display: flex; align-items: baseline; gap: 8px; }
.jobcard .rank { flex: none; font-size: 12px; font-weight: 700; color: var(--c-job); }
.jobcard .title { font-size: 14.5px; font-weight: 600; line-height: 1.35; flex: 1; }
.jobcard .score { flex: none; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.jobcard .score small { font-size: 11px; font-weight: 500; color: var(--muted); }
.jobcard .meta { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.jobcard .why { font-size: 13px; color: var(--ink-2); margin-top: 6px; padding-left: 9px; border-left: 2px solid var(--grid); line-height: 1.55; }
.jobcard .go { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--ring); border-radius: 999px; padding: 4px 12px; text-decoration: none; }
.jobcard .go:active { transform: scale(0.97); }

/* 迷你水平条（谁在用 · 时长对比） */
.hbar { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; margin-top: 5px; }
.hbar > i { display: block; height: 100%; border-radius: 3px; }

/* ---------- 门 ---------- */

.gate { min-height: 82dvh; display: grid; place-content: center; text-align: center; gap: 10px; padding: 24px; }
.gate .pulse-big { width: 120px; height: 36px; margin: 0 auto; }
.gate .pulse-big path { fill: none; stroke: var(--c-flt); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.gate h1 { margin: 6px 0 0; font-size: 22px; }
.gate p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.7; }

/* ---------- 动效偏好 ---------- */

@media (prefers-reduced-motion: reduce) {
  .card, .card:active { transition: none; transform: none; }
  .sheet { transition: opacity 200ms ease; }
}
