/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.8;
    color: #1a1a1a;
    background: #ffffff;
    padding: 0;
}

/* === Layout === */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

/* === Typography === */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #1a1a1a;
}

h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: #1a1a1a;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

p, .text-block {
    margin-bottom: 1rem;
    text-align: justify;
}

.indent {
    text-indent: 2em;
}

/* === Images === */
.figure {
    margin: 1.5rem 0;
    text-align: center;
}

.figure img {
    max-width: 100%;
    height: auto;
}

.figure-caption {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
}

.figure-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.figure-row img {
    max-height: 500px;
    width: auto;
}

/* === Questions === */
.question-block {
    margin: 1.5rem 0;
    padding: 1.25rem 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
}

.question-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #555;
}

.question-text {
    margin-bottom: 1rem;
}

.question-options {
    list-style: none;
    padding: 0;
}

.question-options li {
    padding: 0.4rem 0;
}

.question-options label {
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

/* === Form Elements === */
textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: #333;
}

input[type="text"],
input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.95rem;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #333;
}

select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.95rem;
    background: white;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 10px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid #1a1a1a;
    background: #1a1a1a;
    color: #fff;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn:hover {
    background: #333;
}

.btn:disabled {
    background: #999;
    border-color: #999;
    cursor: not-allowed;
}

.btn-outline {
    background: #fff;
    color: #1a1a1a;
}

.btn-outline:hover {
    background: #f0f0f0;
}

.btn-sm {
    padding: 6px 16px;
    font-size: 0.85rem;
}

/* === Feedback === */
.feedback {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 3px;
    font-size: 0.9rem;
    display: none;
}

.feedback.show {
    display: block;
}

.feedback.correct {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
}

.feedback.incorrect {
    background: #fce4ec;
    border: 1px solid #ef9a9a;
    color: #c62828;
}

.feedback.pending {
    background: #fff3e0;
    border: 1px solid #ffcc02;
    color: #e65100;
}

.feedback.neutral {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1565c0;
}

/* === Tables === */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    border: 1px solid #ddd;
    padding: 10px 12px;
    text-align: center;
}

.data-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.data-table td {
    background: #fff;
}

/* === Matching / Connect === */
.match-container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin: 1rem 0;
}

.match-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.match-item {
    padding: 8px 14px;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, background 0.15s;
    font-size: 0.9rem;
}

.match-item:hover {
    border-color: #666;
    background: #f5f5f5;
}

.match-item.selected {
    border-color: #1a1a1a;
    background: #e8e8e8;
}

.match-item.matched {
    border-color: #4caf50;
    background: #e8f5e9;
}

/* === Navigation === */
.nav-bar {
    position: sticky;
    top: 0;
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 12px 24px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-bar .title {
    font-weight: 600;
    font-size: 1rem;
}

.nav-bar .user-info {
    font-size: 0.85rem;
    color: #666;
}

/* === Login === */
.login-box {
    max-width: 360px;
    margin: 120px auto;
    padding: 2rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.login-box h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
}

.login-box input {
    width: 100%;
    margin-bottom: 1rem;
}

.login-box .btn {
    width: 100%;
}

.login-error {
    color: #c62828;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    display: none;
}

/* === Index page === */
.lesson-list {
    list-style: none;
    margin-top: 2rem;
}

.lesson-list li {
    margin-bottom: 1rem;
}

.lesson-list a {
    display: block;
    padding: 1rem 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    text-decoration: none;
    color: #1a1a1a;
    font-weight: 500;
    transition: border-color 0.15s, background 0.15s;
}

.lesson-list a:hover {
    border-color: #999;
    background: #fafafa;
}

/* === Flow chart (HTML reproduced) === */
.flow-chart {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.flow-box {
    padding: 8px 14px;
    border: 1px solid #333;
    background: #fff;
    white-space: nowrap;
}

.flow-arrow {
    font-size: 1.2rem;
    color: #666;
}

.flow-blank {
    display: inline-block;
    min-width: 80px;
    border-bottom: 1px solid #333;
    text-align: center;
}

/* === Tag markers === */
.tag-interactive {
    display: inline-block;
    padding: 2px 8px;
    background: #e3f2fd;
    color: #1565c0;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 2px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.tag-optional {
    display: inline-block;
    padding: 2px 8px;
    background: #f3e5f5;
    color: #6a1b9a;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 2px;
    margin-right: 0.5rem;
}

/* === Concept map (for lesson 3 Q5) === */
.concept-map {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.concept-node {
    padding: 10px 16px;
    border: 1px solid #333;
    text-align: center;
    font-size: 0.9rem;
    min-width: 120px;
}

.concept-arrows {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 1.2rem;
    color: #666;
}

/* === Responsive === */
@media (max-width: 768px) {
    .container {
        padding: 20px 16px 60px;
    }
    h1 {
        font-size: 1.4rem;
    }
    .match-container {
        flex-direction: column;
    }
    .figure-row {
        flex-direction: column;
        align-items: center;
    }
}

/* Logout button in nav */
.btn-logout {
    margin-left: 12px;
    padding: 4px 12px;
    font-size: 0.8rem;
    border: 1px solid #ccc;
    background: #fff;
    color: #666;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-logout:hover {
    border-color: #c62828;
    color: #c62828;
    background: #fff5f5;
}

/* Hide completion bar on interactive pages (they have their own UI) */
body[data-page="interactive"] #completionStatus {
    display: none !important;
}
