/* Список терминов */
.terms-list {
    background-color: white;
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.terms-list h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.term-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.3s;
}

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

.term-item:hover {
    background-color: var(--background-color);
}

.term-item a {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 18px;
    font-weight: 500;
}

.term-item a:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

/* Страница термина */
.term-page {
    background-color: white;
    padding: 30px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.term-page h1 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 2.5rem;
}

/* Основной блок определения термина */
.term-definition {
    font-size: 18px;
    line-height: 1.7;
    margin-bottom: 30px;
}

/* Абзацы внутри определения */
.term-definition p {
    margin: 0 0 16px 0; /* Отступ между абзацами */
    text-align: justify; /* Ровные края */
    text-justify: inter-word;
    hyphens: auto; /* Автоматические переносы */
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    overflow-wrap: break-word; /* Перенос длинных слов */
    word-break: break-word;
}

.term-definition p:last-child {
    margin-bottom: 0;
}

/* Опционально: красная строка для абзацев */
.term-definition p:not(:first-child)::first-line {
    text-indent: 1.5em; /* Раскомментируйте, если нужен отступ первой строки */
}

.term-link {
    color: var(--secondary-color);
    cursor: pointer;
    border-bottom: 1px dotted var(--secondary-color);
    position: relative;
}

.term-link:hover {
    color: var(--hover-color);
}

/* Всплывающая подсказка */
.tooltip {
    position: fixed;
    background-color: white;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--secondary-color);
    border-radius: 8px;
    padding: 14px 16px;
    max-width: 380px;
    min-width: 220px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    display: none;
    pointer-events: none;
    animation: tooltipFadeIn 0.15s ease;
}

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

.tooltip.show {
    display: block;
}

.tooltip h4 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
}

.tooltip p {
    color: var(--text-color);
    font-size: 13px;
    line-height: 1.5;
}

.tooltip-type-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    background: var(--secondary-color);
    padding: 2px 6px;
    border-radius: 10px;
    margin-bottom: 6px;
    display: inline-block;
}

.tooltip-type-badge.lit {
    background: var(--success-color);
}

/* ====== Редактор определения (wiki-style) ====== */
.editor-wrapper {
    /* border: 2px solid var(--border-color); */
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.3s;
}

.editor-wrapper:focus-within {
    border-color: var(--secondary-color);
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #f8f9fa;
    /* border-bottom: 1px solid var(--border-color); */
    padding: 6px 8px;
    flex-wrap: wrap;
}

.editor-toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 4px;
}

.editor-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    transition: all 0.2s;
    white-space: nowrap;
}

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

.editor-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.editor-textarea {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    border: none;
    outline: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.7;
    resize: vertical;
    min-height: 180px;
    background: white;
}

/* ====== Link/Source picker modal ====== */
.picker-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.45);
    align-items: center;
    justify-content: center;
}

.picker-modal.show {
    display: flex;
}

.picker-content {
    background: white;
    border-radius: 10px;
    width: 92%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

.picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--primary-color);
    color: white;
}

.picker-header h3 {
    margin: 0;
    font-size: 16px;
}

.picker-close {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.picker-close:hover { opacity: 1; }

.picker-search-bar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: #f8f9fa;
}

.picker-search-bar input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.picker-search-bar input:focus {
    border-color: var(--secondary-color);
}

.picker-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.picker-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: none;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.picker-tab.active {
    background: white;
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
}

.picker-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}

.picker-item {
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

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

.picker-item:hover {
    background: #e8f4fd;
}

.picker-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
}

.picker-item-sub {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.picker-empty {
    text-align: center;
    color: #999;
    padding: 30px;
    font-size: 14px;
}

/* ====== Inline links in term definition ====== */
.term-link {
    color: var(--secondary-color);
    cursor: pointer;
    border-bottom: 1px dotted var(--secondary-color);
    position: relative;
    transition: color 0.2s;
}

.term-link:hover {
    color: var(--hover-color);
    border-bottom-color: var(--hover-color);
}

.lit-link {
    color: var(--success-color);
    cursor: pointer;
    border-bottom: 1px dotted var(--success-color);
    position: relative;
}

.lit-link:hover {
    opacity: 0.8;
}

/* Source references superscript */
.source-ref {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: var(--secondary-color);
    border-radius: 3px;
    padding: 1px 5px;
    margin: 0 1px;
    cursor: pointer;
    vertical-align: super;
    line-height: 1;
    transition: background 0.2s;
}

.source-ref:hover {
    background: var(--hover-color);
}

/* Footnotes section */
.footnotes-section {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 20px;
}

.footnotes-section h4 {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footnote-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 6px 0;
    font-size: 15px;
    border-bottom: 1px solid #eee;
}

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

.footnote-num {
    background: var(--secondary-color);
    color: white;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    cursor: pointer;
}

.footnote-text {
    color: var(--text-color);
    line-height: 1.4;
}

.footnote-link {
    color: var(--secondary-color);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.footnote-link:hover { text-decoration: underline; }

/* Связанные термины */
.related-terms {
    background-color: var(--background-color);
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
}

.related-terms h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.related-terms ul {
    list-style: none;
}

.related-terms li {
    padding: 8px 0;
}

.related-terms a {
    color: var(--secondary-color);
    text-decoration: none;
}

.related-terms a:hover {
    text-decoration: underline;
}

/* Литература */
.literature-section {
    background-color: white;
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

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

.literature-item {
    padding: 15px;
    border-left: 4px solid var(--secondary-color);
    margin-bottom: 15px;
    background-color: var(--background-color);
    cursor: pointer;
    transition: all 0.3s;
}

.literature-item:hover {
    border-left-color: var(--hover-color);
    transform: translateX(5px);
}

.literature-item h4 {
    color: var(--primary-color);
    margin-bottom: 8px;
}

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

/* Форма обратной связи */
.feedback-section {
    background-color: white;
    padding: 30px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

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

.form-group {
    margin-bottom: 20px;
}

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

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

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

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

.btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

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

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

/* Сообщения */
.message {
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.message.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.message.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Загрузка */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Адаптивность */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    header .container {
        flex-direction: column;
        gap: 15px;
    }
    
    header nav {
        width: 100%;
        text-align: center;
    }
    
    .letters {
        justify-content: center;
    }
    
    .term-page h1 {
        font-size: 2rem;
    }
}

/* Связанные термины */
.related-terms {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 20px 0;
}

.related-terms h3 {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px;
}

.related-terms ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.related-term-item {
    border-bottom: 1px solid #eee;
}

.related-term-item:last-child {
    border-bottom: none;
}

.related-term-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.15s;
}

.related-term-link:hover {
    background: #e8f4fd;
}

.related-term-link:hover .related-term-title {
    color: var(--secondary-color);
}

.related-term-title {
    font-size: 17px;
    font-weight: 500;
    transition: color 0.15s;
}

.related-term-arrow {
    font-size: 14px;
    color: #bbb;
    transition: color 0.15s, transform 0.15s;
}

.related-term-link:hover .related-term-arrow {
    color: var(--secondary-color);
    transform: translateX(3px);
}

.footnote-meta {
    color: #888;
    font-size: 12px;
}

/* Контейнер для верхней части шапки */
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    border-bottom: 2px solid var(--border-color, #bdc3c7); /* цвет из переменной или свой */
    padding-bottom: 15px;   /* отступ внутри, чтобы линия не прилипала к ссылкам */
    margin-bottom: 10px;    /* дополнительный воздух между линией и заголовком */
}

/* Стили для ссылки-логотипа */
.logo-link {
    display: flex;
    align-items: center;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

/* Стили для картинки логотипа */
.logo-img {
    height: 50px;
    width: auto;
    display: block;
}


.header-title-container{
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
    margin-bottom: 10px;
}



.main-title {
    color: var(--primary-color, #2c3e50);
    font-size: 1.9rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
    word-break: break-word;
    text-align: center;
  }

/* Сброс отступов у заголовка внутри ссылки */
.logo-link h1 {
    color: var(--primary-color);
    margin: 0;                 /* Убирает стандартные отступы h1 */
    font-size: 0.9rem;         /* Размер шрифта (опционально) */
    max-width: 340px;
}

/* Эффект при наведении (опционально) */
.logo-link:hover {
    opacity: 0.85;
}  

@media (max-width: 768px) {
    .header-top {
        flex-direction: column; /* Лого и навигация друг под другом на мобильных */
        text-align: center;
    }
    
    .main-title {
        font-size: 1.4rem;
        text-align: center;
    }
}

.site-header {
    background-color: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 0;
    transition: box-shadow 0.3s ease;
}

.site-header:hover {
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.12);
}

.main-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.main-nav a {
    color: var(--primary-color, #2c3e50);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    padding: 8px 16px;
    border-radius: 40px;
    background-color: transparent;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.main-nav a:hover {
    background-color: rgba(52, 152, 219, 0.08);
    color: #e73e10;
    transform: translateY(-1px);
}
  
.main-nav a:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .site-header {
      padding: 10px 0;
      position: relative; /* на мобильных липкость может мешать */
    }
  
    .header-top {
      flex-direction: column;
      gap: 15px;
    }
  
    .main-nav {
      justify-content: center;
      width: 100%;
    }
  
    .main-nav a {
      font-size: 0.9rem;
      padding: 6px 12px;
    }
  
    .main-title {
      font-size: 1.5rem;
      text-align: center;
    }
}

@media (max-width: 480px) {
    .main-title {
      font-size: 1.3rem;
    }
}