/* ==========================================
   ОБЩИЕ СТИЛИ И СБРОС
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Цветовая палитра */
    --primary-color: #1a365d;
    --secondary-color: #2f855a;
    --accent-color: #d69e2e;
    --text-color: #2d3748;
    --bg-light: #f7fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --hover-color: #2c5282;
    --danger-color: #e53e3e;
    --success-color: #38a169;
    --warning-color: #dd6b20;
    
    /* Типографика */
    --font-main: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.6;
    
    /* Отступы */
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
    
    /* Размеры */
    --max-width: 1600px;
    --nav-height: 70px;
    --footer-height: 50px;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    color: var(--text-color);
    background-color: var(--bg-light);
    line-height: var(--line-height-base);
    overflow-x: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==========================================
   ВЕРХНЯЯ ПАНЕЛЬ
   ========================================== */
.top-bar {
    background: var(--primary-color);
    color: white;
    padding: 4px 0;
    position: relative;
    z-index: 1002;
}

.top-bar-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-name {
    font-weight: 600;
    font-size: 18px;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cart-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.cart-btn:hover {
    background: rgba(255,255,255,0.3);
}

#cartCount {
    background: var(--accent-color);
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    margin-left: 4px;
}

.auth-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.5);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.auth-btn:hover {
    background: rgba(255,255,255,0.1);
}

.auth-btn.register {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

#authBlock, #userBlock {
    display: flex;
    align-items: center;
    gap: 8px;
}

#userName {
    font-weight: 500;
}

.user-menu-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
}

.user-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--primary-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    min-width: 200px;
    z-index: 1001;
    padding: 8px 0;
    border: 1px solid rgba(255,255,255,0.2);
}

.user-menu a {
    display: block;
    padding: 12px 16px;
    color: white;
    text-decoration: none;
    transition: background 0.2s;
    font-size: 14px;
}

.user-menu a:hover {
    background: rgba(255,255,255,0.15);
}

.user-menu hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.2);
    margin: 8px 0;
}

#userBlock {
    position: relative;
}

/* ==========================================
   НАВИГАЦИЯ (ваш оригинальный стиль)
   ========================================== */
.navbar {
    background: var(--bg-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: auto;
    padding: 6px 0;
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo {
    display: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--spacing-xs);
    align-items: stretch;
}

.nav-menu li {
    display: flex;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    border-radius: 6px;
    border: 2px solid #cbd5e0;
    background: #e8f4f8;
    transition: all 0.3s ease;
    font-size: 15px;
}

.nav-link:visited {
    color: var(--text-color);
}

.nav-link:hover {
    background: #f5e6fd;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.nav-link.active {
    background: #e0b6fa;
    color: var(--primary-color);
    border: 3px solid var(--primary-color);
    font-weight: 600;
}

/* ==========================================
   ОСНОВНОЙ КОНТЕНТ
   ========================================== */
.main-content {
    flex: 1;
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: var(--spacing-md);
    min-height: calc(100vh - var(--nav-height) - var(--footer-height));
}

.tab-content {
    display: none;
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
    display: block;
}

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

/* ==========================================
   ВКЛАДКА: О СЕБЕ
   ========================================== */
.about-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: var(--spacing-xl);
    height: calc(100vh - var(--nav-height) - var(--footer-height) - 100px);
    overflow-y: auto;
}

.about-left-column {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    position: sticky;
    top: 0;
    height: fit-content;
}

.about-left {
    background: var(--bg-white);
    padding: var(--spacing-lg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    text-align: center;
}

.profile-photo {
    width: 200px;
    height: 200px;
    margin: 0 auto var(--spacing-md);
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--primary-color);
    background: var(--bg-light);
}

.profile-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.name {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.slogan {
    color: var(--text-color);
    font-size: 15px;
    font-style: italic;
}

.about-right {
    background: var(--bg-white);
    padding: var(--spacing-lg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.about-right h3 {
    color: var(--primary-color);
    font-size: 20px;
    margin: var(--spacing-md) 0 var(--spacing-sm) 0;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: var(--spacing-xs);
}

.about-right h3:first-child {
    margin-top: 0;
}

.about-right p {
    margin-bottom: var(--spacing-sm);
    line-height: 1.7;
}

.achievements {
    list-style: none;
    padding-left: 0;
}

.achievements li {
    padding: var(--spacing-xs) 0;
    padding-left: 28px;
    position: relative;
}

.achievements li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 18px;
}

/* ==========================================
   ВКЛАДКИ: МАТЕМАТИКА
   ========================================== */
.subject-container {
    background: var(--bg-white);
    padding: var(--spacing-lg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    height: calc(100vh - var(--nav-height) - var(--footer-height) - 100px);
    overflow-y: auto;
}

.subject-header {
    margin-bottom: var(--spacing-lg);
}

.subject-header h2 {
    color: var(--primary-color);
    font-size: 32px;
    margin-bottom: var(--spacing-sm);
}

.subject-description {
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-color);
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.topic-column h4 {
    color: var(--primary-color);
    font-size: 18px;
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    border-bottom: 2px solid var(--accent-color);
}

.topic-column ul {
    list-style: none;
    padding: 0;
}

.topic-column li {
    padding: var(--spacing-xs) 0;
    padding-left: 20px;
    position: relative;
    font-size: 15px;
}

.topic-column li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-size: 20px;
}

.materials-section {
    margin-top: var(--spacing-xl);
}

.materials-section h3 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.materials-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
}

.material-card {
    background: var(--bg-light);
    padding: var(--spacing-md);
    border-radius: 10px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
}

.material-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-color);
}

.material-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-sm);
}

.material-card h4 {
    color: var(--primary-color);
    font-size: 18px;
    margin-bottom: var(--spacing-xs);
}

.material-card p {
    font-size: 14px;
    color: var(--text-color);
}

.cta-section {
    text-align: center;
    margin-top: 40px;
    padding: 32px;
    background: var(--bg-light);
    border-radius: 12px;
}

.cta-section h3 {
    color: var(--primary-color);
    margin-bottom: 12px;
}

.cta-btn {
    margin-top: 16px;
    padding: 14px 32px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.cta-btn:hover {
    background: #276749;
}

/* ==========================================
   ВКЛАДКА: ПОРТФОЛИО
   ========================================== */
.section-title {
    text-align: center;
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: var(--spacing-lg);
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
    max-height: calc(100vh - var(--nav-height) - var(--footer-height) - 150px);
    overflow-y: auto;
    padding: var(--spacing-sm);
}

.portfolio-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
}

.portfolio-item:hover {
    transform: scale(1.03);
}

.portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portfolio-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(26, 54, 93, 0.95), transparent);
    color: var(--bg-white);
    padding: var(--spacing-md) var(--spacing-sm);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.portfolio-item:hover .portfolio-overlay {
    transform: translateY(0);
}

/* ==========================================
   ВКЛАДКА: КОНТАКТЫ
   ========================================== */
.contacts-container {
    background: var(--bg-white);
    padding: var(--spacing-xl);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    max-width: 1000px;
    margin: 0 auto;
}

.contacts-container h2 {
    text-align: center;
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.contacts-intro {
    text-align: center;
    font-size: 17px;
    color: var(--text-color);
    margin-bottom: var(--spacing-xl);
}

.contacts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
}

.contact-methods h3,
.contact-form h3 {
    color: var(--primary-color);
    font-size: 22px;
    margin-bottom: var(--spacing-md);
}

.contact-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: var(--spacing-sm);
}

.contact-icon {
    font-size: 32px;
}

.contact-details strong {
    display: block;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.contact-details a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.contact-details a:hover {
    color: var(--primary-color);
}

.pricing-info {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--primary-color), var(--hover-color));
    color: var(--bg-white);
    border-radius: 8px;
}

.pricing-info h4 {
    font-size: 18px;
    margin-bottom: var(--spacing-sm);
}

.pricing-info p {
    margin: 4px 0;
    font-size: 15px;
}

.pricing-note {
    font-size: 13px;
    opacity: 0.9;
    font-style: italic;
}

/* ==========================================
   ФОРМЫ
   ========================================== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 15px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 13px;
}

.form-group.checkbox label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.form-group.checkbox input {
    width: auto;
    margin-top: 4px;
}

.form-error {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 8px;
}

.form-success {
    display: none;
    color: var(--success-color);
    background: #c6f6d5;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
}

.form-success.show {
    display: block;
}

/* ==========================================
   КНОПКИ
   ========================================== */
.btn, .submit-btn {
    display: inline-block;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.btn:hover, .submit-btn:hover {
    background: var(--hover-color);
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--secondary-color);
}

.btn-primary:hover {
    background: #276749;
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-large {
    padding: 16px 32px;
    font-size: 18px;
}

.back-btn {
    background: var(--primary-color);
    color: var(--bg-white);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: var(--spacing-lg);
    transition: background 0.3s ease;
}

.back-btn:hover {
    background: var(--hover-color);
}

/* ==========================================
   ФУТЕР
   ========================================== */
.footer {
    background: var(--primary-color);
    color: var(--bg-white);
    text-align: center;
    padding: 8px var(--spacing-md);
}

.footer-links {
    margin-bottom: 8px;
}

.footer-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    margin: 0 16px;
    font-size: 14px;
}

.footer-links a:hover {
    color: white;
}

.footer p {
    margin: 4px 0;
    font-size: 13px;
}

.footer-legal {
    opacity: 0.7;
}

/* ==========================================
   КНОПКА-ССЫЛКА НА СТАТЬЮ
   ========================================== */
.article-link-btn {
    display: inline-block;
    background: var(--secondary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    margin-top: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(47, 133, 90, 0.3);
}

.article-link-btn:hover {
    background: #276749;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(47, 133, 90, 0.4);
}

/* ==========================================
   БЛОК PROFI.RU
   ========================================== */
.profi-block {
    background: var(--bg-white);
    padding: var(--spacing-md);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    text-align: center;
    min-width: 280px;
    overflow: hidden;
}

.profi-block .profi-widget {
    width: 300px;
    height: 280px;
    margin: 0 auto;
    overflow: hidden;
}

.profi-block iframe {
    border: none;
    border-radius: 8px;
    width: 300px !important;
    height: 280px !important;
}

.profi-block a {
    display: inline-block;
}

.profi-block img {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 8px;
    max-width: 100%;
}

.profi-block a:hover img {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* ==========================================
   ИНТЕРАКТИВНЫЕ МАТЕРИАЛЫ
   ========================================== */
.interactive-container {
    background: var(--bg-white);
    padding: var(--spacing-xl);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.section-intro {
    color: #666;
    font-size: 16px;
    margin-bottom: var(--spacing-lg);
    max-width: 800px;
}

.interactive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-md);
}

.interactive-card {
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.interactive-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.interactive-card .interactive-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-sm);
}

.interactive-card h3 {
    color: var(--primary-color);
    font-size: 20px;
    margin-bottom: var(--spacing-xs);
}

.interactive-card p {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.interactive-card.placeholder-card {
    background: var(--bg-light);
    border-style: dashed;
    text-align: center;
    cursor: default;
}

.interactive-card.placeholder-card:hover {
    transform: none;
    box-shadow: none;
}

/* Превью встроенного iframe */
.interactive-card .preview-frame {
    width: 100%;
    height: 150px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: var(--spacing-sm);
    overflow: hidden;
    pointer-events: none;
}

.interactive-card .card-actions {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

.interactive-card .btn-open {
    flex: 1;
    text-align: center;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.interactive-card .btn-open:hover {
    background: var(--hover-color);
}

/* Новые стили для динамических карточек */
.interactive-card-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-sm);
}

.interactive-card-title {
    color: var(--primary-color);
    font-size: 20px;
    margin-bottom: var(--spacing-xs);
}

.interactive-card-desc {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: var(--spacing-sm);
}

.interactive-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--spacing-sm);
}

.interactive-tag {
    background: var(--bg-light);
    color: var(--text-color);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.interactive-card-arrow {
    display: block;
    text-align: right;
    font-size: 24px;
    color: var(--secondary-color);
    transition: transform 0.2s;
}

.interactive-card:hover .interactive-card-arrow {
    transform: translateX(6px);
}

.interactive-empty {
    text-align: center;
    padding: var(--spacing-xl);
    color: #888;
    font-size: 18px;
    background: var(--bg-light);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

/* ==========================================
   COOKIE-БАННЕР
   ========================================== */
.cookie-banner {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 9999;
    max-width: 90%;
}

.cookie-banner a {
    color: #90cdf4;
    text-decoration: none;
}

.cookie-banner a:hover {
    text-decoration: underline;
}

.cookie-banner button {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.cookie-banner button:hover {
    background: #38a169;
}

/* ==========================================
   УВЕДОМЛЕНИЯ
   ========================================== */
.notification {
    position: fixed;
    bottom: 20px; /* Внизу экрана */
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    padding: 16px 24px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: slideUp 0.3s ease;
    max-width: 400px;
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100%); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.notification button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.notification-success { border-left: 4px solid var(--success-color); }
.notification-error { border-left: 4px solid var(--danger-color); }
.notification-warning { border-left: 4px solid var(--warning-color); }
.notification-info { border-left: 4px solid var(--primary-color); }

/* ==========================================
   ЗАГРУЗКА И ОШИБКИ
   ========================================== */
.loading {
    text-align: center;
    padding: 48px;
    color: #666;
}

.error-message {
    text-align: center;
    padding: 48px;
    color: var(--danger-color);
}

/* Блок ошибки с кнопкой повтора */
.error-block {
    text-align: center;
    padding: 48px 24px;
    background: var(--bg-light);
    border-radius: 12px;
    margin: 20px 0;
}

.error-block .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.error-block h3 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 20px;
}

.error-block p {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.error-block .btn {
    margin: 0 8px;
}

/* ==========================================
   СТАТЬИ
   ========================================== */
.articles-container {
    background: var(--bg-white);
    padding: var(--spacing-xl);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    max-height: calc(100vh - var(--nav-height) - var(--footer-height) - 100px);
    overflow-y: auto;
}

.articles-filters {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    padding: var(--spacing-md);
    background: var(--bg-light);
    border-radius: 8px;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
    font-size: 14px;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--spacing-md);
}

.article-card {
    background: var(--bg-white);
    border-radius: 10px;
    border: 2px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    overflow: hidden;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.article-cover {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: var(--bg-light);
}

.article-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-card-content {
    padding: var(--spacing-md);
}

.article-card-header {
    margin-bottom: var(--spacing-sm);
}

.article-title {
    color: var(--primary-color);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.article-meta {
    display: flex;
    gap: var(--spacing-sm);
    font-size: 13px;
    color: #666;
    margin-bottom: var(--spacing-sm);
    flex-wrap: wrap;
}

.article-category {
    background: var(--primary-color);
    color: var(--bg-white);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.article-preview {
    color: var(--text-color);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: var(--spacing-sm);
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.article-tag {
    background: var(--bg-white);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

/* Полный вид статьи */
.article-full {
    padding: var(--spacing-md);
}

#articleContent h2 {
    color: var(--primary-color);
    font-size: 32px;
    margin-bottom: var(--spacing-md);
}

#articleContent h3 {
    color: var(--primary-color);
    font-size: 22px;
    margin: var(--spacing-lg) 0 var(--spacing-sm) 0;
}

#articleContent p {
    line-height: 1.7;
    margin-bottom: var(--spacing-md);
}

#articleContent ul {
    margin: var(--spacing-md) 0;
    padding-left: 30px;
}

#articleContent li {
    margin-bottom: var(--spacing-xs);
    line-height: 1.6;
}

.no-articles {
    text-align: center;
    padding: 48px;
    color: #666;
    grid-column: 1 / -1;
}

/* ==========================================
   ОГЛАВЛЕНИЕ СТАТЬИ (TOC)
   ========================================== */

.article-layout {
    display: flex;
    gap: var(--spacing-lg);
    max-width: 1200px;
    margin: 0 auto;
}

.article-toc {
    position: sticky;
    top: 20px;
    width: 240px;
    min-width: 240px;
    max-height: calc(100vh - 120px);
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: var(--spacing-sm);
    overflow-y: auto;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.toc-header {
    font-weight: 600;
    color: var(--primary-color);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--secondary-color);
    font-size: 14px;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc-link {
    display: block;
    padding: 8px 12px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 13px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.toc-link:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.toc-link.active {
    background: rgba(47, 133, 90, 0.1);
    color: var(--secondary-color);
    border-left-color: var(--secondary-color);
    font-weight: 500;
}

/* Уровни вложенности в оглавлении */
.toc-link.toc-h1 {
    font-weight: 600;
    font-size: 14px;
}

.toc-link.toc-h2 {
    padding-left: 16px;
    font-weight: 500;
}

.toc-link.toc-h3 {
    padding-left: 28px;
    font-size: 12px;
    color: #666;
}

.toc-link.toc-h3:hover,
.toc-link.toc-h3.active {
    color: var(--secondary-color);
}

.article-main {
    flex: 1;
    min-width: 0;
}

/* Оглавление пустое - скрываем */
.article-toc.hidden {
    display: none;
}

.article-layout.no-toc {
    max-width: 800px;
}

.article-layout.no-toc .article-main {
    width: 100%;
}

/* Scroll margin для заголовков */
.article-main h1[id],
.article-main h2[id],
.article-main h3[id] {
    scroll-margin-top: 80px;
}

/* ==========================================
   АДАПТИВНОСТЬ
   ========================================== */

/* Планшеты */
@media (max-width: 1024px) {
    .about-grid {
        grid-template-columns: 300px 1fr;
        gap: var(--spacing-md);
    }
    
    .materials-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .portfolio-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Маленькие планшеты */
@media (max-width: 768px) {
    :root {
        --nav-height: auto;
        --font-size-base: 15px;
    }
    
    .top-bar-container {
        flex-direction: column;
        gap: 8px;
    }
    
    .nav-container {
        flex-direction: column;
        padding: var(--spacing-sm);
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .main-content {
        min-height: auto;
    }
    
    .about-grid {
        grid-template-columns: 1fr;
        height: auto;
    }

    .about-left-column {
        position: static;
    }

    .about-left {
        position: static;
    }
    
    .subject-container {
        height: auto;
    }
    
    .topics-grid {
        grid-template-columns: 1fr;
    }
    
    .materials-grid {
        grid-template-columns: 1fr;
    }
    
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: none;
    }
    
    .contacts-grid {
        grid-template-columns: 1fr;
    }
    
    .articles-filters {
        flex-direction: column;
    }

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

    /* Оглавление статьи на планшетах */
    .article-layout {
        flex-direction: column;
    }

    .article-toc {
        position: static;
        width: 100%;
        min-width: unset;
        max-height: none;
        margin-bottom: var(--spacing-md);
    }

    .toc-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }

    .toc-link {
        padding: 6px 12px;
        border-left: none;
        border-bottom: 2px solid transparent;
        border-radius: 4px;
        white-space: nowrap;
    }

    .toc-link.active {
        border-left: none;
        border-bottom-color: var(--secondary-color);
    }

    .toc-link.toc-h2,
    .toc-link.toc-h3 {
        padding-left: 12px;
    }
}

/* Мобильные */
@media (max-width: 480px) {
    .logo {
        font-size: 20px;
    }
    
    .nav-link {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
    
    .subject-header h2,
    .section-title {
        font-size: 24px;
    }
}
