/* ============================================================
   英文單字溫習系統 — 樣式（手機版優先 Mobile First）
   ============================================================ */

:root {
    --bg: #eef1f8;
    --surface: #ffffff;
    --text: #1e2433;
    --text-soft: #6b7280;
    --text-faint: #9aa1b0;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef0ff;
    --success: #16a34a;
    --success-soft: #e8f7ed;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --warn: #b45309;
    --warn-soft: #fdf3e3;
    --border: #e6e8f0;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 10px 30px rgba(31, 41, 96, 0.08);
    --shadow-soft: 0 4px 14px rgba(31, 41, 96, 0.06);

    /* 各等級主題色 */
    --a1: #22c55e;
    --a2: #06b6d4;
    --b1: #6366f1;
    --b2: #a855f7;
    --c1: #ef4444;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
        "Microsoft JhengHei", "Noto Sans TC", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* 手機版容器：置中、限制最大寬度 */
.app {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    margin: 0 auto;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.04);
}

.content {
    flex: 1;
    padding: 18px 18px 32px;
}

/* ---------- Hero（首頁頂部） ---------- */
.hero {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    padding: 46px 24px 34px;
    border-radius: 0 0 30px 30px;
    box-shadow: var(--shadow);
}

.hero-badge {
    display: inline-block;
    font-size: 12px;
    letter-spacing: 1px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.18);
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 14px;
}

.hero-title {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 1px;
}

.hero-sub {
    margin: 8px 0 0;
    font-size: 15px;
    opacity: 0.92;
}

/* ---------- 頂欄（練習頁 / 錯題本） ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    padding: 14px 14px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--text);
    text-decoration: none;
    background: var(--bg);
    border-radius: 12px;
    line-height: 1;
}

.topbar-btn:active {
    background: var(--border);
}

/* ---------- 等級標籤 ---------- */
.level-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 24px;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
}

.level-a1 { background: var(--a1); }
.level-a2 { background: var(--a2); }
.level-b1 { background: var(--b1); }
.level-b2 { background: var(--b2); }
.level-c1 { background: var(--c1); }

/* ---------- 等級選擇卡 ---------- */
.level-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 4px;
}

.level-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: var(--primary);
}

.level-card.level-a1::before { background: var(--a1); }
.level-card.level-a2::before { background: var(--a2); }
.level-card.level-b1::before { background: var(--b1); }
.level-card.level-b2::before { background: var(--b2); }
.level-card.level-c1::before { background: var(--c1); }

.level-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow);
}

.level-tag {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    background: var(--primary);
    flex-shrink: 0;
}

.level-a1 .level-tag,
.level-card.level-a1 .level-tag { background: var(--a1); }
.level-card.level-a2 .level-tag { background: var(--a2); }
.level-card.level-b1 .level-tag { background: var(--b1); }
.level-card.level-b2 .level-tag { background: var(--b2); }
.level-card.level-c1 .level-tag { background: var(--c1); }

.level-info {
    flex: 1;
}

.level-name {
    font-size: 17px;
    font-weight: 700;
}

.level-meta {
    font-size: 13px;
    color: var(--text-soft);
    margin-top: 2px;
}

.level-arrow {
    font-size: 26px;
    color: var(--text-soft);
    font-weight: 300;
}

/* ---------- 通用卡片 ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border);
}

.info-card {
    margin-top: 18px;
    background: var(--primary-soft);
    border-color: #dfe1fb;
}

/* ---------- 統計列 ---------- */
.statbar-group {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.statbar-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-soft);
    padding: 9px 16px 0;
}

.statbar {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.statbar-group .statbar {
    border-bottom: none;
}

.stat {
    flex: 1;
    text-align: center;
    padding: 12px 6px;
    border-right: 1px solid var(--border);
}

.stat:last-child {
    border-right: none;
}

.stat-num {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 2px;
}

/* ---------- 題目卡 ---------- */
.question-card {
    text-align: center;
    padding: 34px 22px;
    margin-top: 10px;
}

.question-hint {
    font-size: 13px;
    color: var(--text-soft);
    letter-spacing: 0.5px;
}

.question-meaning {
    font-size: 40px;
    font-weight: 800;
    margin: 18px 0 6px;
    line-height: 1.25;
    word-break: break-word;
}

.question-pos {
    display: inline-block;
    font-size: 13px;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 3px 12px;
    border-radius: 999px;
    margin-bottom: 20px;
}

.question-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.question-meta .question-pos {
    margin-bottom: 0;
}

.answer-form {
    margin-top: 12px;
}

.answer-input {
    width: 100%;
    font-size: 20px;
    text-align: center;
    padding: 15px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    margin-bottom: 14px;
    background: #fafbff;
    transition: border-color 0.15s ease;
}

.answer-input:focus {
    border-color: var(--primary);
    background: #fff;
}

/* ---------- 按鈕 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    padding: 15px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s ease, background 0.15s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.28);
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-next {
    margin-top: 18px;
}

/* ---------- 結果卡 ---------- */
.result-card {
    text-align: center;
    padding: 30px 22px;
    margin-top: 10px;
    animation: pop 0.25s ease;
}

@keyframes pop {
    from { transform: scale(0.94); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.result-icon {
    width: 66px;
    height: 66px;
    margin: 0 auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: #fff;
    font-weight: 700;
}

.result-correct .result-icon { background: var(--success); }
.result-wrong .result-icon { background: var(--danger); }

.result-text {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 18px;
}

.result-correct .result-text { color: var(--success); }
.result-wrong .result-text { color: var(--danger); }

.result-meaning {
    font-size: 26px;
    font-weight: 700;
}

.result-pos {
    display: inline-block;
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 6px;
}

.result-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.result-meta .result-pos {
    margin-top: 0;
}

.result-answer {
    margin-top: 18px;
    padding: 16px;
    background: var(--success-soft);
    border-radius: var(--radius-sm);
}

.result-wrong .result-answer {
    background: var(--primary-soft);
}

.answer-label {
    font-size: 12px;
    color: var(--text-soft);
}

.answer-word {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    margin-top: 2px;
    word-break: break-word;
}

.your-answer {
    margin-top: 14px;
    font-size: 14px;
    color: var(--text-soft);
}

.your-answer span {
    color: var(--danger);
    font-weight: 700;
    text-decoration: line-through;
}

/* ---------- 提示文字 ---------- */
.hint {
    font-size: 13px;
    color: var(--text-soft);
    margin: 0;
}

.hint.center {
    text-align: center;
    margin-top: 16px;
}

/* ---------- 錯題本 ---------- */
.review-summary {
    font-size: 14px;
    color: var(--text-soft);
    margin: 4px 2px 14px;
}

.review-summary strong {
    color: var(--danger);
}

.mistake-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mistake-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
}

.mistake-word {
    font-size: 18px;
    font-weight: 700;
    word-break: break-word;
}

.mistake-meaning {
    font-size: 13px;
    color: var(--text-soft);
    margin-top: 2px;
}

.mistake-pos {
    color: var(--primary);
    margin-left: 4px;
}

.mistake-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.badge {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.badge-fail {
    background: var(--danger-soft);
    color: var(--danger);
}

.mistake-level {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--primary);
}

/* ---------- 空狀態 ---------- */
.empty-state {
    text-align: center;
    padding: 40px 24px;
    margin-top: 20px;
}

.empty-icon {
    font-size: 46px;
}

.empty-title {
    font-size: 19px;
    font-weight: 800;
    margin-top: 10px;
}

.empty-sub {
    font-size: 14px;
    color: var(--text-soft);
    margin-top: 6px;
}

/* ---------- 提示 / 通知 ---------- */
.notice {
    font-size: 14px;
    margin-bottom: 12px;
}

.notice.ok {
    background: var(--success-soft);
    border-color: #cdeed6;
    color: #14663a;
}

.notice.warn {
    background: var(--warn-soft);
    border-color: #f3e2c0;
    color: var(--warn);
}

.notice a {
    color: var(--primary);
    font-weight: 700;
}

.summary-card {
    margin: 4px 0 18px;
}

.summary-line {
    font-size: 15px;
    margin-bottom: 6px;
}

/* ---------- 學習統計頁 ---------- */
.section-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    margin: 22px 2px 12px;
}

.progress {
    height: 12px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.progress-fill.fill-primary {
    background: var(--primary);
}

.stats-overall {
    text-align: center;
    margin: 4px 0 8px;
}

.stats-overall-label {
    font-size: 14px;
    color: var(--text-soft);
}

.stats-overall-num {
    font-size: 42px;
    font-weight: 800;
    line-height: 1.2;
    margin: 6px 0 16px;
}

.stats-overall-num span {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-faint);
}

.stats-overall-pct {
    font-size: 13px;
    color: var(--text-soft);
    margin-top: 8px;
}

.stats-status {
    font-size: 14px;
    font-weight: 700;
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.stats-status.ok {
    background: var(--success-soft);
    color: #14663a;
}

.stats-status.warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.stats-level-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-level {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
}

.stats-level-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.stats-level-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-level-desc {
    font-size: 14px;
    font-weight: 600;
}

.stats-level-count {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-soft);
    flex-shrink: 0;
}

.stats-level-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chip {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
}

.chip.ok {
    background: var(--success-soft);
    color: #14663a;
}

.chip.warn {
    background: var(--danger-soft);
    color: var(--danger);
}

.chip.muted {
    background: var(--bg);
    color: var(--text-soft);
}

/* ---------- 頁尾 ---------- */
.footer {
    text-align: center;
    padding: 20px;
}

.footer-link {
    font-size: 13px;
    color: var(--text-soft);
    text-decoration: none;
}

.footer-link:active {
    color: var(--primary);
}

.footer-user {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 10px;
}

/* ---------- 登入頁 ---------- */
.login-content {
    justify-content: center;
    min-height: 80vh;
    gap: 4px;
}

.login-brand {
    text-align: center;
    margin-bottom: 26px;
}

.login-logo {
    font-size: 54px;
    line-height: 1;
}

.login-title {
    font-size: 26px;
    font-weight: 800;
    margin: 12px 0 4px;
}

.login-sub {
    font-size: 14px;
    color: var(--text-soft);
    margin: 0;
}

.login-card {
    width: 100%;
}

.login-error {
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
}

.field-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-soft);
    margin: 12px 2px 6px;
}

.login-form .btn {
    margin-top: 22px;
}

/* ---------- 桌面時的置中背景 ---------- */
@media (min-width: 520px) {
    body {
        background: #dfe3ef;
    }
    .app {
        margin-top: 20px;
        margin-bottom: 20px;
        min-height: calc(100vh - 40px);
        border-radius: 26px;
        overflow: hidden;
    }
    .hero {
        border-radius: 0;
    }
}
