:root {
  --bg0: #0a1122;
  --bg1: #0b1326;
  --bg2: #0d1730;
  --bg: #0d1730;
  --bg: #070c18;
  --accent-text: #7dd3fc;
  --accent-text-2: #a5b4fc;
  --on-accent: #04101f;
  --ok-text: #6ee7b7;
  --danger-text: #fca5a5;
  --panel-solid: rgba(17, 27, 51, 0.94);
  --input-bg: rgba(10, 16, 32, 0.75);
  color-scheme: dark;
  --bg: #070c18;
  --panel: rgba(140, 175, 255, 0.05);
  --border: rgba(130, 165, 255, 0.16);
  --border-strong: rgba(130, 165, 255, 0.32);
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --accent-glow: rgba(56, 189, 248, 0.35);
  --text: #ffffff;
  --text-2: #c9d7ee;
  --text-3: #93a7c8;
  --danger: #f87171;
  --ok: #34d399;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html {
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg1) 45%, var(--bg2) 100%);
}
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(1100px 520px at 85% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(900px 480px at -10% 10%, rgba(56, 189, 248, 0.12), transparent 55%),
    radial-gradient(1200px 620px at 50% 112%, rgba(56, 189, 248, 0.10), transparent 60%),
    radial-gradient(900px 520px at 20% 95%, rgba(99, 102, 241, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg2) 0%, var(--bg1) 45%, var(--bg2) 100%);
  background-attachment: fixed;
}

/* 验证页容器：锁定一屏，禁止拖拽出空白 */
.license-page {
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 20px;
}

/* 验证页可见时连 body 一起锁死（PC/移动通用）；验证成功进入 map 后自动解锁 */
body:has(#license-gate:not(.license-hidden)) {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

/* VPN 引导过渡页：与验证页同风格，锁定一屏 */
.vpn-gate {
  position: relative;
  z-index: 50;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 60%, var(--bg2) 100%);
}
body:has(#vpn-gate[style*="display:flex"]) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
.vpn-gate-panel {
  position: relative;
  width: min(100%, 400px);
  min-width: 0;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 34px 30px 26px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-solid);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(160, 190, 255, 0.12);
}
.vpn-gate-logo {
  width: 56px;
  height: 56px;
  display: block;
  margin: 0 auto 20px;
  filter: drop-shadow(0 0 14px rgba(99, 102, 241, 0.45));
}
.vpn-gate-heading { text-align: center; }
.vpn-gate-heading h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-text), var(--accent-text-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.vpn-gate-heading p { margin: 10px 0 24px; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.vpn-gate-steps {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  gap: 10px;
}
.vpn-gate-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid rgba(130, 165, 255, 0.14);
  border-radius: 10px;
  background: rgba(140, 175, 255, 0.06);
  color: var(--text-2);
  font-size: 14px;
}
.vpn-gate-steps .vpn-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 12px;
  font-weight: 700;
}
.vpn-gate-steps li:last-child { margin-bottom: 0; }
.vpn-gate-actions { display: grid; gap: 12px; }
.vpn-gate-btn {
  height: 46px;
  border: 0;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.vpn-gate-btn:hover { filter: brightness(1.1); }
.vpn-gate-btn:active { transform: translateY(1px); }
.vpn-gate-primary {
  color: var(--on-accent);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.28);
}
.vpn-gate-secondary {
  color: var(--text-2);
  background: rgba(140, 175, 255, 0.07);
  border: 1px solid var(--border);
}
.vpn-gate-countdown {
  margin: 16px 0 0;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
}
.vpn-gate-countdown span { color: var(--accent-text); font-weight: 700; }

/* 验证卡片 */
.license-panel {
  position: relative;
  width: min(100%, 400px);
  min-width: 0;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 34px 30px 26px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(165deg, var(--panel-hover), rgba(140, 175, 255, 0.03));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(160, 190, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.license-logo {
  width: 56px;
  height: 56px;
  display: block;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 14px rgba(99, 102, 241, 0.45));
}
.license-heading h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: 0;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-text), var(--accent-text-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.license-heading p { margin: 8px 0 26px; color: var(--text-2); font-size: 14px; line-height: 1.6; }

/* 表单 */
.license-form { display: grid; gap: 10px; min-width: 0; }
.license-form label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.license-form input {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: var(--input-bg);
  font: inherit;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.license-form input::placeholder { color: var(--text-3); letter-spacing: 0; }
.license-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18), 0 0 14px rgba(56, 189, 248, 0.15);
}
.license-form button {
  height: 46px;
  margin-top: 4px;
  border: 0;
  border-radius: 10px;
  color: var(--on-accent);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.28);
  transition: filter 0.15s, transform 0.1s;
}
.license-form button:hover { filter: brightness(1.1); }
.license-form button:active { transform: translateY(1px); }
.license-form button:disabled { cursor: wait; opacity: 0.65; }
.license-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }

/* 底部信息 */
.license-meta {
  display: flex;
  gap: 16px;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid rgba(130, 165, 255, 0.1);
  color: var(--text-3);
  font-size: 11px;
}
.license-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.license-hidden { display: none !important; }
.hidden { display: none !important; }

/* 系统更新公告弹窗 */
.announce-dialog {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.announce-panel {
  position: relative;
  width: min(100%, 400px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 30px 28px 24px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(140, 175, 255, 0.09), rgba(140, 175, 255, 0.03)), var(--panel-solid);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.announce-count {
  position: absolute;
  top: 12px;
  right: 14px;
  padding: 3px 9px;
  border: 1px solid rgba(130, 165, 255, 0.3);
  border-radius: 999px;
  color: var(--text-3);
  background: rgba(140, 175, 255, 0.08);
  font-size: 11px;
}
.announce-icon { font-size: 40px; margin-bottom: 10px; }
.announce-panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-text), var(--accent-text-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.announce-body { text-align: left; font-size: 14px; line-height: 1.7; color: var(--text-2); }
.announce-body p { margin: 0 0 10px; }
.announce-body ol { margin: 0 0 12px; padding-left: 22px; list-style: decimal; }
.announce-body ol li { margin-bottom: 6px; list-style: decimal; display: list-item; }
.announce-body .announce-note {
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 8px;
  color: var(--ok-text);
  background: rgba(52, 211, 153, 0.08);
  font-weight: 600;
}
.announce-ok {
  width: 100%;
  height: 44px;
  margin-top: 18px;
  border: 0;
  border-radius: 10px;
  color: var(--on-accent);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.announce-ok:hover { filter: brightness(1.1); }
.announce-ok:active { transform: translateY(1px); }
.client-info-bar {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(360px, calc(100% - 24px));
}
.client-info-bar .ci-toggle {
  border: 1px solid rgba(130, 165, 255, 0.35);
  border-radius: 20px;
  padding: 7px 16px;
  color: var(--accent-text);
  background: var(--panel-solid);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
.client-info-bar .ci-toggle:hover { filter: brightness(1.2); }
.client-info-bar .ci-content {
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid rgba(130, 165, 255, 0.25);
  border-radius: 12px;
  background: var(--panel-solid);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}
.client-info-bar .ci-content span { display: block; word-break: break-all; }
.client-info-bar .ci-content .ci-bar-warn { color: var(--danger-text); }

/* 验证成功后的应用页保持原浅色风格 */
#app { background: #f3f5f8; min-height: 100dvh; }

/* 本地模式按钮（由脚本注入，与底部定位按钮统一尺寸） */
.local-reset-btn {
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: 999px;
  height: 46px;
  min-width: 122px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10b981, var(--ok));
  color: var(--on-accent);
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(52, 211, 153, 0.3);
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
}
.local-reset-btn::before { content: "↺  "; font-size: 15px; }
.local-reset-btn:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(52, 211, 153, 0.4); }
.local-reset-btn:active { transform: scale(0.95); }
.local-reset-btn:disabled { cursor: wait; opacity: 0.65; }
.local-vpn-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(130, 165, 255, 0.28);
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, var(--accent-2)) !important;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: filter 0.15s, transform 0.1s;
}
.local-vpn-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.local-vpn-btn:active { transform: scale(0.94); }
.local-vpn-btn:disabled { cursor: wait; opacity: 0.65; }

/* 响应式 */
@media (max-width: 420px) {
  .license-page { padding: 16px; }
  .license-panel { padding: 28px 22px 22px; }
  .license-heading h1 { font-size: 21px; }
  .btn-group.local-controls { gap: 7px !important; }
  .btn-group .lock-btn,
  .btn-group .virtual-btn,
  .local-reset-btn { padding-left: 14px !important; padding-right: 14px !important; }
}


/* ==== themes ==== */
[data-theme="black"] {
  --bg0: #050505;
  --bg1: #0a0a0a;
  --bg2: #111111;
  --bg: #111111;
  --accent: #e4e4e7;
  --accent-2: #8b8b93;
  --accent-text: #fafafa;
  --accent-text-2: #a1a1aa;
  --on-accent: #09090b;
  --ok: #4ade80;
  --ok-text: #86efac;
  --danger: #f87171;
  --danger-text: #fca5a5;
  --text: #fafafa;
  --text-2: #c9c9d1;
  --text-3: #8a8a93;
  --panel-solid: rgba(18, 18, 20, 0.95);
  --input-bg: rgba(10, 10, 10, 0.8);
}
[data-theme="aurora"] {
  --bg0: #150a2e;
  --bg1: #1e1140;
  --bg2: #2a1656;
  --bg: #2a1656;
  --accent: #a855f7;
  --accent-2: #6366f1;
  --accent-text: #d8b4fe;
  --accent-text-2: #c7d2fe;
  --on-accent: #14041f;
  --ok: #34d399;
  --ok-text: #6ee7b7;
  --danger: #fb7185;
  --danger-text: #fecdd3;
  --text: #ffffff;
  --text-2: #d5c6ee;
  --text-3: #9d8bc4;
  --panel-solid: rgba(34, 20, 66, 0.94);
  --input-bg: rgba(21, 10, 46, 0.8);
}
[data-theme="emerald"] {
  --bg0: #052e1f;
  --bg1: #064e34;
  --bg2: #0a3d2e;
  --bg: #0a3d2e;
  --accent: #34d399;
  --accent-2: #059669;
  --accent-text: #6ee7b7;
  --accent-text-2: #a7f3d0;
  --on-accent: #03140c;
  --ok: #34d399;
  --ok-text: #86efac;
  --danger: #f87171;
  --danger-text: #fca5a5;
  --text: #ffffff;
  --text-2: #c3e8d8;
  --text-3: #8bb8a6;
  --panel-solid: rgba(6, 40, 28, 0.94);
  --input-bg: rgba(4, 30, 21, 0.8);
}
[data-theme="ember"] {
  --bg0: #2b0f05;
  --bg1: #3b1505;
  --bg2: #4a1c07;
  --bg: #4a1c07;
  --accent: #fb923c;
  --accent-2: #f97316;
  --accent-text: #fdba74;
  --accent-text-2: #fed7aa;
  --on-accent: #1c0900;
  --ok: #4ade80;
  --ok-text: #86efac;
  --danger: #f87171;
  --danger-text: #fecaca;
  --text: #ffffff;
  --text-2: #f0d6c0;
  --text-3: #c4a08a;
  --panel-solid: rgba(54, 24, 8, 0.94);
  --input-bg: rgba(43, 15, 5, 0.8);
}
[data-theme="rose"] {
  --bg0: #2b0510;
  --bg1: #3b0818;
  --bg2: #4a0a1e;
  --bg: #4a0a1e;
  --accent: #fb7185;
  --accent-2: #e11d48;
  --accent-text: #fda4af;
  --accent-text-2: #fecdd3;
  --on-accent: #22020a;
  --ok: #34d399;
  --ok-text: #86efac;
  --danger: #f87171;
  --danger-text: #fecaca;
  --text: #ffffff;
  --text-2: #f0c4cf;
  --text-3: #c493a2;
  --panel-solid: rgba(56, 10, 26, 0.94);
  --input-bg: rgba(43, 5, 16, 0.8);
}
[data-theme="ocean"] {
  --bg0: #04222a;
  --bg1: #064452;
  --bg2: #07515f;
  --bg: #07515f;
  --accent: #22d3ee;
  --accent-2: #0891b2;
  --accent-text: #67e8f9;
  --accent-text-2: #a5f3fc;
  --on-accent: #031720;
  --ok: #34d399;
  --ok-text: #86efac;
  --danger: #fb7185;
  --danger-text: #fecdd3;
  --text: #ffffff;
  --text-2: #c2e4ec;
  --text-3: #8cb6c2;
  --panel-solid: rgba(5, 40, 50, 0.94);
  --input-bg: rgba(4, 34, 42, 0.8);
}
[data-theme="moon"] {
  --bg0: #f1f5f9;
  --bg1: #e2e8f0;
  --bg2: #f8fafc;
  --bg: #f8fafc;
  --accent: #0ea5e9;
  --accent-2: #6366f1;
  --accent-text: #0284c7;
  --accent-text-2: #4f46e5;
  --on-accent: #ffffff;
  --ok: #059669;
  --ok-text: #047857;
  --danger: #dc2626;
  --danger-text: #b91c1c;
  --text: #1e293b;
  --text-2: #475569;
  --text-3: #94a3b8;
  --panel-solid: rgba(255, 255, 255, 0.95);
  --input-bg: rgba(255, 255, 255, 0.9);
}
[data-theme="gold"] {
  --bg0: #1f1300;
  --bg1: #2b1a02;
  --bg2: #3a2305;
  --bg: #3a2305;
  --accent: #fbbf24;
  --accent-2: #d97706;
  --accent-text: #fcd34d;
  --accent-text-2: #fde68a;
  --on-accent: #1c0e00;
  --ok: #4ade80;
  --ok-text: #86efac;
  --danger: #f87171;
  --danger-text: #fecaca;
  --text: #ffffff;
  --text-2: #ecdcb8;
  --text-3: #c4ae85;
  --panel-solid: rgba(52, 34, 6, 0.94);
  --input-bg: rgba(31, 19, 0, 0.8);
}
[data-theme="sakura"] {
  --bg0: #2a0d1e;
  --bg1: #3a1230;
  --bg2: #4a1538;
  --bg: #4a1538;
  --accent: #f472b6;
  --accent-2: #ec4899;
  --accent-text: #f9a8d4;
  --accent-text-2: #fbcfe8;
  --on-accent: #240312;
  --ok: #34d399;
  --ok-text: #86efac;
  --danger: #fb7185;
  --danger-text: #fecdd3;
  --text: #ffffff;
  --text-2: #f0c9de;
  --text-3: #c693b1;
  --panel-solid: rgba(56, 18, 44, 0.94);
  --input-bg: rgba(42, 13, 30, 0.8);
}
