* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

h1 {
    color: #c0392b;
    border-bottom: 2px solid #c0392b;
    padding-bottom: 10px;
}

h2 {
    color: #2c3e50;
}

.chapter-info {
    background: #ecf0f1;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #555;
}

.exercise-container {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.instruction {
    font-style: italic;
    color: #555;
    margin-bottom: 15px;
    font-size: 1.1em;
}

/* Matching exercise */
.matching-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.matching-table td, .matching-table th {
    border: 1px solid #ddd;
    padding: 10px;
    vertical-align: top;
}

.matching-table th {
    background: #2c3e50;
    color: white;
    text-align: center;
}

.matching-table tr:nth-child(even) {
    background: #f9f9f9;
}

/* Fill-in exercise */
.dialog-block {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border-left: 4px solid #3498db;
    border-radius: 0 5px 5px 0;
}

.dialog-block h3 {
    margin: 0 0 10px 0;
    color: #3498db;
}

.dialog-line {
    margin: 5px 0;
}

input[type="text"] {
    border: none;
    border-bottom: 2px solid #3498db;
    background: transparent;
    padding: 2px 5px;
    font-size: 1em;
    width: 140px;
    outline: none;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    border-bottom-color: #e74c3c;
}

input[type="text"].correct {
    border-bottom-color: #27ae60;
    background: #eafaf1;
}

input[type="text"].incorrect {
    border-bottom-color: #e74c3c;
    background: #fdedec;
}

select {
    border: 1px solid #3498db;
    padding: 5px 10px;
    font-size: 1em;
    border-radius: 3px;
    outline: none;
}

select.correct {
    border-color: #27ae60;
    background: #eafaf1;
}

select.incorrect {
    border-color: #e74c3c;
    background: #fdedec;
}

/* Buttons */
.buttons {
    margin-top: 25px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 25px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s;
}

.btn-check {
    background: #27ae60;
    color: white;
}

.btn-check:hover {
    background: #219a52;
}

.btn-clear {
    background: #e74c3c;
    color: white;
}

.btn-clear:hover {
    background: #c0392b;
}

.btn-nav {
    background: #3498db;
    color: white;
    text-decoration: none;
    display: inline-block;
}

.btn-nav:hover {
    background: #2980b9;
}

.btn-download {
    background: #8e44ad;
    color: white;
}

.btn-download:hover {
    background: #7d3c98;
}

/* Results */
.result {
    margin-top: 15px;
    padding: 10px 15px;
    border-radius: 5px;
    font-weight: bold;
    display: none;
}

.result.show {
    display: block;
}

.result-good {
    background: #eafaf1;
    color: #27ae60;
    border: 1px solid #27ae60;
}

.result-partial {
    background: #fef9e7;
    color: #f39c12;
    border: 1px solid #f39c12;
}

.result-bad {
    background: #fdedec;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

/* Navigation */
nav {
    background: #2c3e50;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

nav a {
    color: #ecf0f1;
    text-decoration: none;
    display: block;
    padding: 8px 15px;
    border-radius: 4px;
    transition: background 0.3s;
}

nav a:hover {
    background: #34495e;
}

nav a.active {
    background: #3498db;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-list li {
    margin: 3px 0;
}

/* No answers warning */
.no-answers-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 12px 15px;
    border-radius: 5px;
    margin: 15px 0;
    font-weight: bold;
}

/* Table exercise */
.fill-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.fill-table td, .fill-table th {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}

.fill-table th {
    background: #3498db;
    color: white;
}

.fill-table .given {
    background: #eafaf1;
    font-weight: bold;
}

/* Word bank */
.word-bank {
    background: #eaf2f8;
    padding: 15px;
    border-radius: 5px;
    margin: 15px 0;
    border: 1px dashed #3498db;
}

.word-bank span {
    display: inline-block;
    margin: 3px 8px;
    padding: 3px 8px;
    background: white;
    border-radius: 3px;
    border: 1px solid #bdc3c7;
}

/* Infinitive / person hints next to a blank */
.answer-hint {
    color: #7f8c8d;
    font-style: italic;
    font-size: 0.9em;
    white-space: nowrap;
}

/* Correction hints */
.correction {
    color: #27ae60;
    font-weight: bold;
    font-size: 0.9em;
    margin-left: 5px;
}

/* Matching exercise - click to connect */
.matching-instruction {
    font-style: italic;
    color: #777;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.matching-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 15px 0;
}

.matching-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.matching-item {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    user-select: none;
    background: white;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}

.matching-item:hover {
    border-color: #3498db;
    background: #eaf2f8;
}

.matching-item.selected {
    border-color: #f39c12;
    background: #fef9e7;
    box-shadow: 0 0 8px rgba(243, 156, 18, 0.4);
}

.matching-item.paired {
    background: #f8f9fa;
}

.matching-item.prefilled {
    opacity: 0.6;
    cursor: default;
}

.matching-item.prefilled:hover {
    border-color: #ddd;
    background: white;
}

.matching-item.match-correct {
    border-color: #27ae60 !important;
    background: #eafaf1 !important;
}

.matching-item.match-incorrect {
    border-color: #e74c3c !important;
    background: #fdedec !important;
}

.matching-number, .matching-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background: #2c3e50;
    color: white;
    border-radius: 50%;
    font-size: 0.8em;
    font-weight: bold;
    flex-shrink: 0;
}

.matching-letter {
    background: #8e44ad;
}

.matching-text {
    flex: 1;
}

.matching-corrections {
    background: #fdedec;
    border: 1px solid #e74c3c;
    border-radius: 5px;
    padding: 12px 15px;
    margin-top: 15px;
    line-height: 1.8;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .exercise-container {
        padding: 15px;
    }
    
    .buttons {
        flex-direction: column;
    }
    
    .btn {
        text-align: center;
    }

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

    .matching-item {
        font-size: 0.9em;
        padding: 8px 10px;
    }
}
