/* WLOC 控制台 —— 手机优先的深色控制台样式 */
:root {
  --bg: #070b16;
  --card: #0e1526;
  --card2: #131c31;
  --line: #22304d;
  --text: #e8eefc;
  --dim: #8d9cbb;
  --accent: #3ea6ff;
  --accent2: #21d07a;
  --bad: #ff6b6b;
  --warn: #ffb545;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性必须压过任何 display 规则,否则弹层关不掉 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(900px 400px at 15% -8%, #14315e 0%, transparent 60%),
    radial-gradient(700px 380px at 100% 0%, #0d3b46 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}

body { padding: 0 12px calc(28px + env(safe-area-inset-bottom)); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: calc(14px + env(safe-area-inset-top)) 2px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(150deg, #3ea6ff, #1b3f8f 70%);
  box-shadow: 0 6px 18px rgba(62,166,255,.35);
  position: relative;
}
.logo::after {
  content: ""; position: absolute; inset: 10px 12px 12px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: #fff; opacity: .92;
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.topbar p { margin: 1px 0 0; font-size: 11.5px; color: var(--dim); }
.ver {
  font-size: 11px; color: var(--dim); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}

/* ---------- 卡片 ---------- */
.card {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 10px 26px rgba(0,0,0,.28);
}
.card-title {
  font-size: 13px; margin: 0 0 10px; color: #b9c7e6;
  display: flex; align-items: center; justify-content: space-between;
  letter-spacing: .4px; text-transform: none; font-weight: 600;
}
.refresh {
  background: #17233c; color: #9fd0ff; border: 1px solid #26406b;
  font-size: 12px; padding: 5px 11px; border-radius: 9px;
}
.refresh:active { transform: scale(.96); }

/* ---------- 状态列表 ---------- */
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px dashed #1e2a44; font-size: 13.5px;
}
.status-list li:last-child { border-bottom: none; }
.status-list span { color: var(--dim); flex: none; }
.status-list b { font-weight: 600; text-align: right; word-break: break-all; }
.ok { color: var(--accent2) !important; }
.bad { color: var(--bad) !important; }
.mid { color: var(--warn) !important; }

.hint { color: var(--dim); font-size: 12.5px; margin: 8px 0 0; }
.hint b, .hint strong { color: #cfe0ff; }

.banner {
  background: linear-gradient(180deg, #3a2c12, #2a2110);
  border: 1px solid #6d4e1a; color: #ffd79a;
  padding: 11px 13px; border-radius: var(--radius);
  font-size: 12.5px; line-height: 1.6; margin-bottom: 12px;
}
.banner b { color: #ffe6bb; }
.dl-item.disabled { opacity: .5; }

/* ---------- 地图 ---------- */
.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row input {
  flex: 1; min-width: 0; background: #0a1222; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.search-row button, .actions button, .chips button {
  background: #17233c; color: #cfe0ff; border: 1px solid #26406b;
  border-radius: 10px; padding: 10px 14px; font-size: 14px; white-space: nowrap;
}
.search-row button:active, .actions button:active { transform: scale(.97); }
.actions button.primary {
  background: linear-gradient(180deg, #2f8ffb, #1f6fe0);
  border-color: #3f9bff; color: #fff; font-weight: 600;
}
.results {
  background: #0a1222; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; overflow: hidden;
}
.results div { padding: 10px 12px; font-size: 13.5px; border-bottom: 1px solid #16203a; }
.results div:last-child { border-bottom: none; }
.results div:active { background: #16233d; }

.map {
  height: 320px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); background: #0a1020;
}
.map-note { font-size: 11.5px; color: var(--dim); margin: 6px 0 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.grid2 label { font-size: 11.5px; color: var(--dim); display: flex; flex-direction: column; gap: 4px; }
.grid2 input {
  background: #0a1222; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 10px; font-size: 14px; width: 100%;
}

.slider-label { display: block; font-size: 12.5px; color: var(--dim); margin: 14px 0 0; }
.slider-label b { color: var(--accent); font-size: 14px; }
input[type=range] { width: 100%; margin: 6px 0 0; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips button { padding: 7px 12px; font-size: 12.5px; border-radius: 999px; }

.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* ---------- 验证结果 ---------- */
.check {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 0; border-bottom: 1px dashed #1e2a44; font-size: 13px;
}
.check:last-child { border-bottom: none; }
.check .mark { flex: none; width: 20px; height: 20px; border-radius: 50%; text-align: center; line-height: 20px; font-size: 12px; margin-top: 1px; }
.check .mark.ok { background: rgba(33,208,122,.16); color: var(--accent2); }
.check .mark.bad { background: rgba(255,107,107,.16); color: var(--bad); }
.check b { display: block; font-size: 13px; margin-bottom: 2px; }
.check p { margin: 0; color: var(--dim); font-size: 12.5px; }

/* ---------- 下载 ---------- */
.dl { display: flex; flex-direction: column; gap: 9px; margin: 10px 0 0; }
.dl-item {
  display: block; text-decoration: none; color: inherit;
  background: #0a1222; border: 1px solid #26406b; border-radius: 12px; padding: 12px;
}
.dl-item:active { background: #132140; }
.dl-item b { display: block; font-size: 14px; color: #d6e6ff; margin-bottom: 3px; }
.dl-item span { font-size: 12px; color: var(--dim); }

/* ---------- 步骤 / 限制 ---------- */
.steps { margin: 0; padding-left: 20px; font-size: 13.5px; color: #cfdcf4; }
.steps li { margin-bottom: 7px; }
.limits { margin: 0; padding-left: 18px; font-size: 13px; color: #c7d5ee; }
.limits li { margin-bottom: 7px; }
.warn-card { border-color: #4a3a1c; background: linear-gradient(180deg, #1d1a12, var(--card)); }

footer { text-align: center; color: #5f6d8c; font-size: 11.5px; padding: 6px 0 22px; }

/* ---------- 定位开关 ---------- */
.actions button.restore {
  background: #241d10; border-color: #6d4e1a; color: #ffd79a;
}
.actions button.resume {
  background: #0f2419; border-color: #1d6b4a; color: #9ff0c4;
}
.actions button:disabled, .btn-blue.disabled {
  opacity: .5; pointer-events: none;
}
.mode-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0;
}
.mode-line .hint { margin: 0; flex: 1; min-width: 180px; }
.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line);
}
.tag.ok { color: #9ff0c4; background: rgba(33,208,122,.12); border-color: #1d6b4a; }
.tag.warn { color: #ffd79a; background: rgba(255,181,69,.12); border-color: #6d4e1a; }

/* ---------- WireGuard 配置块 ---------- */
.wg-box {
  margin-top: 10px; padding: 12px; border-radius: 12px;
  background: #0a1222; border: 1px solid #26406b;
}
.wg-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 6px; margin-bottom: 10px;
}
.wg-head b { font-size: 14px; color: #d6e6ff; }
.wg-addr { font-size: 11.5px; color: #9fd0ff; word-break: break-all; }

.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-wrap img {
  width: 100%; max-width: 240px; height: auto; border-radius: 10px;
  background: #fff; padding: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.qr-wrap .hint { text-align: center; margin: 0; }

.wg-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.btn-blue, .wg-actions button {
  display: block; text-align: center; text-decoration: none;
  background: linear-gradient(180deg, #2f8ffb, #1f6fe0); color: #fff;
  border: 1px solid #3f9bff; border-radius: 10px;
  padding: 11px 14px; font-size: 14px; font-weight: 600;
}
.wg-actions button {
  background: #17233c; color: #cfe0ff; border-color: #26406b; font-weight: 400;
}
.btn-blue:active, .wg-actions button:active { transform: scale(.98); }

.wg-manual { margin-top: 12px; }
.wg-manual summary {
  font-size: 12.5px; color: #9fd0ff; cursor: pointer; padding: 4px 0;
}
.kv { list-style: none; margin: 6px 0 0; padding: 0; }
.kv li {
  display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
  padding: 7px 0; border-bottom: 1px dashed #1e2a44; font-size: 12.5px;
}
.kv li:last-child { border-bottom: none; }
.kv span { color: var(--dim); flex: none; }
.kv b { font-weight: 600; word-break: break-all; text-align: right; font-family: ui-monospace, Menlo, monospace; }

/* leaflet 深色适配 */
.leaflet-container { background: #0a1020; }
.leaflet-control-attribution { background: rgba(0,0,0,.35) !important; color: #93a3c4 !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #93a3c4 !important; }
.leaflet-bar a { background: #131c31 !important; color: #cfe0ff !important; border-color: #22304d !important; }

/* 地图上的选点标记 */
.pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 38%, #6fd2ff 0%, #2f8ffb 55%, #1b4fd0 100%);
  border: 2px solid #eaf4ff;
  box-shadow: 0 4px 14px rgba(47,143,251,.65), 0 0 0 3px rgba(47,143,251,.18);
  position: relative;
}
.pin::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #1b4fd0;
}

/* ---------- 地图源切换器(右下角) ---------- */
.map-wrap { position: relative; border-radius: 12px; }
.src-btn {
  position: absolute; right: 10px; bottom: 26px; z-index: 620;
  display: flex; align-items: center; gap: 6px;
  background: rgba(10,18,34,.92); color: #d6e6ff;
  border: 1px solid #26406b; border-radius: 999px;
  padding: 7px 13px; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 6px 16px rgba(0,0,0,.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  max-width: 62%;
}
.src-btn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-btn:active { transform: scale(.96); }
.src-caret { font-size: 9px; color: #7f95bd; margin-left: -1px; flex: none; }
.src-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--accent2); box-shadow: 0 0 0 3px rgba(33,208,122,.18);
}
.src-backdrop {
  position: fixed; inset: 0; z-index: 2400;
  background: rgba(3,6,12,.62);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.src-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2500;
  max-height: 68vh;
  display: flex; flex-direction: column;
  background: #0d1626; border: 1px solid #26406b; border-bottom: none;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -14px 40px rgba(0,0,0,.6);
  padding-bottom: env(safe-area-inset-bottom);
  animation: srcUp .18s ease-out;
}
@keyframes srcUp { from { transform: translateY(14px); opacity: .4; } to { transform: none; opacity: 1; } }
.src-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 15px 11px; border-bottom: 1px solid #1e2a44; flex: none;
}
.src-head::before {
  content: ""; position: absolute; left: 50%; top: 6px; transform: translateX(-50%);
  width: 38px; height: 4px; border-radius: 2px; background: #2c3f63;
}
.src-head b { font-size: 14px; color: #d6e6ff; }
.src-head button {
  background: transparent; border: none; color: var(--dim);
  font-size: 16px; padding: 2px 6px; line-height: 1;
}
.src-list { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; }
.src-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; background: transparent; border: none;
  border-bottom: 1px solid #16203a; color: var(--text);
  padding: 12px 15px; font-size: 14px;
}
.src-item:last-child { border-bottom: none; }
.src-item:active { background: #16233d; }
.src-item.on { background: rgba(62,166,255,.12); }
.src-item .src-name { font-weight: 600; }
.src-item.on .src-name { color: #9fd0ff; }
.src-item.on .src-name::before {
  content: "●"; color: var(--accent); font-size: 10px; margin-right: 6px; vertical-align: 1px;
}
.src-item .src-meta { font-size: 11px; color: var(--dim); text-align: right; flex: none; }
.src-tip {
  margin: 0; padding: 10px 15px; font-size: 11.5px; color: var(--dim);
  border-top: 1px solid #1e2a44; background: #0a1222; flex: none; line-height: 1.55;
}
.src-tip b { color: #9fd0ff; }

/* ---------- 未授权定位的锁提示 ---------- */
.lock-hint {
  margin: 8px 0 0; font-size: 12.5px; color: #ffd79a;
  background: rgba(255,181,69,.09); border: 1px solid #6d4e1a;
  border-radius: 10px; padding: 9px 11px; line-height: 1.55;
}

/* ---------- 全屏门槛(主屏幕 / 定位权限) ---------- */
.gate {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(4,7,14,.93);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px calc(16px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.gate-card {
  width: 100%; max-width: 430px;
  background: linear-gradient(180deg, #16203a, #0c1526);
  border: 1px solid #2a3c60; border-radius: 18px;
  padding: 22px 18px 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,.65);
  margin: auto;
}
.gate-icon { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.gate-card h2 { font-size: 19px; margin: 0 0 8px; letter-spacing: .2px; }
.gate-sub { font-size: 13px; color: var(--dim); margin: 0 0 16px; line-height: 1.65; }
.gate-sub b { color: #cfe0ff; }

.gate-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.gs {
  display: flex; gap: 11px; align-items: flex-start;
  background: #0a1222; border: 1px solid #26406b; border-radius: 12px;
  padding: 11px 12px; font-size: 13.5px; line-height: 1.5;
}
.gs-n {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(180deg, #2f8ffb, #1f6fe0); color: #fff;
  font-size: 12px; font-weight: 700; text-align: center; line-height: 22px;
}
.gs b { color: #d6e6ff; }
.gs-sub { display: block; font-size: 11.5px; color: var(--dim); margin-top: 3px; }

.gate-go {
  display: block; width: 100%; text-align: center;
  background: linear-gradient(180deg, #2f8ffb, #1f6fe0); color: #fff;
  border: 1px solid #3f9bff; border-radius: 12px;
  padding: 13px 14px; font-size: 15px; font-weight: 700;
  box-shadow: 0 8px 22px rgba(47,143,251,.32);
}
.gate-go:active { transform: scale(.98); }
.gate-skip {
  display: block; width: 100%; margin-top: 10px;
  background: transparent; border: none; color: var(--dim);
  font-size: 12.5px; padding: 9px; text-decoration: underline;
  text-decoration-color: #35496e; text-underline-offset: 3px;
}
.gate-help {
  margin-top: 14px; border-top: 1px solid #1e2a44; padding-top: 12px;
}
.gate-help summary { font-size: 12.5px; color: #9fd0ff; cursor: pointer; }
.gate-help ol { margin: 10px 0 0; padding-left: 19px; font-size: 12.5px; color: #c7d5ee; line-height: 1.75; }
.gate-help ol b { color: #ffe6bb; }
.gate-help p { font-size: 11.5px; color: var(--dim); margin: 9px 0 0; }

/* ---------- 定位门槛:实时状态 / 手动兜底 ---------- */
.geo-env { font-size: 11.5px; color: var(--dim); margin: -6px 0 14px; }
.geo-env b { color: #9fd0ff; }
.geo-status {
  margin-top: 14px; border-radius: 12px; padding: 12px 13px;
  font-size: 13px; line-height: 1.62;
  background: rgba(62,166,255,.08); border: 1px solid #26406b; color: #cfe0ff;
}
.geo-status.wait { background: rgba(62,166,255,.10); border-color: #2f6fd0; }
.geo-status.ok   { background: rgba(33,208,122,.10); border-color: #1f7a4c; color: #bff3d8; }
.geo-status.bad  { background: rgba(255,107,107,.10); border-color: #7a2b2b; color: #ffd0d0; }
.geo-tip { display: block; margin-top: 8px; font-size: 11.5px; color: #a8bad6; }
.gate-go[disabled] { opacity: .72; }
.fb-row { display: flex; gap: 8px; margin: 10px 0 8px; }
.fb-row input {
  flex: 1 1 0; min-width: 0; background: #0a1222; border: 1px solid #26406b;
  border-radius: 10px; color: var(--text); padding: 11px 12px; font-size: 13px;
}
.fb-row2 { display: flex; gap: 8px; }
.fb-btn {
  flex: 1 1 0; background: linear-gradient(180deg, #2f8ffb, #1f6fe0); color: #fff;
  border: 1px solid #3f9bff; border-radius: 10px; padding: 11px 12px;
  font-size: 13px; font-weight: 700;
}
.fb-btn.ghost { background: transparent; color: #9fd0ff; border-color: #2a3c60; font-weight: 600; }
.gate-link {
  display: block; margin-top: 12px; font-size: 12.5px; text-align: center;
  color: #7fb6ff; text-decoration: none; opacity: .85;
}
