/* ============================================================
 * EKO FUND — 与主站同一套设计语言（黑底 / 发丝线 / 电光蓝 / 等宽标注）
 * 差别: 这是看盘界面, 信息密度高, 数字是主角
 * 涨跌配色按 A 股习惯: 红涨绿跌
 * ============================================================ */
@font-face { font-family: "Syne"; src: url("../fonts/syne-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Syne"; src: url("../fonts/syne-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/plexmono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/plexmono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #060607;
  --panel: #0a0a0c;
  --raised: rgba(255, 255, 255, 0.025);
  --ink: #eceae4;
  --ink-dim: rgba(236, 234, 228, 0.55);
  --ink-faint: rgba(236, 234, 228, 0.32);
  --hairline: rgba(236, 234, 228, 0.14);
  --accent: #3b6bff;
  --accent-soft: rgba(59, 107, 255, 0.12);
  --up: #ff4d4f;      /* A 股: 红涨 */
  --down: #2ecc71;    /*        绿跌 */
  --warn: #ffb020;
  --display: "Syne", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: "Plex Mono", "Cascadia Mono", Consolas, monospace;
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --pad: clamp(14px, 2.4vw, 32px);
}

/* 刘海屏横屏时左右会被挖掉一块 —— 内边距把安全区算进去, 免得内容压在刘海下。
   ≤720px 的媒体查询在 iPhone 横屏(844 宽)时并不生效, 所以这条必须放在全局。 */
@supports (padding: env(safe-area-inset-left)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* 给元素设了 display 就会盖掉 hidden 属性的 display:none —— 统一兜住,
   否则 JS 里 el.hidden = true 会"不生效"，而且极难看出原因 */
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 40px;
}
::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.sub { color: var(--ink-faint); margin-bottom: 12px; }
.sub--gap { margin-top: 28px; }   /* CSP 禁内联 style, 布局微调也走 class */
.sub em { font-style: normal; text-transform: none; letter-spacing: 0.04em; margin-left: 10px; opacity: 0.7; }
.spacer { flex: 1; }
.r { text-align: right; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--ink-dim); }

.grain {
  position: fixed; inset: 0; z-index: 200; pointer-events: none; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}
@keyframes grain-shift {
  0% { background-position: 0 0; } 25% { background-position: -13px 9px; }
  50% { background-position: 11px -7px; } 75% { background-position: -7px -13px; }
  100% { background-position: 0 0; }
}

/* ---------------------------------------------- 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 18px;
  padding: 11px var(--pad);
  background: rgba(6, 6, 7, 0.92);
  border-bottom: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.brand__text { font-family: var(--display); font-weight: 800; font-size: 16px; letter-spacing: 0.02em; }
.brand__text em { font-style: normal; color: var(--accent); margin-left: 4px; }

.ticker { flex: 1; min-width: 0; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); }
.ticker__track { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.ticker__track::-webkit-scrollbar { display: none; }
.tick { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; flex: none; }
.tick__name { font-family: var(--mono); font-size: 10.5px; color: var(--ink-dim); letter-spacing: 0.06em; }
.tick__val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500; }
.tick__pct { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11px; }

.topbar__right { display: flex; align-items: center; gap: 8px; flex: none; }
.phase {
  color: var(--ink-dim); border: 1px solid var(--hairline); border-radius: 99px;
  padding: 4px 11px; white-space: nowrap;
}
.phase.is-open { color: var(--up); border-color: rgba(255, 77, 79, 0.4); }
.phase.is-open::before { content: "● "; }

.btn {
  border: 1px solid var(--hairline); border-radius: 99px; background: transparent;
  color: var(--ink-dim); padding: 6px 14px; cursor: pointer; white-space: nowrap;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  transition: border-color 0.25s, color 0.25s, background 0.25s; line-height: 1.4;
}
.btn:hover { border-color: var(--accent); color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn--primary:hover { filter: brightness(1.14); color: #fff; }
.btn--icon { padding: 5px 10px; font-size: 13px; letter-spacing: 0; }
.btn--danger:hover { border-color: var(--up); color: var(--up); }

/* ---------------------------------------------- 分区 */
.tabs { display: flex; gap: 0; padding: 0 var(--pad); border-bottom: 1px solid var(--hairline); }
.tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--ink-faint); padding: 13px 18px 11px; cursor: pointer;
  font: inherit; font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; transition: color 0.25s, border-color 0.25s;
}
.tab em { font-style: normal; font-size: 9px; opacity: 0.5; margin-left: 6px; }
.tab:hover { color: var(--ink-dim); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }

main { padding: clamp(18px, 3vw, 32px) var(--pad); max-width: 1440px; margin: 0 auto; }
.view { display: none; }
.view.is-active { display: block; }

/* ---------------------------------------------- 未解锁 */
.locked { text-align: center; padding: clamp(48px, 12vh, 110px) 20px; }
.locked__title { font-family: var(--display); font-weight: 700; font-size: clamp(20px, 3vw, 28px); margin-bottom: 10px; }
.locked__desc { color: var(--ink-faint); margin-bottom: 24px; }

/* ---------------------------------------------- 总览 */
.summary {
  display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: clamp(16px, 3vw, 40px);
  align-items: center; padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--hairline); border-radius: 12px; background: var(--panel);
  margin-bottom: 18px;
}
.summary__label { color: var(--ink-faint); margin-bottom: 8px; }
.summary__big {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(30px, 5.4vw, 52px); font-weight: 500; line-height: 1.05; letter-spacing: -0.02em;
}
.summary__sub { color: var(--ink-faint); margin-top: 6px; }
.summary__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: clamp(12px, 2vw, 28px); }
.stat__label { color: var(--ink-faint); font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 5px; }
.stat__value { font-size: clamp(15px, 1.8vw, 19px); font-weight: 500; }

.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.bar__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bar__hint { color: var(--ink-faint); }
.bar__hint.warn-text { color: var(--warn); }

/* ---------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: 12px; background: var(--panel); }
.table { width: 100%; border-collapse: collapse; min-width: 760px; }
.table th {
  text-align: left; padding: 11px 14px; color: var(--ink-faint);
  border-bottom: 1px solid var(--hairline); font-weight: 400; white-space: nowrap;
  background: var(--raised); position: sticky; top: 0;
}
.table th.r { text-align: right; }
.table td { padding: 12px 14px; border-bottom: 1px solid rgba(236, 234, 228, 0.06); white-space: nowrap; }
.table td.r { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table tbody tr { cursor: pointer; transition: background 0.2s; }
.table tbody tr:hover { background: var(--accent-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.fund-cell { display: flex; flex-direction: column; gap: 2px; }
.fund-cell__name { font-weight: 500; }
.fund-cell__meta { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); letter-spacing: 0.06em; }
.big-num { font-size: 15px; font-weight: 500; }
.tag {
  display: inline-block; font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  border: 1px solid var(--hairline); border-radius: 99px; padding: 1px 7px; color: var(--ink-faint);
  margin-left: 6px; text-transform: uppercase; vertical-align: middle;
}
.tag--warn { color: var(--warn); border-color: rgba(255, 176, 32, 0.4); }

.empty { color: var(--ink-faint); text-align: center; padding: 40px 20px; }

/* ---------------------------------------------- 面板 */
.panel { margin-top: 20px; border: 1px solid var(--hairline); border-radius: 12px; background: var(--panel); padding: clamp(16px, 2.5vw, 26px); }
.panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel__title { font-family: var(--display); font-weight: 700; font-size: 19px; }
.panel__title em { font-style: normal; font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--ink-faint); margin-left: 10px; }
.panel__desc { color: var(--ink-dim); font-size: 13px; margin-bottom: 18px; }
.panel__note { color: var(--ink-faint); margin-top: 14px; line-height: 1.8; }
.pen-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: clamp(16px, 3vw, 36px); }

/* 权重条 */
.wrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(236, 234, 228, 0.06); }
.wrow:last-child { border-bottom: 0; }
.wrow__label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wrow__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrow__bar { height: 3px; background: rgba(236, 234, 228, 0.08); border-radius: 2px; overflow: hidden; margin-top: 5px; }
.wrow__fill { height: 100%; background: var(--accent); border-radius: 2px; }
.wrow__fill--up { background: var(--up); }
.wrow__fill--down { background: var(--down); }
.wrow__val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; text-align: right; }

/* AI 输出 */
.ai-out { white-space: pre-wrap; line-height: 1.9; color: var(--ink-dim); font-size: 14px; min-height: 60px; }
.ai-out strong, .ai-out b { color: var(--ink); font-weight: 500; }
.ai-out .cursor { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------------------------------------------- 行情卡片 */
.quote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.quote {
  border: 1px solid var(--hairline); border-radius: 10px; background: var(--panel);
  padding: 14px 16px; transition: border-color 0.25s, transform 0.25s;
  /* 现在是按钮(点开看走势), 复位一下按钮默认样式 */
  display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.quote:hover { border-color: rgba(59, 107, 255, 0.4); transform: translateY(-2px); }
.quote:disabled { cursor: default; }
.quote:disabled:hover { border-color: var(--hairline); transform: none; }
.drawer__range { margin-bottom: 16px; }
.quote__name { font-size: 13px; color: var(--ink-dim); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote__price { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 500; line-height: 1.2; }
.quote__chg { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; margin-top: 4px; }

/* 分段控件 */
.seg { display: inline-flex; border: 1px solid var(--hairline); border-radius: 99px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--ink-dim); padding: 6px 13px; cursor: pointer;
  font: inherit; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; transition: background 0.2s, color 0.2s;
}
.seg button:hover { color: var(--ink); }
.seg button.is-active { background: var(--accent); color: #fff; }
.seg button:focus-visible { outline-offset: -2px; }

/* 抽屉和两个弹窗共用一个滚动锁 class —— 谁开谁加、全关才解, 不会互相拆台 */
body.scroll-lock { overflow: hidden; }

/* ---------------------------------------------- 抽屉 */
.drawer { position: fixed; inset: 0; z-index: 300; }
.drawer[hidden] { display: none; }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(3, 3, 4, 0.82); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
  background: var(--panel); border-left: 1px solid var(--hairline);
  padding: clamp(18px, 3vw, 28px); overflow-y: auto; overscroll-behavior: contain;
  animation: drawer-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes drawer-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.drawer__name { font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1.25; }
.drawer__code { color: var(--ink-faint); margin-top: 4px; }
.drawer__est { border: 1px solid var(--hairline); border-radius: 10px; padding: 16px; margin-bottom: 22px; background: var(--raised); }
.drawer__est-big { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 32px; font-weight: 500; line-height: 1.1; }
.drawer__est-row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.drawer__est-item { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); letter-spacing: 0.08em; }
.drawer__est-item b { display: block; color: var(--ink-dim); font-weight: 500; font-size: 13px; margin-top: 3px; }
.chart { margin-bottom: 24px; }
.chart svg { display: block; width: 100%; height: auto; }

/* ---------------------------------------------- 弹窗 */
.modal { position: fixed; inset: 0; z-index: 320; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(3, 3, 4, 0.85); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal__panel {
  position: relative; width: min(680px, 96vw); max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 12px;
  padding: clamp(18px, 3vw, 26px); display: flex; flex-direction: column; gap: 14px;
  animation: modal-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal__panel--sm { width: min(360px, 94vw); }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal__title { font-family: var(--display); font-weight: 700; font-size: 18px; }
.modal__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal__hint, .modal__err { color: var(--ink-faint); }
.modal__err { color: var(--up); }

.input {
  width: 100%; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--hairline);
  border-radius: 8px; color: var(--ink); padding: 10px 13px; font: inherit; font-size: 14px;
  transition: border-color 0.25s;
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--ink-faint); }
.input--sm { padding: 7px 10px; font-size: 13px; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.search { position: relative; }
.search__results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5;
  background: #101013; border: 1px solid var(--hairline); border-radius: 10px;
  max-height: 260px; overflow-y: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.search__item { display: flex; align-items: center; gap: 10px; padding: 10px 13px; cursor: pointer; border-bottom: 1px solid rgba(236, 234, 228, 0.06); }
.search__item:last-child { border-bottom: 0; }
.search__item:hover, .search__item.is-active { background: var(--accent-soft); }
.search__code { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); flex: none; }
.search__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------- 截图导入 */
.shot {
  display: block; position: relative;
  border: 1px dashed rgba(236, 234, 228, 0.3); border-radius: 10px;
  padding: 20px 16px; text-align: center; cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
}
.shot:hover, .shot.is-over { border-color: var(--accent); background: var(--accent-soft); }
.shot input { display: none; }
.shot__idle b { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.shot__idle em { font-style: normal; color: var(--ink-faint); }
.shot__busy { display: flex; align-items: center; justify-content: center; gap: 10px; }
.shot__busy em { font-style: normal; color: var(--accent); }
.spin {
  width: 14px; height: 14px; border: 2px solid rgba(59, 107, 255, 0.25);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.shot:focus-visible { border-color: var(--accent); outline: 1px solid var(--accent); outline-offset: 2px; }
.shot__err { color: var(--up); }
.shot__privacy { color: var(--ink-faint); margin-top: 8px; text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.shot__tip { color: var(--ink-faint); margin-top: 10px; }

.shot-result { border: 1px solid var(--hairline); border-radius: 10px; padding: 12px; background: var(--raised); }
.shot-result__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.shot-result__head .mono { color: var(--ink-dim); }
.shot-row {
  display: grid; grid-template-columns: 22px 1fr 200px; gap: 10px; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid rgba(236, 234, 228, 0.07); opacity: 0.5;
  transition: opacity 0.2s;
}
.shot-row.is-picked { opacity: 1; }
.shot-row:last-child { border-bottom: 0; }
.shot-row__cb { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.shot-row__main { min-width: 0; }
.shot-row__name { font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.shot-row__meta { color: var(--ink-faint); margin-top: 3px; }
.shot-row__warn { color: var(--warn); margin-top: 4px; }
.shot-row__inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.input.is-derived { border-style: dashed; }

.edit-list { display: flex; flex-direction: column; gap: 8px; }
.edit-row { display: grid; grid-template-columns: 1fr 110px 110px 36px; gap: 8px; align-items: center; }
.edit-row__fund { min-width: 0; }
.edit-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.edit-row__code { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); letter-spacing: 0.08em; }
.edit-head { display: grid; grid-template-columns: 1fr 110px 110px 36px; gap: 8px; color: var(--ink-faint); }

.foot {
  max-width: 1440px; margin: 40px auto 0; padding: 18px var(--pad); border-top: 1px solid var(--hairline);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--ink-faint);
  text-transform: none; letter-spacing: 0.04em; line-height: 1.8;
}
.foot__warn { color: rgba(255, 176, 32, 0.55); }

.toast {
  position: fixed; left: 50%; z-index: 400; transform: translateX(-50%);
  bottom: calc(28px + env(safe-area-inset-bottom));   /* 别落在 home indicator 上 */
  max-width: calc(100vw - 32px);
  background: #16161a; border: 1px solid var(--hairline); border-radius: 99px;
  padding: 10px 20px; color: var(--ink); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------------------------------------- 响应式 */
@media (max-width: 900px) {
  .summary { grid-template-columns: 1fr; }
  .pen-grid { grid-template-columns: 1fr; }
}

/* ============================================================
 * 手机 (≤720px)
 * 核心思路: 表格横向滚动在手机上没法用 —— 每一行改成一张卡片,
 * 表头隐藏, 字段名靠 data-label 显示。操作按钮吸底, 拇指够得着。
 * ============================================================ */
@media (max-width: 720px) {
  body { padding-bottom: 0; }
  .tab em { display: none; }
  .brand__text { font-size: 15px; }
  .foot { flex-direction: column; gap: 6px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }

  /* 顶栏: 指数条挪到第二行整宽横滑, 而不是干脆隐藏 —— 行情是这个站的主角 */
  .topbar { flex-wrap: wrap; gap: 10px 12px; padding: 10px var(--pad); }
  .ticker { order: 3; flex: 1 0 100%; margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad); }
  .ticker__track { gap: 16px; }
  .tick__name { font-size: 10px; }
  .topbar__right { gap: 6px; }
  .phase { padding: 4px 9px; font-size: 10px; }

  /* 总览: 大数字压一档, 四个小指标两列 */
  .summary { padding: 16px; gap: 16px; }
  .summary__big { font-size: clamp(28px, 9vw, 40px); }
  .summary__grid { grid-template-columns: repeat(2, 1fr); gap: 14px 12px; }

  /* 操作栏固定在屏幕底部 —— 表格再长也不用滚回顶部才能点。
     注意不能用 sticky: 它的粘附范围是父元素 .bar, 而 .bar 只有一行高,
     等于没地方可粘, 会跟着内容一起滚走 */
  .bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .bar__hint { order: 1; text-align: center; }
  .bar .spacer { display: none; }
  .bar__actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    padding: 10px calc(var(--pad) + env(safe-area-inset-right))
             calc(10px + env(safe-area-inset-bottom))
             calc(var(--pad) + env(safe-area-inset-left));
    background: linear-gradient(to top, var(--bg) 62%, rgba(6, 6, 7, 0.86) 88%, rgba(6, 6, 7, 0));
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
  .bar__actions .btn { padding: 12px 6px; font-size: 10.5px; letter-spacing: 0.06em; }
  /* 给固定操作栏让出高度, 否则最后一张卡片被压在下面 */
  #view-portfolio { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  /* 只有持仓页有这个栏 */
  #view-market .bar__actions, #view-rank .bar__actions { display: none; }

  /* 表格 → 卡片 */
  .table-wrap { border: 0; border-radius: 0; background: transparent; overflow: visible; }
  .table { min-width: 0; border-collapse: separate; }
  .table thead { display: none; }
  .table tbody, .table tr, .table td { display: block; }
  .table tr {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px;
    border: 1px solid var(--hairline); border-radius: 12px;
    background: var(--panel); padding: 14px; margin-bottom: 10px;
  }
  .table tbody tr:hover { background: var(--panel); }   /* 手机没有 hover, 别留高亮残影 */
  .table tbody tr:active { border-color: rgba(59, 107, 255, 0.5); }
  .table td { padding: 0; border: 0; white-space: normal; }

  /* 第一行: 基金名 + 今日涨跌 */
  .table td:nth-child(1) { flex: 1 1 55%; order: 1; }
  .table td:nth-child(2) { flex: 0 0 auto; order: 2; margin-left: auto; font-size: 18px; text-align: right; }
  /* 其余字段: 一排小字, 带字段名 */
  .table td[data-label] {
    order: 4; flex: 0 0 auto; margin-top: 10px;
    font-family: var(--mono); font-size: 11.5px; text-align: left;
  }
  /* 排序依据那一列要看得出来 —— 写在 [data-label] 之后才盖得住(同特异性后者胜) */
  .table td.td-hero { font-size: 15px; color: inherit; }
  .table td[data-label]::before {
    content: attr(data-label); color: var(--ink-faint);
    margin-right: 5px; font-size: 10px; letter-spacing: 0.1em;
  }
  .fund-cell__name { font-size: 15px; }
  .big-num { font-size: 18px; }

  /* 榜单: 序号缩小, 加入按钮独占一行。
     基金名那格要显式复位 —— 通用规则给 nth-child(2) 设了右对齐+18px(为持仓页的大数字),
     榜单第 2 格却是基金名, 不复位会把名字甩到右边 */
  #rank-body td:nth-child(1) { flex: 0 0 auto; order: 0; color: var(--ink-faint); margin-right: 4px; }
  #rank-body td:nth-child(2) {
    flex: 1 1 auto; order: 1; text-align: left; font-size: inherit; margin-left: 0;
  }
  #rank-body td:last-child { flex: 0 0 100%; order: 5; margin-top: 10px; text-align: right; }
  /* 空状态/错误提示那一行是个 colspan 单元格, 别被上面的右对齐规则拽偏 */
  #rank-body td.empty { flex: 0 0 100%; order: 0; text-align: center; padding: 16px 0; margin: 0; }

  /* 抽屉: 从底部升起, 更像手机原生 */
  .drawer__panel {
    width: 100vw; top: auto; height: 92vh; height: 92dvh; border-left: 0;
    border-top: 1px solid var(--hairline); border-radius: 16px 16px 0 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    animation: drawer-up 0.34s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes drawer-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .drawer__est-big { font-size: 28px; }

  /* 弹窗铺满。不贴底: 贴底的话 iOS 键盘弹出会把面板下半截(搜索结果、保存按钮)
     永久压在键盘后面, 内部再怎么滚也够不着。顶部对齐 + 自身滚动最稳。 */
  .modal { padding: 0; align-items: flex-start; }
  .modal__panel {
    width: 100vw; height: 100vh; height: 100dvh; max-height: none;
    border-radius: 0; border: 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    padding-left: calc(clamp(14px, 4vw, 26px) + env(safe-area-inset-left));
    padding-right: calc(clamp(14px, 4vw, 26px) + env(safe-area-inset-right));
  }
  .modal__panel--sm { width: 100vw; height: auto; min-height: 42vh; border-radius: 0 0 16px 16px; }
  .edit-row, .edit-head { grid-template-columns: 1fr 76px 76px 34px; gap: 6px; }
  .edit-row__name { font-size: 12.5px; }

  /* 截图导入: 两列输入改上下, 免得挤成条 */
  .shot-row { grid-template-columns: 20px 1fr; gap: 8px; }
  .shot-row__inputs { grid-column: 2; grid-template-columns: 1fr 1fr; }
  .shot { padding: 24px 14px; }

  /* 触达: 手指比鼠标粗 */
  .btn { padding: 9px 14px; }
  .seg button { padding: 9px 14px; }
  .quote-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}

@media (max-width: 400px) {
  .summary__grid { gap: 12px 8px; }
  .bar__actions .btn { padding: 11px 2px; font-size: 10px; letter-spacing: 0.02em; }
  .edit-row, .edit-head { grid-template-columns: 1fr 66px 66px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .ai-out .cursor { animation: none; }
  .drawer__panel, .modal__panel, .toast { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
