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

body {
    font-family: 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
header {
    background: white;
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    color: #667eea;
    font-size: 1.8em;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.user-stats {
    display: flex;
    gap: 20px;
    font-size: 0.9em;
    color: #666;
}

.user-stats strong {
    color: #667eea;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.tab {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s;
    color: #333;
}

.tab:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tab.active {
    background: white;
    color: #667eea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.content {
    display: none;
}

.content.active {
    display: block;
}

/* Course Grid */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.course-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    position: relative;
}

.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.course-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.course-icon {
    font-size: 3em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s;
}

.settings-btn:hover {
    opacity: 1;
    transform: rotate(90deg);
}

.course-body h3 {
    color: #333;
    margin-bottom: 8px;
    font-size: 1.3em;
}

.course-body p {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.course-stats-mini {
    display: flex;
    gap: 15px;
    font-size: 0.85em;
    color: #888;
    margin-bottom: 15px;
}

.course-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    flex: 1;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-small:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.course-settings {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #f0f0f0;
    gap: 10px;
}

.course-settings.show {
    display: flex;
}

.course-settings button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.course-settings button:first-child {
    background: #667eea;
    color: white;
}

.course-settings button:last-child {
    background: #dc3545;
    color: white;
}

.lessons-panel {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9ff;
    border-radius: 10px;
    border: 2px solid #e8eaff;
}

.lessons-panel.show {
    display: block;
}

.lessons-panel h4 {
    color: #667eea;
    margin-bottom: 15px;
}

.lesson-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
}

.lesson-info {
    flex: 1;
}

.lesson-info strong {
    display: block;
    color: #333;
    margin-bottom: 5px;
}

.lesson-info span {
    font-size: 0.85em;
    color: #888;
}

.lesson-actions {
    display: flex;
    gap: 5px;
}

.btn-mini {
    padding: 6px 10px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.btn-mini:hover {
    background: #5568d3;
}

/* Practice Area */
.practice-container {
    max-width: 900px;
    margin: 0 auto;
}

.practice-setup {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.practice-setup h2 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
}

.mode-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.mode-card {
    padding: 30px;
    border: 3px solid #e8eaff;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-card:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2);
}

.mode-card.selected {
    border-color: #667eea;
    background: #f8f9ff;
}

.mode-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.mode-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.mode-desc {
    font-size: 0.9em;
    color: #888;
}

.course-lesson-selector {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.course-lesson-selector label {
    font-weight: 600;
    color: #555;
}

.course-lesson-selector select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: border-color 0.3s;
}

.course-lesson-selector select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-start {
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s;
}

.btn-start:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.practice-area {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.practice-info {
    display: flex;
    gap: 20px;
    font-weight: 600;
    color: #667eea;
}

.practice-timer {
    font-size: 1.2em;
    font-weight: 600;
    color: #667eea;
}

.question-card {
    margin-bottom: 30px;
}

.question-number {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.6;
}

.question-stats {
    font-size: 0.85em;
    color: #888;
    margin-bottom: 20px;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option {
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.05em;
}

.option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.option.selected {
    border-color: #667eea;
    background: #f0f3ff;
}

.option.correct {
    border-color: #28a745;
    background: #d4edda;
    pointer-events: none;
}

.option.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
    pointer-events: none;
}

.option.memorize-correct {
    border: 3px solid #28a745;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    font-weight: 600;
    pointer-events: none;
    cursor: default;
    position: relative;
    padding-left: 50px;
}

.option.memorize-correct::before {
    content: '✓';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5em;
    color: #28a745;
    font-weight: bold;
}

.option.memorize-option {
    border-color: #e0e0e0;
    background: #f8f9fa;
    color: #6c757d;
    pointer-events: none;
    cursor: default;
    opacity: 0.7;
}

.practice-controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.answer-feedback {
    margin-top: 20px;
}

.feedback {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    border-radius: 10px;
    animation: slideIn 0.3s;
}

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

.feedback-correct {
    background: #d4edda;
    border: 2px solid #28a745;
}

.feedback-wrong {
    background: #f8d7da;
    border: 2px solid #dc3545;
}

.feedback-icon {
    font-size: 2.5em;
}

.feedback-text {
    flex: 1;
    line-height: 1.6;
}

/* Wrong Book */
.wrong-book-container {
    max-width: 1000px;
    margin: 0 auto;
}

.wrong-book-header {
    background: white;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.wrong-book-header h2 {
    color: #667eea;
    margin: 0;
}

.wrong-book-stats {
    display: flex;
    gap: 20px;
    font-size: 0.95em;
    color: #666;
}

.wrong-book-stats strong {
    color: #dc3545;
}

.filter-bar {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.filter-bar select {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
}

.filter-bar select:focus {
    outline: none;
    border-color: #667eea;
}

.filter-bar .btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.filter-bar .btn:hover {
    transform: scale(1.05);
}

.wrong-questions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.wrong-question-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #dc3545;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.wrong-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.wrong-question-tag {
    background: #f8d7da;
    color: #dc3545;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 500;
}

.wrong-question-reviewed {
    font-size: 0.85em;
    color: #888;
}

.wrong-question-body {
    margin-bottom: 15px;
}

.options-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.option-display {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.95em;
}

.option-display.correct {
    background: #d4edda;
    color: #155724;
    font-weight: 600;
}

.wrong-question-actions {
    display: flex;
    justify-content: flex-end;
}

/* Stats Dashboard */
.stats-dashboard {
    max-width: 1000px;
    margin: 0 auto;
}

.stats-dashboard h2 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.stat-card-highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-card-highlight .stat-icon,
.stat-card-highlight .stat-value,
.stat-card-highlight .stat-label {
    color: white;
}

.stat-card-memorize {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.stat-card-memorize .stat-icon,
.stat-card-memorize .stat-value,
.stat-card-memorize .stat-label {
    color: white;
}

.stat-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 0.95em;
    color: #888;
}

.course-stats-section, .recent-practice-section {
    background: white;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.course-stats-section h3, .recent-practice-section h3 {
    color: #667eea;
    margin-bottom: 20px;
}

.course-stat-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.course-stat-item:last-child {
    border-bottom: none;
}

.course-stat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.course-stat-icon {
    font-size: 1.5em;
}

.course-stat-name {
    font-weight: 600;
    color: #333;
}

.course-stat-data {
    display: flex;
    gap: 20px;
}

.stat-mini {
    display: flex;
    flex-direction: column;
}

.stat-mini-label {
    font-size: 0.8em;
    color: #888;
}

.stat-mini-value {
    font-size: 1.2em;
    font-weight: 600;
    color: #667eea;
}

.recent-record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.recent-record-item:last-child {
    border-bottom: none;
}

.recent-record-time {
    font-size: 0.85em;
    color: #888;
    min-width: 150px;
}

.recent-record-info {
    flex: 1;
    color: #555;
}

.recent-record-result {
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.9em;
}

.recent-record-result.correct {
    background: #d4edda;
    color: #155724;
}

.recent-record-result.wrong {
    background: #f8d7da;
    color: #721c24;
}

/* Manage Container */
.manage-container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.manage-container h2 {
    color: #667eea;
    margin-bottom: 25px;
}

.question-edit-card {
    border: 2px solid #e8eaff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    transition: all 0.3s;
}

.question-edit-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
}

.question-edit-card h4 {
    color: #667eea;
    margin-bottom: 15px;
}

.question-edit-card label {
    display: block;
    margin: 12px 0 6px;
    font-weight: 600;
    color: #555;
}

.question-input, .option-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
}

.question-input {
    min-height: 80px;
    resize: vertical;
}

.question-input:focus, .option-input:focus {
    outline: none;
    border-color: #667eea;
}

.option-edit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.option-edit-row input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.question-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #f0f0f0;
}

.btn-save {
    flex: 1;
    padding: 10px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-save:hover {
    background: #218838;
    transform: scale(1.02);
}

.btn-delete {
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-delete:hover {
    background: #c82333;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    font-size: 1.5em;
    color: #667eea;
    margin-bottom: 20px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    color: #667eea;
}

.modal-body label {
    display: block;
    margin: 12px 0 6px;
    font-weight: 600;
    color: #555;
}

.modal-body input, .modal-body select, .modal-body textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
}

.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
    outline: none;
    border-color: #667eea;
}

.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.cancel-btn {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.cancel-btn:hover {
    background: #5a6268;
}

.btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.import-info {
    background: #f8f9ff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #555;
}

.import-info ul {
    margin-left: 20px;
    margin-top: 10px;
}

.import-info li {
    margin-bottom: 5px;
}

.file-input-label {
    display: block;
    padding: 15px;
    background: #f8f9ff;
    border: 2px dashed #667eea;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.file-input-label:hover {
    background: #e8eaff;
    border-color: #5568d3;
}

.file-input-icon {
    font-size: 2em;
    display: block;
    margin-bottom: 10px;
}

.format-options {
    display: flex;
    gap: 15px;
}

.format-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
    }

    .user-info {
        text-align: center;
        margin-top: 15px;
    }

    .tabs {
        justify-content: center;
    }

    .courses-grid {
        grid-template-columns: 1fr;
    }

    .mode-selector {
        grid-template-columns: 1fr;
    }

    .practice-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .filter-bar {
        flex-direction: column;
    }
}