/* Базовые настройки шрифтов и контейнера */
:root {
   --bg-dark: #0f0f1a;
   --card-bg: #161625;
   --accent-gold: #f39c12;
   --accent-blue: #3498db;
   --accent-purple: #9b59b6;
   --accent-red: #e74c3c;
   --accent-green: #2ecc71;
   --text-main: #cbd5e0;
   --comment-bg: #1a1a2a;
   --comment-border: #2a2a3a;
   --comment-hover: #22223a;
   --link-color: #b0a0ff;
   --link-hover: #d0c0ff;
   --accent-warning: #ffb347;
   --danger: #ff7a7a;
   --success: #5fcf8a;
}

body {
   font-size: 1.15rem;
   line-height: 1.7;
}

.fragment-container {
   width: 95%;
   max-width: 1600px;
   margin: 0 auto;
   background: var(--card-bg);
   border-radius: 20px;
   overflow: hidden;
   box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
}

/* Обложка без обрезки */
.fragment-cover {
   width: 100%;
   height: auto;
   background: #000;
   line-height: 0;
}

.fragment-cover img {
   width: 100%;
   height: auto;
   object-fit: contain;
   display: block;
}

/* Тип существа */
.race-classification {
   margin: 20px 0 40px 0;
   padding: 25px;
   background: linear-gradient(135deg, rgba(52, 152, 219, 0.15) 0%, transparent 100%);
   border: 1px solid rgba(52, 152, 219, 0.3);
   border-left: 6px solid var(--accent-blue);
   border-radius: 8px;
}

.race-classification label {
   font-size: 0.9rem;
   color: var(--accent-blue);
   text-transform: uppercase;
   letter-spacing: 3px;
   font-weight: 800;
   display: block;
   margin-bottom: 8px;
}

.race-classification .value {
   font-size: 1.6rem;
   color: #fff;
   font-weight: 700;
   text-shadow: 0 0 15px rgba(52, 152, 219, 0.4);
}

/* Обтекание картинками */
.rich-text p {
   display: block;
   margin-bottom: 1.2rem;
}

.rich-text img {
   height: auto !important;
}

/* Единый стиль отображения пользовательского rich-text */
.fragment-content .rich-text,
.fragment-content .rich-text * {
   color: #ffffff !important;
}

.fragment-content .rich-text * {
   background-color: transparent !important;
}

.rich-text img[style*="float: right"] {
   float: right !important;
   margin-left: 20px !important;
   margin-bottom: 15px !important;
   max-width: 40%;
}

.rich-text img[style*="float: left"] {
   float: left !important;
   margin-right: 20px !important;
   margin-bottom: 15px !important;
   max-width: 40%;
}

.rich-text::after {
   content: "";
   display: table;
   clear: both;
}

.rich-text-preview img {
   max-width: 100%;
   height: auto;
}

/* Улучшенные нижние блоки */
.section-label {
   font-size: 1.3rem;
   color: var(--accent-gold);
   border-bottom: 1px solid rgba(243, 156, 18, 0.2);
   padding-bottom: 10px;
   margin-bottom: 25px;
   text-transform: uppercase;
   letter-spacing: 1.5px;
}

.info-item-card {
   background: rgba(255, 255, 255, 0.03);
   border: 1px solid rgba(255, 255, 255, 0.07);
   border-radius: 12px;
   padding: 25px;
   transition: all 0.3s ease;
}

.row.g-3,
.row.g-4 {
   display: flex;
   flex-wrap: wrap;
}

.row.g-3>[class*="col-"],
.row.g-4>[class*="col-"] {
   display: flex;
   flex-direction: column;
}

.info-item-card {
   flex: 1 1 auto;
}

.card-grid {
   display: grid;
   grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
   gap: 1rem;
   margin-bottom: 1.5rem;
}

.card-grid .info-item-card {
   height: 100%;
   margin-bottom: 0;
}

.info-item-card:hover {
   background: rgba(255, 255, 255, 0.05);
   transform: translateY(-5px);
}

.subrace-card {
   border-top: 4px solid var(--accent-purple);
}

.relation-card {
   border-top: 4px solid var(--accent-red);
}

.talent-card {
   border-top: 4px solid var(--accent-green);
}

.info-item-card h5 {
   font-size: 1.4rem;
   margin-bottom: 15px;
   color: #fff;
}

.info-item-card p {
   font-size: 1.1rem;
   color: var(--text-main);
   margin: 0;
}

.physiology-card {
   background: rgba(255, 255, 255, 0.03);
   border: 1px solid rgba(255, 255, 255, 0.07);
   border-top: 4px solid var(--accent-blue);
   border-radius: 12px;
   padding: 25px;
   transition: all 0.3s ease;
}

.physiology-card:hover {
   background: rgba(255, 255, 255, 0.05);
   transform: translateY(-5px);
}

.fragment-content table {
   width: 100%;
   border-collapse: collapse;
   margin: 20px 0;
   background: rgba(0, 0, 0, 0.2);
}

.fragment-content td,
.fragment-content th {
   border: 1px solid var(--border-color);
   padding: 12px;
}

/* Стили для таблиц внутри контента */
.info-item-card table {
   width: 100% !important;
   border-collapse: collapse;
   margin: 1rem 0;
   background: rgba(255, 255, 255, 0.03);
   border: 1px solid rgba(255, 255, 255, 0.1);
   color: #e0e0e0;
   border-radius: 8px;
   overflow: hidden;
}

.info-item-card table th,
.info-item-card table td {
   padding: 12px 15px;
   border: 1px solid rgba(255, 255, 255, 0.1);
   text-align: left;
}

.info-item-card table tr:first-child td,
.info-item-card table th {
   background: rgba(255, 255, 255, 0.07);
   color: var(--accent-gold);
   font-weight: bold;
   text-transform: uppercase;
   font-size: 0.85rem;
   letter-spacing: 1px;
}

.info-item-card table tr:nth-child(even) {
   background: rgba(255, 255, 255, 0.02);
}

.info-item-card table tr:hover {
   background: rgba(255, 255, 255, 0.05);
   transition: background 0.3s ease;
}

@media (max-width: 768px) {
   .info-item-card table {
      display: block;
      overflow-x: auto;
      white-space: nowrap;
   }

   .info-item-card,
   .physiology-card {
      padding: 15px;
   }

   .section-label {
      font-size: 1.1rem;
      margin-bottom: 15px;
   }

   .physiology-card .rich-text {
      font-size: 1rem;
   }

   .info-item-card p {
      font-size: 0.95rem;
   }
}

/* Стили для таблиц классов */
.class-view table {
   width: 100% !important;
   border-collapse: collapse;
   margin: 1rem 0;
   background: rgba(255, 255, 255, 0.03);
   border: 1px solid rgba(255, 255, 255, 0.1);
   color: #e0e0e0;
   border-radius: 8px;
   overflow: hidden;
}

.class-view table th,
.class-view table td {
   padding: 12px 15px;
   border: 1px solid rgba(255, 255, 255, 0.1);
   text-align: left;
}

.class-view table tr:first-child td,
.class-view table th {
   background: rgba(255, 255, 255, 0.07);
   color: var(--accent-gold);
   font-weight: bold;
   text-transform: uppercase;
   font-size: 0.85rem;
   letter-spacing: 1px;
}

.class-view table tr:nth-child(even) {
   background: rgba(255, 255, 255, 0.02);
}

.class-view table tr:hover {
   background: rgba(255, 255, 255, 0.05);
   transition: background 0.3s ease;
}

@media (max-width: 768px) {
   .class-view table {
      display: block;
      overflow-x: auto;
      white-space: nowrap;
   }
}

/* Адаптив для узких экранов */
@media (max-width: 425px) {
   .fragment-container {
      width: 100%;
      border-radius: 0;
   }

   .race-classification {
      padding: 15px;
   }

   .race-classification .value {
      font-size: 1.3rem;
   }

   .info-item-card,
   .physiology-card {
      padding: 12px;
   }

   .section-label {
      font-size: 1rem;
      margin-bottom: 12px;
   }

   .bi {
      font-size: 1rem;
   }

   .card-grid {
      grid-template-columns: 1fr;
      gap: 0.75rem;
   }

   .info-item-card p,
   .physiology-card .rich-text {
      font-size: 0.9rem;
      line-height: 1.5;
   }

   .info-item-card a {
      font-size: 0.95rem;
   }
}

@media (max-width: 375px) {

   .info-item-card,
   .physiology-card {
      padding: 10px;
   }

   .race-classification .value {
      font-size: 1.2rem;
   }
}

.info-item-card a {
   display: inline-block;
   min-height: 44px;
   line-height: 1.2;
}

/* ========== СТИЛИ ДЛЯ КОММЕНТАРИЕВ (ФИНАЛЬНАЯ ВЕРСИЯ) ========== */
.comment {
   background: linear-gradient(145deg, #1a1a2a 0%, #1e1e30 100%);
   border: 1px solid #2a2a3a;
   border-radius: 16px;
   padding: 18px 22px !important;
   margin-bottom: 16px;
   box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
   transition: all 0.2s ease;
   position: relative;
   color: #f0f0f0;
   font-size: 0.95rem;
}

.comment:hover {
   background: linear-gradient(145deg, #1e1e32 0%, #22223a 100%);
   border-color: #4a3a6a;
   box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
}

/* Имя автора */
.comment .text-info {
   color: #b0a0ff !important;
   font-weight: 700;
   font-size: 1rem;
   letter-spacing: 0.3px;
}

/* Дата */
.comment .text-muted {
   color: #a090b0 !important;
   font-size: 0.8rem;
}

/* Текст комментария */
.comment p {
   margin: 12px 0 8px 0;
   color: #eaeaea;
   line-height: 1.6;
   font-size: 0.95rem;
   word-break: break-word;
}

/* Метка "отредактировано" */
.comment small.text-warning {
   color: #ffb347 !important;
   font-style: italic;
   background: rgba(255, 180, 70, 0.1);
   padding: 3px 10px;
   border-radius: 30px;
   display: inline-block;
   margin-top: 5px;
}

/* Бейдж "голос доработать" */
.comment .badge.bg-warning {
   background: #ffb347 !important;
   color: #1a1a1a !important;
   font-weight: 600;
   padding: 5px 12px;
   border-radius: 30px;
   font-size: 0.7rem;
   text-transform: uppercase;
   letter-spacing: 0.5px;
   margin-left: 8px;
}

/* Ответ пользователю */
.comment .reply-to {
   display: block;
   margin-bottom: 6px;
   font-size: 0.8rem;
   color: #b0a0b0 !important;
   border-left: 2px solid #6b4f9f;
   padding-left: 8px;
}

/* Кнопки действий */
.comment .btn-sm {
   padding: 0.25rem 1rem;
   font-size: 0.75rem;
   border-radius: 30px;
   font-weight: 600;
   transition: all 0.15s;
   text-transform: uppercase;
   letter-spacing: 0.5px;
   border-width: 1px;
}

.comment .btn-outline-secondary {
   border-color: #4a4a6a;
   color: #c0b0d0;
   background: transparent;
}

.comment .btn-outline-secondary:hover {
   background-color: #4a4a6a;
   color: #fff;
   border-color: #6a5a8a;
}

.comment .btn-outline-info {
   border-color: #6b4f9f;
   color: #b0a0ff;
}

.comment .btn-outline-info:hover {
   background-color: #6b4f9f;
   color: #fff;
}

.comment .btn-outline-danger {
   border-color: #b14a4a;
   color: #ff9f9f;
}

.comment .btn-outline-danger:hover {
   background-color: #b14a4a;
   color: #fff;
}

/* Скрытые формы ответа/редактирования */
#replyForm,
#editForm {
   background: #25253a;
   padding: 20px;
   border-radius: 16px;
   margin-top: 15px;
   border-left: 4px solid #b0a0ff;
   box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* Кнопка "Показать ответы" */
.btn-link.text-info {
   color: #b0a0ff !important;
   text-decoration: none;
   padding: 0;
   font-size: 0.85rem;
   border: none;
   background: none;
   cursor: pointer;
   font-weight: 600;
}

.btn-link.text-info:hover {
   text-decoration: underline;
   color: #d0c0ff !important;
}

/* Вертикальные линии для вложенных комментариев */
.comment.level-1,
.comment.level-2,
.comment.level-3,
.comment.level-4,
.comment.level-5 {
   border-left: 4px solid;
   border-left-style: solid;
}

.comment.level-1 {
   border-left-color: #b0a0ff;
   /* фиолетовый */
}

.comment.level-2 {
   border-left-color: #ffb347;
   /* оранжевый */
}

.comment.level-3 {
   border-left-color: #5fcf8a;
   /* зелёный */
}

.comment.level-4 {
   border-left-color: #ff7a7a;
   /* красный */
}

.comment.level-5 {
   border-left-color: #9b59b6;
   /* ярко-фиолетовый */
}

/* Соединительная линия (пунктир) от родителя */
.comment.level-1:before,
.comment.level-2:before,
.comment.level-3:before,
.comment.level-4:before,
.comment.level-5:before {
   content: '';
   position: absolute;
   left: -12px;
   top: 24px;
   width: 8px;
   height: calc(100% - 30px);

   border-radius: 0 0 0 8px;
   pointer-events: none;
}

/* Корневой комментарий без левой границы */
.comment.level-0 {
   border-left: none;
}

/* Отступы для вложенности задаются через margin-left в коде, мы их не трогаем */