/* === 1. CSS 变量定义 === */
:root {
  --bg-color: #f5f7fa;
  --card-bg: #ffffff;
  --text-color: #1f1f1f;
  --text-secondary: #666666;
  --border-color: #ebebeb;
  --primary-color: #52c41a;
  --primary-rgb: 82, 196, 26;
  --primary-hover: #73d13d;
  --primary-active: #389e0d;
  --text-tertiary: #999999;
  --accent: #1ab0c4;
  --text-on-accent: #ffffff;
  --chart-bg: #ebebeb;
  --error-color: #dc3545;
  --warning-color: #FFA500;
  --hover-bg: #f5f5f5;
  --header-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --dropdown-shadow: 0 10px 30px -10px rgba(0,0,0,0.15);
  --sub-nav-bg: #fafafa;
  --input-bg: #ffffff;
  --input-border: #d9d9d9;
  
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition: all 0.3s var(--ease-out);
}

:root.dark-mode {
  --bg-color: #0a0a0a;
  --card-bg: #141414;
  --text-color: #e5e5e5;
  --text-secondary: #a3a3a3;
  --border-color: #262626;
  --hover-bg: #1f1f1f;
  --chart-bg: #2a2a2a;
  --header-shadow: 0 1px 0 0 #262626;
  --dropdown-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
  --sub-nav-bg: #0f0f0f;
  --input-bg: #141414;
  --input-border: #434343;
}

/* Prevent transitions on load */
.preload * {
  transition: none !important;
}

/* === 2. 全局基础 === */
* { box-sizing: border-box; }
body {
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: background-color 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; transition: var(--transition); }
button, input { font-family: inherit; border: none; outline: none; }

/* === 3. UI 组件库 === */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 20px; height: 48px; border-radius: 8px; font-weight: 600; font-size: 15px;
  cursor: pointer; transition: var(--transition); border: 1px solid transparent;
  user-select: none;
}
.btn-primary { 
  background-color: var(--primary-color); color: #fff; 
  box-shadow: 0 4px 14px 0 rgba(var(--primary-rgb), 0.3);
}
.btn-primary:hover { 
  background-color: var(--primary-hover); 
  transform: translateY(-1px);
  box-shadow: 0 6px 20px 0 rgba(var(--primary-rgb), 0.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost { background-color: transparent; color: var(--text-secondary); height: 40px; font-size: 14px; }
.btn-ghost:hover { color: var(--text-color); background-color: var(--hover-bg); }

.input {
  width: 100%; height: 48px; padding: 0 16px; font-size: 16px;
  border: 1px solid var(--input-border); background-color: var(--input-bg);
  color: var(--text-color); border-radius: 8px; transition: var(--transition);
}
.input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(82, 196, 26, 0.15); }

/* Segmented Control */
.segmented-control {
  display: inline-flex;
  background-color: var(--hover-bg);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  height: 40px;
  align-items: center;
  box-sizing: border-box; /* Ensure total height includes padding/border */
}
.segment-option { display: none; }
.segment-label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%; /* Fill the container's available height */
  padding: 0 16px;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
  user-select: none;
  line-height: 1;
  box-sizing: border-box;
}
.segment-option:checked + .segment-label {
  background-color: var(--card-bg);
  color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
body.dark-mode .segment-option:checked + .segment-label {
    background-color: #2a2a2a;
    color: var(--primary-color);
}

/* === 4. Modal 核心样式 (Upgrade Version) === */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: all 0.3s var(--ease-out);
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-box {
    background-color: var(--card-bg);
    width: 90%; max-width: 420px;
    padding: 32px 24px;
    border-radius: 20px;
    box-shadow: var(--dropdown-shadow);
    border: 1px solid var(--border-color);
    text-align: center;
    transform: scale(0.95) translateY(10px);
    transition: all 0.35s var(--ease-bounce);
    display: flex; flex-direction: column; align-items: center;
}
.modal-overlay.active .modal-box { transform: scale(1) translateY(0); }

/* 图标变体 */
.modal-icon {
    width: 64px; height: 64px; margin-bottom: 20px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 32px; flex-shrink: 0;
}
.icon-success { background: rgba(82, 196, 26, 0.1); color: var(--primary-color); }
.icon-warning { background: rgba(250, 173, 20, 0.1); color: var(--warning-color); }
.icon-danger  { background: rgba(255, 77, 79, 0.1);  color: var(--danger-color); }
.icon-info    { background: rgba(24, 144, 255, 0.1); color: var(--info-color); }

.modal-title { font-size: 20px; font-weight: 700; color: var(--text-color); margin: 0 0 12px 0; }
.modal-message { font-size: 15px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 24px; width: 100%; white-space: pre-wrap; word-break: break-word;}

/* 输入框 (用于 Prompt) */
.modal-input {
    width: 100%; height: 44px; padding: 0 12px; margin-bottom: 24px;
    border: 1px solid var(--border-color); border-radius: 8px;
    background: var(--bg-color); color: var(--text-color); font-size: 16px;
    outline: none; transition: border 0.2s; display: none; /* 默认隐藏 */
}
.modal-input:focus { border-color: var(--primary-color); }

/* 底部按钮组 */
.modal-actions { display: flex; gap: 12px; width: 100%; justify-content: center; }
.modal-actions .btn { flex: 1; }

/* Loading 动画 */
.modal-spinner {
    width: 40px; height: 40px; border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--primary-color); border-radius: 50%;
    animation: spin 1s linear infinite; margin-bottom: 20px; display: none;
}
:root.dark-mode .modal-spinner { border-color: rgba(255,255,255,0.1); border-top-color: var(--primary-color); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Button Styles for Modal if not present */
.btn {
    height: 44px; padding: 0 20px; border-radius: 8px; font-weight: 600; font-size: 14px;
    cursor: pointer; border: none; transition: all 0.2s var(--ease-out);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #f0f0f0; color: #595959; }
.btn-secondary:hover { background: #d9d9d9; }
.btn-danger { background: #ff4d4f; color: white; }
.btn-danger:hover { background: #ff7875; }
.btn-info { background: #1890ff; color: white; }
:root.dark-mode .btn-secondary { background: #2a2a2a; color: #a3a3a3; }
:root.dark-mode .btn-secondary:hover { background: #3a3a3a; }

/* === 4. Header 布局 === */
.app-header {
  background-color: var(--card-bg);
  box-shadow: var(--header-shadow);
  position: relative;
  z-index: 100;
}
.header-main-wrapper { border-bottom: 1px solid var(--border-color); }
.header-main {
  height: 64px; max-width: 1200px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 40px; }
.logo { 
    font-size: 20px; font-weight: 800; color: var(--text-color); 
    display: flex; align-items: center; gap: 8px; letter-spacing: -0.5px;
}
.nav-links { display: flex; gap: 24px; }
.nav-link { 
    color: var(--text-secondary); font-weight: 500; font-size: 14px; 
    position: relative; padding: 22px 0;
}
.nav-link:hover { color: var(--text-color); }
.nav-link.active { color: var(--text-color); font-weight: 600; }
.nav-link.active::after {
    content: ''; position: absolute; bottom: -1px; left: 0; width: 100%; height: 2px;
    background-color: var(--primary-color);
}
.header-right { display: flex; align-items: center; gap: 12px; }
.auth-buttons { display: flex; gap: 8px; }

/* User Profile */
.user-profile-wrapper { position: relative; padding: 4px 0; }
.user-avatar-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
    border: 2px solid transparent; cursor: pointer; overflow: hidden;
    transition: var(--transition); display: flex; align-items: center; justify-content: center;
}
.user-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar-btn:hover { border-color: var(--primary-color); transform: scale(1.05); }

.user-dropdown, .more-dropdown {
    position: absolute; background: var(--card-bg);
    border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: var(--dropdown-shadow);
    opacity: 0; visibility: hidden;
    transform: translateY(10px) scale(0.98);
    transition: all 0.2s var(--ease-out);
    z-index: 50;
}
.user-profile-wrapper:hover .user-dropdown,
.more-tools-wrapper:hover .more-dropdown {
    opacity: 1; visibility: visible; transform: translateY(0) scale(1);
}
.user-dropdown { top: 100%; right: 0; width: 240px; margin-top: 12px; padding: 8px; transform-origin: top right; }
.user-dropdown::before {
    content: ''; position: absolute; top: -6px; right: 14px; width: 12px; height: 12px;
    background: var(--card-bg); border-top: 1px solid var(--border-color); border-left: 1px solid var(--border-color);
    transform: rotate(45deg);
}
.dropdown-header { padding: 12px 16px; border-bottom: 1px solid var(--border-color); margin-bottom: 8px; }
.user-name { font-weight: 700; color: var(--text-color); font-size: 15px; }
.user-email { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.dropdown-menu-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px; 
    color: var(--text-color); font-size: 14px; border-radius: 8px;
    cursor: pointer; transition: background 0.15s;
}
.dropdown-menu-item:hover { background-color: var(--hover-bg); color: var(--primary-color); }
.dropdown-menu-item.danger:hover { background-color: #fff1f0; color: #ff4d4f; }
.dropdown-menu-item .icon { font-size: 16px; width: 20px; text-align: center; }

/* Sub Nav */
.sub-nav-wrapper { background-color: var(--sub-nav-bg); border-bottom: 1px solid var(--border-color); }
.sub-nav { 
    max-width: 1200px; margin: 0 auto; padding: 10px 20px; 
    display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.sub-item {
    display: inline-flex; align-items: center; color: var(--text-secondary);
    padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
    transition: var(--transition);
}
.sub-item span { margin-right: 6px; }
.sub-item:hover, .sub-item.active { 
    background-color: var(--card-bg); color: var(--primary-color); 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); 
}
.more-tools-wrapper { position: relative; }
.more-dropdown {
    top: 100%; left: 0; min-width: 220px; padding: 8px; margin-top: 4px; transform-origin: top left;
}

/* === Dark Mode Toggle Icons === */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-block; }

:root.dark-mode .theme-toggle .icon-sun { display: inline-block; }
:root.dark-mode .theme-toggle .icon-moon { display: none; }

/* === 5. Content Area === */
.container { max-width: 1200px; margin: 0 auto; padding: 40px 20px; min-height: calc(100vh - 300px); }

.hero-section {
    text-align: center; margin-bottom: 60px; padding: 50px 40px; 
    background: var(--card-bg); border-radius: 20px; 
    border: 1px solid var(--border-color);
    background-image: radial-gradient(circle at top right, rgba(82,196,26,0.05), transparent 40%);
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

/* === Hero Title 动态闪耀效果 === */
.hero-title {
    font-size: 38px; font-weight: 800; margin: 0 0 32px 0; letter-spacing: -1px;
    
    /* 设置渐变背景：文本色 -> 文本色 -> 品牌高亮色 -> 文本色 -> 文本色 */
    /* 这样保证大部分时候是文本色，只有中间一道光闪过 */
    background: linear-gradient(
        110deg,
        var(--text-color) 35%,
        rgba(82, 196, 26, 0.8) 50%, 
        var(--text-color) 65%
    );
    
    /* 放大背景尺寸，以便移动背景实现动画 */
    background-size: 200% auto;
    
    /* 标准的文字裁剪属性 */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    
    /* 动画：6秒一次循环，匀速，无限循环 */
    animation: textShimmer 6s linear infinite;
}

/* 定义闪耀动画关键帧 */
@keyframes textShimmer {
    0% {
        background-position: 200% center;
    }
    100% {
        background-position: -200% center;
    }
}

.hero-input-group { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.hero-options-row { display: flex; justify-content: center; gap: 20px; }
.hero-option-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.option-group { text-align: left; }
.input-wrapper { display: flex; gap: 12px; }

/* Features Grid */
.features-grid { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 24px; margin-bottom: 60px; 
}
.feature-card {
    background: var(--card-bg); border: 1px solid var(--border-color); 
    border-radius: 16px; padding: 28px;
    cursor: pointer; display: flex; flex-direction: column; height: 100%;
    position: relative; transition: all 0.3s var(--ease-out); overflow: hidden;
}
.feature-card:hover { 
    transform: translateY(-8px); border-color: var(--primary-color); 
    box-shadow: 0 20px 40px -10px rgba(var(--primary-rgb), 0.15); 
}
.feature-icon { font-size: 36px; margin-bottom: 20px; transition: transform 0.4s var(--ease-bounce); }
.feature-card:hover .feature-icon { transform: scale(1.15) rotate(5deg); }
.feature-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; color: var(--text-color); }
.feature-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; flex-grow: 1; }
.feature-link { 
    margin-top: 24px; color: var(--primary-color); font-weight: 600; font-size: 14px; 
    display: flex; align-items: center; gap: 6px; transition: var(--transition); transform: translateX(-5px);
}
.feature-card:hover .feature-link { transform: translateX(0); }

/* Sponsors Section */
.sponsors-section {
    margin-top: 80px;
    text-align: center;
    padding-top: 40px;
    border-top: 1px dashed var(--border-color);
}
.section-title {
    font-size: 14px; font-weight: 700; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 30px;
}
.sponsors-grid {
    display: flex; justify-content: center; align-items: center;
    flex-wrap: wrap; gap: 40px;
}
.sponsor-item {
    display: block; opacity: 0.5; filter: grayscale(100%);
    transition: all 0.3s var(--ease-out);
    height: 40px;
}
.sponsor-item img {
    height: 100%; width: auto; display: block;
}
.sponsor-item:hover {
    opacity: 1; filter: grayscale(0%); transform: scale(1.05);
}
.become-sponsor {
    display: inline-block; margin-top: 30px; font-size: 13px; 
    color: var(--text-secondary); text-decoration: underline;
}
.become-sponsor:hover { color: var(--primary-color); }

/* === 7. Footer === */
.app-footer {
    background-color: var(--card-bg); border-top: 1px solid var(--border-color); padding: 40px 0; margin-top: auto;
}
.footer-inner {
    max-width: 1200px; margin: 0 auto; padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.footer-links { display: flex; gap: 30px; }
.footer-link { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.footer-link:hover { color: var(--primary-color); }
.copyright { font-size: 13px; color: #999; margin-top: 8px; }

/* Footer Right Layout */
.footer-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px; /* Increased spacing */
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-color);
    font-size: 18px;
}
.theme-toggle:hover {
    background-color: var(--hover-bg);
    border-color: var(--border-color);
}
/* Default (Light Mode): Show Sun */
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }

/* Dark Mode: Show Moon */
body.dark-mode .theme-toggle .icon-moon { display: block; }
body.dark-mode .theme-toggle .icon-sun { display: none; }

/* Lang Selector */
.lang-selector-wrapper { position: relative; }
.lang-select {
    appearance: none; -webkit-appearance: none;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 32px 6px 12px;
    font-size: 13px;
    color: var(--text-color);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.762L10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.lang-select:hover { border-color: var(--primary-color); }
.lang-select:focus { border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(82, 196, 26, 0.1); }

body.dark-mode .switch { background-color: #444; }
body.dark-mode .switch::after { background-color: #222; }

/* Mobile */
@media (max-width: 768px) {
    .header-main { padding: 0 20px; }
    .nav-links { display: none; }
    .sub-nav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .input-wrapper { flex-direction: column; }
    .hero-options-row { flex-direction: row; gap: 10px; justify-content: space-between; }
    .option-group { flex: 1; }
    .segmented-control { width: 100%; display: flex; }
    .segment-label { flex: 1; text-align: center; }
    .footer-inner { flex-direction: column; gap: 24px; text-align: center; }
    .features-grid { grid-template-columns: 1fr; }
    .sponsors-grid { gap: 24px; }
    /* 移动端减弱闪耀效果，避免分散注意力 */
    .hero-title { animation-duration: 8s; font-size: 28px; } 
}

/* === Large Screen Optimization (>1410px) === */
@media (min-width: 1410px) {
  .container,
  .header-main,
  .app-footer .footer-inner,
  .sub-nav {
    max-width: 1400px;
  }

}
