/* 全局样式 */
* {
    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));
    }
}

/* ==================== 错题本 & 积分说明 ==================== */

.header-score-today {
    font-style: normal;
    font-size: 11px;
    color: #f59e0b;
    margin-left: 4px;
}

.btn-badge {
    display: inline-block;
    margin-left: 6px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 10px;
}

.stat-hint {
    margin-top: 10px;
    font-size: 11px;
    color: #9ca3af;
    line-height: 1.5;
}

.rules-card summary {
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    color: #374151;
}

.rules-list {
    margin: 12px 0 0 18px;
    font-size: 13px;
    color: #4b5563;
    line-height: 1.9;
}

.rules-list strong {
    color: #10b981;
}

.wrong-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: #fff;
    border-radius: 14px;
    padding: 14px 8px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.wrong-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.wrong-summary-item strong {
    font-size: 20px;
    color: #1f2937;
}

.wrong-summary-item span {
    font-size: 11px;
    color: #9ca3af;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.filter-tab {
    flex: 1;
    padding: 9px 0;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 10px;
    font-size: 13px;
    color: #6b7280;
    cursor: pointer;
}

.filter-tab.active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
    font-weight: 600;
}

.wrong-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.wrong-actions .btn {
    flex: 1;
    font-size: 13px;
    padding: 11px 8px;
}

.wrong-actions .btn:disabled {
    opacity: 0.45;
}

.empty-wrong {
    padding: 40px 0;
    line-height: 1.9;
    font-style: normal;
}

.wrong-item {
    padding: 14px;
}

.wrong-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.wrong-word {
    font-size: 19px;
    font-weight: 700;
    color: #1f2937;
}

.wrong-phonetic {
    margin-left: 8px;
    font-size: 12px;
    color: #9ca3af;
}

.fam-badge {
    flex-shrink: 0;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.fam-low {
    background: #fee2e2;
    color: #b91c1c;
}

.fam-mid {
    background: #fef3c7;
    color: #b45309;
}

.fam-high {
    background: #d1fae5;
    color: #047857;
}

.wrong-meaning {
    margin-top: 6px;
    font-size: 14px;
    color: #374151;
}

.wrong-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    font-size: 11px;
    color: #9ca3af;
}

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

.wrong-item-actions .btn {
    flex: 1;
}

.btn-small.btn-danger,
.btn-danger.btn-small {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.text-orange {
    color: #f59e0b;
}

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

/* ==================== 单词信息区（词性 / 词形变化） ==================== */

.word-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px 0 4px;
}

.word-title-row .word {
    margin: 0;
    line-height: 1.2;
}

.speak-btn {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, transform .1s;
}

.speak-btn:active {
    transform: scale(.94);
    background: #eef2ff;
}

.speak-btn.playing {
    border-color: #a5b4fc;
    background: #eef2ff;
    animation: speak-pulse 1s ease-in-out infinite;
}

@keyframes speak-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, .35); }
    50% { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
}

.pos-line {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 6px;
}

.pos-line strong {
    color: #6d28d9;
    font-weight: 600;
}

.word-forms {
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 12px;
    padding: 10px 12px;
    margin: 10px 0 4px;
}

.forms-head {
    font-size: 12px;
    font-weight: 700;
    color: #6d28d9;
    letter-spacing: .5px;
    margin-bottom: 8px;
}

.forms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
}

.form-item {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 13px;
    line-height: 1.5;
}

.form-item em {
    font-style: normal;
    color: #9ca3af;
    font-size: 11px;
}

.form-item strong {
    color: #1f2937;
    font-weight: 600;
}

.form-irregular {
    border-color: #fdba74;
    background: #fffbeb;
}

.form-irregular strong {
    color: #b45309;
}

/* ==================== 答对后的例句卡 ==================== */

.example-card {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 14px 0 8px;
    text-align: left;
}

.example-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    color: #15803d;
    margin-bottom: 6px;
}

.link-btn {
    border: none;
    background: transparent;
    color: #059669;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
}

.link-btn:disabled {
    opacity: .5;
    cursor: default;
}

.example-en {
    font-size: 15px;
    line-height: 1.7;
    color: #14532d;
    word-break: break-word;
}

.example-en .hit-word {
    color: #b91c1c;
    font-weight: 700;
    background: #fef2f2;
    padding: 0 2px;
    border-radius: 3px;
}

.example-from {
    margin-top: 6px;
    font-size: 11px;
    color: #86efac;
    color: #6b7280;
}

.wrong-tip {
    margin-top: 6px;
    font-size: 13px;
    color: #b91c1c;
}

/* ==================== 例句中文翻译 ==================== */

.example-zh {
    margin: 8px 0 0;
    padding-top: 8px;
    border-top: 1px dashed #bbf7d0;
    font-size: 14px;
    line-height: 1.75;
    color: #166534;
}

.audio-hint {
    text-align: center;
    font-size: 12px;
    color: #b45309;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 6px 10px;
    margin: 8px 0 0;
}
