/* =============================================================
   Pengfei Auth — Apple ID style, full-bleed, no card border.
   ============================================================= */

:root {
  --bg: #fbfbfd;
  --fg: #1d1d1f;
  --fg-muted: #6e6e73;
  --fg-faint: #86868b;
  --accent: #0071e3;
  --accent-press: #005bbf;
  --danger: #d4332c;
  --success: #29a35c;
  --field-bg: #fff;
  --field-border: #d2d2d7;
  --field-border-focus: #0071e3;
  --field-shadow-focus: 0 0 0 4px rgba(0, 113, 227, 0.18);
  --hover: rgba(0, 0, 0, 0.04);
  --row-divider: rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --fg: #f5f5f7;
    --fg-muted: #a1a1a6;
    --fg-faint: #6e6e73;
    --accent: #2997ff;
    --accent-press: #0a84ff;
    --danger: #ff453a;
    --success: #30d158;
    --field-bg: #1c1c1e;
    --field-border: #3a3a3c;
    --field-border-focus: #2997ff;
    --field-shadow-focus: 0 0 0 4px rgba(41, 151, 255, 0.22);
    --hover: rgba(255, 255, 255, 0.06);
    --row-divider: rgba(255, 255, 255, 0.10);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
}
body { min-height: 100vh; min-height: 100dvh; }
button { font-family: inherit; }

/* ----- Top bar ----- */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--row-divider);
  font-size: 14px;
  color: var(--fg-muted);
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.topbar .brand-mini {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--fg); font-weight: 500; font-size: 15px;
}
.topbar .brand-mini .dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #2997ff, #0040dd);
}

/* ----- Page layout ----- */
.page {
  max-width: 380px;
  margin: 0 auto;
  padding: 56px 22px 96px;
  display: flex; flex-direction: column; gap: 24px;
  min-height: calc(100vh - 52px);
  min-height: calc(100dvh - 52px);
}

.hero {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.hero h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.hero .sub {
  color: var(--fg-muted);
  font-size: 15px;
  margin: 0;
}

/* ----- Form ----- */
form { display: flex; flex-direction: column; gap: 14px; }

.field {
  position: relative;
  display: flex;
  align-items: stretch;
}
.field input {
  flex: 1;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--fg);
  font-size: 16px;
  border-radius: 12px;
  outline: none;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--fg-faint); }
.field input:focus {
  border-color: var(--field-border-focus);
  box-shadow: var(--field-shadow-focus);
}
.field.has-suffix input { padding-right: 116px; }
.field .suffix {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: color .12s, background .12s, opacity .12s;
}
.field .suffix:hover:not(:disabled) { background: var(--hover); }
.field .suffix:disabled { color: var(--fg-faint); cursor: not-allowed; }

.field-hint {
  font-size: 12px;
  color: var(--fg-faint);
  padding: 0 4px;
  margin-top: -4px;
}

/* ----- Buttons ----- */
.btn {
  width: 100%;
  height: 50px;
  font-size: 17px;
  font-weight: 500;
  border: none;
  border-radius: 980px;
  cursor: pointer;
  transition: background .12s, color .12s, transform 0.06s ease, opacity .15s;
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: -0.01em;
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-press); }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--field-border);
}
.btn-ghost:hover:not(:disabled) { background: var(--hover); }
.btn-text {
  background: none; border: none; padding: 0;
  color: var(--accent); font-size: 14px; cursor: pointer; font-weight: 500;
}
.btn-text:hover { text-decoration: underline; }

/* ----- Switch row ----- */
.switch-row {
  text-align: center;
  font-size: 14px;
  color: var(--fg-muted);
}
.switch-row a {
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}

.divider-text {
  display: flex; align-items: center; gap: 10px;
  color: var(--fg-faint); font-size: 12px;
}
.divider-text::before, .divider-text::after {
  content: ""; flex: 1; height: 1px; background: var(--row-divider);
}

/* ----- Inline messages ----- */
.msg {
  font-size: 13px;
  padding: 11px 14px;
  border-radius: 12px;
  line-height: 1.5;
  display: flex; align-items: flex-start; gap: 8px;
}
.msg::before { content: ""; width: 4px; align-self: stretch; border-radius: 2px; background: currentColor; opacity: 0.6; }
.msg.error { background: rgba(212,51,44,0.10); color: var(--danger); }
.msg.success { background: rgba(41,163,92,0.12); color: var(--success); }
@media (prefers-color-scheme: dark) {
  .msg.error { background: rgba(255,69,58,0.16); }
  .msg.success { background: rgba(48,209,88,0.16); }
}

/* ----- Profile page ----- */
.profile-head {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 4px;
}
.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, #2997ff, #0040dd);
  display: grid; place-items: center; color: white; font-size: 28px; font-weight: 500;
  box-shadow: 0 4px 18px rgba(41,151,255,0.30);
}
.profile-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.profile-head .sub { color: var(--fg-muted); font-size: 14px; margin: 0; }

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  padding: 0 4px;
  margin: 6px 0 -4px;
}

.app-list {
  display: flex; flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background: var(--field-bg);
  border: 1px solid var(--row-divider);
}
.app-list a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--fg);
  font-size: 15px;
  border-bottom: 1px solid var(--row-divider);
  transition: background .12s;
}
.app-list a:last-child { border-bottom: none; }
.app-list a:hover { background: var(--hover); }
.app-list a .name { font-weight: 500; }
.app-list a .arrow { color: var(--fg-faint); }

.row-actions {
  display: flex; flex-direction: column; gap: 10px;
}

footer.foot {
  text-align: center;
  font-size: 12px;
  color: var(--fg-faint);
  margin-top: auto;
  padding-top: 28px;
}
footer.foot a { color: var(--fg-muted); text-decoration: none; }
footer.foot a:hover { text-decoration: underline; }

/* ----- Mobile tweaks ----- */
@media (max-width: 480px) {
  .page { padding: 36px 18px 96px; }
  .hero h1 { font-size: 26px; }
}

@supports (padding: max(0px)) {
  .page {
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
    padding-bottom: max(96px, env(safe-area-inset-bottom));
  }
}

/* Boot loader */
#app.boot {
  display: grid; place-items: center;
  min-height: 100vh; min-height: 100dvh;
}
#app.boot::after {
  content: "";
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--row-divider);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
