/* 哆啦A梦的云口袋 · AI 量化系统 — dark terminal theme */
:root {
  color-scheme: dark;
  --bg: #0b0e12;
  --surface-1: #12161c;
  --surface-2: #181d25;
  --border: #232a34;
  --border-strong: #2f3845;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8b8f98;
  --grid: #222831;
  --series-btc: #3987e5;   /* categorical slot 1 (dark) */
  --series-eth: #d95926;   /* categorical slot 2 (dark) */
  --good: #0ca30c;
  --good-text: #4cc54c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-text: #f07070;
  --accent: #3987e5;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(57,135,229,.08), transparent 60%),
    var(--bg);
  color: var(--text-primary);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, p { margin: 0; }
.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-muted); font-size: 13px; font-weight: 400; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* Demo banner */
.demo-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px;
  padding: 9px 16px; text-align: center;
  background: repeating-linear-gradient(135deg, rgba(250,178,25,.10) 0 12px, rgba(250,178,25,.04) 12px 24px);
  border-bottom: 1px solid rgba(250,178,25,.35);
  font-size: 14px;
}
.demo-banner strong { color: var(--warning); letter-spacing: .02em; }
.demo-banner__tag {
  font: 700 11px/1 var(--mono); letter-spacing: .12em;
  background: var(--warning); color: #1a1405; padding: 4px 7px; border-radius: 4px;
}
.demo-banner__sub { color: var(--text-secondary); font-size: 13px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: rgba(11,14,18,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__logo { width: 38px; height: 38px; flex: none; }
.brand__name { font-size: 18px; font-weight: 650; letter-spacing: .01em; }
.brand__dot { color: var(--text-muted); }
.brand__sub { color: var(--text-muted); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.header-meta { display: flex; align-items: center; gap: 12px; }
.clock { font: 500 13px var(--mono); color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.chip--ghost { border: 1px solid var(--border-strong); color: var(--text-secondary); }

.pill {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 550;
  border: 1px solid;
}
.pill__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill--warn { color: var(--warning); border-color: rgba(250,178,25,.4); background: rgba(250,178,25,.08); }
.pill--warn .pill__dot { animation: pulse 2s ease-in-out infinite; }
.pill--idle { color: var(--text-secondary); border-color: var(--border-strong); background: var(--surface-2); }
.pill--live { color: var(--good-text); border-color: rgba(76,197,76,.45); background: rgba(12,163,12,.10); }
.pill--live .pill__dot { box-shadow: 0 0 0 0 rgba(76,197,76,.6); animation: ping 2s ease-out infinite; }
.pill--pending { color: var(--text-secondary); border-color: var(--border-strong); background: var(--surface-2); }
.pill--pending .pill__dot { animation: pulse 1.2s ease-in-out infinite; }
.pill--down { color: var(--critical-text); border-color: rgba(240,112,112,.45); background: rgba(208,59,59,.10); }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(76,197,76,.55); } 80%, 100% { box-shadow: 0 0 0 6px rgba(76,197,76,0); } }

/* Live (real) data markers — green, solid border; contrasts with dashed amber DEMO tags */
.live-tag {
  display: inline-flex; align-items: center; gap: 6px; font: 600 11px/1.4 var(--sans); letter-spacing: .04em;
  color: var(--good-text); border: 1px solid rgba(76,197,76,.5); background: rgba(12,163,12,.08);
  padding: 1px 8px; border-radius: 4px;
}
.live-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.live-tag--stale { color: var(--warning); border-color: rgba(250,178,25,.5); background: rgba(250,178,25,.08); }
.live-tag--demo { color: var(--warning); border: 1px dashed rgba(250,178,25,.55); background: transparent; }
.live-tag--demo::before { display: none; }

.card--live { border-color: rgba(76,197,76,.22); background: linear-gradient(180deg, rgba(12,163,12,.04), transparent 70%), var(--surface-1); }
.feed-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.feed-time { font: 12px var(--mono); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.feed-alert {
  margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  color: var(--warning); background: rgba(250,178,25,.08); border: 1px solid rgba(250,178,25,.35);
}
.feed-alert strong { color: var(--critical-text); margin-right: 6px; }

.tickers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ticker {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  transition: border-color .4s;
}
.ticker__sym { font: 600 13px var(--mono); color: var(--text-secondary); }
.ticker__sym::after { content: "-PERP"; color: var(--text-muted); font-weight: 400; }
.ticker__chg { font: 500 12px var(--mono); color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.ticker__px { grid-column: 1 / -1; font: 600 22px/1.3 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ticker.flash-up { border-color: rgba(76,197,76,.6); }
.ticker.flash-down { border-color: rgba(240,112,112,.6); }
.ticker.is-stale .ticker__px { color: var(--text-muted); }
.note--top { margin: -4px 0 12px; }

/* Sections */
main { padding: 24px 0 40px; display: grid; gap: 20px; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section__head h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; }
.grid-2 > .card:only-child { grid-column: 1 / -1; }

.demo-tag {
  display: inline-block; font: 600 11px/1.4 var(--sans); letter-spacing: .04em;
  color: var(--warning); border: 1px dashed rgba(250,178,25,.55); padding: 1px 7px; border-radius: 4px;
}
.demo-tag--sm { font-size: 10px; padding: 0 5px; margin-left: 4px; vertical-align: 1px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi__label { color: var(--text-secondary); font-size: 13px; }
.kpi__value { font: 600 26px/1.3 var(--mono); font-variant-numeric: tabular-nums; margin: 6px 0 4px; letter-spacing: -.01em; }
.kpi__foot { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.meter__fill { display: block; height: 100%; background: var(--serious); border-radius: 3px; }
.up { color: var(--good-text); }
.down { color: var(--critical-text); }

/* Tabs */
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.tab {
  appearance: none; border: 0; background: transparent; color: var(--text-secondary);
  font: 600 12px var(--mono); padding: 6px 12px; border-radius: 6px; cursor: pointer; min-height: 32px;
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] { background: var(--border-strong); color: var(--text-primary); }

/* Chart */
.quote { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.quote__sym { font: 600 13px var(--mono); color: var(--text-secondary); }
.quote__px { font: 600 24px var(--mono); font-variant-numeric: tabular-nums; }
.quote__chg { font: 500 14px var(--mono); font-variant-numeric: tabular-nums; }
.quote__note { color: var(--text-muted); font-size: 12px; margin-left: auto; }
.chart { position: relative; height: 280px; touch-action: pan-y; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-label { fill: var(--text-muted); font: 11px var(--mono); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--surface-1); stroke-width: 2; }
.chart__tip {
  position: absolute; top: 8px; pointer-events: none; z-index: 2;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 6px 10px; font: 12px/1.5 var(--mono); color: var(--text-primary); white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.chart__tip .t { color: var(--text-muted); }
.chart__foot { color: var(--text-muted); font-size: 12px; margin-top: 8px; }

/* Strategy */
.kv, .params { margin: 0; display: grid; gap: 10px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.kv dt { color: var(--text-muted); font-size: 13px; }
.kv dd { margin: 0; text-align: right; font-size: 14px; }
.sub { font-size: 14px; font-weight: 600; margin: 18px 0 10px; }
.params { grid-template-columns: 1fr 1fr; }
.params div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.params dt { color: var(--text-muted); font-size: 12px; }
.params dd { margin: 2px 0 0; font: 500 14px var(--mono); }
.note { margin-top: 14px; font-size: 12px; color: var(--text-muted); border-left: 2px solid var(--border-strong); padding-left: 10px; }

/* Table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.table th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.side { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.side--long { color: var(--good-text); background: rgba(12,163,12,.12); }
.side--short { color: var(--critical-text); background: rgba(208,59,59,.12); }
.sym { font-family: var(--mono); font-weight: 600; }
.sym small { color: var(--warning); font: 600 10px var(--sans); margin-left: 6px; }

/* Risk rules */
.rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.rule { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: start; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.rule__icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; font-size: 15px; }
.rule__icon--crit { color: var(--critical-text); background: rgba(208,59,59,.14); }
.rule__icon--warn { color: var(--warning); background: rgba(250,178,25,.12); }
.rule__icon--info { background: rgba(57,135,229,.14); }
.rule__name { font-weight: 600; font-size: 14px; }
.rule__desc { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.rule__val { font: 600 13px var(--mono); color: var(--text-primary); white-space: nowrap; padding-top: 6px; }
.rule--key { border-color: rgba(57,135,229,.4); }

/* Steps */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 32px 1fr; gap: 14px; position: relative; padding-bottom: 20px; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--border-strong); border-radius: 1px; }
.step--done:not(:last-child)::after { background: linear-gradient(var(--good), var(--border-strong)); }
.step__mark { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 600 13px var(--mono); }
.step--done .step__mark { background: var(--good); color: #fff; }
.step--pending .step__mark { border: 2px dashed var(--border-strong); color: var(--text-muted); }
.step__name { font-weight: 600; }
.step__desc { color: var(--text-secondary); font-size: 13px; margin: 2px 0 6px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.badge--done { color: var(--good-text); background: rgba(12,163,12,.14); }
.badge--done::before { content: "● "; }
.badge--pending { color: var(--warning); background: rgba(250,178,25,.10); }
.badge--pending::before { content: "○ "; }

/* Log */
.log { list-style: none; margin: 0; padding: 0; font: 13px/1.5 var(--mono); max-height: 280px; overflow-y: auto; }
.log li { display: grid; grid-template-columns: 76px 64px 1fr; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.log li.new { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(57,135,229,.12); } to { background: transparent; } }
.log time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.lv { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.lv--info { color: var(--accent); }
.lv--warn { color: var(--warning); }
.lv--ok { color: var(--good-text); }
.log .msg { color: var(--text-secondary); font-family: var(--sans); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0 36px; }
.site-footer .wrap { display: grid; gap: 8px; }
.disclaimer { color: var(--text-secondary); font-size: 13px; padding: 12px 14px; border: 1px solid rgba(208,59,59,.35); background: rgba(208,59,59,.06); border-radius: 8px; }
.disclaimer strong { color: var(--critical-text); }

/* Responsive */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .tickers { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .wrap { width: calc(100% - 24px); }
  .card { padding: 16px; }
  .kpis { gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi__value { font-size: 20px; }
  .tickers { gap: 8px; }
  .ticker { padding: 10px 12px; }
  .ticker__px { font-size: 18px; }
  .header-meta { flex-wrap: wrap; gap: 8px; }
  .brand__name { font-size: 16px; }
  .site-header { position: static; }
  .chart { height: 220px; }
  .quote__note { margin-left: 0; width: 100%; }
  .params { grid-template-columns: 1fr; }
  .rule { grid-template-columns: 32px 1fr; }
  .rule__val { grid-column: 2; padding-top: 0; }
  .log li { grid-template-columns: 64px 1fr; }
  .log .msg { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .chart .line { stroke: CanvasText; }
  .demo-tag, .live-tag, .pill, .ticker { border: 1px solid CanvasText; }
}
