:root {
  --bg: #08080A;
  --card: #0E1013;
  --card-2: #12151A;
  --ink: #F0F3F8;
  --ink-2: #C6CDD8;
  --muted: #8A93A2;
  --line: #1E2430;
  --line-strong: #2A3140;
  --brand: #4C8DFF;
  --brand-hi: #6AA3FF;
  --brand-dim: rgba(76, 141, 255, .12);
  --ok: #2FCB8A;
  --bad: #F0565C;
  --warn: #E0A63D;
  --radius: 16px;
  --shadow: 0 16px 48px rgba(0, 0, 0, .5);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; }
*, *::before, *::after { -webkit-tap-highlight-color: transparent; }
a, button, [role="button"], input, select, textarea { touch-action: manipulation; }
:focus { outline: none; }
:focus-visible { outline: 2px solid rgba(76, 141, 255, .55); outline-offset: 2px; }
::-moz-focus-inner { border: 0; }

html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 480px at 50% -12%, rgba(76, 141, 255, .07), transparent 60%),
    linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 28px 28px, 28px 28px, auto;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); text-decoration: none; }
img { display: block; }
button { font: inherit; }

.page {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  padding: 22px 16px calc(28px + env(safe-area-inset-bottom));
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 0 4px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line-strong);
}
span.brand-logo {
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 19px;
  background: var(--brand);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; letter-spacing: .2px; }
.brand-text small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.user-mini { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); object-fit: cover; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta b { font-size: 12.5px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 10.5px; color: var(--muted); }
.user-meta.guest b { color: var(--ink-2); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
}
.chip-ok { color: var(--ok); background: rgba(47, 203, 138, .1); border: 1px solid rgba(47, 203, 138, .25); }
.chip-bad { color: var(--bad); background: rgba(240, 86, 92, .1); border: 1px solid rgba(240, 86, 92, .25); }

/* 主卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px 22px 22px;
  animation: rise .45s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card-head { text-align: left; margin-bottom: 18px; }
.pill {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  color: var(--brand-hi); background: var(--brand-dim);
  border: 1px solid rgba(76, 141, 255, .3);
  padding: 5px 10px; border-radius: 999px;
}
.card-head h1 {
  font-size: 23px; line-height: 1.3; letter-spacing: -.4px;
  margin: 12px 0 6px;
  background: linear-gradient(120deg, #F0F3F8, #A9C9FF 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* 账号区 */
.account {
  border: 1px solid var(--line);
  background: var(--card-2);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 18px;
}
.account-main { display: flex; align-items: center; gap: 12px; }
.account-avatar { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; background: var(--card-2); border: 1px solid var(--line); }
.account-info { min-width: 0; flex: 1; }
.account-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.account-line b { font-size: 14.5px; }
.account-line .muted { font-size: 11.5px; }
.account-status { margin-top: 5px; font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(47, 203, 138, .14); }
.dot-bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(240, 86, 92, .12); }
.account-actions { display: flex; gap: 8px; margin-top: 12px; }
.buy-line { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-strong); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.login-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(76, 141, 255, .35);
  background: linear-gradient(120deg, rgba(76, 141, 255, .1), rgba(76, 141, 255, .04));
  margin-bottom: 18px;
  color: var(--ink);
  transition: transform .15s ease, border-color .15s ease;
}
.login-banner:hover { transform: translateY(-1px); border-color: var(--brand); }
.login-icon {
  width: 40px; height: 40px; border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  flex-shrink: 0;
}
.login-banner b { display: block; font-size: 13.5px; }
.login-banner small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.login-banner .arrow { margin-left: auto; font-size: 22px; color: var(--muted); }

/* 表单 */
.field { margin-bottom: 15px; }
.field > label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  margin-bottom: 7px;
}
.mini-link {
  border: 0; background: none; padding: 0;
  color: var(--brand); font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.input-row { display: flex; gap: 8px; }
input[type="text"], select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  background: #0A0C0F;
  border-radius: 10px;
  padding: 0 13px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238A93A2' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
input[type="text"]:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(76, 141, 255, .18);
}
input::placeholder { color: #5C6675; }

.preview {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--card-2);
  border: 1px dashed var(--line-strong);
  margin: 4px 0 16px;
}
.preview-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.preview-bubble {
  font-size: 13px; max-width: 70%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: #0A0C0F; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 5px 10px;
}
.opt-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); color: var(--muted);
  font-size: 10px; font-weight: 600; vertical-align: 1px;
}
.preview-net { color: var(--brand-hi); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, opacity .12s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 6px 18px rgba(76, 141, 255, .28);
}
.btn-primary:hover { background: var(--brand-hi); }
.btn-primary[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  color: var(--ink-2); background: transparent; border-color: var(--line-strong);
}
.btn-ghost:hover { color: var(--ink); border-color: #3A4354; background: rgba(255, 255, 255, .03); }
.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn-inline { height: 46px; padding: 0 14px; white-space: nowrap; }
.spinner {
  display: inline-block;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner-dark { border-color: var(--line-strong); border-top-color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.form-tip { text-align: center; color: #5C6675; font-size: 11px; margin: 10px 0 0; }

/* 提示 */
.alert {
  margin-top: 14px; padding: 12px 14px;
  border-radius: 10px; font-size: 13px; line-height: 1.6;
  border: 1px solid transparent;
}
.alert-ok { color: var(--ok); background: rgba(47, 203, 138, .08); border-color: rgba(47, 203, 138, .3); }
.alert-bad { color: var(--bad); background: rgba(240, 86, 92, .08); border-color: rgba(240, 86, 92, .3); }
.alert-info { color: var(--brand-hi); background: var(--brand-dim); border-color: rgba(76, 141, 255, .3); }

.notice {
  margin: 18px 0 0; padding: 14px 14px 14px 30px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--muted); font-size: 11.8px; line-height: 1.75;
}
.notice li { margin: 2px 0; }
.notice a { color: var(--brand); }

.footer { text-align: center; color: #5C6675; font-size: 11px; line-height: 1.9; margin-top: 18px; }
.footer a { color: #5C6675; }
.footer p { margin: 0; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; }
.modal-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop .2s ease;
  overflow: hidden;
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-x { border: 0; background: var(--card-2); border: 1px solid var(--line); width: 30px; height: 30px; border-radius: 50%; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 16px 18px 20px; font-size: 13px; color: var(--ink-2); line-height: 1.75; }
.modal-body p { margin: 8px 0; }
.steps { margin: 4px 0 12px; padding-left: 20px; }
.steps li { margin: 7px 0; }
code {
  background: #161B22; border: 1px solid var(--line-strong); border-radius: 5px;
  padding: 1px 5px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #A9C9FF;
}
.link { color: var(--brand); word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.center { text-align: center; }
.hint { color: var(--warn); font-size: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%) translateY(-6px);
  z-index: 200;
  max-width: min(92vw, 440px);
  padding: 10px 16px; border-radius: 10px;
  background: #161B22; color: var(--ink);
  border: 1px solid var(--line-strong);
  font-size: 13px; line-height: 1.5;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .page { padding: 16px 12px 26px; }
  .card { padding: 20px 16px 18px; }
  .card-head h1 { font-size: 20.5px; }
  .brand-text small { display: none; }
  .preview { flex-direction: column; align-items: flex-start; gap: 6px; }
  .preview-bubble { max-width: 100%; }
}

/* ---------- 登录页 ---------- */
.page-narrow { max-width: 520px; }
.login-card { text-align: center; }
.login-card .card-head { text-align: center; }
.qr-box {
  position: relative;
  width: 216px; height: 216px;
  margin: 6px auto 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 0 6px #fff, 0 0 24px rgba(76, 141, 255, .12);
  display: grid; place-items: center;
  overflow: hidden;
}
.qr-img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.qr-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.qr-loading p { margin: 0; }
.qr-mask {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(8, 8, 10, .86);
  backdrop-filter: blur(2px);
  color: var(--ink-2); font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.qr-status { font-size: 13px; color: var(--ink-2); margin: 10px 0 16px; min-height: 20px; }
.qr-status[data-tone="ok"] { color: var(--ok); }
.qr-status[data-tone="bad"] { color: var(--bad); }
.login-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.login-tips { text-align: left; }

@media (max-width: 480px) {
  .qr-box { width: 196px; height: 196px; }
  .login-actions { grid-template-columns: 1fr; }
}

/* JS 渲染的二维码 */
.qr-code {
  width: 100%; height: 100%;
  padding: 12px;
  display: grid; place-items: center;
  background: #fff;
}
.qr-code svg { width: 100%; height: 100%; display: block; }
.qr-code[hidden] { display: none !important; }
.quick-actions { grid-template-columns: 1fr; margin-bottom: 10px; }

/* 截图提取 */
.ocr-preview { margin-bottom: 10px; }
.ocr-preview img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #0A0C0F;
  display: block;
}
.ocr-cand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--card-2);
}
.ocr-cand code {
  flex: 1;
  word-break: break-all;
  font-size: 13px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink);
}
.ocr-cand .btn { flex-shrink: 0; }
.ocr-cand-rec {
  border: 1px solid var(--brand);
  background: var(--brand-dim);
  padding: 14px 12px;
}
.ocr-tag {
  display: block;
  width: 100%;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand-hi);
  margin-bottom: 4px;
}
.ocr-tag-dim { color: var(--muted); font-weight: 600; }
