/* ============================================================
 * TokenPocket 移动端侧边抽屉菜单 —— 按截图 1:1 复刻
 * 纯本地样式，无任何 CDN / Web Font / 外部图标依赖
 * 桌面与移动自适应：全屏白色抽屉，内容区宽屏居中、窄屏铺满
 * ============================================================ */

:root {
  --tp-blue: #2f6bff;
  --tp-bg: #ffffff;
  --tp-text: #111318;
  --tp-sub: #5b6270;
  --tp-chevron: #c8ccd4;
  --tp-line: #e4ebf9;
  --tp-track: #e6e8ec;
  --tp-knob: #ffffff;
  --tp-shadow: 0 2px 10px rgba(20, 40, 90, .08);
}

html[theme="dark"] {
  --tp-bg: #14161b;
  --tp-text: #f2f4f8;
  --tp-sub: #a7aebc;
  --tp-chevron: #565d6b;
  --tp-line: #262b34;
  --tp-track: #3b414d;
  --tp-knob: #f2f4f8;
  --tp-shadow: 0 2px 14px rgba(0, 0, 0, .35);
}

/* ---------- 触发按钮（PC 与移动都可见，方便随时查看菜单） ---------- */
.tp-hamburger {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 9000;
  width: 38px;
  height: 38px;
  border: 1px solid var(--tp-line);
  border-radius: 10px;
  background: var(--tp-bg);
  box-shadow: var(--tp-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform .18s ease, opacity .18s ease;
}
.tp-hamburger:hover { transform: translateY(-1px); }
.tp-hamburger span {
  display: block;
  position: relative;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--tp-text);
}
.tp-hamburger span::before,
.tp-hamburger span::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--tp-text);
}
.tp-hamburger span::before { top: -6px; }
.tp-hamburger span::after  { top:  6px; }
.tp-drawer-open .tp-hamburger { opacity: 0; pointer-events: none; }

/* ---------- 透明遮罩（点击空白处关闭，视觉上不影响 1:1） ---------- */
.tp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.tp-drawer-open .tp-backdrop { opacity: 1; visibility: visible; }

/* ---------- 抽屉主体：全屏白底 ---------- */
.tp-drawer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--tp-bg);
  color: var(--tp-text);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}
.tp-drawer-open .tp-drawer {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 顶栏：左 TP 品牌，右关闭 ×，底部一条极浅蓝线 */
.tp-drawer-head {
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--tp-line);
  box-sizing: border-box;
}
.tp-brand { display: flex; align-items: center; gap: 10px; }
.tp-brand-mark { width: 22px; height: 22px; flex: none; }
.tp-brand-text {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .09em;
  color: var(--tp-text);
  white-space: nowrap;
}
.tp-close {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tp-text);
}
.tp-close svg { width: 18px; height: 18px; }

/* 内容区：宽屏居中但箭头仍贴内容区右缘，窄屏铺满 */
.tp-menu-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 0 40px;
}
.tp-menu-row {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 24px;
  color: var(--tp-text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.tp-menu-row:hover { background: rgba(47, 107, 255, .045); }
html[theme="dark"] .tp-menu-row:hover { background: rgba(255, 255, 255, .045); }
.tp-menu-row .tp-ico {
  width: 19px;
  height: 19px;
  flex: none;
  stroke: var(--tp-text);
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tp-menu-row .tp-label { flex: 1; }
.tp-menu-row .tp-chev {
  width: 14px;
  height: 14px;
  flex: none;
  stroke: var(--tp-chevron);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 深色模式开关 */
.tp-switch {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--tp-track);
  flex: none;
  transition: background .2s ease;
  cursor: pointer;
}
.tp-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tp-knob);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
  transition: transform .2s ease;
}
.tp-switch[aria-checked="true"] { background: var(--tp-blue); }
.tp-switch[aria-checked="true"]::after { transform: translateX(16px); }

/* 语言二级面板 */
.tp-lang-panel {
  display: none;
  padding: 4px 0 10px 58px;
}
.tp-lang-panel.tp-show { display: block; }
.tp-lang-opt {
  display: block;
  padding: 9px 24px 9px 0;
  font-size: 14px;
  color: var(--tp-sub);
  text-decoration: none;
  cursor: pointer;
}
.tp-lang-opt:hover, .tp-lang-opt.tp-active { color: var(--tp-blue); }

/* 移动端底部下载入口（PC 隐藏，不破坏桌面 1:1 观感） */
.tp-dl-fab {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 8000;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  border-radius: 12px;
  background: var(--tp-blue);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(47, 107, 255, .32);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", Arial, sans-serif;
}
.tp-dl-fab svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; }

@media (max-width: 768px) {
  .tp-drawer-head { padding: 0 18px; height: 54px; }
  .tp-menu-inner  { padding: 14px 0 90px; }
  .tp-menu-row    { padding: 0 18px; height: 48px; font-size: 15px; }
  .tp-lang-panel  { padding-left: 52px; }
  .tp-dl-fab      { display: flex; }
  .tp-hamburger   { top: 12px; right: 14px; width: 34px; height: 34px; }
}

/* 尊重系统减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  .tp-drawer, .tp-backdrop, .tp-switch::after { transition: none; }
}


/* ============================================================
 * 小目录（二级面板）与语言面板 —— 由 tp-menu.js 动态渲染
 * ============================================================ */
.tp-view { display: none; }
.tp-view.tp-active { display: block; }
.tp-view-sub, .tp-view-lang {
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tp-sub-head {
  height: 50px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--tp-line);
  position: sticky;
  top: 0;
  background: var(--tp-bg);
  z-index: 2;
}
.tp-sub-back {
  display: flex; align-items: center; gap: 6px;
  border: 0; background: transparent; padding: 0;
  color: var(--tp-text); font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.tp-sub-back .tp-ico { width: 15px; height: 15px; stroke-width: 2; }
.tp-sub-title { flex: 1; font-size: 15px; font-weight: 700; }
.tp-sub-head .tp-close { width: 26px; height: 26px; }

.tp-sub-row {
  display: flex; align-items: center; gap: 14px;
  min-height: 62px; padding: 10px 24px;
  color: var(--tp-text); text-decoration: none;
  border-bottom: 1px solid rgba(127, 140, 170, .10);
  -webkit-tap-highlight-color: transparent;
}
.tp-sub-row:hover { background: rgba(47, 107, 255, .05); }
.tp-sub-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tp-sub-name { font-size: 14px; font-weight: 700; }
.tp-sub-desc { font-size: 12px; color: var(--tp-sub); line-height: 1.5; }
.tp-sub-empty { padding: 24px; color: var(--tp-sub); font-size: 13px; }
.tp-sub-row .tp-chev { width: 13px; height: 13px; }

.tp-lang-list { padding: 8px 0 30px; }
.tp-lang-opt {
  display: flex; align-items: center;
  width: 100%; height: 44px; padding: 0 24px;
  border: 0; background: transparent;
  color: var(--tp-text); font: inherit; font-size: 14px; text-align: left;
  cursor: pointer;
}
.tp-lang-opt:hover { background: rgba(47, 107, 255, .05); }
.tp-lang-opt.tp-active { color: var(--tp-blue); font-weight: 700; }
.tp-lang-opt.tp-active::after { content: "✓"; margin-left: auto; font-weight: 800; }

@media (max-width: 768px) {
  .tp-sub-row { padding: 10px 18px; }
  .tp-sub-head { padding: 0 14px; }
  .tp-lang-opt { padding: 0 18px; }
}
