/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    color: #333;
    -webkit-font-smoothing: antialiased;
}

/* 布局 */
.page {
    min-height: 100vh;
    padding-bottom: 80px;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-emoji {
    font-size: 28px;
}

.header-user h2 {
    font-size: 18px;
    line-height: 1.3;
}

.header-score {
    font-size: 13px;
    color: #fbbf24;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 卡片 */
.card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h2 { margin-bottom: 8px; font-size: 22px; }
.card h3 { margin-bottom: 12px; font-size: 16px; color: #374151; }

/* 表单 */
.form-group {
    margin-bottom: 14px;
}

.input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s;
    background: #fafafa;
}

.input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
    background: white;
}

select.input {
    appearance: none;
    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='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* 按钮 */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-outline {
    background: white;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-outline:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-small {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
}

.btn-small:hover {
    background: #e5e7eb;
}

.btn-small:active {
    background: #d1d5db;
}

.btn-round {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    background: white;
    font-size: 22px;
    font-weight: 600;
    color: #3b82f6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-round:active {
    background: #f0f2f5;
    border-color: #3b82f6;
}

.btn-save {
    background: #3b82f6;
    color: white;
    font-weight: 600;
}

/* 登录页面 */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-page .container {
    width: 100%;
}

.login-header {
    text-align: center;
    color: white;
    margin-bottom: 28px;
}

.login-header h1:first-child {
    font-size: 48px;
    margin-bottom: 4px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header .subtitle {
    opacity: 0.85;
    font-size: 15px;
}

.links {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
}

.links a {
    color: #3b82f6;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
}

.links a:active {
    opacity: 0.7;
}

/* 首页header */
.home-page .header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.home-page .header h2 {
    color: white;
}

/* 进度卡片 */
.progress-card {
    text-align: center;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.progress-header h3 {
    margin-bottom: 0;
}

.progress-count {
    font-size: 24px;
    font-weight: 700;
    color: #3b82f6;
}

.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.card-actions .btn {
    flex: 1;
}

/* 签到按钮 */
.btn-signin {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-signin:active {
    background: rgba(255,255,255,0.4);
}

.signin-badge.signed {
    background: rgba(255,255,255,0.15);
    color: white;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 13px;
    white-space: nowrap;
}

.signin-streak {
    color: #fbbf24;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.stat {
    font-size: 48px;
    font-weight: 700;
    text-align: center;
    color: #3b82f6;
}

.text-sm {
    font-size: 14px;
    color: #6b7280;
}

.text-center {
    text-align: center;
}

.text-green {
    color: #10b981;
}

.text-red {
    color: #ef4444;
}

/* 学习统计网格 */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: #f9fafb;
    border-radius: 12px;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #3b82f6;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

/* 学习页面 */
.word {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    margin: 12px 0;
    color: #1f2937;
}

.phonetic {
    text-align: center;
    color: #6b7280;
    font-size: 16px;
    margin-bottom: 16px;
}

.word-header {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.tag-new {
    background: #dbeafe;
    color: #1e40af;
}

.tag-review {
    background: #fef3c7;
    color: #92400e;
}

.example-sentence {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 10px;
    margin: 10px 0;
    font-size: 14px;
    color: #555;
    border-left: 4px solid #10b981;
    line-height: 1.6;
}

.pos-badge {
    display: inline-block;
    vertical-align: middle;
    background: #ede9fe;
    color: #6d28d9;
    font-size: 14px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    margin-left: 8px;
}

.irregular-forms {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 10px 0;
    font-size: 14px;
    color: #7c2d12;
}

.irr-title {
    font-weight: 700;
    color: #c2410c;
}

.irr-form strong {
    color: #9a3412;
}

.instruction {
    text-align: center;
    color: #374151;
    font-weight: 500;
    margin: 16px 0 12px;
    font-size: 15px;
}

.audio-btn {
    margin: 8px 0;
}

/* 选项 */
.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    text-align: left;
    padding: 16px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.option-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.correct {
    background: #d1fae5 !important;
    border: 2px solid #10b981 !important;
    color: #065f46 !important;
}

.wrong {
    background: #fee2e2 !important;
    border: 2px solid #ef4444 !important;
    color: #991b1b !important;
}

/* 结果 */
.result {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.result-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 24px;
    font-weight: 700;
}

.result-correct {
    background: #d1fae5;
    color: #10b981;
}

.result-wrong {
    background: #fee2e2;
    color: #ef4444;
}

.next-btn {
    margin-top: 16px;
}

/* 词库 */
.library-item {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.15s;
}

.library-item:active {
    background: #f3f4f6;
}

.library-info {
    flex: 1;
}

.library-info h3 {
    margin-bottom: 4px;
    font-size: 15px;
}

.library-info p {
    font-size: 13px;
    color: #6b7280;
}

.library-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
    transition: all 0.2s;
}

.library-check.checked {
    background: #3b82f6;
    border-color: #3b82f6;
}

/* 间距 */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* Flex */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.goal-adjust {
    margin: 8px 0 16px;
}

.goal-num {
    font-size: 28px;
    font-weight: 700;
    min-width: 48px;
    text-align: center;
    color: #3b82f6;
}

/* 设置页 */
.settings-avatar {
    text-align: center;
    margin-bottom: 12px;
}

.avatar-emoji {
    font-size: 48px;
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #374151;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    z-index: 200;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    text-align: center;
}

.toast-enter-active,
.toast-leave-active {
    transition: all 0.3s ease;
}

.toast-enter-from,
.toast-leave-to {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px);
}

/* 加载状态 */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    gap: 12px;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: #6b7280;
    font-size: 14px;
}

/* 网络错误 */
.network-error {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    font-size: 14px;
}

.btn-retry {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}

/* 自动跳转提示 */
.text-muted {
    color: #9ca3af;
    font-style: italic;
    animation: pulse 1.5s ease-in-out infinite;
    margin-top: 8px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 安全区域 (iOS notch) */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
    .toast {
        top: calc(24px + env(safe-area-inset-top));
    }
}
