/* ═══════════════════════════════════════════════════════════════
   Veyrun 悦跑 · App 外壳（侧栏 + 全屏地图 + 底部卡片轮播）
   ───────────────────────────────────────────────────────────────
   版式来自用户手绘稿：
     左上品牌 + 右侧登录/注册 · 左侧竖栏可折叠 · 地图占满
     底部正中 5 张小卡片，左右拖动即切页 · 下面一排分页点
   加载顺序在 style.css / home.css 之后，只覆盖桌面壳层。
   ═══════════════════════════════════════════════════════════════ */

:root {
  --rail: 232px;          /* 侧栏展开宽度 */
  --rail-mini: 76px;      /* 侧栏收起宽度 */
  --rail-w: var(--rail);  /* 当前生效宽度，由 body.rail-mini 改写 */
  --dock-h: 96px;
  --panel-zone: 400px;    /* 首页左侧控制面板占掉的宽度，dock 用它避让 */
}

body.rail-mini { --rail-w: var(--rail-mini); }

/* ───────────── 壳层骨架 ───────────── */

.vrail {
  position: fixed; inset: 0 auto 0 0; z-index: 70;
  width: var(--rail-w);
  display: flex; flex-direction: column;
  padding: 18px 12px 14px;
  background:
    linear-gradient(180deg, rgba(30, 19, 58, .92), rgba(11, 8, 22, .96) 62%, rgba(8, 6, 16, .98));
  backdrop-filter: saturate(170%) blur(26px);
  -webkit-backdrop-filter: saturate(170%) blur(26px);
  border-right: 1px solid rgba(198, 166, 234, .10);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .03), 24px 0 60px -46px rgba(0, 0, 0, 1);
  transition: width 460ms var(--ease-ios, cubic-bezier(.32, .72, 0, 1));
  overflow: visible;   /* 折叠手柄要伸出右缘，不能被裁掉 */
}
/* 侧栏右缘一线紫光，收起时也保留，作为「这是一块玻璃」的边界 */
.vrail::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 1px;
  background: linear-gradient(180deg, rgba(198, 166, 234, .34), rgba(110, 69, 186, .06) 40%, transparent);
  pointer-events: none;
}

/* ── 品牌行：logo 在左，登录/注册紧贴它右边（稿子明确要求） ── */
.vrail-top {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 6px 16px;
  flex: none;
}
.vlogo { display: flex; align-items: center; gap: 9px; min-width: 0; flex: none; }
.vlogo-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: none; overflow: hidden;
  background: linear-gradient(140deg, #af85e5, #2c1f5c 62%, #2e1065);
  box-shadow: 0 4px 16px rgba(110, 69, 186, .5), 0 0 0 1px rgba(198, 166, 234, .22),
              inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: box-shadow 260ms var(--ease-out, ease), transform 220ms var(--spring, ease);
}
.vlogo-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vlogo:hover .vlogo-mark { box-shadow: 0 6px 22px rgba(139, 92, 246, .68), 0 0 0 1px rgba(196, 181, 253, .4), inset 0 1px 0 rgba(255,255,255,.4); }
.vlogo:active .vlogo-mark { transform: scale(.94); }
.vlogo-txt { display: flex; flex-direction: column; line-height: 1.02; white-space: nowrap; }
.vlogo-txt b {
  font-size: 15.5px; font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(100deg, #fff, #ddd0ff 48%, #af85e5);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.vlogo-txt i { font-size: 9px; font-style: normal; letter-spacing: .3em; color: var(--ink-3); font-weight: 700; margin-top: 1px; }

/* 登录 / 注册：贴着品牌右边的袖珍胶囊 */
.vauth {
  margin-left: 2px; flex: none;
  padding: 7px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap;
  color: #f3ecff;
  background: linear-gradient(180deg, rgba(139, 92, 246, .92), rgba(91, 33, 182, .92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .34), 0 6px 18px -8px rgba(139, 92, 246, .9);
  transition: transform 180ms var(--spring, ease), box-shadow 220ms var(--ease-out, ease), filter 220ms;
}
.vauth:hover { filter: brightness(1.08); box-shadow: inset 0 1px 0 rgba(255,255,255,.44), 0 8px 24px -8px rgba(167, 139, 250, 1); }
.vauth:active { transform: scale(.955); }
.vauth.ghosted {
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 0 0 1px rgba(198, 166, 234, .16);
  color: var(--ink-2);
}

/* ── 侧栏导航（分组，照参考站） ── */
.vnav { display: flex; flex-direction: column; flex: 1; overflow-y: auto; overflow-x: hidden; padding: 2px 0 10px; }
.vnav::-webkit-scrollbar { width: 0; }
.vgrp { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.vgrp-t {
  padding: 10px 12px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em;
  color: rgba(196, 166, 234, .40);
  white-space: nowrap;
  transition: opacity 200ms var(--ease-out, ease);
}
.vsep { height: 1px; margin: 10px 10px; background: linear-gradient(90deg, transparent, rgba(198, 166, 234, .18), transparent); flex: none; }
.vnav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  height: 42px; padding: 0 11px; border-radius: 13px;
  color: var(--ink-2); font-size: 13.5px; font-weight: 600; letter-spacing: -.005em;
  white-space: nowrap;
  transition: background 240ms var(--ease-out, ease), color 180ms var(--ease-out, ease), transform 180ms var(--spring, ease);
}
/* NEW 小徽标 */
.vnav a .vb {
  flex: none; padding: 3px 6px; border-radius: 7px;
  font-size: 9px; font-weight: 800; letter-spacing: .04em;
  color: #0f0a1e; background: linear-gradient(180deg, #f1e7f9, #c6a6ea);
  box-shadow: 0 4px 12px -6px rgba(198, 166, 234, .9);
  transition: opacity 200ms var(--ease-out, ease);
}
.vnav a .vi {
  width: 20px; flex: none; text-align: center; font-size: 15px; line-height: 1;
  opacity: .9; transition: transform 260ms var(--spring, ease), opacity 200ms;
}
.vnav a .vt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; transition: opacity 220ms var(--ease-out, ease); }
.vnav a:hover { background: rgba(255, 255, 255, .055); color: #fff; }
.vnav a:hover .vi { transform: translateY(-1px) scale(1.06); opacity: 1; }
.vnav a:active { transform: scale(.985); }
/* 选中：紫色渐层胶囊 + 左缘一道竖光，跟 iOS 侧边栏同一套语言 */
.vnav a.on {
  color: #fff;
  background: linear-gradient(100deg, rgba(110, 69, 186, .48), rgba(110, 69, 186, .16) 78%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 8px 26px -18px rgba(139, 92, 246, 1);
  text-shadow: 0 0 18px rgba(198, 166, 234, .5);
}
.vnav a.on::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 2.5px; height: 17px; border-radius: 2px;
  background: linear-gradient(180deg, #e9dcff, #a855f7);
  box-shadow: 0 0 12px rgba(168, 85, 247, .95);
}
.vnav a.on .vi { opacity: 1; }

/* ── 侧栏底部：剩余额度卡 + 用户行 ── */
.vrail-bot { flex: none; padding-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.vbal {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 13px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .03));
  box-shadow: inset 0 0 0 1px rgba(198, 166, 234, .14), inset 0 1px 0 rgba(255, 255, 255, .07);
  color: var(--ink-2); font-size: 12px; font-weight: 600;
  transition: background 220ms, box-shadow 220ms;
}
.vbal:hover { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(198, 166, 234, .26); }
.vbal b { font-size: 15px; font-weight: 800; letter-spacing: -.02em; color: #fff; }
.vbal b em { font-style: normal; font-size: 10px; font-weight: 600; color: var(--ink-3); margin-left: 3px; }

.vuser {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 2px 2px;
}
.vava {
  width: 26px; height: 26px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #fff;
  background: linear-gradient(140deg, #a877f0, #4a2f8c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3);
}
.vuname {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12.5px; font-weight: 650; color: var(--ink-1);
  transition: opacity 200ms;
}
.vacts { display: flex; align-items: center; gap: 1px; flex: none; }
.vacts button {
  width: 24px; height: 24px; border-radius: 8px;
  display: grid; place-items: center;
  background: transparent; border: 0; padding: 0;
  color: var(--ink-3);
  transition: background 180ms, color 180ms, transform 160ms var(--spring, ease);
}
.vacts button svg { display: block; }
.vacts button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.vacts button:active { transform: scale(.9); }

/* 折叠手柄：贴在侧栏右缘中间，伸出来半个圆，收起时也不会遮住导航 */
.vfold {
  position: absolute; right: -13px; top: 50%; transform: translateY(-50%);
  z-index: 3;
  width: 26px; height: 44px; border-radius: 0 13px 13px 0;
  display: grid; place-items: center;
  background: rgba(30, 20, 52, .92);
  box-shadow: inset 0 0 0 1px rgba(198, 166, 234, .16), inset 0 1px 0 rgba(255, 255, 255, .07), 8px 0 20px -14px rgba(0, 0, 0, 1);
  color: var(--ink-2);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: background 200ms, color 200ms, width 200ms, right 200ms;
}
.vfold:hover { background: rgba(60, 40, 100, .95); color: #fff; width: 30px; right: -15px; }
.vfold:active { transform: translateY(-50%) scale(.94); }
/* 折叠箭头：一道 chevron，收起时转 180° */
.vfold i {
  width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); margin-left: 2px;
  transition: transform 420ms var(--ease-ios, ease);
}
body.rail-mini .vfold i { transform: rotate(225deg); margin-left: -2px; }

/* ── 收起态：只留图标 ── */
body.rail-mini .vrail { padding-left: 10px; padding-right: 10px; }
body.rail-mini .vlogo-txt,
body.rail-mini .vnav a .vt,
body.rail-mini .vnav a .vb,
body.rail-mini .vgrp-t,
body.rail-mini .vuname,
body.rail-mini .vacts,
body.rail-mini .vbal span,
body.rail-mini .vbal b { opacity: 0; pointer-events: none; }
body.rail-mini .vgrp-t { height: 0; padding: 2px 0; overflow: hidden; }
body.rail-mini .vbal { justify-content: center; padding: 9px 0; }
body.rail-mini .vuser { justify-content: center; }
body.rail-mini .vrail-top { flex-direction: column; align-items: flex-start; gap: 12px; padding-left: 8px; }
body.rail-mini .vauth {
  margin-left: 0; width: 34px; height: 30px; padding: 0;
  display: grid; place-items: center; font-size: 0;
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 0 0 0 1px rgba(198, 166, 234, .16), inset 0 1px 0 rgba(255, 255, 255, .07);
  color: var(--ink-2);
}
body.rail-mini .vauth::after { content: "⇥"; font-size: 14px; font-weight: 800; }
body.rail-mini .vauth:hover { background: rgba(255, 255, 255, .12); color: #fff; }
body.rail-mini .vnav a { justify-content: center; padding: 0; gap: 0; }

/* ───────────── 主区域 ───────────── */

/* 页面里的多列卡片栅格（之前只有 .grid 类名、没有规则，卡片会一列到底） */
.grid { display: grid; gap: 16px; }
.grid.g2 { grid-template-columns: repeat(auto-fit, minmax(288px, 1fr)); }
.grid.g3 { grid-template-columns: repeat(auto-fit, minmax(238px, 1fr)); }

.vmain {
  margin-left: var(--rail-w);
  min-height: 100vh;
  transition: margin-left 460ms var(--ease-ios, cubic-bezier(.32, .72, 0, 1));
}

/* 桌面壳层生效时，老顶栏与底部 tabbar 都退场（窄屏仍然用它们导航） */
@media (min-width: 1024px) {
  body.shell .top,
  body.shell .tabbar { display: none; }
}

/* 首页 = 地图铺满，不再有文档流长度 */
body.shell.page-map { overflow: hidden; }
body.shell.page-map .vmain { height: 100vh; overflow: hidden; }
body.shell.page-map .foot { display: none; }

/* 首页把 route.js 的舞台拉满整块主区 */
body.shell.page-map .run-stage {
  height: 100%; width: 100%; max-width: none; margin: 0;
  border-radius: 0; border: 0; box-shadow: none;
}
body.shell.page-map .run-stage .run-map { border-radius: 0; height: 100%; }
body.shell.page-map .hv-lead { display: none; }

/* 地图之上的暗角：让底部的卡片轮播与右上面板压得住画面 */
body.shell.page-map .vmain::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background:
    linear-gradient(180deg, rgba(8, 6, 16, .34) 0%, transparent 22%, transparent 62%, rgba(8, 6, 16, .72) 100%),
    radial-gradient(120% 70% at 50% 118%, rgba(88, 44, 168, .30), transparent 62%);
}

/* ───────────── 非首页：底部只留一点呼吸位 ───────────── */
body.shell:not(.page-map) .vmain { padding-bottom: 40px; }
body.shell:not(.page-map) .foot { padding-bottom: 34px; }

/* ───────────── 首页：把 route.js 的舞台彻底铺满 ───────────── */
body.page-map .vmain { position: relative; }
body.page-map .hv-top.hv-full {
  position: absolute; inset: 0; margin: 0; padding: 0; width: 100%; height: 100%;
  background: none;
}
body.page-map .hv-top.hv-full::before,
body.page-map .hv-top.hv-full::after { display: none; }
body.page-map .hv-top .run-stage {
  height: 100%; width: 100%; max-width: none; margin: 0;
  border-radius: 0; border: 0; box-shadow: none; background: #08060f;
}
body.page-map .hv-top .run-stage > * { border-radius: 0; }
body.page-map .run-note { display: none; }

/* 舞台里的路线卡：地图铺满后靠左上，避开底部 dock */
body.page-map .run-panel {
  margin: 18px 0 0 18px;
  max-height: calc(100% - 36px);
}
/* 底部统计条压在法务条之上，横向让开左侧控制面板 */
body.page-map .run-stage .run-stats {
  bottom: 40px;
  left: calc(50% + var(--panel-zone) / 2);
}
/* 右侧浮动工具条与三条候选路线错开 */
body.page-map .run-stage .run-tools { bottom: 210px; top: auto; }

/* ───────────── 移动端 / 窄屏：回到顶栏 + tabbar 的老壳 ───────────── */
@media (max-width: 1023px) {
  .vrail { display: none; }
  .vmain { margin-left: 0; }
  body.shell.page-map { overflow: auto; }
  body.shell.page-map .vmain { height: auto; overflow: visible; }
  body.shell.page-map .vmain::after { display: none; }
  body.shell.page-map .hv-top.hv-full { position: static; height: auto; padding: 12px 0 18px; }
  body.shell.page-map .hv-top .run-stage {
    height: clamp(420px, calc(100vh - 190px), 640px);
    border-radius: 24px; margin: 0 12px;
  }
  body.page-map .run-panel { margin: 12px 0 0 12px; }
}

/* 登录 / 注册这类独立页不套壳 */
body.shell-bare .vrail { display: none; }
body.shell-bare .vmain { margin-left: 0; }

/* 降噪：用户开了减少动态就全关掉位移 */
@media (prefers-reduced-motion: reduce) {
  .vrail, .vmain { transition-duration: 1ms !important; }
}
