/* ==========================================
   🍎 Apple / Samsung 極簡風格系統設定
   ========================================== */
:root {
    --bg-color: #f5f5f7; /* Apple 經典淺灰背景 */
    --card-bg: #ffffff;
    --primary: #0071e3; /* Apple 官網招牌科技藍 */
    --primary-hover: #0077ed;
    --text-main: #1d1d1f; /* 頂級鈦灰色，比純黑更有質感 */
    --text-muted: #86868b;
    --success: #00a82d; /* 柔和的安全綠 */
    --success-bg: #e5f6eb;
    --error: #ff3b30; /* Apple 警告紅 */
    --error-bg: #ffeceb;
    --border-radius: 18px; /* 更圓潤的蘋果風導角 */
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.02); /* 頂級微陰影 */
}

* { box-sizing: border-box; }

body {
    font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    
    /* 終極防拷貝 (禁止滑鼠反白圈選文字) */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ==========================================
   🌐 頂部導覽列 (毛玻璃特效)
   ========================================== */
.top-navbar {
    background-color: rgba(255, 255, 255, 0.75); 
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky; 
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    height: 56px;
}

.nav-container {
    display: flex;
    max-width: 980px;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.nav-brand {
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text-main);
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-item {
    text-decoration: none !important;
    color: var(--text-main);
    font-weight: 400;
    font-size: 0.85rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.nav-item.active {
    background-color: var(--text-main);
    color: #ffffff !important;
    font-weight: 500;
}

/* ==========================================
   📦 系統主要內容區塊
   ========================================== */
.container {
    width: 100%;
    max-width: 650px;
    margin: 2rem auto; /* 修正原本 flex 導致與 navbar 衝突的問題 */
    padding: 0 1rem;
}

.header { text-align: center; margin-bottom: 2rem; }
.header h1 { margin: 0 0 0.5rem 0; font-size: 2rem; color: var(--text-main); letter-spacing: -0.02em; }
.subtitle { color: var(--text-muted); margin: 0; }

.card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid rgba(0,0,0,0.02);
}

#upload-section { text-align: center; }
input[type="file"] { display: none; }

.btn {
    border: none;
    padding: 0.85rem 1.75rem;
    border-radius: 999px; /* Apple 風格全圓角按鈕 */
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); transform: scale(0.98); }

/* --- 進度條與題目 --- */
.progress-container { width: 100%; background-color: #e5e7eb; height: 6px; border-radius: 999px; margin-bottom: 1rem; overflow: hidden; }
.progress-bar { height: 100%; background-color: var(--primary); width: 0%; transition: width 0.4s ease; }
#progress-text { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; font-weight: 500; }
.question-text { font-size: 1.2rem; font-weight: 600; margin-bottom: 1.5rem; line-height: 1.6; }

/* --- 選項設計 --- */
.option {
    background: #ffffff;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    border: 1.5px solid #e5e7eb;
    transition: all 0.2s ease;
    font-size: 1rem;
}
.option:hover { border-color: var(--primary); background: #f8fafc; }
.option.correct { background: var(--success-bg); border-color: var(--success); color: #064e3b; }
.option.wrong { background: var(--error-bg); border-color: var(--error); color: #7f1d1d; }

.feedback-box { margin-top: 1.5rem; padding: 1.25rem; border-radius: 12px; background: #f9fafb; border-left: 4px solid var(--primary); }
.explanation-text { margin-top: 0.75rem; font-size: 0.95rem; color: #374151; }

/* --- 錯題本與測驗結果 --- */
.review-card { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 12px; padding: 1.5rem; margin-bottom: 1rem; text-align: left;}
.review-question { font-weight: 600; font-size: 1.05rem; margin-bottom: 1rem; color: var(--text-main); }
.review-answer { margin-bottom: 0.5rem; padding: 0.75rem; border-radius: 8px; font-size: 0.95rem; }
.review-wrong { background-color: var(--error-bg); color: #7f1d1d; border-left: 4px solid var(--error); }
.review-correct { background-color: var(--success-bg); color: #064e3b; border-left: 4px solid var(--success); }

/* --- 導覽按鈕區塊 --- */
.question-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; padding: 1rem; background: #f9fafb; border-radius: 12px; border: 1px solid #e5e7eb; }
.nav-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid #d1d5db; background: #ffffff; cursor: pointer; font-weight: 600; color: var(--text-muted); transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; font-size: 0.95rem; }
.nav-btn:hover { background: #f8fafc; border-color: var(--primary); color: var(--primary); }
.nav-btn.active { border: 2px solid var(--primary); transform: scale(1.1); color: var(--text-main); }
.nav-btn.answered-correct { background: var(--success); color: white; border-color: var(--success); }
.nav-btn.answered-wrong { background: var(--error); color: white; border-color: var(--error); }

/* --- 歷史紀錄與其他 --- */
.history-item { background: #ffffff; border: 1px solid #e5e7eb; padding: 1rem; border-radius: 12px; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; }
.history-btn { background-color: var(--primary); color: white; border: none; padding: 0.5rem 1rem; border-radius: 999px; cursor: pointer; font-weight: 600; }
.form-select { padding: 0.5rem 1rem; border-radius: 8px; border: 1px solid #d1d5db; font-size: 1rem; background-color: white; color: var(--text-main); outline: none; cursor: pointer; font-family: inherit; }
.form-select:focus { border-color: var(--primary); }

.subject-container { max-height: 250px; overflow-y: auto; border: 1px solid #d1d5db; border-radius: 12px; padding: 0.5rem; background: #ffffff; }
.subject-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem; border-bottom: 1px solid #f3f4f6; }
.subject-item:last-child { border-bottom: none; }
.subject-checkbox { width: 18px; height: 18px; margin-right: 12px; accent-color: var(--primary); }
.subject-label { display: flex; align-items: center; flex: 1; cursor: pointer; font-weight: 500; color: var(--text-main); }
.delete-subject-btn { background: var(--error-bg); color: var(--error); border: none; border-radius: 999px; padding: 0.25rem 0.75rem; cursor: pointer; font-size: 0.85rem; font-weight: 600; }