/* 指标学堂 · 设计系统 */
:root {
  --bg: #F2F4F9;
  --panel: #FFFFFF;
  --panel2: #F7F9FD;
  --panel3: #EEF2F9;
  --line: #E4E8F2;
  --line2: #D3DAE8;
  --t1: #181D2A;
  --t2: #39435A;
  --t3: #6A7488;
  --accent: #4A5AF0;
  --accent2: #3A46CC;
  --accent-soft: rgba(74, 90, 240, .09);
  --up: #E0483D;
  --down: #12A06A;
  --warn: #C9861A;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 26px rgba(16, 24, 40, .06);
  --shadow-lg: 0 2px 6px rgba(16, 24, 40, .08), 0 24px 60px rgba(16, 24, 40, .12);
}
html[data-wk="night"] {
  --bg: #0E1116;
  --panel: #171C25;
  --panel2: #1B212C;
  --panel3: #222A38;
  --line: #262D3B;
  --line2: #333D4F;
  --t1: #EDF0F7;
  --t2: #C6CEDA;
  --t3: #8C97AB;
  --accent: #8A97FF;
  --accent2: #A6B1FF;
  --accent-soft: rgba(138, 151, 255, .14);
  --up: #FF6B5E;
  --down: #2ECC8F;
  --warn: #E3A83C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .5), 0 30px 70px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--t1);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }

/* 顶栏 */
.appbar {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  height: 56px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.bar-inner {
  max-width: 1480px; height: 100%; margin: 0 auto;
  padding: 0 20px; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.brand svg { width: 26px; height: 26px; border-radius: 7px; }
.tabs { display: flex; gap: 2px; margin-left: 8px; padding: 3px; background: var(--panel3); border-radius: 9px; }
.tabs button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 7px;
  color: var(--t3); font-size: 14px; transition: .16s;
}
.tabs button:hover { color: var(--t1); }
.tabs button.on { background: var(--panel); color: var(--t1); box-shadow: 0 1px 3px rgba(16, 24, 40, .1); font-weight: 600; }
.bar-tools { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; display: grid; place-items: center; color: var(--t3);
  transition: .16s;
}
.icon-btn:hover { background: var(--panel3); color: var(--t1); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

main { max-width: 1480px; margin: 0 auto; padding: 56px 20px 90px; }
.view { display: none; }
.view.on { display: block; }

/* 搜索层 */
.search-layer {
  position: fixed; inset: 56px 0 0 0; z-index: 90;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px); padding: 30px 20px;
}
.search-box { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; }
.search-box input {
  flex: 1; height: 48px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line2); background: var(--panel); color: var(--t1);
  font-size: 15px; outline: none; box-shadow: var(--shadow);
}
.search-box input:focus { border-color: var(--accent); }
.search-box .close { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 22px; color: var(--t3); }
.search-results { max-width: 720px; margin: 14px auto 0; display: grid; gap: 8px; }
.sr-item { padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.sr-item:hover { border-color: var(--accent); }
.sr-item b { display: block; font-size: 14px; }
.sr-item span { color: var(--t3); font-size: 13px; }

/* 首页 */
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 30px; align-items: center;
  padding: 34px 36px; margin-bottom: 22px;
  background: linear-gradient(135deg, var(--panel) 0%, var(--panel2) 100%);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.hero h1 { font-size: 26px; line-height: 1.35; margin-bottom: 12px; }
.hero p { color: var(--t2); font-size: 14.5px; max-width: 720px; }
.hero-stats { display: flex; gap: 26px; margin-top: 22px; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats b { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.hero-stats span { color: var(--t3); font-size: 12.5px; }
.hero-ring { position: relative; width: 120px; height: 120px; }
.hero-ring svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--panel3); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 314; stroke-dashoffset: 314; transition: stroke-dashoffset .6s ease; }
.ring-txt { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-txt b { font-size: 21px; display: block; line-height: 1.2; }
.ring-txt span { font-size: 11.5px; color: var(--t3); }

.cat-filter { display: flex; gap: 8px; margin: 6px 0 18px; flex-wrap: wrap; }
.cat-filter button {
  border: 1px solid var(--line); background: var(--panel); color: var(--t2);
  padding: 7px 15px; border-radius: 999px; font-size: 13.5px; transition: .16s;
}
.cat-filter button:hover { border-color: var(--line2); color: var(--t1); }
.cat-filter button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-wk="night"] .cat-filter button.on { color: #10131a; }

.cat-block { margin-bottom: 30px; }
.cat-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.cat-title h3 { font-size: 16px; }
.cat-title span { color: var(--t3); font-size: 12.5px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; }
.icard {
  position: relative; padding: 16px 16px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r); cursor: pointer;
  transition: .18s; display: flex; flex-direction: column; gap: 8px; min-height: 132px;
}
.icard:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line2); }
.icard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.icard h4 { font-size: 15px; font-weight: 640; }
.icard p { color: var(--t3); font-size: 12.8px; line-height: 1.6; flex: 1; }
.icard .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line2); flex: none; }
.icard[data-mastery="1"] .dot { background: var(--warn); }
.icard[data-mastery="2"] .dot { background: var(--down); }
.icard .pct { font-size: 11.5px; color: var(--t3); }

.note-band { margin-top: 26px; padding: 18px 20px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); }
.note-band b { font-size: 13.5px; }
.note-band p { color: var(--t3); font-size: 13px; margin-top: 6px; }

/* 详情 */
.detail-layout { display: grid; grid-template-columns: 216px minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.side-nav { position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow: auto; padding-right: 4px; }
.side-nav .group { margin-bottom: 14px; }
.side-nav .gtitle { font-size: 11.5px; color: var(--t3); letter-spacing: .06em; padding: 4px 10px; }
.side-nav a { display: block; padding: 6px 10px; border-radius: 7px; font-size: 13.5px; color: var(--t2); }
.side-nav a:hover { background: var(--panel3); color: var(--t1); }
.side-nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.detail-main { min-width: 0; }
.d-head { margin-bottom: 14px; }
.crumb { font-size: 12.5px; color: var(--t3); margin-bottom: 6px; }
.d-head h1 { font-size: 24px; line-height: 1.3; }
.d-head .tag { color: var(--t2); font-size: 14px; margin-top: 8px; }
.d-meta { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--panel3); color: var(--t3); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.chart-toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chart-toolbar select, .chart-toolbar input[type="range"] { accent-color: var(--accent); }
.chart-toolbar select {
  height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line2);
  background: var(--panel); color: var(--t1); font-size: 13px; outline: none; max-width: 180px;
}
.chart-title { padding: 12px 16px 0; font-size: 13px; color: var(--t3); }
.chart { width: 100%; height: 430px; max-width: 100%; overflow: hidden; }
.chart-foot { padding: 10px 16px 14px; font-size: 12.5px; color: var(--t3); border-top: 1px dashed var(--line); }

.param-bar { display: flex; gap: 16px; padding: 10px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.param { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--t3); }
.param input[type="range"] { width: 110px; }
.param b { color: var(--t1); font-weight: 600; min-width: 34px; display: inline-block; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.stat {
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.stat span { display: block; font-size: 11.5px; color: var(--t3); }
.stat b { font-size: 19px; font-weight: 680; letter-spacing: -.02em; }
.stat b.up { color: var(--up); }
.stat b.down { color: var(--down); }
.stat-note { font-size: 12.2px; color: var(--t3); line-height: 1.7; margin: -4px 0 16px; }

/* 右栏 */
.side-notes { position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.panel h4 { font-size: 13px; color: var(--t3); font-weight: 600; letter-spacing: .04em; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.panel h4::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--accent); }
.formula {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
  line-height: 1.9; white-space: pre-wrap; word-break: break-word;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; color: var(--t2);
}
.fnote { margin-top: 10px; display: grid; gap: 6px; }
.fnote div { font-size: 12.5px; color: var(--t3); display: flex; gap: 8px; }
.fnote b { color: var(--t2); font-weight: 600; flex: none; }

.mastery-row { display: flex; gap: 6px; }
.mastery-row button { flex: 1; padding: 7px 0; font-size: 12.5px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--t3); }
.mastery-row button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-wk="night"] .mastery-row button.on { color: #10131a; }

.note-area { width: 100%; min-height: 96px; resize: vertical; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel2); color: var(--t1); padding: 10px; font: inherit; font-size: 13px; outline: none; }
.note-area:focus { border-color: var(--accent); }

/* 正文块 */
.sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; margin-bottom: 14px; }
.sec h3 { font-size: 15.5px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.sec h3 .num { width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.sec p { color: var(--t2); font-size: 14.3px; line-height: 1.85; }
.sec p + p { margin-top: 10px; }

.sig-list, .fail-list { display: grid; gap: 8px; }
.sig { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 10px 12px; background: var(--panel2); border-radius: var(--r-sm); border: 1px solid transparent; }
.sig:hover { border-color: var(--line); }
.sig b { font-size: 13px; color: var(--t1); }
.sig span { font-size: 13px; color: var(--t3); }
.sig em { font-style: normal; color: var(--t2); display: block; font-size: 13px; }

.fail { padding: 12px 14px; border-left: 3px solid var(--warn); background: var(--panel2); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.fail b { display: block; font-size: 13.5px; color: var(--t1); margin-bottom: 4px; }
.fail p { font-size: 13.2px; color: var(--t3); line-height: 1.75; }

.p-table { width: 100%; border-collapse: collapse; font-size: 13.2px; }
.p-table th { text-align: left; color: var(--t3); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.p-table td { padding: 8px; border-bottom: 1px solid var(--line); color: var(--t2); vertical-align: top; }
.p-table td:first-child { color: var(--t1); font-weight: 600; white-space: nowrap; }
.p-table tr:last-child td { border-bottom: 0; }

.quiz { display: grid; gap: 14px; }
.q { padding: 14px 16px; background: var(--panel2); border-radius: var(--r-sm); }
.q > b { display: block; font-size: 13.8px; margin-bottom: 8px; }
.opt { display: block; width: 100%; text-align: left; padding: 8px 12px; margin-bottom: 6px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); font-size: 13.2px; color: var(--t2); transition: .14s; }
.opt:hover { border-color: var(--line2); }
.opt.right { border-color: var(--down); background: color-mix(in srgb, var(--down) 10%, transparent); color: var(--t1); }
.opt.wrong { border-color: var(--up); background: color-mix(in srgb, var(--up) 9%, transparent); }
.q .why { display: none; font-size: 12.8px; color: var(--t3); padding-top: 6px; border-top: 1px dashed var(--line); margin-top: 4px; }
.q.done .why { display: block; }

/* 实验室 */
.lab-head { margin-bottom: 16px; }
.lab-head h2 { font-size: 22px; margin-bottom: 8px; }
.lab-head p { color: var(--t3); font-size: 14px; max-width: 760px; }
.lab-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.lab-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.lab-panel .ph { font-size: 12.5px; color: var(--t3); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.lab-panel .ph i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.lab-panel select { width: 100%; height: 34px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel); color: var(--t1); padding: 0 10px; outline: none; margin-bottom: 10px; }
.lab-params { display: flex; flex-direction: column; gap: 8px; }

/* 闪卡 */
.cards-head { margin-bottom: 16px; }
.cards-head h2 { font-size: 22px; margin-bottom: 8px; }
.cards-head p { color: var(--t3); font-size: 14px; max-width: 720px; }
.flash-wrap { max-width: 760px; }
.flash-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 26px 26px 22px; }
.flash-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--t3); margin-bottom: 14px; }
.flash-q { font-size: 17px; font-weight: 600; line-height: 1.6; margin-bottom: 18px; }
.flash-opts { display: grid; gap: 8px; }
.flash-opts button { text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 14px; color: var(--t2); }
.flash-opts button:hover { border-color: var(--accent); }
.flash-opts button.right { border-color: var(--down); background: color-mix(in srgb, var(--down) 10%, transparent); }
.flash-opts button.wrong { border-color: var(--up); background: color-mix(in srgb, var(--up) 9%, transparent); }
.flash-explain { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--panel3); font-size: 13.5px; color: var(--t2); display: none; }
.flash-explain.on { display: block; }
.flash-foot { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; }
.btn { padding: 9px 18px; border-radius: 9px; border: 1px solid var(--line2); background: var(--panel); font-size: 13.5px; color: var(--t1); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-wk="night"] .btn.primary { color: #10131a; }
.btn.primary:hover { background: var(--accent2); color: #fff; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: var(--t1); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; z-index: 300; box-shadow: var(--shadow-lg);
}

/* 响应式 */
@media (max-width: 1240px) {
  .detail-layout { grid-template-columns: 196px minmax(0, 1fr) 300px; }
  .stat-row { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 980px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1080px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .side-nav { display: none; }
  .chart { height: 380px; }
}
@media (max-width: 860px) {
  main { padding: 56px 14px 96px; }
  .bar-inner { padding: 0 14px; gap: 10px; }
  .tabs { display: none; }
  .detail-layout { grid-template-columns: 1fr; }
  .side-notes { position: static; max-height: none; }
  .hero { grid-template-columns: 1fr; padding: 24px 20px; }
  .hero-ring { display: none; }
  .hero h1 { font-size: 21px; }
  .chart { height: 320px; }
  .lab-controls { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .icard { min-height: 118px; padding: 13px; }
  .icard p { font-size: 12.2px; }
  .sig { grid-template-columns: 1fr; gap: 4px; }
  .sec { padding: 16px; }
  .flash-card { padding: 20px 16px; border-radius: 14px; }
  .flash-q { font-size: 15.5px; }
}
@media (max-width: 560px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .hero-stats { gap: 18px; }
  .hero-stats b { font-size: 19px; }
  .d-head h1 { font-size: 20px; }
  .chart { height: 290px; }
  .chart-toolbar { gap: 8px; }
  .chart-toolbar select { max-width: 130px; }
  .param input[type="range"] { width: 78px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* 窄屏防溢出 */
.detail-layout > * { min-width: 0; }
.chart-toolbar, .param-bar, .stat-row { min-width: 0; }
.p-table { table-layout: fixed; width: 100%; }
.p-table td:first-child { white-space: normal; }
.formula { overflow-wrap: anywhere; }
.pill { max-width: 100%; white-space: normal; }
.chart-toolbar select { min-width: 0; }
.param { min-width: 0; }
.param input[type="range"] { min-width: 0; }

@media (max-width: 860px) {
  .chart-toolbar select { max-width: 100%; flex: 1 1 160px; }
  #rangeInfo { font-size: 11.5px; line-height: 1.5; }
}

/* 行业轮动矩阵 */
.d-extra:empty { display: none; }
.sector-grid { padding: 14px 16px 18px; }
.sector-row {
  display: grid; grid-template-columns: minmax(96px, 0.85fr) 86px 86px minmax(120px, 1.7fr);
  align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line);
}
.sector-row:last-of-type { border-bottom: 0; }
.sector-row .sn { font-size: 13.5px; color: var(--t1); display: flex; align-items: center; gap: 6px; }
.sector-row .sn i { font-style: normal; font-size: 11px; color: var(--t3); }
.sector-row b { font-size: 13.5px; font-weight: 650; text-align: right; }
.sector-row .bar { height: 7px; background: var(--panel3); border-radius: 4px; overflow: hidden; position: relative; }
.sector-row .bar i { display: block; height: 100%; border-radius: 4px; }
.sector-row .bar i.up { background: var(--up); }
.sector-row .bar i.down { background: var(--down); }
.sector-key {
  display: grid; grid-template-columns: minmax(96px, 0.85fr) 86px 86px minmax(120px, 1.7fr);
  gap: 10px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line2);
}
.sector-key span { font-size: 11.5px; color: var(--t3); }
.sector-key span:nth-child(2), .sector-key span:nth-child(3) { text-align: right; }

/* 龙虎榜候选 */
.dragon-list { padding: 10px 16px 16px; }
.dl-head, .dl-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.dl-head { color: var(--t3); font-size: 11.5px; border-bottom-color: var(--line2); }
.dl-row b { font-weight: 650; }
.dl-row span:last-child, .dl-head span:last-child { text-align: right; }
.dl-row b { text-align: right; }
.d-extra { border-top: 1px dashed var(--line); }
.d-extra:empty { border-top: 0; }
.cards-head, .flash-wrap { max-width: 760px; margin-left: auto; margin-right: auto; }
.cards-head { max-width: 760px; }
