/* ===== 全局重置和变量 ===== */
:root {
    --primary: #8B4513;
    --primary-light: #D2691E;
    --primary-dark: #654321;
    --bg: #FFFBF0;
    --bg-card: #FFFFFF;
    --text: #3C2814;
    --text-secondary: #8B7355;
    --text-light: #B8A088;
    --border: #E8DDD0;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --vip-gold: #FFD700;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(139,69,19,0.08);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
input, button, textarea { font-family: inherit; font-size: inherit; }

/* ===== 布局 ===== */
#app {
    min-height: 100vh;
    padding-bottom: 70px;
    position: relative;
}
.page { display: none; padding: 16px; }
.page.active { display: block; }

/* ===== 导航栏 ===== */
.navbar {
    position: sticky; top: 0; z-index: 100;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
}
.navbar .back { font-size: 20px; cursor: pointer; width: 32px; text-align: center; }
.navbar .title { font-size: 17px; font-weight: 600; flex: 1; }

/* ===== 底部TabBar ===== */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: #fff; border-top: 1px solid var(--border);
    display: flex; height: 56px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}
.tab-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: #999; font-size: 11px; cursor: pointer; transition: color 0.2s;
    text-decoration: none;
}
.tab-item .icon { font-size: 22px; }
.tab-item.active { color: var(--primary); }

/* ===== 卡片 ===== */
.card {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 24px; padding: 12px 32px;
    font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity 0.2s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { display: flex; width: 100%; box-sizing: border-box; }
.btn-block.btn { padding-left: 16px; padding-right: 16px; }
.btn-sm { padding: 8px 20px; font-size: 13px; border-radius: 18px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== VIP标签 ===== */
.vip-badge {
    display: inline-flex; align-items: center; gap: 2px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #654321; font-size: 11px; font-weight: 700;
    padding: 2px 10px; border-radius: 10px;
}

/* ===== Flex工具 ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; align-items: center; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* ===== 文字工具 ===== */
.text-primary { color: var(--primary); }
.text-secondary { color: var(--text-secondary); }
.text-light { color: var(--text-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.text-xxl { font-size: 28px; }

/* ===== 间距 ===== */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }

/* ===== 标签 ===== */
.tag {
    display: inline-block; padding: 4px 12px; border-radius: 14px;
    font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s;
    background: #f5f0e8; color: var(--text-secondary);
}
.tag.active { color: #fff; }

/* ===== 进度条 ===== */
.progress-bar {
    height: 8px; background: #f0e8d8; border-radius: 4px; overflow: hidden;
}
.progress-bar .fill {
    height: 100%; border-radius: 4px; transition: width 0.3s;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

/* ===== 空状态 ===== */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 0; color: var(--text-light);
}
.empty-state .icon { font-size: 64px; margin-bottom: 16px; }

/* ===== Toast ===== */
#global-toast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0,0,0,0.75); color: #fff; padding: 12px 24px;
    border-radius: 8px; font-size: 14px; z-index: 9999;
    opacity: 0; transition: all 0.3s; pointer-events: none;
}
#global-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ===== 加载 ===== */
.loading { text-align: center; padding: 40px; color: var(--text-light); }
.spinner {
    display: inline-block; width: 28px; height: 28px;
    border: 3px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 输入框 ===== */
.input {
    width: 100%; padding: 12px 16px; border: 1.5px solid var(--border);
    border-radius: 10px; font-size: 14px; outline: none; transition: border-color 0.2s;
    background: #fff;
}
.input:focus { border-color: var(--primary); }

/* ===== 分割线 ===== */
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ===== 列表项 ===== */
.list-item {
    display: flex; align-items: center; padding: 14px 16px;
    background: #fff; border-bottom: 1px solid var(--border); cursor: pointer;
}
.list-item:active { background: #faf6f0; }
.list-item .arrow { color: var(--text-light); margin-left: auto; }

/* ===== 单词卡片翻转 ===== */
.word-card-container { perspective: 600px; }
.word-card {
    position: relative; width: 100%; min-height: 260px;
    transition: transform 0.5s; transform-style: preserve-3d; cursor: pointer;
}
.word-card.flipped { transform: rotateY(180deg); }
.word-card .front, .word-card .back {
    position: absolute; inset: 0; backface-visibility: hidden;
    border-radius: var(--radius); padding: 24px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.word-card .front { background: #fff; box-shadow: var(--shadow); }
.word-card .back { background: #fff; box-shadow: var(--shadow); transform: rotateY(180deg); }

/* ===== 选项按钮 ===== */
.option-btn {
    display: block; width: 100%; padding: 14px 16px; margin-bottom: 10px;
    background: #fff; border: 2px solid var(--border); border-radius: 10px;
    font-size: 14px; text-align: left; cursor: pointer; transition: all 0.2s;
}
.option-btn:active { background: #faf6f0; }
.option-btn.correct { border-color: var(--success); background: #e8f5e9; color: var(--success); }
.option-btn.wrong { border-color: var(--danger); background: #ffebee; color: var(--danger); }

/* ===== 成绩圆环 ===== */
.score-ring {
    width: 140px; height: 140px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 700; color: #fff;
}

/* ===== VIP锁定 ===== */
.vip-lock-overlay {
    position: absolute; inset: 0; background: rgba(255,255,255,0.85);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: var(--radius); z-index: 10;
}
.vip-lock-overlay .lock-icon { font-size: 48px; margin-bottom: 12px; }
.vip-lock-overlay .lock-text { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }

/* ===== 响应式 - 平板 (768px+) ===== */
@media (min-width: 768px) {
    body {
        background: linear-gradient(135deg, #f5f0e8 0%, #e8e0d5 100%);
    }

    #app {
        max-width: 600px;
        margin: 0 auto;
        min-height: 100vh;
        background: var(--bg);
        box-shadow: 0 0 40px rgba(139,69,19,0.1);
        position: relative;
    }

    .tabbar {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
    }

    .navbar {
        border-radius: 0;
    }

    /* 卡片在大屏幕上更圆润 */
    .card {
        border-radius: 16px;
    }

    /* 按钮hover效果 */
    .btn:hover {
        opacity: 0.9;
        transform: translateY(-1px);
    }

    .option-btn:hover {
        border-color: var(--primary);
        background: #faf6f0;
    }

    .list-item:hover {
        background: #faf6f0;
    }

    /* 输入框hover效果 */
    .input:hover {
        border-color: var(--primary-light);
    }
}

/* ===== 响应式 - 桌面 (1024px+) ===== */
@media (min-width: 1024px) {
    #app {
        max-width: 700px;
        margin: 20px auto;
        min-height: calc(100vh - 40px);
        border-radius: 20px;
        overflow: hidden;
    }

    .tabbar {
        max-width: 700px;
        border-radius: 0 0 20px 20px;
    }

    .navbar {
        border-radius: 20px 20px 0 0;
    }

    /* 更大的字体 */
    body {
        font-size: 15px;
    }

    .navbar .title {
        font-size: 18px;
    }

    .tab-item .icon {
        font-size: 24px;
    }

    .tab-item {
        font-size: 12px;
    }

    /* 更大的卡片间距 */
    .page {
        padding: 20px;
    }

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

    /* 更大的按钮 */
    .btn {
        padding: 14px 36px;
        font-size: 16px;
    }

    /* 更大的输入框 */
    .input {
        padding: 14px 18px;
        font-size: 15px;
    }

    /* 更大的单词卡片 */
    .word-card {
        min-height: 320px;
    }

    /* 更大的选项按钮 */
    .option-btn {
        padding: 16px 20px;
        font-size: 15px;
        margin-bottom: 12px;
    }
}

/* ===== 响应式 - 大屏幕 (1440px+) ===== */
@media (min-width: 1440px) {
    #app {
        max-width: 800px;
        margin: 30px auto;
        min-height: calc(100vh - 60px);
    }

    .tabbar {
        max-width: 800px;
    }

    .page {
        padding: 24px;
    }

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

    body {
        font-size: 16px;
    }
}

/* ===== 打印样式 ===== */
@media print {
    .tabbar, .navbar {
        display: none;
    }
    #app {
        padding-bottom: 0;
    }
}
