/* ============================================================
   YilongTos · Apple 极简
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-subtle: #f5f5f7;
  --bg-hover: #ebebed;
  --border: #e5e5ea;
  --border-strong: #d1d1d6;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;

  --accent: #0051ff;
  --accent-hover: #0040cc;
  --accent-soft: #eef2ff;

  --radius-card: 16px;
  --radius-btn: 10px;
  --radius-input: 10px;
  --radius-badge: 6px;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.08);
}

body.dark {
  --bg: #000000;
  --bg-subtle: #1c1c1e;
  --bg-hover: #2c2c2e;
  --border: #38383a;
  --border-strong: #48484a;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #8e8e93;
  --accent: #4d8aff;
  --accent-hover: #6fa0ff;
  --accent-soft: #1a2a4a;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.4);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }

body {
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text-primary);
  background: var(--bg);
  padding-bottom: 96px;
  font-size: 15px;
  line-height: 1.55;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--accent-soft); color: var(--accent); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* 布局 */
.page { max-width: 520px; margin: 0 auto; padding: 20px 20px 40px; }

.top-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  margin: -20px -20px 20px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid var(--border);
}
body.dark .top-bar { background: rgba(0,0,0,0.85); }

.brand { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }

/* 卡片 */
.glass, .glass.card {
  background: var(--bg-subtle);
  border: none;
  border-radius: var(--radius-card);
  box-shadow: none;
}

.glass.card {
  padding: 20px;
  margin-bottom: 12px;
  transition: background 0.2s ease;
}

.card { padding: 20px; margin-bottom: 12px; }

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 13px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-primary);
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

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

.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 8px; }

/* 输入框 */
.input {
  width: 100%; padding: 13px 16px; margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: var(--text-tertiary); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input { resize: vertical; }

/* 等级徽章 */
.level-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-badge);
  font-size: 12px; font-weight: 600;
}
.lv-registered { background: var(--bg-subtle); color: var(--text-secondary); }
.lv-silver { background: #f0f0f3; color: #6e6e73; }
.lv-gold { background: #fef7e0; color: #a67600; }
.lv-platinum { background: #e8f4fd; color: #0066a3; }
.lv-yilong { background: #f0e8ff; color: #6c30d9; }
.lv-super { background: #fff0e8; color: #c45b00; }
.lv-private {
  background: #1d1d1f;
  color: #ffd700;
}
body.dark .lv-registered { background: var(--bg-subtle); color: var(--text-secondary); }
body.dark .lv-silver { background: #2c2c2e; color: #a1a1a6; }
body.dark .lv-gold { background: #2a2418; color: #ffd060; }
body.dark .lv-platinum { background: #1a2530; color: #6bb8e8; }
body.dark .lv-yilong { background: #241a3a; color: #b18cff; }
body.dark .lv-super { background: #2a1c14; color: #ff9d5c; }
body.dark .lv-private { background: #f5f5f7; color: #000000; }

/* 底部导航 */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-top: 1px solid var(--border);
}
body.dark .bottom-nav { background: rgba(0,0,0,0.9); }

.nav-item {
  flex: 1; text-align: center;
  padding: 6px 0;
  font-size: 10px; font-weight: 500;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.2s;
  min-height: 44px;
  display: flex; flex-direction: column; justify-content: center;
}
.nav-item.active { color: var(--accent); font-weight: 600; }
.nav-item span { display: block; font-size: 20px; margin-bottom: 2px; }

/* 通用 */
.copyright {
  text-align: center; font-size: 11px; color: var(--text-tertiary);
  padding: 28px 0 16px;
}

.progress-track {
  height: 4px; background: var(--border);
  border-radius: 999px; overflow: hidden; margin: 6px 0;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.text-secondary { color: var(--text-secondary); font-size: 13px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.hidden { display: none !important; }
.text-center { text-align: center; }

.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.empty-state { text-align: center; padding: 32px 20px; }

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-subtle) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s linear infinite;
  border-radius: 8px;
}
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.short { width: 60%; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 头像框 */
.avatar-frame {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px; border-radius: 50%;
  background: var(--border);
}
.avatar-frame > .frame-inner {
  border-radius: 50%;
  background: var(--bg);
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600;
  color: var(--text-secondary);
}
.avatar-frame-silver { background: linear-gradient(135deg, #d8e2ec, #8a9aac); }
.avatar-frame-gold { background: linear-gradient(135deg, #f5e4a0, #c4a040); }
.avatar-frame-platinum { background: linear-gradient(135deg, #e8f4fa, #a0c0d0); }
.avatar-frame-yilong { background: linear-gradient(135deg, #d9b8ff, #9060d0); }
.avatar-frame-private { background: linear-gradient(135deg, #ffd700, #ff6b9d, #6c8cff, #6cff9a); }
.avatar-frame-rose { background: linear-gradient(135deg, #ffd6e0, #d97a94); }
.avatar-frame-ocean { background: linear-gradient(135deg, #a8e0ff, #2a7ab8); }
.avatar-frame-forest { background: linear-gradient(135deg, #b8e6c8, #2a7d4e); }
.avatar-frame-sunset { background: linear-gradient(135deg, #ffd9a8, #d96838); }
.avatar-frame-galaxy { background: linear-gradient(135deg, #b8a8ff, #5e4d9e); }
.avatar-frame-rainbow {
  background: linear-gradient(135deg, #ff5e5e, #ffb800, #7ee85e, #4d8aff, #b45eff);
}

.frame-picker { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.frame-option {
  width: 60px; height: 60px; padding: 3px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}
.frame-option.selected { border-color: var(--accent); }
.frame-option .frame-inner {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--bg); display: flex; align-items: center;
  justify-content: center; font-size: 20px;
  color: var(--text-secondary); font-weight: 600;
}
.frame-option.disabled { opacity: 0.3; cursor: not-allowed; }

/* 启动动画 */
#splash-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  opacity: 1;
  transition: opacity 0.6s ease;
}
#splash-screen.splash-out { opacity: 0; pointer-events: none; }

.splash-inner { text-align: center; }
.splash-text {
  font-family: "Brush Script MT", "Segoe Script", "Snell Roundhand", "Apple Chancery", cursive;
  font-size: 56px;
  color: transparent;
  background: linear-gradient(100deg, #0051ff 0%, #4d8aff 50%, #a0c0ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  clip-path: inset(0 100% 0 0);
  animation: splash-write 1.3s cubic-bezier(0.65, 0, 0.35, 1) 0.2s forwards;
}
.splash-underline { width: 220px; height: 12px; display: block; margin: 4px auto 0; }
.splash-underline path {
  stroke: #0051ff;
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  animation: splash-draw 0.8s ease-out 1.3s forwards;
}
.splash-sub {
  margin-top: 20px; font-size: 10px; letter-spacing: 6px;
  color: var(--text-tertiary); opacity: 0;
  animation: splash-fade 0.8s ease-out 1.7s forwards;
}
@keyframes splash-write { to { clip-path: inset(0 0 0 0); } }
@keyframes splash-draw { to { stroke-dashoffset: 0; } }
@keyframes splash-fade { to { opacity: 1; } }

/* 模态框 */
#edit-modal, #gift-modal, .battle-result-modal {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: modal-fade-in 0.2s ease-out;
}
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }

#edit-modal > .glass,
#gift-modal > .glass,
.battle-result-card {
  background: var(--bg);
  animation: modal-scale-in 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
}
@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

/* 页面切换 */
body.page-fade-out { opacity: 0; transition: opacity 0.25s ease; }

/* 覆盖 HTML 内联暗色样式 */
[style*="rgba(255,255,255,0.05"],
[style*="rgba(255,255,255,0.06"],
[style*="rgba(255,255,255,0.07"],
[style*="rgba(255,255,255,0.08"],
[style*="rgba(255,255,255,0.1"],
[style*="rgba(255,255,255,0.12"],
[style*="rgba(255,255,255,0.15"] {
  background: var(--bg-subtle) !important;
}
[style*="rgba(0,0,0,0.25"], [style*="rgba(0,0,0,0.3"] {
  background: var(--bg-subtle) !important;
}
[style*="border-bottom:1px solid rgba(255,255,255"] {
  border-bottom-color: var(--border) !important;
}
[style*="color:rgba(245,245,247,0.5"], [style*="color:rgba(245,245,247,0.4"],
[style*="color:rgba(150,155,175"] {
  color: var(--text-tertiary) !important;
}

canvas { border-radius: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  #splash-screen { display: none; }
}