/* 灵境 OZON · 购买页（深色玻璃版，只换皮）。依赖 dark.css（先加载）。
   buy.js / buy-a11y.js 不改：这里给静态的 #by* 结构与运行时生成的 .by-plan* / .by-rec / .by-loading / .by-msg /
   .by-amount / .by-poll / .is-pulse / .is-empty 写样式。可读性优先：表单与金额用实底面，不用大面积玻璃与发光。
   二维码始终放在白底卡片上（手机才扫得出）。字号只用 --fs-* 令牌或 em。 */

/* 旧令牌别名（旧版脚本与第三方嵌入可能还在读） */
:root {
  --bg-0: var(--bg);
  --fg-0: var(--fg);
  --brand: var(--blue);
  --line-1: var(--line);
}

/* ---------- 旧按钮名兼容层（.hg-btn） ---------- */
.hg-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: transparent; color: var(--fg);
  font-size: var(--fs-sm); font-weight: 550;
  transition: color var(--dur-1);
}
.hg-btn:hover { color: #fff; }
.hg-btn--solid { background: var(--grad); color: var(--on-grad); border-color: transparent; }
.hg-btn--ghost { border-color: transparent; color: var(--fg-2); }
.ico--back { width: 16px; height: 16px; transform: rotate(180deg); }
.by-back { margin-right: -14px; }
@media (pointer: coarse) {
  .hg-btn.by-back { min-height: 44px; }
}

/* ---------- 页头 ---------- */
.by-top { position: relative; border-bottom: 1px solid var(--line); background: rgba(5, 7, 13, 0.9); }
.by-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--grad-line); }
.by-top__bar { display: flex; align-items: center; justify-content: space-between; min-height: var(--nav-h); }

/* ---------- 主体 ---------- */
.page--buy { background: radial-gradient(60% 40% at 85% 0%, rgba(91, 140, 255, 0.12), transparent 70%) no-repeat, var(--bg); }
.by-main { min-height: calc(100vh - var(--nav-h)); padding-top: var(--sp-6); padding-bottom: var(--sp-8); }

/* 三格步骤尺 */
.by-steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 640px; margin-bottom: var(--sp-6);
  border-top: 1px solid var(--line-2);
}
.by-step {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 14px 8px 0 0;
  color: var(--fg-3); font-size: var(--fs-sm); font-weight: 600;
}
.by-step::before {
  content: ""; position: absolute; left: 0; right: 0; top: -2px; height: 3px; border-radius: 2px;
  background: var(--grad);
  transform: scaleX(0); transform-origin: 0 50%;
  transition: transform var(--dur-3) var(--ease-io);
}
.by-step.is-on, .by-step.is-done { color: var(--fg); }
.by-step.is-on::before, .by-step.is-done::before { transform: none; }
.by-step.is-done::before { opacity: 0.45; }
.by-step__mark {
  position: relative; display: inline-grid; place-items: center;
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 1px solid var(--line-2); border-radius: 50%;
}
.by-step__num { font-variant-numeric: tabular-nums; font-size: var(--fs-xs); font-weight: 700; }
.by-step__check { position: absolute; width: 14px; height: 14px; opacity: 0; }
.by-step__check path { stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.by-step.is-on .by-step__mark { background: var(--grad); border-color: transparent; color: var(--on-grad); }
.by-step.is-done .by-step__mark { border-color: rgba(75, 227, 176, 0.5); color: var(--ok); }
.by-step.is-done .by-step__num { opacity: 0; }
.by-step.is-done .by-step__check { opacity: 1; }

/* 双栏：左流程，右摘要。摘要在 DOM 里排在流程前面（手机上它就在顶部，Tab 顺序 = 视觉顺序），
   ≥900 用网格把它放进右栏，不再用 order 倒序。 */
.by-shell { display: grid; gap: var(--sp-5); }
@media (min-width: 900px) {
  .by-shell { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-7); align-items: start; }
  .by-flow { grid-column: 1; grid-row: 1; }
  .by-side { grid-column: 2; grid-row: 1; position: -webkit-sticky; position: sticky; top: var(--sp-5); }
}
@media (min-width: 1100px) {
  .by-shell { grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); column-gap: var(--sp-8); }
  .by-steps { max-width: none; }
}

.by-panel { display: grid; gap: var(--sp-4); align-content: start; }
.by-panel--center { justify-items: start; }
.by-h1 {
  font-family: var(--font-head); font-weight: 700; font-synthesis: none;
  font-size: var(--fs-note); line-height: 1.2; letter-spacing: -0.02em;
  color: var(--fg);
}
.by-lead { color: var(--fg-2); font-size: var(--fs-md); line-height: 1.75; max-width: 34em; }

/* ---------- 套餐单选组（buy.js 运行时生成） ---------- */
/* R3-12：卡面与价格页票据同一套（玻璃底 + 细线，推荐档渐变描边，选中档最强）。
   /api/plans 回来之前就按加载完的最大高度占好位（CLS ≈ 0），数值用 r1/fix-pages/sweep.mjs 实测：
   <600 = 一张展开 + 三行收起；600–1099 = 两列两行（竖排卡）；≥1100 = 两列两行（价格在左、条款在右的横排卡）。 */
.by-plans { display: grid; gap: 10px; margin-top: var(--sp-2); min-height: 340px; align-content: start; }
/* 代理只卖其中几档（R5-12）：不再按四张卡留高，免得卡片和表单之间空一大块 */
.by-plans[data-count="1"], .by-plans[data-count="2"], .by-plans[data-count="3"] { min-height: 0; }
@media (min-width: 600px) {
  .by-plans { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-height: 384px; }
}
@media (min-width: 1100px) {
  .by-plans { min-height: 272px; }
}
/* 读取中 / 读取失败：占满预留区的一块虚线托盘，不是一行孤零零的字 */
.by-loading {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center;
  min-height: 340px; padding: var(--sp-4);
  border: 1px dashed var(--line-2); border-radius: var(--r);
  color: var(--fg-2); text-align: center;
}
@media (min-width: 600px) {
  .by-loading { min-height: 384px; }
}
@media (min-width: 1100px) {
  .by-loading { min-height: 272px; }
}
.by-plan {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name tick" "price price" "term term" "per per" "save save";
  align-items: baseline; row-gap: 0;
  padding: 16px 18px 14px 20px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--glass);
  color: var(--fg); font-family: inherit; text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-1), transform var(--dur-1) var(--ease);
}
.by-plan:not(.is-on):not(.is-rec):hover { border-color: var(--line-2); }
.by-plan:active { transform: translateY(1px); }
/* 推荐档（季卡）未选中：柔和的渐变描边，无外发光 */
.by-plan.is-rec:not(.is-on) {
  border-color: transparent;
  background: linear-gradient(180deg, #0f1629, #0a0f1d) padding-box,
    linear-gradient(135deg, rgba(116, 232, 255, 0.5), rgba(91, 140, 255, 0.32) 50%, rgba(164, 125, 255, 0.5)) border-box;
}
/* 选中档：满色渐变描边 + 外发光，永远最强 */
.by-plan.is-on {
  border-color: transparent;
  background: linear-gradient(180deg, #141d38, #0c1124) padding-box, var(--grad) border-box;
  box-shadow: var(--sh-glow);
}
.by-plan:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.by-rec {
  position: absolute; right: 50px; top: 15px;
  padding: 1px 9px; border-radius: var(--r-pill);
  background: var(--grad); color: var(--on-grad);
  font-size: var(--fs-xs); font-weight: 700; line-height: 1.6;
}
.by-plan:not(.is-on) .by-rec { background: rgba(116, 232, 255, 0.12); color: var(--cyan); box-shadow: inset 0 0 0 1px rgba(116, 232, 255, 0.35); }
.by-plan-tick {
  grid-area: tick; align-self: center; display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--fg-3);
  transition: background-color var(--dur-1), border-color var(--dur-1);
}
.by-plan-tick svg { width: 12px; height: 12px; opacity: 0; }
.by-plan-tick path { stroke: var(--on-grad); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.by-plan:hover .by-plan-tick { border-color: var(--cyan); }
.by-plan.is-on .by-plan-tick { background: var(--cyan); border-color: var(--cyan); }
.by-plan.is-on .by-plan-tick svg { opacity: 1; }
.by-plan-name { grid-area: name; font-weight: 650; color: var(--fg); line-height: 1.5; }
.by-plan:not(.is-on) .by-plan-name { color: var(--fg-2); }
.by-plan-price { grid-area: price; margin-top: 4px; font-size: var(--fs-price); font-weight: 700; line-height: 1.05; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.by-plan-price i { font-style: normal; font-size: 0.5em; color: var(--fg-2); vertical-align: 0.6em; margin-right: 3px; }
.by-plan-term, .by-plan-per, .by-plan-save { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); line-height: 1.55; color: var(--fg-2); }
.by-plan-term { grid-area: term; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.by-plan-per { grid-area: per; }
.by-plan-per b { font-weight: 650; color: var(--fg); }
.by-plan-save { grid-area: save; color: var(--ok); }

/* ≥1100：横排票据，价格在左，时长 / 折合每月 / 省额在右侧竖线后，整卡矮一半，去付款回到首屏 */
@media (min-width: 1100px) {
  .by-plan {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "name name tick" "price term term" "price per per" "price save save";
    grid-template-rows: auto auto auto 1fr;
    column-gap: 18px; padding: 16px 18px 16px 22px;
  }
  .by-plan-price { align-self: center; margin-top: 8px; font-size: 2.125em; }
  .by-plan-save { white-space: nowrap; }
  .by-plan-term { margin-top: 10px; padding-top: 0; border-top: 0; }
  .by-plan-term, .by-plan-per, .by-plan-save { padding-left: 16px; border-left: 1px solid var(--line); }
}

@media (min-width: 1280px) {
  .by-plan-price { font-size: 2.5em; }
}

/* <600：没选中的套餐收成一行（名称 + 天数 | 价格 | 圈），只有选中的那张多出「折合每月 / 省额」一行；
   推荐签进网格，不再浮在角上。 */
@media (max-width: 599px) {
  .by-plan {
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: "name rec . price tick" "term term . price tick" "more more more more more";
    align-items: center; column-gap: 10px;
    padding: 12px 16px 12px 18px;
  }
  .by-rec { position: static; grid-area: rec; justify-self: start; }
  .by-plan-name { line-height: 1.45; }
  .by-plan-price { margin-top: 0; font-size: var(--fs-price-row); padding-right: 4px; }
  .by-plan-term { margin-top: 0; padding-top: 0; border-top: 0; font-size: var(--fs-xs); color: var(--fg-3); }
  /* 折合每月与省额同处一格：左右分开，上面一条整宽细线 */
  .by-plan-per, .by-plan-save { grid-area: more; margin-top: 8px; padding-top: 8px; }
  .by-plan-per { border-top: 1px solid var(--line); }
  .by-plan-save { justify-self: end; }
  .by-plan:not(.is-on) .by-plan-per, .by-plan:not(.is-on) .by-plan-save { display: none; }
}

/* 手机：页顶留白收一档，选好套餐后联系方式落在首屏内 */
@media (max-width: 599px) {
  .by-main { padding-top: var(--sp-5); }
  .by-steps { margin-bottom: var(--sp-5); }
  .by-shell { gap: var(--sp-4); }
}

/* ---------- 表单 ---------- */
.by-form { display: grid; gap: var(--sp-3); margin-top: var(--sp-3); max-width: 560px; }
.by-field { display: grid; gap: 8px; }
.by-field > span { font-size: var(--fs-sm); font-weight: 600; color: var(--fg); }
.by-field input {
  min-height: 52px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: #0c1222; color: var(--fg);
  font: inherit; font-size: var(--fs-base);
  transition: border-color var(--dur-1);
}
.by-field input::placeholder { color: var(--fg-3); opacity: 1; }
.by-field input:hover { border-color: rgba(150, 172, 255, 0.4); }
.by-field input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; border-color: transparent; }
.by-field small { color: var(--fg-3); font-size: var(--fs-sm); line-height: 1.65; }
.by-submit {
  position: relative; justify-self: start;
  min-height: 56px; min-width: 220px; padding: 0 32px;
  border: 1px solid transparent; border-radius: 12px;
  background: var(--grad); color: var(--on-grad);
  font: inherit; font-size: var(--fs-base); font-weight: 700; letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease), opacity var(--dur-1);
}
.by-submit:not(:disabled):hover { transform: translateY(-1px); }
.by-submit:active { transform: translateY(1px); }
/* 还没选好：空心虚线，不是一块发灰的渐变 */
.by-submit:disabled { background: transparent; border: 1px dashed var(--line-2); color: var(--fg-3); cursor: not-allowed; transform: none; }
@media (max-width: 599px) {
  .by-submit { justify-self: stretch; }
}
.by-msg { min-height: 1.6em; font-size: var(--fs-sm); color: var(--fg-2); }
.by-msg.is-warn { color: var(--warn); }
.by-msg.is-error { color: var(--bad); }

/* ---------- 付款：二维码在白底卡片上 ---------- */
.by-pay { display: grid; gap: var(--sp-4); justify-items: start; }
.by-qr-wrap {
  position: relative; display: grid; justify-items: center; gap: 12px;
  padding: 40px 28px 22px; border-radius: var(--r-md);
  background: #ffffff; color: #1d2433;
  box-shadow: 0 0 0 1px rgba(150, 172, 255, 0.25), var(--sh-glow);
}
.by-qr-label { position: absolute; left: 16px; top: 12px; color: #1a7f46; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; }
#byQr { width: 240px; height: 240px; max-width: 100%; image-rendering: pixelated; }
.by-qr-hint { font-size: var(--fs-sm); color: #3b4458; text-align: center; max-width: 240px; overflow-wrap: anywhere; }
.by-qr-hint code { font-size: var(--fs-xs); }
.by-poll { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; color: var(--fg-2); }
.by-poll::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.js-motion .by-poll::before { animation: by-blink 1.6s var(--ease-io) infinite; }
@keyframes by-blink { 50% { opacity: 0.25; } }
.by-poll.is-error { color: var(--bad); }
.by-poll.is-error::before { background: var(--bad); box-shadow: none; animation: none; }
.by-link {
  min-height: 44px; padding: 0; border: 0; background: none;
  color: var(--fg-2); font: inherit; font-size: var(--fs-sm);
  text-decoration: underline; text-underline-offset: 4px; cursor: pointer;
}
.by-link:hover { color: var(--fg); }

/* ---------- 取码 ---------- */
.by-code-box {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
  padding: 20px; border-radius: var(--r-md);
  border: 1px solid transparent;
  background: linear-gradient(180deg, #121a33, #0b1022) padding-box, var(--grad) border-box;
  box-shadow: var(--sh-glow);
}
.by-code {
  flex: 1 1 260px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--fs-h3); font-weight: 600; letter-spacing: 0.06em;
  color: var(--fg); overflow-wrap: anywhere; user-select: all;
}
.by-copy {
  min-height: 44px; padding: 0 22px; border: 0; border-radius: var(--r-sm);
  background: var(--grad); color: var(--on-grad);
  font: inherit; font-weight: 700; cursor: pointer;
}
.by-copied {
  position: absolute; right: 16px; top: -13px;
  padding: 2px 10px; border-radius: var(--r-pill);
  background: var(--ok); color: #04130d;
  font-size: var(--fs-xs); font-weight: 700;
  opacity: 0; transform: translateY(4px);
  transition: opacity var(--dur-1), transform var(--dur-1) var(--ease);
}
.by-code-box.is-copied .by-copied { opacity: 1; transform: none; }
.by-next { display: grid; gap: 10px; counter-reset: by; color: var(--fg-2); }
.by-next li { position: relative; padding-left: 36px; counter-increment: by; line-height: 1.7; }
.by-next li::before {
  content: "0" counter(by); position: absolute; left: 0; top: 0.15em;
  font-variant-numeric: tabular-nums; font-size: var(--fs-sm); font-weight: 700; color: var(--cyan);
}
.by-legal { font-size: var(--fs-sm); color: var(--fg-3); line-height: 1.7; max-width: 36em; }

/* ---------- 订单摘要卡 ---------- */
.by-card {
  position: relative; display: grid; gap: 14px;
  padding: 22px 22px 18px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line-2);
}
.by-card::before { content: ""; position: absolute; left: 22px; right: 22px; top: -1px; height: 1px; background: var(--grad-edge); }
.by-card__label { font-size: var(--fs-xs); letter-spacing: 0.16em; color: var(--fg-3); font-weight: 600; }
.by-card__sel { display: grid; gap: 4px; padding-bottom: 14px; border-bottom: 1px dashed var(--line-2); }
.by-card__plan { font-weight: 700; color: var(--fg); }
.by-card__price { font-size: var(--fs-price); font-weight: 700; line-height: 1.05; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--fg); }
.by-card__price i { font-style: normal; font-size: 0.5em; color: var(--fg-2); vertical-align: 0.65em; margin-right: 3px; }
.js-motion .by-card__price.is-pulse { animation: by-pulse 0.4s var(--ease); }
@keyframes by-pulse { 40% { transform: scale(1.04); } }
/* 未选套餐的引导态（buy.js 切 .is-empty）：骨架字段原位隐身（高度不变，选中后不跳），
   上面叠一段提示。手机上摘要在流程上方，所以说「下方」。 */
.by-card__sel { position: relative; }
.by-card.is-empty .by-card__sel > * { visibility: hidden; }
.by-card.is-empty .by-card__sel::before,
.by-card.is-empty .by-card__sel::after { position: absolute; left: 0; right: 0; }
.by-card.is-empty .by-card__sel::before {
  content: "先在下方选一个套餐"; top: 6px;
  font-size: var(--fs-lead); font-weight: 700; line-height: 1.35; color: var(--fg);
}
.by-card.is-empty .by-card__sel::after {
  content: "每个套餐功能完全一致，差别在时长和能同时用的电脑台数。"; top: 48px;
  padding-left: 14px; border-left: 2px solid var(--cyan);
  font-size: var(--fs-sm); line-height: 1.7; color: var(--fg-2);
}
@media (min-width: 900px) {
  .by-card.is-empty .by-card__sel::before { content: "先在左侧选一个套餐"; }
}
.by-summary { display: grid; font-size: var(--fs-sm); }
.by-summary > div { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.by-summary > div:last-child { border-bottom: 0; }
.by-summary dt { color: var(--fg-3); }
.by-summary dd { font-variant-numeric: tabular-nums; text-align: right; color: var(--fg); overflow-wrap: anywhere; }
.by-summary code { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.02em; }
.by-amount { font-size: var(--fs-lead); font-weight: 700; }
.by-card__payway { padding-top: 4px; border-top: 1px solid var(--line-soft); }
.by-card__trust { display: grid; gap: 6px; font-size: var(--fs-sm); color: var(--fg-2); }
.by-card__trust li { display: flex; gap: 10px; align-items: baseline; }
.by-card__trust li::before { content: ""; flex: 0 0 6px; height: 6px; border-radius: 50%; background: var(--ok); transform: translateY(-2px); }

/* 手机：摘要在顶部，折叠成一行 */
.by-side__toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 52px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--panel); color: var(--fg);
  font: inherit; font-variant-numeric: tabular-nums; font-weight: 600; text-align: left;
  cursor: pointer;
}
.by-side__more { font-size: var(--fs-sm); color: var(--cyan); }
.by-side__toggle[aria-expanded="true"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
/* 折叠是 CSS 的默认态（boot.js 加上 .js 之后）：首帧就是一行摘要，buy-a11y.js 晚到也不会让下面整页上跳 */
@media (max-width: 899px) {
  .js .by-side__toggle[hidden] { display: flex !important; }
  .js .by-card { display: none; }
  .js .by-card.is-unfolded { display: grid; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
  .js .by-card.is-unfolded::before { display: none; }
}

/* ---------- 页脚 ---------- */
.by-foot { border-top: 1px solid var(--line); padding: var(--sp-5) 0 var(--sp-6); background: var(--bg-foot); font-size: var(--fs-sm); color: var(--fg-3); }
.by-foot__in { display: grid; gap: 6px; }
.by-foot__in p:first-child { color: var(--fg-2); }

/* ---------- 入场：步骤面板切换时轻轻浮起（只动 transform / opacity） ---------- */
@keyframes by-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.js-motion .by-panel:not([hidden]) { animation: by-up var(--dur-2) var(--ease) both; }

@media (forced-colors: active) {
  .by-plan.is-on, .by-code-box { border: 2px solid Highlight; }
  .by-card::before, .by-top::after { display: none; }
}
