* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    color: #333;
    margin-bottom: 30px;
    text-align: center;
}

h2 {
    color: #555;
    margin: 20px 0 15px 0;
}

.menu {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s;
    font-weight: 600;
    text-align: center;
}

.btn-primary { background: #667eea; color: white; }
.btn-primary:hover { background: #5568d3; transform: translateY(-2px); }
.btn-secondary { background: #e0e0e0; color: #333; }
.btn-secondary:hover { background: #d0d0d0; }
.btn-success { background: #4caf50; color: white; }
.btn-warning { background: #ff9800; color: white; }
.btn-danger { background: #f44336; color: white; }
.btn-small { padding: 8px 14px; font-size: 14px; border-radius: 8px; }

.info {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    margin-top: 30px;
}
.info ul { margin-left: 20px; margin-top: 10px; }
.info li { margin: 10px 0; line-height: 1.6; }

.hidden { display: none !important; }

/* --- Карточка обучения --- */
.card-wrapper {
    background: #f9f9f9;
    border-radius: 15px;
    padding: 25px;
    margin: 20px 0;
}

.card-question {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    border: 2px solid #e8eaff;
}

.card-topic {
    font-size: 14px;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 15px;
    text-transform: uppercase;
    text-align: center;
}

.card-content {
    font-size: 20px;
    line-height: 1.6;
    text-align: center;
    color: #333;
    word-break: break-word;
}

.card-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    margin: 15px auto;
    display: block;
    border: 1px solid #eee;
}

.card-answer-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    border: 2px solid #667eea;
}

.answer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.target-label { font-size: 22px; color: #333; }
.equals-sign { font-size: 22px; font-weight: bold; color: #667eea; }

.tiles-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.tiles-group h4 {
    font-size: 13px;
    color: #667eea;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.tiles-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 40px;
    align-items: center;
}

.tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    min-width: 40px;
    transition: all 0.2s;
}
.tile:hover { background: #667eea; color: white; border-color: #667eea; }
.tile.op-tile { background: #e8eaff; border-color: #667eea; }

.text-mode-hint {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.reference-answer {
    background: #f0fff0;
    border: 2px solid #4caf50;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}
.reference-answer h4 { color: #4caf50; margin-bottom: 10px; }
.reference-content { font-size: 22px; text-align: center; padding: 10px; }

.card-controls {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.rating-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
.rating-buttons .btn { flex: 1; min-width: 120px; max-width: 200px; }

.progress-info {
    text-align: center;
    margin: 20px 0;
    color: #666;
    font-size: 16px;
}

.no-cards { text-align: center; padding: 40px; }
.no-cards h2 { color: #4caf50; font-size: 32px; margin-bottom: 20px; }

/* --- Статистика --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}
.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
}
.stat-number { font-size: 48px; font-weight: bold; margin-bottom: 10px; }
.stat-label { font-size: 16px; opacity: 0.9; }

/* --- Админка --- */
.admin-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.search-box { padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
.count-badge { color: #666; font-size: 14px; margin-left: auto; }
.tag { background: #e8eaff; color: #5568d3; padding: 2px 8px; border-radius: 10px; font-size: 12px; margin-left: 4px; }
.img-badge { font-size: 12px; color: #888; margin-left: 8px; }
.admin-card {
    display: flex;
    background: #f9f9f9;
    border-radius: 12px;
    padding: 16px;
    margin: 10px 0;
    gap: 12px;
    align-items: center;
}
.admin-card-body { flex: 1; min-width: 0; }
.admin-card-topic { color: #667eea; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.admin-card-text { font-size: 14px; color: #333; word-break: break-word; }
.admin-card-answer { font-size: 13px; color: #777; margin-top: 6px; word-break: break-word; }
.admin-card-actions { display: flex; flex-direction: column; gap: 8px; }

/* --- Редактор --- */
.editor { max-width: 950px; }
.edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.edit-row label { font-size: 13px; color: #666; display: block; margin-bottom: 4px; }
.edit-row input, .edit-row select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}
.edit-block { background: #f9f9f9; border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.edit-block h3 { margin-bottom: 12px; color: #555; }
.edit-block textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
}
.latex-palette { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.latex-palette button {
    padding: 6px 10px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.latex-palette button:hover { background: #667eea; color: #fff; }
.preview-label { font-size: 12px; color: #888; margin: 10px 0 4px; }
.preview {
    background: #fff;
    border: 1px dashed #ccc;
    border-radius: 8px;
    padding: 14px;
    min-height: 40px;
    font-size: 16px;
    overflow-x: auto;
}
.img-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.img-preview { max-width: 200px; max-height: 150px; border-radius: 8px; border: 1px solid #ddd; }
.edit-actions { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.status { color: #f44336; margin-top: 10px; }

.tiles-section { margin-bottom: 20px; }
.tiles-section h4 { margin: 10px 0; color: #555; font-size: 14px; }
.tile-content { font-size: 16px; }
.tile-remove {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tile-remove:hover { background: #d32f2f; }