/* ============================================================
   FBNB DAPP 抽屉式目录
   侧滑面板 + 遮罩，配色全部复用主题变量
   ============================================================ */

/* ---------- 菜单按钮（顶栏） ---------- */
.menu-btn {
  width: 30px; height: 40px; flex: 0 0 auto;
  border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  transition: transform .15s, opacity .2s;
}
.menu-btn:hover { opacity: .75; }
.menu-btn:active { transform: scale(.94); }
.menu-btn span {
  display: block; width: 22px; height: 2px; border-radius: 2px; background: var(--primary);
  transition: transform .2s, opacity .2s;
}
.menu-btn span:nth-child(2) { width: 22px; align-self: center; margin-left: 0; }
.menu-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- 遮罩 ---------- */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 108;
  background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity .28s ease, visibility .28s;
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

/* ---------- 抽屉面板 ---------- */
.drawer {
  position: fixed; top: 0; left: 0; z-index: 110;
  width: 280px; max-width: 78vw; height: 100vh; height: 100dvh;
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 44px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  transform: translateX(-103%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.drawer.open { transform: translateX(0); }
body.drawer-open { overflow: hidden; }

/* ---------- 抽屉头部 ---------- */
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.drawer-close {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; transition: all .2s;
}
.drawer-close:hover { color: var(--text); border-color: var(--primary); background: var(--primary-soft2); }

/* ---------- 网络条 ---------- */
.drawer-net {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 20px 6px; padding: 10px 12px;
  background: var(--primary-soft2); border: 1px solid var(--primary-border);
  border-radius: 10px; font-size: 13px; color: var(--text);
}
.drawer-net .net-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); flex: 0 0 auto; }
.drawer-net-tag {
  margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 12px;
  background: var(--cyan-soft); border: 1px solid var(--cyan-border); color: var(--cyan);
}

/* ---------- 导航列表 ---------- */
.drawer-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.drawer-nav::-webkit-scrollbar { width: 6px; }
.drawer-nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.drawer-group-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  color: var(--muted); text-transform: uppercase;
  padding: 16px 10px 8px;
}

.drawer-link {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 10px; margin-bottom: 3px;
  border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
}
.drawer-link:hover { background: var(--primary-soft2); border-color: var(--primary-border); transform: translateX(3px); }
.drawer-link:active { transform: translateX(1px) scale(.99); }
.dl-ico {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px;
  background: var(--primary-soft); color: var(--link);
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.drawer-link:hover .dl-ico { background: var(--primary-border); }
.dl-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.dl-text b { font-size: 14px; font-weight: 600; }
.dl-text small { font-size: 11px; color: var(--muted); }
.dl-arrow { margin-left: auto; color: var(--muted); font-size: 18px; }
.drawer-action { font-family: inherit; }

/* ---------- 抽屉底部 ---------- */
.drawer-foot { padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.drawer-themes { display: flex; gap: 10px; padding: 0 8px 14px; }
.drawer-theme {
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 2px solid transparent; padding: 3px;
  display: grid; place-items: center; transition: transform .15s, border-color .2s;
}
.drawer-theme:hover { transform: translateY(-2px); }
.drawer-theme.active { border-color: var(--primary); }
.drawer-theme .theme-swatch { width: 100%; height: 100%; border-radius: 7px; }
.drawer-ver { font-size: 11px; color: var(--muted); text-align: center; }

/* ---------- 语言切换（顶栏） ---------- */
.lang-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px; border-radius: 9px; cursor: pointer;
  background: transparent; border: none; color: var(--text);
  font-size: 13px; font-weight: 700; letter-spacing: .5px;
  transition: opacity .2s, transform .15s;
}
.lang-btn:hover { opacity: .75; }
.lang-btn:active { transform: scale(.95); }
.lang-globe { font-size: 15px; color: var(--cyan); line-height: 1; }
.lang-flag {
  width: 22px; height: 15px; flex: 0 0 auto; display: block;
  border-radius: 3px; object-fit: cover;
  border: 1px solid rgba(0,0,0,.18); box-shadow: 0 1px 3px rgba(0,0,0,.22);
}
.lang-opt .lang-flag, .drawer-lang .lang-flag { width: 24px; height: 16px; }

/* 语言下拉面板 */
.lang-switch { position: relative; }
.lang-caret { font-size: 10px; color: var(--muted); line-height: 1; margin-left: 1px; transition: transform .2s; }
.lang-btn.open .lang-caret { transform: rotate(180deg); }
.lang-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 90;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
  padding: 8px; min-width: 172px; box-shadow: 0 14px 38px rgba(0,0,0,.38);
  display: none; flex-direction: column; gap: 4px;
}
.lang-menu.open { display: flex; }
.lang-menu { max-height: min(70vh, 520px); overflow-y: auto; scrollbar-width: thin; }
.lang-menu::-webkit-scrollbar { width: 5px; }
.lang-menu::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.lang-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--text);
  text-align: left; transition: background .2s, border-color .2s;
}
.lang-opt:hover { background: var(--primary-soft2); }
.lang-opt.active { border-color: var(--primary); background: var(--primary-soft); }
.lang-opt .lang-code {
  font-size: 10px; font-weight: 800; color: var(--cyan);
  background: var(--cyan-soft); border: 1px solid var(--cyan-border);
  border-radius: 5px; padding: 2px 5px; flex: 0 0 auto; line-height: 1.3;
}
.lang-opt .lang-name { font-size: 12px; font-weight: 600; }
.lang-check { margin-left: auto; color: var(--cyan); font-weight: 700; visibility: hidden; }
.lang-opt.active .lang-check { visibility: visible; }

/* ---------- 语言切换（抽屉） ---------- */
.drawer-langs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 0 10px 8px; }
.drawer-lang {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  background: var(--primary-soft2); border: 1px solid var(--line); color: var(--text);
  text-align: left; transition: border-color .2s, background .2s, transform .15s;
}
.drawer-lang:last-child { grid-column: span 2; }
.drawer-lang:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.drawer-lang.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary-border); }
.lang-code {
  font-size: 10px; font-weight: 800; color: var(--cyan);
  background: var(--cyan-soft); border: 1px solid var(--cyan-border);
  border-radius: 5px; padding: 2px 5px; flex: 0 0 auto; line-height: 1.3;
}
.lang-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 偏好设置分组 ---------- */
.drawer-foot { padding: 6px 12px 18px; }
.drawer-foot .drawer-group-title { padding-top: 14px; padding-bottom: 4px; }
.drawer-sublabel {
  font-size: 11px; color: var(--muted); font-weight: 600;
  padding: 10px 10px 6px;
}
/* 偏好区语言紧凑横排：国旗 + 名称，13 种平分多行 */
.drawer-langs-inline { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 8px 8px; max-height: 176px; overflow-y: auto; scrollbar-width: thin; }
.drawer-langs-inline::-webkit-scrollbar { width: 5px; }
.drawer-langs-inline::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.drawer-langs-inline .drawer-lang { padding: 7px 8px; gap: 6px; }
.drawer-langs-inline .drawer-lang:last-child { grid-column: auto; }
.drawer-langs-inline .lang-flag { width: 20px; height: 14px; }
.drawer-langs-inline .lang-name { font-size: 11px; }
.drawer-foot .drawer-themes { padding-bottom: 8px; }

/* ---------- 邀请链接弹窗 ---------- */
.invite-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0,0,0,.62); backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s;
}
.invite-overlay.open { opacity: 1; visibility: visible; }

.invite-modal {
  position: fixed; z-index: 122; top: 50%; left: 50%;
  width: min(440px, 92vw);
  transform: translate(-50%, -46%) scale(.96);
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
  padding: 26px 24px 22px;
  max-height: 88vh; overflow-y: auto;
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, transform .25s cubic-bezier(.4,0,.2,1), visibility .25s;
}
.invite-modal::-webkit-scrollbar { width: 6px; }
.invite-modal::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
.invite-modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
body.invite-open { overflow: hidden; }

.invite-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; transition: all .2s;
}
.invite-close:hover { color: var(--text); border-color: var(--primary); background: var(--primary-soft2); }

.invite-head { text-align: center; margin-bottom: 20px; }
.invite-ico {
  width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 13px;
  background: var(--grad, linear-gradient(135deg, var(--primary), var(--cyan)));
  color: #fff; font-size: 22px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px var(--btn-shadow);
}
.invite-head h3 { font-size: 19px; margin: 0 0 5px; color: var(--text); }
.invite-head p { font-size: 12px; margin: 0; color: var(--muted); }

.invite-addr-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 13px; margin-bottom: 16px;
  background: var(--primary-soft2); border: 1px solid var(--primary-border);
  border-radius: 11px; font-size: 12px; color: var(--muted);
}
.invite-addr-row b { font-size: 13px; color: var(--muted); font-family: monospace; }
.invite-addr-row b.ok { color: var(--cyan); }

/* 推荐资格 opt-in（M1 修复接入） */
.invite-optin-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 10px 13px; margin: -6px 0 16px;
  background: var(--primary-soft2); border: 1px solid var(--primary-border);
  border-radius: 11px;
}
.invite-optin-row .btn-primary { flex: 0 0 auto; padding: 8px 14px; font-size: 12px; }
.invite-optin-row .btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.invite-optin-status { font-size: 11px; color: var(--muted); line-height: 1.5; }
.invite-optin-status.ok { color: var(--cyan); }
.invite-optin-status.warn { color: #d98841; }

/* 二维码 */
.invite-qr-wrap { text-align: center; margin: 4px 0 18px; }
.invite-qr {
  width: 158px; height: 158px; margin: 0 auto;
  padding: 10px; box-sizing: border-box;
  background: #fff; border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
  display: grid; place-items: center; overflow: hidden;
}
.invite-qr svg { width: 100%; height: 100%; display: block; }
.invite-qr .qr-placeholder {
  font-size: 11px; color: #94a3b8; line-height: 1.5; text-align: center; padding: 0 4px;
  white-space: pre-line;
}
.invite-qr-label { margin-top: 9px; font-size: 11px; color: var(--muted); }

.invite-label { display: block; font-size: 12px; color: var(--text); font-weight: 600; margin-bottom: 8px; }
.invite-link-row { display: flex; gap: 8px; }
.invite-link-row input {
  flex: 1; min-width: 0; padding: 11px 12px;
  background: var(--primary-soft2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 12px; font-family: monospace;
}
.invite-link-row input:focus { outline: none; border-color: var(--primary); }
.invite-link-row .btn-primary { flex: 0 0 auto; padding: 0 18px; }
.invite-link-row .btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.invite-note {
  margin-top: 16px; padding: 12px 13px; border-radius: 10px;
  background: var(--cyan-soft); border: 1px solid var(--cyan-border);
  color: var(--muted); font-size: 11px; line-height: 1.6;
}

/* 邀请弹窗内：推荐 / 团队奖励规则 */
.invite-rules { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.rule-block {
  padding: 13px 13px 12px; border-radius: 11px;
  background: var(--primary-soft2); border: 1px solid var(--primary-border);
}
.rule-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.rule-table { display: flex; flex-direction: column; gap: 7px; }
.rule-row { display: flex; align-items: center; gap: 8px; }
.rule-row-label { flex: 0 0 76px; font-size: 11px; color: var(--muted); }
.rule-cells { flex: 1; min-width: 0; display: flex; gap: 4px; }
.rule-cells b, .rule-cells em {
  flex: 1; min-width: 0; text-align: center; font-style: normal;
  padding: 5px 0; border-radius: 7px; font-size: 11px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}
.rule-cells em { color: var(--cyan); font-weight: 700; }
.rule-note { margin-top: 9px; font-size: 10px; line-height: 1.5; color: var(--muted); }
.rule-peer {
  margin-top: 9px; padding: 7px 9px; border-radius: 8px;
  background: var(--cyan-soft); border: 1px solid var(--cyan-border);
  font-size: 10px; line-height: 1.5; color: var(--text);
}

/* ---------- 视图切换：一类目一页 ---------- */
[data-view] { display: none; }
[data-view].view-active { display: block; animation: view-in .25s ease; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 顶栏 / 抽屉当前类目高亮 */
.nav-links a.active { color: var(--link); font-weight: 700; }
.drawer-link.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}
.drawer-link.active .dl-ico { background: var(--grad); color: #fff; }
.drawer-link.active .dl-arrow { color: var(--link); }

/* ============================================================
   抽屉 2.0：居中品牌头 + 可折叠分组 + 缩进子项
   ============================================================ */
.drawer-head {
  position: relative; display: flex; justify-content: center;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.drawer-head .drawer-close { position: absolute; top: 14px; right: 14px; }
.dh-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.dh-logo { width: 160px; height: auto; max-width: 100%; filter: drop-shadow(0 4px 14px var(--btn-shadow)); }
.dh-name { margin-top: 10px; font-size: 24px; font-weight: 800; letter-spacing: 1px; color: var(--text); }
.dh-badge {
  margin-top: 8px; display: inline-block; padding: 5px 16px; border-radius: 999px;
  background: var(--grad); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  box-shadow: 0 4px 14px var(--btn-shadow);
}

/* 常用入口：无图标、稍大 */
.drawer-nav { padding-top: 6px; }
.dr-feature { padding: 12px 12px; }
.dr-feature .dl-text b { font-size: 15px; font-weight: 700; }

/* 可折叠分组 */
.dr-group { border-top: 1px solid var(--line); }
.dr-group:first-of-type { border-top: 1px solid var(--line); }
.dr-group > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 12px 11px; font-size: 14px; font-weight: 700; color: var(--text);
}
.dr-group > summary::-webkit-details-marker { display: none; }
.dr-caret { font-size: 18px; line-height: 1; color: var(--muted); transition: transform .22s ease; }
.dr-group[open] > .dr-caret,
.dr-group[open] > summary .dr-caret { transform: rotate(180deg); }
.dr-sub { padding: 0 8px 10px; }

/* 缩进子项：无方块图标 */
.dr-sub .drawer-link { padding: 10px 12px 10px 20px; margin-bottom: 2px; border-radius: 10px; }
.dr-sub .dl-text b { font-size: 13px; font-weight: 600; }
.dr-sub .dl-text small { font-size: 10px; }
.dr-sub .dl-arrow { font-size: 16px; }

/* 当前项：主题色描边高亮（参考图的红框效果） */
.drawer-link.active {
  background: var(--primary-soft); border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary-border);
}
.drawer-link.active .dl-text b { color: var(--link); font-weight: 800; }
.drawer-link.active .dl-arrow { color: var(--link); }

/* 版本信息贴底 */
.drawer-ver { padding: 8px 12px 16px; border-top: 1px solid var(--line); }

/* ---------- 响应式 ---------- */
@media (max-width: 560px) {
  .nav-inner { gap: 10px; }
  .drawer { width: 268px; }
  .lang-btn { padding: 6px 3px; }
  .lang-globe { display: none; }
  .nav-actions { gap: 6px; }
  .invite-modal { padding: 24px 18px 18px; }
  .topbar #connectBtn { padding: 9px 14px; font-size: 12px; }
}
