/*
 * 我的门户 · 样式（单文件、无外部依赖、无 CDN）
 * 兼容目标：Chrome 66 / Android App 内置 WebView（Chrome 57+ 均支持这里的全部特性）
 * 刻意避开：flex gap、inset、dvh、clamp/min/max、color-mix、:focus-visible、backdrop-filter
 */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1b2333;
  --muted: #69738a;
  --faint: #9aa4b7;
  --line: #e3e8f2;
  --accent: #4d7cfe;
  --shadow: 0 1px 2px rgba(24, 39, 75, 0.05);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131a;
    --card: #161c26;
    --text: #e8edf6;
    --muted: #98a3b8;
    --faint: #7c8699;
    --line: #26303f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 16px 28px;
}

@supports (padding: env(safe-area-inset-top)) {
  .page {
    padding-top: calc(22px + env(safe-area-inset-top));
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

/* ---------- 顶部：标题 + 余额 ---------- */

.head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  margin-right: 12px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: #4d7cfe;
  background: linear-gradient(135deg, #4d7cfe, #7c5cff);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(77, 124, 254, 0.26);
}

.logo svg { width: 22px; height: 22px; }

.brand-text { min-width: 0; padding-left: 10px; }

.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.balance {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-appearance: none;
  appearance: none;
}

.balance:active { opacity: 0.75; }

.balance-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #22c55e;
}

.balance.warn .balance-dot { background: #f59e0b; }
.balance.low .balance-dot { background: #ef4444; }
.balance.error .balance-dot { background: #94a3b8; }

.balance-label { margin-right: 5px; color: var(--muted); }

.balance strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- 区块标题 ---------- */

.section { margin-top: 26px; }

.section-title {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ---------- 应用卡片 ---------- */

.apps {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -5px;
}

.card {
  display: flex;
  align-items: center;
  flex: 1 1 210px;
  min-height: 78px;
  margin: 0 5px 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.card:active { opacity: 0.85; }

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
}

.card-icon svg { width: 22px; height: 22px; }

.card-blue .card-icon { background: #e8effe; color: #3b6ef5; }
.card-green .card-icon { background: #e6f7f0; color: #0f9d6b; }
.card-purple .card-icon { background: #efeaff; color: #6d4df6; }

.card-body {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0 10px;
}

.card-name {
  display: block;
  font-size: 15.5px;
  font-weight: 600;
}

.card-desc {
  display: block;
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--muted);
}

.card-host {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-go {
  flex: 0 0 auto;
  margin-left: 2px;
  font-size: 18px;
  line-height: 1;
  color: #b6c0d4;
}

@media (hover: hover) {
  .card {
    -webkit-transition: border-color 0.16s ease, box-shadow 0.16s ease, -webkit-transform 0.16s ease;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  }
  .card:hover {
    border-color: #c9d6f8;
    box-shadow: 0 8px 22px rgba(24, 39, 75, 0.09);
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
  }
  .jump-btn:hover { background: #3f6ae6; }
  .balance:hover { border-color: #c9d6f8; }
}

/* ---------- 地址栏 ---------- */

.jump {
  display: flex;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.jump:focus-within {
  border-color: #9db4f7;
  box-shadow: 0 0 0 3px rgba(77, 124, 254, 0.14);
}

.jump-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

.jump-input::-webkit-input-placeholder { color: var(--faint); }
.jump-input::placeholder { color: var(--faint); }

.jump-btn {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.jump-btn:active { background: #3f6ae6; }

.jump-hint {
  min-height: 16px;
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--muted);
}

.jump-hint.error { color: #e5484d; }

/* ---------- 底部 ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-top: 30px;
  font-size: 11.5px;
  color: var(--faint);
}

.foot span { padding: 0 4px; }

.noscript {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 24px;
  font-size: 13px;
  color: #e5484d;
}

/* ---------- 深色模式（旧内核自动忽略，保持浅色） ---------- */

@media (prefers-color-scheme: dark) {
  .card-blue .card-icon { background: #16233d; color: #7ea2ff; }
  .card-green .card-icon { background: #102a22; color: #3ddc97; }
  .card-purple .card-icon { background: #1e1a33; color: #a48cff; }
  .card:hover { border-color: #33415a; }
  .jump:focus-within { border-color: #3f5a99; }
}

/* ---------- 小屏 ---------- */

@media (max-width: 379px) {
  .page { padding: 18px 13px 24px; }
  .logo { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; }
  .logo svg { width: 20px; height: 20px; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { font-size: 11.5px; }
  .balance { height: 31px; padding: 0 10px; font-size: 12px; }
  .card { flex: 1 1 100%; }
  .foot { margin-top: 24px; font-size: 11px; }
}

/* ---------- 减少动画 ---------- */

@media (prefers-reduced-motion: reduce) {
  .card { -webkit-transition: none; transition: none; }
}
