/* ================================================================
   portal_lib.css — стили библиотеки (страница /p/lib.php)
   Подключается ПОСЛЕ portal.css — переопределяет/дополняет.
   Все селекторы скоупим через .lib-page, чтобы не ломать другие страницы.
   ================================================================ */

/* ===== КОНТЕЙНЕР / ЗАГОЛОВОК С ПРОГРЕССОМ ===== */
.lib-page .page-title {
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px 25px !important;
}

.lib-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
    max-width: 320px;
    flex: 1 1 220px;
}

.lib-progress span {
    color: #d4b28c;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lib-progress .progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #8b5a2b;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.lib-progress .progress-bar > div {
    height: 100%;
    background: linear-gradient(90deg, #8b5a2b, #b8860b, #ffd700);
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== ПОИСК ===== */
.lib-search {
    margin: 20px 0 25px;
    position: relative;
}

.lib-search .search-form {
    display: flex;
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
    background: linear-gradient(145deg, rgba(63, 46, 34, 0.9), rgba(43, 30, 14, 0.9));
    border: 2px solid #8b5a2b;
    border-radius: 40px;
    padding: 6px 6px 6px 22px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: border-color 0.25s, box-shadow 0.25s;
}

.lib-search .search-form:focus-within {
    border-color: #ffd700;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.3);
}

.lib-search .search-input {
    flex: 1;
    min-width: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #fff8e7;
    font-size: 16px;
    padding: 10px 0;
    font-family: inherit;
    height: auto;
}

.lib-search .search-input::placeholder { color: #8b7355; }
.lib-search .search-input:focus { outline: none; }

.lib-search .search-submit {
    background: linear-gradient(145deg, #b8860b, #8b5a2b);
    border: 2px solid #ffd700;
    border-radius: 30px;
    color: #1f140c;
    font-weight: 700;
    font-size: 14px;
    padding: 10px 26px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
    height: auto;
    line-height: 1.2;
}

.lib-search .search-submit:hover {
    background: linear-gradient(145deg, #ffd700, #b8860b);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4), 0 0 20px rgba(255, 215, 0, 0.5);
}

.lib-search .clear-search {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #8b5a2b;
    border-radius: 50%;
    color: #ffd966;
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
    transition: all 0.25s;
    flex-shrink: 0;
}

.lib-search .clear-search:hover {
    background: #8b5a2b;
    color: #fff;
    transform: rotate(90deg);
}

/* ===== ТАБЫ КАТЕГОРИЙ ===== */
.lib-page .lib-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 14px;
    border: 1px solid #6b4f2a;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

.lib-page .lib-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 10px;
    min-height: 50px;
    background: linear-gradient(145deg, #3f2e22, #2b1e0e);
    border: 2px solid #8b5a2b;
    border-radius: 10px;
    color: #fff8e7;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.3;
    word-break: break-word;
    position: relative;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.lib-page .lib-tab::before {
    content: '';
    position: absolute;
    inset: 0;
    left: -100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.2), transparent);
    transition: left 0.4s;
    pointer-events: none;
}

.lib-page .lib-tab:hover {
    background: linear-gradient(145deg, #5a3e2b, #3f2e22);
    border-color: #ffd700;
    color: #ffd700;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 215, 0, 0.2);
}

.lib-page .lib-tab:hover::before { left: 100%; }

.lib-page .lib-tab.active {
    background: linear-gradient(145deg, #b8860b, #8b5a2b);
    border-color: #ffd700;
    color: #1f140c;
    font-weight: 700;
    box-shadow: 0 4px 0 #5a3e2b, 0 0 20px rgba(255, 215, 0, 0.6),
    inset 0 0 10px rgba(255, 248, 231, 0.4);
    pointer-events: none;
}

/* Бейдж непрочитанных — аккуратнее и с пульсацией */
.lib-page .unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #ff4444;
    border-radius: 50%;
    box-shadow: 0 0 8px #ff0000;
    vertical-align: middle;
    margin-left: 4px;
    animation: lib-pulse 2s infinite;
}

@keyframes lib-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.25); opacity: 0.7; }
}

.lib-page .lib-tab.active .unread-dot {
    background: #8b0000;
    box-shadow: 0 0 8px #ff0000;
}

/* ===== ПОДМЕНЮ ===== */
.lib-page .lib-submenu {
    list-style: none;
    padding: 12px;
    margin: 0 0 25px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: linear-gradient(145deg, #2f241b, #1f150e);
    border-radius: 12px;
    border: 1.5px solid #a0522d;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7), 0 6px 12px rgba(0, 0, 0, 0.5);
}

.lib-page .lib-submenu li { margin: 0; padding: 0; }

.lib-page .lib-submenu a {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    background: linear-gradient(145deg, #3f2e22, #2b1e0e);
    border: 1.5px solid #8b5a2b;
    border-radius: 25px;
    color: #fff8e7;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.25s;
    line-height: 1.4;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.lib-page .lib-submenu a:hover {
    background: linear-gradient(145deg, #5a3e2b, #3f2e22);
    border-color: #ffd700;
    color: #ffd700;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 215, 0, 0.3);
}

.lib-page .lib-submenu .lib_act_men a {
    background: linear-gradient(145deg, #b8860b, #8b5a2b);
    border-color: #ffe68f;
    color: #1f140c;
    font-weight: 700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6), inset 0 0 8px rgba(255, 243, 176, 0.4);
    cursor: default;
    pointer-events: none;
}

/* Мобильный селект */
.lib-page .lib-submenu-select {
    display: none;
    width: 100%;
    padding: 14px 45px 14px 18px;
    margin: 0 0 20px;
    background: linear-gradient(145deg, #3f2e22, #2b1e0e);
    color: #ffd966;
    border: 2px solid #b8860b;
    border-radius: 40px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%23ffd966'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

.lib-page .lib-submenu-select:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

/* ===== КОНТЕНТ СТАТЬИ ===== */
.lib-page .lib-content h1.news-title {
    position: relative;
    padding: 20px 30px 20px 45px;
    background: linear-gradient(145deg, rgba(63, 46, 34, 0.6), rgba(43, 30, 14, 0.6));
    border-left: 6px solid #ffd700;
    border-radius: 0 20px 20px 0;
    font-size: clamp(24px, 3.5vw, 38px);
    color: #ffd966;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.3);
    margin: 0 0 30px;
    line-height: 1.25;
    font-weight: 700;
    word-break: break-word;
    letter-spacing: 0.5px;
}

.lib-page .lib-content h1.news-title::before {
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    filter: drop-shadow(0 0 10px gold);
}

/* Типографика тела статьи */
.lib-page .lib-content .rank-lvl {
    font-family: 'Open Sans', 'Segoe UI', 'Philosopher', sans-serif;
    font-size: clamp(15px, 1.25vw, 17px);
    line-height: 1.75;
    color: #e8dcc4;
}

.lib-page .lib-content .rank-lvl > *:first-child { margin-top: 0; }

.lib-page .lib-content .rank-lvl h2 {
    position: relative;
    color: #ffd966;
    font-size: clamp(22px, 2.4vw, 30px);
    margin: 35px 0 18px;
    padding: 12px 0 12px 20px;
    border-left: 5px solid #b8860b;
    background: linear-gradient(90deg, rgba(184, 134, 11, 0.2), transparent);
    border-radius: 0 12px 12px 0;
    text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
    line-height: 1.3;
    font-weight: 700;
}

.lib-page .lib-content .rank-lvl h3 {
    color: #ffcc66;
    font-size: clamp(18px, 1.9vw, 22px);
    margin: 26px 0 14px;
    padding: 6px 0 6px 14px;
    border-left: 4px solid #a0522d;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
    line-height: 1.35;
    font-weight: 700;
}

.lib-page .lib-content .rank-lvl h4 {
    color: #f0c060;
    font-size: clamp(16px, 1.5vw, 18px);
    margin: 22px 0 10px;
    line-height: 1.4;
    font-weight: 700;
}

.lib-page .lib-content .rank-lvl p {
    margin: 0 0 15px;
    text-align: justify;
    hyphens: auto;
    word-wrap: break-word;
}

.lib-page .lib-content .rank-lvl p:last-child { margin-bottom: 0; }

.lib-page .lib-content .rank-lvl strong,
.lib-page .lib-content .rank-lvl b {
    color: #ffd966;
    font-weight: 700;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.2);
}

.lib-page .lib-content .rank-lvl em,
.lib-page .lib-content .rank-lvl i {
    color: #d4b28c;
    font-style: italic;
}

.lib-page .lib-content .rank-lvl a {
    color: #ffd966;
    text-decoration: none;
    border-bottom: 1px dotted #b8860b;
    padding: 0 2px;
    transition: all 0.2s;
    font-weight: 500;
}

.lib-page .lib-content .rank-lvl a:hover {
    color: #fff;
    border-bottom-color: #ffd700;
    text-shadow: 0 0 8px gold, 0 0 15px #ffaa00;
    background: rgba(255, 215, 0, 0.08);
    border-radius: 3px;
}

/* Списки */
.lib-page .lib-content .rank-lvl ul,
.lib-page .lib-content .rank-lvl ol {
    padding-left: 30px;
    margin: 15px 0;
}

.lib-page .lib-content .rank-lvl li {
    margin-bottom: 9px;
    line-height: 1.65;
}

.lib-page .lib-content .rank-lvl ul li::marker {
    color: #ffd700;
    font-size: 1.15em;
}

.lib-page .lib-content .rank-lvl ol li::marker {
    color: #ffd966;
    font-weight: 700;
}

/* Цитаты */
.lib-page .lib-content .rank-lvl blockquote {
    position: relative;
    margin: 22px 0;
    padding: 18px 22px 18px 60px;
    background: linear-gradient(135deg, rgba(184, 134, 11, 0.15), rgba(63, 46, 34, 0.35));
    border-left: 5px solid #ffd700;
    border-radius: 0 16px 16px 0;
    color: #f0ddc0;
    font-style: italic;
    font-size: 1.03em;
    line-height: 1.7;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.lib-page .lib-content .rank-lvl blockquote::before {
    content: '❝';
    position: absolute;
    left: 14px;
    top: 4px;
    font-size: 44px;
    color: #ffd700;
    opacity: 0.5;
    line-height: 1;
    font-style: normal;
}

.lib-page .lib-content .rank-lvl blockquote p:last-child { margin-bottom: 0; }

/* Инлайн-код */
.lib-page .lib-content .rank-lvl code {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #8b5a2b;
    border-radius: 4px;
    padding: 2px 8px;
    color: #ffd966;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

/* ===== ТАБЛИЦЫ В СТАТЬЯХ ===== */
/* Гасим агрессивный глобальный `table td { padding: 25px 40px }` из style.css */
.lib-page .lib-content .rank-lvl table {
    width: 100% !important;
    max-width: 100%;
    margin: 22px 0;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #8b5a2b !important;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: table; /* возвращаем нормальное поведение, если где-то был block */
}

.lib-page .lib-content .rank-lvl table thead {
    background: linear-gradient(145deg, #5a3e2b, #3f2e22);
}

.lib-page .lib-content .rank-lvl table thead th {
    padding: 12px 10px !important;
    color: #ffd966;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border: none !important;
    border-bottom: 2px solid #b8860b !important;
    border-right: 1px solid rgba(139, 90, 43, 0.4) !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
    vertical-align: middle;
    background: transparent;
    line-height: 1.35;
}

.lib-page .lib-content .rank-lvl table thead th:last-child { border-right: none !important; }

.lib-page .lib-content .rank-lvl table tbody tr {
    background: transparent;
    transition: background 0.2s;
}

.lib-page .lib-content .rank-lvl table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.15);
}

.lib-page .lib-content .rank-lvl table tbody tr:hover {
    background: rgba(184, 134, 11, 0.18);
}

.lib-page .lib-content .rank-lvl table td {
    padding: 9px 10px !important;
    color: #e8dcc4;
    border: none !important;
    border-bottom: 1px solid rgba(139, 90, 43, 0.3) !important;
    border-right: 1px solid rgba(139, 90, 43, 0.15) !important;
    vertical-align: middle;
    line-height: 1.5;
    font-size: 13.5px;
    text-align: left;
    background: transparent;
}

.lib-page .lib-content .rank-lvl table td:last-child { border-right: none !important; }
.lib-page .lib-content .rank-lvl table tbody tr:last-child td { border-bottom: none !important; }

/* Иконки внутри таблиц (звания, титулы) */
.lib-page .lib-content .rank-lvl table img {
    display: inline-block;
    vertical-align: middle;
    border: 1px solid #8b5a2b;
    border-radius: 4px;
    margin: 0 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    max-width: none;
}

/* ===== КАРТИНКИ / ИЛЛЮСТРАЦИИ ===== */
.lib-page .lib-content .rank-lvl .lib_img {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 24px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px dashed rgba(184, 134, 11, 0.35);
    border-radius: 14px;
}

.lib-page .lib-content .rank-lvl .lib_img img {
    max-width: 100%;
    height: auto;
    border: 3px solid #d4af37;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.7), 0 0 20px rgba(184, 134, 11, 0.3);
    margin: 0 !important;
    transition: transform 0.3s, box-shadow 0.3s;
}

.lib-page .lib-content .rank-lvl .lib_img img:hover {
    transform: scale(1.03);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85), 0 0 30px rgba(255, 215, 0, 0.4);
}

.lib-page .lib-content .rank-lvl > p.lib_img > img:only-child {
    max-width: min(100%, 800px);
}

/* ===== КАЛЛАУТЫ (единый стиль для плашек «архив» и предупреждений) ===== */
.lib-page .lib-content .rank-lvl .lib-callout,
.lib-page .lib-content .rank-lvl .lib-alert {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    margin: 20px 0;
    background: linear-gradient(135deg, rgba(184, 134, 11, 0.15), rgba(0, 0, 0, 0.3));
    border-left: 5px solid #ffd700;
    border-radius: 0 12px 12px 0;
    color: #f0e6d2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-size: 0.97em;
    line-height: 1.6;
}

.lib-page .lib-content .rank-lvl .lib-callout::before {
    content: '💡';
    font-size: 1.4em;
    line-height: 1;
    flex-shrink: 0;
}

.lib-page .lib-content .rank-lvl .lib-callout.warning {
    border-left-color: #ff8800;
    background: linear-gradient(135deg, rgba(255, 136, 0, 0.15), rgba(0, 0, 0, 0.3));
}
.lib-page .lib-content .rank-lvl .lib-callout.warning::before { content: '⚠️'; }

.lib-page .lib-content .rank-lvl .lib-callout.danger {
    border-left-color: #ff4444;
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.15), rgba(0, 0, 0, 0.3));
}
.lib-page .lib-content .rank-lvl .lib-callout.danger::before { content: '⛔'; }

.lib-page .lib-content .rank-lvl .lib-callout.success {
    border-left-color: #27ae60;
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.15), rgba(0, 0, 0, 0.3));
}
.lib-page .lib-content .rank-lvl .lib-callout.success::before { content: '✓'; }

.lib-page .lib-content .rank-lvl .lib-callout.info {
    border-left-color: #3498db;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.15), rgba(0, 0, 0, 0.3));
}
.lib-page .lib-content .rank-lvl .lib-callout.info::before { content: 'ℹ️'; }

/* ===== НАВИГАЦИЯ «ПРЕДЫДУЩАЯ / СЛЕДУЮЩАЯ» ===== */
.lib-page .lib-navigation {
    display: flex;
    gap: 15px;
    margin: 40px 0 0;
    padding-top: 25px;
    border-top: 2px dashed #b8860b;
}

.lib-page .lib-navigation a {
    flex: 1;
    display: block;
    padding: 16px 22px;
    background: linear-gradient(145deg, #3f2e22, #2b1e0e);
    border: 2px solid #8b5a2b;
    border-radius: 12px;
    color: #fff8e7;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    transition: all 0.25s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
    line-height: 1.4;
    word-break: break-word;
}

.lib-page .lib-navigation a:first-child::before {
    content: '← Предыдущая';
    display: block;
    font-size: 11px;
    color: #b8a58e;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    font-weight: 500;
}

.lib-page .lib-navigation a:last-child {
    text-align: right;
}

.lib-page .lib-navigation a:last-child::before {
    content: 'Следующая →';
    display: block;
    font-size: 11px;
    color: #b8a58e;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    text-align: right;
    font-weight: 500;
}

.lib-page .lib-navigation a:hover {
    background: linear-gradient(145deg, #b8860b, #8b5a2b);
    border-color: #ffd700;
    color: #1f140c;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.4);
}

.lib-page .lib-navigation a:hover::before { color: #1f140c; }
.lib-page .lib-navigation > span { flex: 1; }

/* ===== РЕАКЦИИ / НАГРАДЫ ===== */
.lib-page .reactions-rewards-row {
    display: flex;
    gap: 20px;
    margin: 30px 0 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.25);
    border: 1.5px solid #8b5a2b;
    border-radius: 16px;
    flex-wrap: wrap;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.lib-page .reactions-rewards-row .reactions-block,
.lib-page .reactions-rewards-row .rewards-block {
    flex: 1 1 250px;
    padding: 0;
    margin: 0;
    background: none;
}

.lib-page .reactions-rewards-row h4 {
    color: #ffd966 !important;
    font-size: 14px !important;
    margin: 0 0 12px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 1 !important;
    border-bottom: 1px solid rgba(184, 134, 11, 0.3);
    padding-bottom: 6px;
}

.lib-page .reactions-rewards-row .reaction-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1.5px solid #8b5a2b;
    border-radius: 30px;
    padding: 6px 14px;
    color: #fff8e7;
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1;
    transition: all 0.2s;
    min-height: 0;
}

.lib-page .reactions-rewards-row .reaction-btn:hover {
    background: #8b5a2b;
    border-color: #ffd700;
    transform: translateY(-2px);
}

.lib-page .reactions-rewards-row .reaction-btn.active {
    background: linear-gradient(145deg, #ffd700, #b8860b);
    border-color: #ffe68f;
    color: #1f140c;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    font-weight: 700;
}

.lib-page .reactions-rewards-row .reaction-btn .count {
    font-weight: 700;
    font-size: 13px;
    min-width: 14px;
    text-align: center;
}

.lib-page .reactions-rewards-row .reward-item {
    width: 64px;
    height: 64px;
    transition: transform 0.2s;
}

.lib-page .reactions-rewards-row .reward-item:hover {
    transform: scale(1.08);
    z-index: 10;
}

.lib-page .reactions-rewards-row .reward-item.not-obtained {
    filter: grayscale(0.9) brightness(0.65);
    opacity: 0.75;
}

.lib-page .reactions-rewards-row .reward-action-icons {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 10px;
    padding: 2px 6px;
    border: 1px solid #b8860b;
    z-index: 6;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
}

.lib-page .reactions-rewards-row .reward-status {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 17px;
    font-weight: 700;
    text-shadow: 0 0 4px #000, 0 0 8px #000;
    z-index: 5;
    line-height: 1;
}

/* ===== КОММЕНТАРИИ (поверх portal.css) ===== */
.lib-page .comments-block {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px dashed #8b5a2b;
}

.lib-page .comments-block h4 {
    color: #ffd966;
    font-size: 22px;
    margin: 0 0 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid rgba(184, 134, 11, 0.4);
    padding-bottom: 10px;
    opacity: 1;
}

.lib-page .comments-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 20px;
}

/* ================================================================
   Таблицы библиотеки — улучшенное оформление
   ================================================================ */

/* Компактный вариант таблицы для статей (опыт, звания, титулы) */
.lib-page .lib-content .rank-lvl table.lib-table,
.lib-page .lib-content .rank-lvl .lib-table {
    width: 100% !important;
    margin: 22px 0;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(184, 134, 11, 0.55) !important;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    font-size: 14px;
}

/* Заголовок таблицы */
.lib-page .lib-content .rank-lvl table.lib-table thead {
    background: linear-gradient(145deg, #4a3320, #2f1f12);
}

.lib-page .lib-content .rank-lvl table.lib-table thead th {
    padding: 12px 14px !important;
    color: #ffd966;
    font-weight: 700;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    text-align: left;
    border: none !important;
    border-bottom: 2px solid rgba(184, 134, 11, 0.7) !important;
    vertical-align: middle;
    background: transparent;
    line-height: 1.35;
    white-space: nowrap;
}

/* Тело */
.lib-page .lib-content .rank-lvl table.lib-table tbody tr {
    background: transparent;
    transition: background 0.2s ease;
}

.lib-page .lib-content .rank-lvl table.lib-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.025);
}

.lib-page .lib-content .rank-lvl table.lib-table tbody tr:hover {
    background: rgba(184, 134, 11, 0.16);
}

.lib-page .lib-content .rank-lvl table.lib-table td {
    padding: 10px 14px !important;
    color: #e8dcc4;
    border: none !important;
    border-bottom: 1px solid rgba(139, 90, 43, 0.22) !important;
    vertical-align: middle;
    line-height: 1.5;
    font-size: 14px;
    text-align: left;
}

.lib-page .lib-content .rank-lvl table.lib-table tbody tr:last-child td {
    border-bottom: none !important;
}

/* Числовые ячейки — выравниваем по правому краю */
.lib-page .lib-content .rank-lvl table.lib-table td:nth-child(n+2):not(:last-child) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Особый случай: в таблице званий/титулов последний столбец «Мин. уровень» — по центру */
.lib-page .lib-content .rank-lvl table.lib-table thead th:last-child,
.lib-page .lib-content .rank-lvl table.lib-table td:last-child {
    text-align: center;
}

/* Жирные значения (максимальные уровни, финальные звания) */
.lib-page .lib-content .rank-lvl table.lib-table td b {
    color: #ffd966;
    font-weight: 700;
}

/* Заголовки внутри таблицы не должны переноситься неудачно */
@media (max-width: 768px) {
    .lib-page .lib-content .rank-lvl table.lib-table thead th {
        padding: 10px 10px !important;
        font-size: 11.5px;
        white-space: normal;
    }
    .lib-page .lib-content .rank-lvl table.lib-table td {
        padding: 8px 10px !important;
        font-size: 13px;
    }
}

/* На мобильных — горизонтальный скролл, если таблица не влезает */
@media (max-width: 768px) {
    .lib-page .lib-content .rank-lvl > table.lib-table {
        display: block !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .lib-page .lib-content .rank-lvl > table.lib-table thead,
    .lib-page .lib-content .rank-lvl > table.lib-table tbody {
        display: table;
        width: 100%;
        min-width: 420px;
    }
}

/* ================================================================
   Мелкие улучшения читаемости разделов
   ================================================================ */

/* Немного больше воздуха между подразделами статей */
.lib-page .lib-content .rank-lvl > h2 + p,
.lib-page .lib-content .rank-lvl > h3 + p {
    margin-top: 10px;
}

/* Плашки-«лиды» (если в статье есть короткое пояснение) */
.lib-page .lib-content .rank-lvl .lib-lead {
    color: #d4b28c;
    font-style: italic;
    font-size: 1.02em;
    margin: 0 0 18px;
    padding: 10px 16px;
    border-left: 3px solid rgba(184, 134, 11, 0.6);
    background: rgba(184, 134, 11, 0.06);
    border-radius: 0 10px 10px 0;
}

/* Код-инлайн в статьях стал менее «админским» — но остаётся читаемым */
.lib-page .lib-content .rank-lvl code {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(184, 134, 11, 0.35);
    border-radius: 5px;
    padding: 1px 7px;
    color: #ffe9b5;
    font-size: 0.88em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* Подсветка ссылок на другие статьи (внутренние #LIB[...]# после рендера) */
.lib-page .lib-content .rank-lvl a[href*="lib.php"] {
    color: #ffd966;
    font-weight: 500;
    border-bottom: 1px dotted rgba(184, 134, 11, 0.8);
    text-decoration: none;
    transition: color 0.2s, border-color 0.2s, text-shadow 0.2s;
}

.lib-page .lib-content .rank-lvl a[href*="lib.php"]:hover {
    color: #fff;
    border-bottom-color: #ffd700;
    text-shadow: 0 0 8px gold;
}

/* ================================================================
   Иконки званий и титулов в таблицах библиотеки
   ================================================================ */
.lib-page .lib-content .rank-lvl table.lib-table td img.rank-icon,
.lib-page .lib-content .rank-lvl table.lib-table .rank-icon {
    display: inline-block !important;
    width: 14px !important;
    height: 14px !important;
    max-width: 14px !important;
    max-height: 14px !important;
    margin: 0 6px 0 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    vertical-align: -2px !important;
    object-fit: contain;
    filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.35));
}

/* Убеждаемся, что изображение в первой ячейке не сломает выравнивание */
.lib-page .lib-content .rank-lvl table.lib-table td:first-child {
    white-space: nowrap;
}

/* На мобильных чуть-чуть крупнее — 16px читается лучше */
@media (max-width: 768px) {
    .lib-page .lib-content .rank-lvl table.lib-table td img.rank-icon {
        width: 16px !important;
        height: 16px !important;
        max-width: 16px !important;
        max-height: 16px !important;
        vertical-align: -3px !important;
    }
}

/* ===== АДАПТИВ ===== */
@media (max-width: 992px) {
    .lib-page .page-title {
        flex-direction: column;
        align-items: stretch;
        padding: 15px 18px !important;
        gap: 12px;
    }

    .lib-progress {
        max-width: 100%;
        min-width: 0;
    }

    .lib-page .lib-content h1.news-title {
        font-size: 24px;
        padding: 15px 20px 15px 35px;
        border-left-width: 4px;
    }

    .lib-page .lib-content h1.news-title::before {
        font-size: 24px;
        left: -10px;
    }

    .lib-page .lib-content .rank-lvl h2 { font-size: 22px; padding: 10px 0 10px 15px; }
    .lib-page .lib-content .rank-lvl h3 { font-size: 18px; padding: 6px 0 6px 12px; }

    .lib-page .lib-tabs { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .lib-page .lib-tab  { padding: 10px 8px; font-size: 12px; min-height: 44px; }

    .lib-page .lib-navigation { flex-direction: column; }
    .lib-page .lib-navigation a:last-child,
    .lib-page .lib-navigation a:last-child::before { text-align: left; }
    .lib-page .lib-navigation > span { display: none; }

    .lib-page .reactions-rewards-row { flex-direction: column; padding: 15px; }
}

@media (max-width: 768px) {
    .lib-page .lib-search .search-form { padding: 5px 5px 5px 16px; }
    .lib-page .lib-search .search-input { font-size: 14px; }
    .lib-page .lib-search .search-submit { padding: 9px 18px; font-size: 13px; }

    /* Скрываем горизонтальное подменю, показываем select */
    .lib-page .lib-submenu { display: none; }
    .lib-page .lib-submenu-select { display: block; }

    /* Таблицы — горизонтальный скролл */
    .lib-page .lib-content .rank-lvl > table {
        display: block !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .lib-page .lib-content .rank-lvl > table thead,
    .lib-page .lib-content .rank-lvl > table tbody {
        display: table;
        width: 100%;
    }

    .lib-page .lib-content .rank-lvl p { text-align: left; }

    .lib-page .lib-content .rank-lvl h2 { font-size: 20px; padding: 8px 0 8px 12px; }
    .lib-page .lib-content .rank-lvl h3 { font-size: 16px; padding: 5px 0 5px 10px; }

    .lib-page .lib-content h1.news-title { font-size: 20px; padding: 12px 14px 12px 30px; }
    .lib-page .lib-content h1.news-title::before { font-size: 20px; left: -8px; }

    .lib-page .reactions-rewards-row .reward-item { width: 55px; height: 55px; }
}

@media (max-width: 480px) {
    .lib-page .lib-tabs { grid-template-columns: 1fr 1fr; }

    .lib-page .lib-search .search-form {
        flex-direction: column;
        border-radius: 14px;
        padding: 10px;
    }
    .lib-page .lib-search .search-submit { width: 100%; }
    .lib-page .lib-search .clear-search {
        position: absolute;
        top: 15px;
        right: 15px;
        width: 34px;
        height: 34px;
        font-size: 16px;
        z-index: 2;
    }

    .lib-page .lib-content .rank-lvl blockquote { padding: 14px 14px 14px 42px; }
    .lib-page .lib-content .rank-lvl blockquote::before { font-size: 34px; left: 8px; }
}