/* TraderOS 乾元·玄衡 v2 companion；同时锁定主题与路由。 */

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] {
  color-scheme: dark;
  --xc-bg: #081218;
  --xc-surface: #101f27;
  --xc-raised: #172a33;
  --xc-border: #30444d;
  --xc-text: #f3efe4;
  --xc-text-2: #c6cecc;
  --xc-text-3: #9eaaac;
  --xc-metal: #c8b071;
  --xc-metal-bright: #dcc98f;
  --xc-water: #6fa5b9;
  --xc-up: #ff5a5f;
  --xc-down: #22b573;
  --xc-warning: #ffb547;
  --xc-blocked: #c9a8ff;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--xc-text);
  background: radial-gradient(circle at 100% 0, rgb(66 122 149 / 20%), transparent 22rem), linear-gradient(160deg, var(--xc-bg), #0c1920);
  font: 14px/1.55 "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] *,
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] *::before,
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] *::after { box-sizing: border-box; }

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"]::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image: linear-gradient(rgb(200 176 113 / 4%) 1px, transparent 1px), linear-gradient(90deg, rgb(200 176 113 / 4%) 1px, transparent 1px);
  background-size: 48px 48px;
}

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] > header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  color: var(--xc-text);
  background: rgb(8 18 24 / 96%);
  border-bottom: 1px solid rgb(200 176 113 / 70%);
  box-shadow: 0 9px 26px rgb(0 0 0 / 24%);
  backdrop-filter: blur(14px);
}

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] > header::before {
  width: 40px;
  height: 40px;
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  content: "乾";
  color: var(--xc-metal-bright);
  background: #0c1920;
  border: 1px solid rgb(200 176 113 / 72%);
  border-radius: 50%;
  font: 600 16px/1 "STKaiti", "KaiTi", serif;
}

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] > header strong,
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] > header span { display: block; grid-column: 2; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] > header strong { font-size: 17px; letter-spacing: .04em; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] > header span { margin: 3px 0 0; color: var(--xc-metal); font-size: 14px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] main { width: min(760px, 100%); margin: 0 auto; padding: 12px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] section { margin-bottom: 12px; }

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .status { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 12px; color: var(--xc-text); background: var(--xc-surface); border: 1px solid var(--xc-border); border-radius: 9px 9px 0 0; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .status b { color: var(--xc-metal-bright); font-size: 14px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .status span { color: var(--xc-text-3); font-size: 14px; text-align: right; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .identity { display: grid; gap: 7px; padding: 10px 12px; color: var(--xc-text-2); background: #0c1a21; border: 1px solid var(--xc-border); border-top: 0; border-radius: 0 0 9px 9px; font-size: 14px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .identity span { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 7px; align-items: start; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .identity code { color: #b5c8cf; font: 14px/1.55 "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .layer-summary,
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .copy-feedback { margin: 0 0 12px; padding: 10px 12px; color: var(--xc-text-2); background: var(--xc-surface); border: 1px solid var(--xc-border); border-radius: 8px; font-size: 14px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .copy-feedback[data-kind="success"] { color: #b7d8ff; border-color: #4c82b1; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .copy-feedback[data-kind="warning"] { color: #ffe0a1; border-color: #947231; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .copy-feedback[data-kind="danger"] { color: #eadcff; border-color: #7e5ead; }

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] h1 { margin: 0; padding: 11px 12px; color: var(--xc-text); background: linear-gradient(90deg, rgb(200 176 113 / 9%), transparent), var(--xc-raised); border: 1px solid var(--xc-border); border-bottom: 0; border-radius: 9px 9px 0 0; font-size: 16px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .list { overflow: hidden; display: grid; gap: 1px; background: var(--xc-border); border: 1px solid var(--xc-border); border-radius: 0 0 9px 9px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] button { width: 100%; min-height: 52px; display: grid; grid-template-columns: 82px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px 11px; color: var(--xc-text); background: var(--xc-surface); border: 0; border-left: 2px solid transparent; font: inherit; text-align: left; cursor: pointer; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] button:hover { background: #18303a; border-left-color: var(--xc-water); }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] button:focus-visible { position: relative; z-index: 2; outline: 2px solid var(--xc-metal-bright); outline-offset: -2px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] button b { color: var(--xc-metal-bright); font: 14px/1.5 "Cascadia Mono", Consolas, monospace; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] button span { min-width: 0; color: var(--xc-text); font-size: 14px; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] button small { color: var(--xc-text-3); font-size: 14px; text-align: right; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .list p { margin: 0; padding: 20px; color: var(--xc-text-3); background: var(--xc-surface); font-size: 14px; text-align: center; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] > footer { padding: 14px; color: var(--xc-text-3); background: #09151b; border-top: 1px solid var(--xc-border); font-size: 14px; text-align: center; }

html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .market-up,
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] [data-market-move="up"] { color: var(--xc-up) !important; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .market-down,
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] [data-market-move="down"] { color: var(--xc-down) !important; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .semantic-warning { color: var(--xc-warning) !important; }
html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .semantic-blocked { color: var(--xc-blocked) !important; }

@media (max-width: 520px) {
  html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] main { padding: 9px; }
  html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] button { grid-template-columns: 76px minmax(0, 1fr); }
  html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] button small { grid-column: 2; text-align: left; }
  html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .status { align-items: flex-start; flex-direction: column; }
  html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] .status span { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] *,
  html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] *::before,
  html[data-tr-theme="xuanheng-qianyuan"] body[data-tr-route="companion"] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
