.detail-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto auto;
    gap: 40px;
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    transition: background 0.3s, border 0.3s;
    margin-top: 10px;
    max-width: 100%;
    box-sizing: border-box;
}

.detail-container * {
    box-sizing: border-box;
}

.detail-content-top {
    grid-column: 1;
    grid-row: 1;
}

.detail-content-bottom {
    grid-column: 1;
    grid-row: 2;
}

.cover-wrapper {
    grid-column: 2;
    grid-row: 1 / 3;
    position: relative;
    display: block;
    text-decoration: none;
    border-radius: var(--radius-md);
    overflow: hidden;
    align-self: start;
}
.cover-img {
    width: 100%;
    display: block;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transition: filter 0.3s ease;
}
@media (hover: hover) {
    .cover-wrapper:hover .cover-img {
        filter: brightness(0.7);
    }
}

.cover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: var(--radius-md);
}
.cover-overlay svg {
    width: 48px;
    height: 48px;
}
.cover-overlay span {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
@media (hover: hover) {
    .cover-wrapper:hover .cover-overlay {
        opacity: 1;
    }
}

.cover-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #ffc107, #ffb300);
    color: #111;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
}

.detail-title-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.detail-title-row h1 {
    font-size: 28px;
    color: var(--text-color);
    line-height: 1.2;
    margin: 0;
}
.detail-premium-pill {
    background: linear-gradient(135deg, #ffc107, #ffb300);
    color: #111;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
    white-space: nowrap;
    margin-top: 6px;
}

.detail-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: color-mix(in srgb, var(--secondary-color) 18%, transparent);
    color: var(--text-color);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--nav-border);
}
.meta-pill svg { width: 14px; height: 14px; opacity: 0.8; }

.detail-content p {
    color: var(--text-color);
    font-size: 15px;
    margin-bottom: 8px;
}

.detail-divider {
    border: 0;
    height: 1px;
    background: var(--nav-border);
    margin: 24px 0;
}

.synopsis-title {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-color);
}
.synopsis-text {
    color: var(--text-color);
    font-size: 15px;
    line-height: 1.7;
    text-align: justify;
}
.synopsis-text p { margin: 0 0 12px 0; }
.synopsis-text p:last-child { margin-bottom: 0; }

.meta-date {
    opacity: 0.6;
    font-style: italic;
    font-size: 13px;
    margin-top: 4px;
}

/* ===== Rating inline (dentro do detail-container) ===== */
.rating-inline {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 16px 0 4px;
}

.rating-stars {
    display: inline-flex;
    gap: 2px;
}

.rating-stars .star {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: color-mix(in srgb, var(--text-color) 25%, transparent);
    transition: transform var(--transition-smooth), color var(--transition-fast);
    will-change: transform;
}
.rating-stars .star svg { width: 26px; height: 26px; display: block; }
.rating-stars .star:hover {
    transform: scale(1.18);
    color: #ffc107;
}
.rating-stars .star.filled { color: #ffc107; }
.rating-stars .star.filled:hover { color: #ffb300; }

.rating-summary {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    color: var(--text-color);
}
.rating-summary strong {
    font-size: 20px;
    font-weight: 700;
}
.rating-count {
    font-size: 13px;
    opacity: 0.7;
    font-weight: 600;
}

.rating-login-hint {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.8;
}
.rating-login-hint a {
    color: var(--text-color);
    text-decoration: underline;
}

.btn-back-top {
    display: inline-block;
    width: fit-content;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    border-radius: var(--radius-sm);
    background: rgba(200, 200, 200, 0.5);
    text-decoration: none;
    border: 1px solid transparent;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    margin-bottom: 12px;
    cursor: pointer;
}
.btn-back-top::before {
    content: '← ';
}
.btn-back-top:hover,
.btn-back-top:active {
    background: var(--secondary-color);
    border-color: var(--nav-border);
    color: var(--text-color);
    text-shadow: none;
}

@media (max-width: 768px) {
    .detail-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        justify-items: center;
        gap: 24px;
        padding: 24px 20px;
    }
    .detail-content-top { grid-column: 1; grid-row: 1; width: 100%; }
    .cover-wrapper { grid-column: 1; grid-row: 2; max-width: 220px; justify-self: center; }
    .detail-content-bottom { grid-column: 1; grid-row: 3; width: 100%; }

    .cover-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.35);
    }
    .cover-overlay svg { width: 36px; height: 36px; }
    .cover-overlay span { font-size: 14px; }

.cover-img { filter: brightness(0.85); }

    .detail-title-row { justify-content: center; }
    .detail-title-row h1 { font-size: 22px; }
    .detail-meta-row { justify-content: center; }
    .rating-inline { justify-content: center; }
    .detail-section { padding: 20px 16px; width: 100%; box-sizing: border-box; }
    .section-title { font-size: 18px; }
    .rating-stars .star svg { width: 22px; height: 22px; }
    .comment-form-header { 
        flex-direction: row; 
        align-items: flex-start; 
        gap: 12px; 
    }
    .comment-form-header textarea { 
        flex: 1; 
        min-height: 48px; 
    }
    .btn-comment-submit { 
        align-self: flex-end; 
        margin-top: 0;
        width: auto; 
        min-width: 120px; 
        justify-self: end; 
    }
}

@media (max-width: 480px) {
    .detail-container { padding: 20px 16px; }
    .cover-wrapper { max-width: 180px; }
    .detail-title-row h1 { font-size: 20px; }
}
.detail-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-top: 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
    transition: background 0.3s, border 0.3s;
    max-width: 100%;
    box-sizing: border-box;
}

.section-title {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-count {
    background: var(--secondary-color);
    color: var(--text-color);
    font-size: 13px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--nav-border);
}

/* ===== Comments ===== */
.comment-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-card {
    display: flex;
    gap: 14px;
    background: color-mix(in srgb, var(--primary-color) 25%, transparent);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background var(--transition-fast);
}

.comment-avatar {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
}
.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment-avatar svg { width: 22px; height: 22px; }

.comment-body { flex: 1; min-width: 0; }
.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 8px;
}
.comment-author {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
    word-break: break-word;
}
.comment-date {
    font-size: 12px;
    opacity: 0.65;
}
.comment-content {
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.comment-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.comment-btn {
    background: transparent;
    border: 1px solid var(--nav-border);
    color: var(--text-color);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.comment-btn:hover {
    background: color-mix(in srgb, var(--secondary-color) 20%, transparent);
    border-color: var(--secondary-color);
}
.comment-btn-danger { border-color: #dc3545; color: #dc3545; }
.comment-btn-danger:hover { background: rgba(220, 53, 69, 0.12); }

.comment-edit-form { margin-top: 10px; }
.comment-edit-form textarea {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--nav-border);
    color: var(--text-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}
.comment-edit-actions { display: flex; gap: 8px; margin-top: 8px; }

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}
.comment-form-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.comment-form-avatar {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
}
.comment-form-avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment-form-avatar svg { width: 22px; height: 22px; }
.comment-form-header textarea {
    flex: 1;
    background: color-mix(in srgb, var(--primary-color) 20%, transparent);
    border: 1px solid var(--nav-border);
    color: var(--text-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-family: inherit;
    font-size: 15px;
    resize: vertical;
    min-height: 48px;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.comment-form-header textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    background: color-mix(in srgb, var(--primary-color) 30%, transparent);
}
.btn-comment-submit {
    align-self: flex-end;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--secondary-color);
    color: var(--text-color);
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-smooth), opacity var(--transition-fast);
    will-change: transform;
}
.btn-comment-submit svg { width: 16px; height: 16px; }
.btn-comment-submit:hover { transform: translateY(-2px); }

.comments-empty {
    color: var(--text-color);
    opacity: 0.7;
    font-style: italic;
    padding: 12px 0;
}

/* ===== Similar publications ===== */
.similar-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    max-width: 900px;
    margin: 0 auto;
    overflow: hidden;
}
.similar-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    background: color-mix(in srgb, var(--primary-color) 25%, transparent);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
    transition: transform var(--transition-smooth), box-shadow var(--transition-fast);
    will-change: transform;
    width: 160px;
    box-sizing: border-box;
}
.similar-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}
.similar-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: var(--radius-sm);
}
.similar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Desktop: mostrar apenas 5 publicações */
@media (min-width: 769px) {
    .similar-card:nth-child(n+6) {
        display: none;
    }
}
@media (max-width: 768px) {
    .similar-grid {
        gap: 12px;
    }
    .similar-card {
        width: calc(50% - 6px);
        padding: 10px;
    }
    /* Mobile: mostrar apenas 4 publicações */
    .similar-card:nth-child(n+5) {
        display: none;
    }
}
