/* styles.css —— 由 anki.html 拆分而来（原 <style> 块内容，未改动） */

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

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;
    --hard: #e53e3e;
    --good: #38a169;
    --easy: #3182ce;
    --again: #e53e3e;
    --bg: #f7fafc;
    --card-bg: #ffffff;
    --text: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

html {
    /* iOS 横屏时 Safari 会自动放大文字，锁死 */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100%;
}

/* iOS：消除双击缩放与点击延迟（manipulation 不禁止滚动，只去双击） */
body, button, input, textarea, select, label, a {
    touch-action: manipulation;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.nav-tab {
    flex: 1;
    min-width: 80px;
    padding: 14px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

.nav-tab .tab-icon {
    font-size: 20px;
}

/* Pages */
.page {
    display: none;
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .stat-number {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

.stat-card.new .stat-number { color: #3182ce; }
.stat-card.review .stat-number { color: #38a169; }
.stat-card.due .stat-number { color: #e53e3e; }

/* Deck List */
.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.deck-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deck-item {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s;
}

.deck-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.deck-info h3 {
    font-size: 16px;
    font-weight: 600;
}

.deck-info p {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 2px;
}

.deck-badges {
    display: flex;
    gap: 6px;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.badge.new { background: #ebf8ff; color: #3182ce; }
.badge.review { background: #f0fff4; color: #38a169; }
.badge.due { background: #fed7d7; color: #e53e3e; }

.deck-actions {
    display: flex;
    gap: 4px;
}

.deck-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    font-size: 16px;
    transition: background 0.2s;
}

.deck-action-btn:hover {
    background: var(--bg);
}

/* Study Page */
.study-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.study-header h2 {
    font-size: 18px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
}

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

.card-container {
    perspective: 1200px;
    margin-bottom: 20px;
}

.flash-card {
    background: white;
    border-radius: 20px;
    min-height: 300px;
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    position: relative;
}

.flash-card.flipped {
    animation: flipCard 0.6s ease forwards;
}

@keyframes flipCard {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

.card-side-label {
    position: absolute;
    top: 16px;
    left: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-content {
    font-size: 22px;
    text-align: center;
    line-height: 1.6;
    word-break: break-word;
    width: 100%;
}

.card-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 8px 0;
}

.card-speak {
    position: absolute;
    top: 14px;
    right: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
}

.card-speak:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.answer-speak {
    position: static;
    width: auto;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 14px;
    gap: 6px;
    margin-top: 14px;
}

.card-speak.inline-speak {
    position: static;
    width: auto;
    height: auto;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 16px;
    transform: none;
}

.card-speak.inline-speak:hover {
    transform: none;
    background: var(--bg);
}

.card-divider {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #764ba2);
    border-radius: 2px;
    margin: 20px 0;
}

.card-answer {
    font-size: 20px;
    color: var(--text);
    text-align: center;
    line-height: 1.6;
    word-break: break-word;
    width: 100%;
}

.show-answer-btn {
    width: 100%;
    padding: 16px;
    border: none;
    background: linear-gradient(135deg, var(--primary), #764ba2);
    color: white;
    font-size: 16px;
    font-weight: 600;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.show-answer-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.rating-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
}

.rating-btn {
    padding: 14px 8px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: white;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.rating-btn:hover {
    transform: translateY(-2px);
}

.rating-btn .rating-interval {
    font-size: 11px;
    opacity: 0.85;
}

.rating-btn.again { background: linear-gradient(135deg, #e53e3e, #c53030); }
.rating-btn.hard { background: linear-gradient(135deg, #ed8936, #dd6b20); }
.rating-btn.good { background: linear-gradient(135deg, #48bb78, #38a169); }
.rating-btn.easy { background: linear-gradient(135deg, #4299e1, #3182ce); }

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

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-light);
    margin-bottom: 20px;
}

/* Import Page */
.import-section {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.import-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.import-section p {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
    line-height: 1.6;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 14px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

.drop-zone .drop-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.drop-zone p {
    color: var(--text-light);
}

textarea {
    width: 100%;
    min-height: 150px;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    /* 必须 >=16px：iOS Safari 聚焦小于 16px 的输入框会强制放大视口 */
    font-size: 16px;
    font-family: 'Monaco', 'Menlo', monospace;
    resize: vertical;
    transition: border-color 0.2s;
    background: var(--bg);
    line-height: 1.6;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
}

select, input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    /* 必须 >=16px，否则 iOS 聚焦时自动放大页面 */
    font-size: 16px;
    transition: border-color 0.2s;
    background: white;
    -webkit-appearance: none;
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #764ba2);
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
}

.btn-danger {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
}

.btn-block {
    width: 100%;
}

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

/* Add Card Page */
.card-form {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
}

/* Settings / Browse */
.browse-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid var(--border);
    background: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.active {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-list-item {
    background: white;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.card-list-item:hover {
    box-shadow: var(--shadow-lg);
}

.card-list-content {
    flex: 1;
    min-width: 0;
}

.card-list-front {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-list-back {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.card-list-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 12px;
}

.card-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.card-status.new { background: #3182ce; }
.card-status.learning { background: #ed8936; }
.card-status.review { background: #38a169; }

/* Default deck (默认词库) card rendering */
.dc-word {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.dc-phon {
    font-size: 16px;
    color: var(--text-light);
    margin-top: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
}

.dc-zh {
    font-size: 20px;
    font-weight: 600;
    margin-top: 12px;
}

.dc-en {
    font-size: 15px;
    color: var(--text-light);
    margin-top: 4px;
    font-style: italic;
}

.dc-ex {
    margin-top: 12px;
    text-align: left;
    background: var(--bg);
    border-radius: 10px;
    padding: 10px 12px;
}

.dc-ex-en {
    display: block;
    font-size: 15px;
    line-height: 1.5;
}

.dc-ex-zh {
    display: block;
    font-size: 13px;
    color: var(--text-light);
    margin-top: 2px;
    line-height: 1.5;
}

.card-answer .dc-word { font-size: 22px; }
.card-answer .dc-zh { font-size: 18px; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 20px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: flex-end;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
}

.toast {
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    white-space: nowrap;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(20px); }
}

/* Responsive */
@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 12px 8px;
    }

    .stat-card .stat-number {
        font-size: 22px;
    }

    .rating-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
}

.format-examples {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', monospace;
    line-height: 1.8;
    margin-bottom: 12px;
    overflow-x: auto;
}

.format-examples code {
    color: var(--primary-dark);
}

.study-complete {
    text-align: center;
    padding: 40px 20px;
}

.study-complete .complete-icon {
    font-size: 72px;
    margin-bottom: 16px;
}

.study-counter {
    font-size: 13px;
    color: var(--text-light);
}

/* Export section */
.export-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Tags */
.tag {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.search-box {
    position: relative;
    margin-bottom: 16px;
}

.search-box input {
    padding-left: 40px;
}

.search-box .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-light);
}

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

.flex-1 { flex: 1; }

/* ============ 账号与登录门 ============ */

.icon-btn.auth-account {
    width: auto;
    min-width: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    gap: 4px;
}

.icon-btn.auth-account.signed-in {
    background: rgba(255, 255, 255, 0.32);
}

.auth-gate {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(28, 33, 48, 0.62);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-gate.show { display: flex; }

.auth-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 28px 24px 20px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    max-height: 92vh;
    overflow-y: auto;
}

.auth-logo { font-size: 40px; line-height: 1; margin-bottom: 8px; }

.auth-card h2 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text);
}

.auth-hint {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.7;
    margin-bottom: 18px;
}

.auth-hint strong { color: var(--primary); }

.auth-card input {
    width: 100%;
    padding: 12px 14px;
    /* 必须 >=16px，否则 iOS 聚焦时自动放大页面 */
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.15s;
}

.auth-card input:focus { border-color: var(--primary); }

.auth-msg {
    font-size: 13px;
    min-height: 18px;
    margin-top: 10px;
    color: var(--text-light);
}

.auth-msg.error { color: var(--danger); }
.auth-msg.ok { color: var(--success); }

.auth-skip {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 13px;
    margin-top: 14px;
    cursor: pointer;
    text-decoration: underline;
    padding: 6px 8px;
}

.auth-skip:hover { color: var(--text); }

.auth-foot {
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.6;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
