/* ============================================
   News Detail Page Styles — TopMoment
   ============================================ */

/* ---------- Fix <br> spacing & paragraph margins ---------- */
/* Remove all <br> tags — spacing is now handled by CSS margins on p, h1-h6, ul, li, blockquote */
.news-detailed-body br {
    display: none;
}

.news-detailed-body p {
    margin-bottom: 0.5em;
    line-height: 1.45;
}

.news-detailed-body ul li {
    margin-bottom: 0.2em;
    line-height: 1.35;
}

/* ---------- Back button ---------- */
.back-to-news-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    margin: 20px 0 24px;
    background: var(--bg-card);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-input);
    border: 1px solid var(--border-default);
    transition: var(--transition);
    font-size: 0.95rem;
}
.back-to-news-btn:hover {
    background: var(--accent-cyan);
    color: #fff;
    border-color: var(--accent-cyan);
    transform: translateX(-3px);
}
.back-to-news-btn i {
    font-size: 0.85rem;
}

/* ---------- Layout: content + right widgets grid ---------- */
.news-detailed-layout {
    display: grid;
    grid-template-columns: 1fr 860px 380px 1fr;
    gap: 40px;
    align-items: start;
}
.news-detailed-wrapper {
    grid-column: 2;
    width: 100%;
}
.news-detailed-content {
    width: 100%;
}
.news-detailed-sidebar {
    grid-column: 3;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 124px;
    align-self: start;
}

/* ---------- Cover ---------- */
.news-cover {
    border-radius: var(--radius-card);
    overflow: hidden;
    margin-bottom: 0;
}
.news-cover-single {
    width: 100%;
}
.news-cover-image {
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: cover;
    display: block;
    border-radius: var(--radius-card);
}

/* --- Slider cover ---------- */
.news-cover-slider {
    position: relative;
    border-radius: var(--radius-card);
    overflow: hidden;
}
.news-cover-slider-track {
    display: flex;
    transition: transform 0.5s ease;
}
.news-cover-slide {
    flex: 0 0 100%;
    max-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.news-cover-slide img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    display: block;
}
.news-cover-slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 5;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.news-cover-slider-btn:hover {
    background: var(--accent-cyan);
}
.news-cover-slider-btn.prev { left: 12px; }
.news-cover-slider-btn.next { right: 12px; }
.news-cover-slider-bullets {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
}
.news-cover-slider-bullet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}
.news-cover-slider-bullet.active,
.news-cover-slider-bullet:hover {
    background: #fff;
    border-color: var(--accent-cyan);
    transform: scale(1.25);
}

/* --- Carousel cover (slider + autoplay + loop) ---------- */
.news-cover-carousel {
    position: relative;
    border-radius: var(--radius-card);
    overflow: hidden;
}
.news-cover-carousel-track {
    display: flex;
    transition: transform 0.5s ease;
}
.news-cover-carousel-slide {
    flex: 0 0 100%;
    max-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.news-cover-carousel-slide img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    display: block;
}
.news-cover-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 5;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.news-cover-carousel-btn:hover {
    background: var(--accent-cyan);
}
.news-cover-carousel-btn.prev { left: 12px; }
.news-cover-carousel-btn.next { right: 12px; }
.news-cover-carousel-bullets {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
}
.news-cover-carousel-bullet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}
.news-cover-carousel-bullet.active,
.news-cover-carousel-bullet:hover {
    background: #fff;
    border-color: var(--accent-cyan);
    transform: scale(1.25);
}

/* --- Mosaic cover (adaptive grid) ---------- */
.news-cover-mosaic {
    display: grid;
    gap: 4px;
    border-radius: var(--radius-card);
    overflow: hidden;
}
.news-cover-mosaic-item {
    overflow: hidden;
    border-radius: 4px;
    position: relative;
}
.news-cover-mosaic-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0.35s ease;
}
.news-cover-mosaic-item:hover img {
    transform: scale(1.05);
}

/* === Adaptive patterns by image count === */

/* 2 images: 1 large + 1 small */
.news-cover-mosaic[data-mosaic-count="2"] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr 1fr;
    aspect-ratio: 1 / 1;
}
.news-cover-mosaic[data-mosaic-count="2"] .news-cover-mosaic-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
}

/* 3 images: large + 2 small */
.news-cover-mosaic[data-mosaic-count="3"] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr 1fr;
    aspect-ratio: 1 / 1;
}
.news-cover-mosaic[data-mosaic-count="3"] .news-cover-mosaic-item:first-child {
    grid-column: span 2;
}

/* 4 images: 2x2 */
.news-cover-mosaic[data-mosaic-count="4"] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    aspect-ratio: 1 / 1;
}

/* 5 images: 1 large (2x2) + 4 small */
.news-cover-mosaic[data-mosaic-count="5"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    aspect-ratio: 1 / 1;
}
.news-cover-mosaic[data-mosaic-count="5"] .news-cover-mosaic-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
}

/* 6 images: 3x2 grid with varied sizes */
.news-cover-mosaic[data-mosaic-count="6"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    aspect-ratio: 3 / 2;
}

/* 7 images */
.news-cover-mosaic[data-mosaic-count="7"] {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    aspect-ratio: 4 / 2;
}

/* 8 images */
.news-cover-mosaic[data-mosaic-count="8"] {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    aspect-ratio: 4 / 2;
}

/* 9 images */
.news-cover-mosaic[data-mosaic-count="9"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    aspect-ratio: 1 / 1;
}

/* === Old large/small classes (kept for backward compat) === */
.news-mosaic-large {
    grid-column: span 2;
    grid-row: span 2;
}
.news-mosaic-small {
    grid-column: span 1;
    grid-row: span 1;
}
.news-mosaic-wide {
    grid-column: span 2;
    grid-row: span 1;
}
.news-mosaic-tall {
    grid-column: span 1;
    grid-row: span 2;
}

/* ---------- Title ---------- */
.news-detailed-title {
    margin: 28px 0 16px;
    font-size: 2.2rem;
    line-height: 1.25;
    color: var(--text-primary);
    font-weight: 700;
}

/* ---------- Meta ---------- */
.news-detailed-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}
.news-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.news-meta-item i {
    font-size: 0.82rem;
    opacity: 0.7;
}
.news-meta-item #view-count-num {
    font-variant-numeric: tabular-nums;
}

/* ---------- Content body ---------- */
.news-detailed-body {
    font-size: 1.05rem;
    line-height: 1.45;
    color: var(--text-news);
    margin-bottom: 32px;
}

@media (min-width: 1400px) {
    .news-detailed-wrapper {
        margin-right: 320px;
    }
}
.news-detailed-body h1,
.news-detailed-body h2,
.news-detailed-body h3,
.news-detailed-body h4,
.news-detailed-body h5,
.news-detailed-body h6 {
    color: var(--text-primary);
    margin-top: 1.1em;
    margin-bottom: 0.3em;
    line-height: 1.25;
}
.news-detailed-body h1 { font-size: 1.8rem; }
.news-detailed-body h2 { font-size: 1.5rem; }
.news-detailed-body h3 { font-size: 1.25rem; }
.news-detailed-body h4 { font-size: 1.1rem; }
.news-detailed-body p {
    margin-bottom: 0.5em;
}
.news-detailed-body a {
    color: var(--accent-cyan);
    text-decoration: underline;
}
.news-detailed-body a:hover {
    color: var(--accent-cyan-light);
}
.news-detailed-body strong {
    color: var(--text-primary);
    font-weight: 700;
}
.news-detailed-body em {
    font-style: italic;
    color: var(--accent-cyan);
}
.news-detailed-body blockquote {
    border-left: 4px solid var(--accent-cyan);
    padding: 10px 16px;
    margin: 10px 0;
    background: var(--blockquote-bg);
    border-radius: 0 var(--radius-input) var(--radius-input) 0;
    color: var(--text-muted);
    font-style: italic;
}
.news-detailed-body ul,
.news-detailed-body ol {
    margin: 8px 0;
    padding-left: 2em;
}
.news-detailed-body li {
    margin-bottom: 3px;
    line-height: 1.35;
}
.news-detailed-body img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    border-radius: var(--radius-btn-lg);
    margin: 20px auto;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.news-detailed-body img:hover {
    opacity: 0.9;
}
.news-detailed-body pre {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    padding: 20px;
    border-radius: var(--radius-btn-lg);
    overflow-x: auto;
    margin: 24px 0;
}
.news-detailed-body code {
    background: var(--border-subtle);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--text-secondary);
}
.news-detailed-body pre code {
    background: transparent;
    padding: 0;
}
.news-detailed-body hr {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 32px 0;
}
.news-detailed-body .is-gray,
.news-detailed-body .is-info,
.news-detailed-body .is-success,
.news-detailed-body .is-warning,
.news-detailed-body .is-danger {
    color: var(--text-muted);
}

/* ---------- Tags ---------- */
.news-tags-container {
    width: 860px;
    margin: 0 auto 32px;
}
.news-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.news-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: transparent;
    border: 1.5px solid #e1306c;
    color: #e1306c;
    border-radius: 24px;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: var(--transition);
}
.news-tag:hover {
    background: #e1306c;
    color: #fff;
}
.news-tag i {
    font-size: 0.78rem;
}

/* ---------- Hero cards (Support + Streams) ---------- */
.news-hero-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 860px;
    margin: 0 auto 36px;
}
.news-hero-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-radius: var(--radius-card);
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    text-decoration: none;
    transition: var(--transition);
    height: 100%;
    box-sizing: border-box;
}
.news-hero-card:hover {
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.news-hero-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(46, 171, 209, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.news-hero-card-icon i {
    font-size: 1.2rem;
    color: var(--accent-cyan);
}
.news-hero-card-content {
    flex: 1;
}
.news-hero-card-title {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin: 0 0 4px;
    font-weight: 600;
}
.news-hero-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}
.news-hero-card-arrow {
    color: var(--accent-cyan);
    font-size: 1rem;
    opacity: 0.6;
    transition: var(--transition);
}
.news-hero-card:hover .news-hero-card-arrow {
    opacity: 1;
    transform: translateX(4px);
}
.news-hero-support:hover {
    border-color: var(--accent-cyan);
}
.news-hero-streams:hover {
    border-color: #e1306c;
}
.news-hero-streams .news-hero-card-icon {
    background: rgba(225, 48, 108, 0.12);
}
.news-hero-streams .news-hero-card-icon i {
    color: #e1306c;
}

/* ---------- Similar news ---------- */
.news-similar-container {
    width: 860px;
    margin: 0 auto 48px;
}
.news-similar-title {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.news-similar-title i {
    color: var(--accent-cyan);
}
.news-similar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.news-similar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    overflow: hidden;
    transition: var(--transition);
    text-decoration: none;
}
.news-similar-card:hover {
    border-color: var(--accent-cyan);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.news-similar-card-image {
    width: 100%;
    height: 160px;
    overflow: hidden;
}
.news-similar-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.news-similar-card:hover .news-similar-card-image img {
    transform: scale(1.08);
}
.news-similar-card-body {
    padding: 16px;
}
.news-similar-card-title {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin: 0 0 8px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.news-similar-card-title a {
    color: inherit;
    text-decoration: none;
}
.news-similar-card-title a:hover {
    color: var(--accent-cyan);
}
.news-similar-card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================
   Content Media Blocks (slider/mosaic/single inside markdown)
   ============================================ */

.content-slider-wrapper,
.content-mosaic-wrapper,
.content-media-single {
    margin: 28px 0;
    border-radius: var(--radius-card);
    overflow: hidden;
}

/* --- Single image in content --- */
.content-media-single {
    text-align: center;
    width: 100%;
    margin: 20px auto;
    display: block;
    overflow: hidden;
}
.content-media-single img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    border-radius: var(--radius-btn-lg);
    margin: 0 auto;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.content-media-single img:hover {
    opacity: 0.9;
}
.content-media-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-btn-lg);
    margin: 0 auto;
    display: block;
}
.content-image-caption {
    margin: 12px 0 0;
    padding: 0 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

/* --- Slider in content --- */
.content-slider-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-card);
}
.content-slider-container {
    position: relative;
    width: 100%;
    border-radius: var(--radius-card);
    overflow: hidden;
}
.content-slider-track {
    display: flex;
    transition: transform 0.5s ease;
}
.content-slider-slide {
    flex: 0 0 100%;
    max-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.content-slider-slide img {
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
    display: block;
}
.content-slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 5;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.content-slider-btn:hover {
    background: var(--accent-cyan);
}
.content-slider-btn.prev { left: 12px; }
.content-slider-btn.next { right: 12px; }
.content-slider-bullets {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
}
.content-slider-bullet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}
.content-slider-bullet.active,
.content-slider-bullet:hover {
    background: #fff;
    border-color: var(--accent-cyan);
    transform: scale(1.25);
}
.content-slider-caption {
    margin: 16px 0 0;
    padding: 0 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

/* --- Mosaic in content (adaptive) --- */
.content-mosaic-container {
    display: grid;
    gap: 4px;
    border-radius: var(--radius-card);
    overflow: hidden;
}
.content-mosaic-item {
    overflow: hidden;
    border-radius: 4px;
    position: relative;
}
.content-mosaic-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0.35s ease;
}
.content-mosaic-item:hover img {
    transform: scale(1.05);
}

/* Adaptive patterns for content mosaic (same as cover) */
.content-mosaic-container[data-mosaic-count="2"] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr 1fr;
}
.content-mosaic-container[data-mosaic-count="2"] .content-mosaic-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
}
.content-mosaic-container[data-mosaic-count="3"] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr 1fr;
}
.content-mosaic-container[data-mosaic-count="3"] .content-mosaic-item:first-child {
    grid-column: span 2;
}
.content-mosaic-container[data-mosaic-count="4"] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}
.content-mosaic-container[data-mosaic-count="5"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}
.content-mosaic-container[data-mosaic-count="5"] .content-mosaic-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
}
.content-mosaic-container[data-mosaic-count="6"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
}
.content-mosaic-container[data-mosaic-count="7"] {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
}
.content-mosaic-container[data-mosaic-count="8"] {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
}
.content-mosaic-container[data-mosaic-count="9"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

/* Old classes kept for backward compat */
.content-mosaic-large {
    grid-column: span 2;
    grid-row: span 2;
}
.content-mosaic-small {
    grid-column: span 1;
    grid-row: span 1;
}
.content-mosaic-wide {
    grid-column: span 2;
    grid-row: span 1;
}
.content-mosaic-tall {
    grid-column: span 1;
    grid-row: span 2;
}
.content-mosaic-caption {
    margin: 16px 0 0;
    padding: 0 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .news-detailed-layout {
        grid-template-columns: 1fr 1fr 260px 1fr;
        padding: 0 16px;
    }
    .news-tags-container,
    .news-hero-cards,
    .news-similar-container {
        width: 100%;
    }
}

@media (max-width: 992px) {
    .news-detailed-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .news-detailed-wrapper {
        grid-column: 1;
    }
    .news-tags-container,
    .news-hero-cards,
    .news-similar-container {
        width: 100%;
    }
    .content-slider-slide img {
        height: 380px;
    }
    .content-mosaic-container {
        grid-auto-rows: 120px;
    }
    .news-cover-slider-slide img {
        height: 380px;
    }
    .news-cover-carousel-slide img {
        height: 380px;
    }
    .news-cover-mosaic {
        gap: 4px;
    }
}

@media (max-width: 768px) {
    .content-slider-slide img {
        height: 260px;
    }
    .content-mosaic-container {
        gap: 4px;
    }
    .news-cover-mosaic {
        gap: 3px;
    }
    .news-hero-cards {
        grid-template-columns: 1fr;
    }
    .news-similar-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Image Lightbox (TM Lightbox)
   ============================================ */

.tm-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    animation: tmLightboxFadeIn 0.2s ease;
}

@keyframes tmLightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tm-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    cursor: pointer;
}

.tm-lightbox-container {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.tm-lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 85vh;
}

.tm-lightbox-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}

.tm-lightbox-caption {
    margin-top: 16px;
    padding: 0 20px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
}

.tm-lightbox-counter {
    margin-top: 12px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
}

.tm-lightbox-close,
.tm-lightbox-prev,
.tm-lightbox-next {
    position: absolute;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 2;
}

.tm-lightbox-close:hover,
.tm-lightbox-prev:hover,
.tm-lightbox-next:hover {
    background: var(--accent-cyan);
    transform: scale(1.1);
}

.tm-lightbox-close {
    top: -60px;
    right: 0;
}

.tm-lightbox-prev {
    left: -70px;
    top: 50%;
    transform: translateY(-50%);
}
.tm-lightbox-prev:hover {
    transform: translateY(-50%) scale(1.1);
}

.tm-lightbox-next {
    right: -70px;
    top: 50%;
    transform: translateY(-50%);
}
.tm-lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Responsive для лайтбокса */
@media (max-width: 1200px) {
    .tm-lightbox-prev {
        left: 10px;
    }
    .tm-lightbox-next {
        right: 10px;
    }
}

@media (max-width: 768px) {
    .tm-lightbox-close {
        top: -55px;
        right: 0;
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    .tm-lightbox-prev,
    .tm-lightbox-next {
        top: auto;
        bottom: -55px;
        transform: none;
        width: 44px;
        height: 44px;
    }
    .tm-lightbox-prev {
        left: calc(50% - 60px);
    }
    .tm-lightbox-next {
        right: calc(50% - 60px);
    }
    .tm-lightbox-prev:hover,
    .tm-lightbox-next:hover {
        transform: scale(1.1);
    }
    .tm-lightbox-img {
        max-width: 95vw;
        max-height: 70vh;
        border-radius: 4px;
    }
    .tm-lightbox-caption {
        font-size: 0.85rem;
        padding: 0 10px;
    }
}

/* ============================================
   Content Gallery (grid layout)
   ============================================ */

.content-gallery-wrapper {
    margin: 28px 0;
    border-radius: var(--radius-card);
    overflow: hidden;
}

.content-gallery-grid {
    display: grid;
    gap: 8px;
    border-radius: var(--radius-card);
}

/* 2 images: 2 columns */
.content-gallery-grid[data-gallery-count="2"] {
    grid-template-columns: repeat(2, 1fr);
}

/* 3 images: 3 columns */
.content-gallery-grid[data-gallery-count="3"] {
    grid-template-columns: repeat(3, 1fr);
}

/* 4 images: 2x2 */
.content-gallery-grid[data-gallery-count="4"] {
    grid-template-columns: repeat(2, 1fr);
}

/* 5-6 images: 3 columns */
.content-gallery-grid[data-gallery-count="5"],
.content-gallery-grid[data-gallery-count="6"] {
    grid-template-columns: repeat(3, 1fr);
}

/* 7+ images: 4 columns */
.content-gallery-grid[data-gallery-count="7"],
.content-gallery-grid[data-gallery-count="8"],
.content-gallery-grid[data-gallery-count="9"],
.content-gallery-grid[data-gallery-count="10+"] {
    grid-template-columns: repeat(4, 1fr);
}

.content-gallery-item {
    overflow: hidden;
    border-radius: 4px;
    position: relative;
}

.content-gallery-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.2s ease;
}

.content-gallery-item:hover img {
    transform: scale(1.05);
    opacity: 0.9;
}

/* Responsive gallery */
@media (max-width: 992px) {
    .content-gallery-grid[data-gallery-count] {
        grid-template-columns: repeat(2, 1fr);
    }
    .content-gallery-item img {
        height: 150px;
    }
}

@media (max-width: 576px) {
    .content-gallery-grid[data-gallery-count] {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .content-gallery-item img {
        height: 220px;
    }
}