/* ============ 设计基座 ============ */
/* 移动优先 · 明暗双主题 · 单强调色（青绿，与桌面版同一血统）· 圆角体系 16/10/pill */

:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1c1d20;
  --text-dim: #6d7076;
  --text-faint: #a3a6ac;
  --line: rgba(28, 29, 32, 0.08);
  --accent: #2e7d6b;
  --accent-hover: #256a5a;
  --accent-weak: rgba(46, 125, 107, 0.1);
  --on-accent: #ffffff;
  --danger: #b03a3a;
  --danger-weak: rgba(176, 58, 58, 0.09);
  --ok-weak: rgba(46, 125, 107, 0.12);
  --shadow: 0 1px 2px rgba(30, 34, 40, 0.04), 0 6px 24px rgba(30, 34, 40, 0.06);
  --radius-card: 16px;
  --radius-field: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --card: #1e1f23;
    --text: #e9eaec;
    --text-dim: #96999f;
    --text-faint: #66696f;
    --line: rgba(255, 255, 255, 0.09);
    --accent: #6fbfad;
    --accent-hover: #8ccfc0;
    --accent-weak: rgba(111, 191, 173, 0.13);
    --on-accent: #10201c;
    --danger: #d97879;
    --danger-weak: rgba(217, 120, 121, 0.13);
    --ok-weak: rgba(111, 191, 173, 0.15);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei UI', 'Microsoft YaHei', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ============ 按钮 ============ */

.btn {
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.16s ease, opacity 0.16s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.btn-ghost:not(:disabled):hover { color: var(--text); background: var(--accent-weak); }

.btn-danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger-weak); }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: transparent; color: var(--text-dim);
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}
.icon-btn:hover { background: var(--accent-weak); color: var(--text); }

/* ============ 首次进入 ============ */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(360px, 100%);
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 36px 28px 28px;
  text-align: center;
}
.gate-mark {
  width: 52px; height: 52px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--accent-weak);
  position: relative;
}
.gate-mark::after {
  content: '';
  position: absolute;
  inset: 16px;
  border-radius: 4px;
  border: 2.5px solid var(--accent);
  border-top-color: transparent;
  transform: rotate(45deg);
}
.gate-card h1 { font-size: 21px; letter-spacing: 0.02em; }
.gate-sub { color: var(--text-dim); font-size: 13px; margin: 6px 0 22px; }
.gate-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.2em;
}
.gate-card input:focus { border-color: var(--accent); outline: none; }
.gate-advanced { margin-top: 12px; text-align: left; }
.gate-advanced summary { color: var(--text-faint); font-size: 12px; cursor: pointer; }
.gate-advanced input {
  margin-top: 8px;
  text-align: left;
  letter-spacing: normal;
  font-size: 13px;
}
#gateForm .btn { margin-top: 16px; }
.gate-error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ============ 主界面 ============ */

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 16px calc(88px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar-title { display: flex; align-items: baseline; gap: 12px; }
.topbar-name { font-size: 20px; font-weight: 700; letter-spacing: 0.01em; }
.topbar-progress {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-weak);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cdk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius-field);
  padding: 8px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.cdk-bar label { font-size: 12px; font-weight: 700; color: var(--text-dim); flex: none; }
.cdk-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.cdk-bar input::placeholder { color: var(--text-faint); }

/* 账号列表 */
.account-list { display: flex; flex-direction: column; gap: 14px; flex: 1; }

.server-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  margin: 4px 2px -6px;
}

.acct-row {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.acct-state {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--line);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.acct-row.ok .acct-state { background: var(--accent); color: var(--on-accent); }
.acct-row.capped .acct-state { background: var(--ok-weak); color: var(--accent); }
.acct-row.bad .acct-state { background: var(--danger-weak); color: var(--danger); }

.acct-main { flex: 1; min-width: 0; }
.acct-name {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acct-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acct-meta .fail-reason { color: var(--danger); }
.acct-meta .capped-note { font-style: italic; }

.acct-actions { display: flex; gap: 6px; flex: none; }
.acct-actions .btn-sm { padding: 7px 13px; font-size: 12.5px; }
.acct-more {
  border: none;
  background: none;
  color: var(--text-faint);
  font-size: 18px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 8px;
}
.acct-more:hover { color: var(--text); background: var(--accent-weak); }

/* 空状态 */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-dim);
  padding: 40px 0;
}
.empty-art {
  width: 56px; height: 56px;
  border-radius: 18px;
  background: var(--accent-weak);
  margin-bottom: 10px;
}
.empty-hint { font-size: 12px; color: var(--text-faint); }

/* 底部操作栏 */
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
}
.actionbar .btn { min-width: 150px; }

/* ============ 底部抽屉 ============ */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 14, 0.45);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.18s ease;
}

.sheet {
  width: min(520px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  animation: sheet-up 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
.sheet-handle {
  width: 40px; height: 4.5px;
  border-radius: 999px;
  background: var(--line);
  margin: 4px auto 14px;
}
.sheet h2 { font-size: 17px; margin-bottom: 16px; }

@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* 表单 */
.form .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field-row { display: flex; gap: 8px; }
.field-row select, .field-row input { flex: 1; min-width: 0; }
.form select, .form input {
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  appearance: none;
}
.form select { background-image: none; }
.form input:focus, .form select:focus { border-color: var(--accent); outline: none; }
.form input::placeholder { color: var(--text-faint); }

/* 自绘选择器字段（替代原生 select，规避手机下拉被截断） */
.picker-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease;
}
.picker-field:active, .picker-field:focus-visible { border-color: var(--accent); outline: none; }
.picker-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-value.placeholder { color: var(--text-faint); }
.picker-caret { color: var(--text-faint); font-size: 12px; flex: none; }

/* 选择器抽屉：列表限高内滚，长列表也能滚到底 */
.sheet-picker { padding-bottom: calc(16px + var(--safe-bottom)); }
.option-list {
  max-height: 48dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
}
.option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  font-size: 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.12s ease;
}
.option-item:last-child { border-bottom: none; }
.option-item:active, .option-item:hover { background: var(--accent-weak); }
.option-item.selected { color: var(--accent); font-weight: 600; }
.option-item.selected::after { content: '✓'; font-size: 14px; }
.option-empty { padding: 20px 16px; text-align: center; color: var(--text-faint); font-size: 14px; }
.form-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }
.field-note { font-size: 12px; color: var(--text-faint); line-height: 1.6; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }

/* 验证码抽屉 */
.captcha-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.captcha-account { font-size: 13px; font-weight: 600; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.captcha-guess { font-size: 12px; color: var(--accent); font-weight: 600; flex: none; }

.captcha-body { display: flex; gap: 12px; align-items: stretch; }
.captcha-img {
  flex: none;
  width: 132px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  background: #fff;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}
.captcha-img img { width: 100%; height: 44px; object-fit: cover; display: block; }
.captcha-img-hint {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(20, 21, 23, 0.55);
  color: #fff;
  font-size: 10px;
  text-align: center;
  padding: 2px 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.captcha-img:hover .captcha-img-hint, .captcha-img:active .captcha-img-hint { opacity: 1; }
.captcha-body input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  letter-spacing: 0.15em;
  text-align: center;
}
.captcha-body input:focus { border-color: var(--accent); outline: none; }

.captcha-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}
.captcha-status.err { color: var(--danger); }

/* ============ Toast ============ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 48px));
  background: var(--text);
  color: var(--bg);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 50;
  animation: toast-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ 动效克制 ============ */

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop, .toast { animation: none; }
  .btn { transition: none; }
}
