* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    background: linear-gradient(135deg, #f4e6d3 0%, #deb887 100%);
    min-height: 100%;
}

:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --warm-gradient: linear-gradient(135deg, #f4e6d3 0%, #deb887 100%);
    --accent-brown: #8b4513;
    --light-brown: #deb887;
    --card-shadow: 0 8px 24px rgba(139, 69, 19, 0.15);
}

body {
    font-family: 'Noto Serif TC', serif;
    background: var(--warm-gradient);
    height: 100vh;
    height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom));
    color: var(--accent-brown);
    overflow: hidden;
    position: fixed;
    width: 100%;
    padding-top: var(--safe-area-top);
}

.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* Banner 區域樣式 */
.banner-section {
    position: relative;
    flex-shrink: 0;
    margin-bottom: 1rem;
}

.banner-img {
    width: 100%;
    height: auto;
    max-width: 800px;
    object-fit: contain; /* 改為 contain，完整顯示圖片 */
    display: block;
    margin: 0 auto;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.2);
    transition: transform 0.3s ease;
}

.banner-img:hover {
    transform: scale(1.02);
}

/* 返回按鈕樣式 */
.back-button {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 25px;
    color: var(--accent-brown);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.2);
    border: 1px solid rgba(139, 69, 19, 0.1);
}

.back-button svg {
    width: 20px;
    height: 20px;
}

.back-button:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 69, 19, 0.3);
}

/* 內容區域 */
.content-area {
    position: relative;
    flex-grow: 1;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 導航標籤樣式 */
.navigation-tabs {
    display: flex;
    padding: 1rem 1rem 0;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-tab {
    padding: 12px 8px;
	flex: 1;
	text-align: center;
    font-size: 16px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(139, 69, 19, 0.2);
    border-radius: 15px 15px 0 0;
    color: rgba(139, 69, 19, 0.7);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}

.nav-tab:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--accent-brown);
    transform: translateY(-2px);
}

.nav-tab.active {
    background: rgba(255, 255, 255, 0.8);
    color: var(--accent-brown);
    border-color: rgba(139, 69, 19, 0.4);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.1);
}

/* 內容包裝器 */
.content-wrapper {
    flex: 1;
    overflow-y: auto;
    position: relative;
    min-height: 0;
}

/* 區段內容樣式 */
.section-content {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.section-content::-webkit-scrollbar {
    display: none;
}

.section-content.active {
    display: block;
}

/* 文字內容區域 */
.explain-text,
.author-text,
.content-text {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding-bottom: 2rem;
}

/* 標題樣式 */
.explain-title,
.section-title {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--accent-brown);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--light-brown);
    letter-spacing: 0.05em;
}

/* 說明內容樣式 */
/* 說明內容樣式 */
.explain-section {
    flex-grow: 1;
    margin-bottom: 2rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    border-left: 4px solid var(--light-brown);
}

.explain-content,
.section-text {
    font-size: 1.1em;
    line-height: 1.8;
    color: rgba(139, 69, 19, 0.9);
    margin-bottom: 1.5rem;
    background: transparent;
    border-radius: 0;
    border-left: none;
}

.explain-content:last-child,
.section-text:last-child {
    margin-bottom: 0;
}

/* 作者資訊卡片 */
.author-section {
    background: rgba(255, 255, 255, 0.6) !important;
    padding: 1.5rem !important;
    border-radius: 12px !important;
    margin-bottom: 1.5rem !important;
    border-left: 4px solid var(--light-brown);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.1);
}

.author-content {
    font-size: 1.1em;
    line-height: 1.8;
    color: rgba(139, 69, 19, 0.9);
}

/* 課文區段樣式 */
.content-section {
    position: relative;
    margin-bottom: 1rem;
    padding: 2rem 1.5rem 1.5rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 15px;
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.1);
    border-left: 5px solid var(--light-brown);
}

.content-number {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-brown), #a0522d);
    color: #FFF;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.content-controls {
    position: absolute;
    top: 15px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.content-button {
    padding: 8px 20px;
    background: rgba(139, 69, 19, 0.1);
    border: 1px solid rgba(139, 69, 19, 0.3);
    border-radius: 20px;
    color: var(--accent-brown);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.content-button:hover {
    background: rgba(139, 69, 19, 0.2);
    transform: translateY(-2px);
}

.content-button.active {
    background: var(--accent-brown);
    color: #FFF;
}

.content-main {
    margin-top: 2rem;
}

/* 詳細全文的段落樣式 */
.content-paragraph {
    margin-bottom: 0.05rem;  /* 增加段落間距以達到更好的群化效果 */
    line-height: 1.8;
    font-size: 1.1em;
    color: rgba(139, 69, 19, 0.9);
    text-align: justify;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

/* 最後一個段落不需要額外底部間距 */
.content-paragraph:last-child {
    margin-bottom: 0;
}

/* 段析內容 */
.analysis-content {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: rgba(255, 248, 220, 0.8);
    border-radius: 12px;
    border: 1px solid rgba(139, 69, 19, 0.2);
}

.analysis-title {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--accent-brown);
    margin-bottom: 1rem;
}

.analysis-text {
    line-height: 1.8;
    color: rgba(139, 69, 19, 0.9);
    font-size: 1em;
}

/* 練習題區域 */
.practice-button-container {
    margin-top: 2rem;
    padding-top: 1rem;
    text-align: center;
}

.practice-button {
    padding: 12px 30px;
    background: linear-gradient(135deg, var(--accent-brown), #a0522d);
    border: none;
    border-radius: 25px;
    color: #FFF;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.practice-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 69, 19, 0.4);
}

/* 確保按鈕字級一致 */
.practice-button,
.content-button {
    font-size: 16px !important;
}

.practice-section {
    margin-top: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 248, 220, 0.6);
    border-radius: 15px;
    border: 1px solid rgba(139, 69, 19, 0.2);
    position: relative;
    z-index: 1;
}

.question-container,
.sub-question-container {
    background: rgba(255, 255, 255, 0.8);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.1);
}

.question-text,
.sub-question {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--accent-brown);
}

.question-intro {
    font-size: 1.1em;
    color: var(--accent-brown);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* 選項按鈕樣式 */
.option-button {
    padding: 12px 16px;
    font-size: 1rem;
    text-align: left;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(139, 69, 19, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: rgba(139, 69, 19, 0.9);
}

.option-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(139, 69, 19, 0.4);
    transform: translateY(-1px);
}

.option-button.selected {
    background: rgba(139, 69, 19, 0.1);
    border-color: var(--accent-brown);
    color: var(--accent-brown);
    font-weight: 600;
}

.option-button.my-correct {
    background: rgba(34, 139, 34, 0.2);
    border-color: #228B22;
    color: #228B22;
}

.option-button.my-incorrect {
    background: rgba(220, 20, 60, 0.2);
    border-color: #DC143C;
    color: #DC143C;
}

.option-button.correct-answer {
    background: rgba(144, 238, 144, 0.1);
    border-color: #90EE90;
    color: #228B22;
}

.answer-label {
    font-weight: bold;
    font-size: 0.9em;
    margin-left: 10px;
}

.correct-answer .answer-label {
    color: #DC143C;  /* 預設紅色（漏答） */
}

.correct-answer .answer-label:not([data-type="missed"]) {
    color: #228B22;  /* 綠色（單選題的✓） */
}


.option-button:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

/* 檢查答案按鈕 */
.check-answer-button {
    padding: 12px 30px;
    background: var(--accent-brown);
    color: #FFF;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
    margin: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.2);
}

.check-answer-button:not(:disabled) {
    opacity: 1;
}

.check-answer-button:not(:disabled):hover {
    background: #a0522d;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 69, 19, 0.3);
}

.check-answer-button:disabled {
    cursor: not-allowed;
}

/* 答案區域 */
.answer-section {
    background: rgba(255, 248, 220, 0.8);
    padding: 1rem;
    border-radius: 10px;
    margin-top: 1rem;
    border: 1px solid rgba(139, 69, 19, 0.2);
}

.answer-result {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-text {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--accent-brown);
}

.correct-answer {
    font-size: 1rem;
    color: #228B22;
    font-weight: 600;
}

/* 關閉按鈕 */
.close-practice-button {
    display: none;
    margin: 1.5rem auto 0;
    padding: 10px 25px;
    background: var(--accent-brown);
    border: none;
    border-radius: 20px;
    color: #FFF;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.2);
}

.close-practice-button:hover {
    background: #a0522d;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 69, 19, 0.3);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .banner-img {
        max-height: 100px;
        border-radius: 10px;
    }
    
    .back-button {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .back-button svg {
        width: 16px;
        height: 16px;
    }
    
    .nav-tab {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .section-content {
        padding: 1rem;
    }
    
    .explain-title,
    .section-title {
        font-size: 1.5em;
    }
    
    .explain-content,
    .section-text {
        font-size: 1rem;
    }

	/* 課文概覽的段落樣式 */
#explain-content .explain-content {
    font-size: 1.1em;
    line-height: 1.8;
    color: rgba(139, 69, 19, 0.9);
    margin-bottom: 1.5rem;
    background: transparent;
    border-radius: 0;
    border-left: none;
}

#explain-content .explain-content:last-child {
    margin-bottom: 0;
}
    
    .content-number {
        width: 30px;
        height: 30px;
        font-size: 1em;
    }
    
    .content-button {
        padding: 6px 15px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0;
    }
    
    .banner-img {
        max-height: 80px;
        border-radius: 8px;
    }
    
    .back-button {
        top: 8px;
        left: 8px;
        padding: 4px 10px;
        font-size: 12px;
    }
    
    .navigation-tabs {
        padding: 0.5rem 0.5rem 0;
        gap: 0.3rem;
    }
    
    .nav-tab {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .section-content {
        padding: 0.8rem;
    }
    
    .content-section {
        padding: 1.5rem 1rem 1rem;
    }
    
    .option-button {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* 無障礙設計 */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* 閱讀進度條 */
.reading-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    margin: 0.5rem 1rem 0;
    overflow: hidden;
}

.reading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-brown), var(--light-brown));
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(139, 69, 19, 0.5);
}
/* 移除外層框架效果 */
body {
    background: #f9f3ed;
}

.content-area {
    border-radius: 0;
    border: none;
    background: white;
    box-shadow: none;
}

.banner-section {
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.9);
}

.navigation-tabs {
    background: rgba(255, 255, 255, 0.5);
    padding: 0.5rem 0.3rem 0;
}

/* 簡化練習區域 */
.practice-section {
    margin: 1rem 0;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0;
}

.question-container,
.sub-question-container {
    background: #f5f5f5;
    border: none;
    box-shadow: none;
    border-radius: 5px;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

/* 簡化選項按鈕 */
.option-button {
    background: white;
    border: 1px solid #e0e0e0;
}

/* 簡化內容區段 */
.content-section {
    margin: 0 0 1rem 0;
    padding: 1.5rem 0.8rem 1rem;
    border-radius: 0;
    border-left: 3px solid var(--light-brown);
    box-shadow: none;
}
/* 強制多選題漏答為紅色 */
.correct-answer .answer-label {
    color: #DC143C !important;
}

/* 載入指示器樣式 */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(139, 69, 19, 0.1);
    border-left: 4px solid var(--accent-brown);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.2em;
    color: var(--accent-brown);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.error-container {
    text-align: center;
    padding: 2rem;
}

.error-icon {
    font-size: 3em;
    margin-bottom: 1rem;
}

.error-text {
    font-size: 1.3em;
    color: #dc143c;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.error-subtitle {
    font-size: 1em;
    color: rgba(139, 69, 19, 0.7);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.retry-button {
    padding: 12px 24px;
    background: var(--accent-brown);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.retry-button:hover {
    background: #a0522d;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 69, 19, 0.4);
}

/* 主要內容文字改為黑色 */
.question-text,
.question-intro,
.content-paragraph,
.explain-content,
.section-text,
.author-content,
.analysis-text {
    color: #000 !important;
}

