body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0; background: #f9f9f9; }
.container { max-width: 800px; margin: 0 auto; padding: 20px; }
header.main-header { background: #fff; border-bottom: 1px solid #eee; padding: 20px 0; text-align: center; margin-bottom: 30px; }
header.main-header h1 { margin: 0; color: #222; }
header.main-header a { text-decoration: none; color: inherit; }

.post-card { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); margin-bottom: 30px; transition: transform 0.2s; }
.post-card:hover { transform: translateY(-5px); }
.post-card img { width: 100%; height: 250px; object-fit: cover; }
.post-card-content { padding: 20px; }
.post-card h2 { margin-top: 0; font-size: 1.5rem; }
.post-card h2 a { text-decoration: none; color: #222; }
.post-card .meta { font-size: 0.9rem; color: #888; margin-bottom: 10px; }
.btn-read { display: inline-block; background: #007bff; color: #fff; padding: 8px 16px; border-radius: 4px; text-decoration: none; margin-top: 10px; }

article { background: #fff; padding: 40px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
article h1 { font-size: 2.5rem; margin-bottom: 10px; }
article img.featured { width: 100%; border-radius: 8px; margin-bottom: 20px; }
article .content { font-size: 1.1rem; }
article h2 { border-left: 4px solid #007bff; padding-left: 15px; margin-top: 30px; }
article a { color: #007bff; }

.adsense-block { margin: 20px 0; text-align: center; min-height: 1px; }

@media (max-width: 600px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        overflow-x: hidden;
    }

    .container,
    header.main-header .container {
        display: block;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    article {
        display: block;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 16px 10px !important;
        border-radius: 0;
        box-shadow: none;
        overflow-wrap: anywhere;
    }

    /* Alguns artigos do CMS já trazem um <article style="max-width:800px...">. */
    article .content > article,
    article .content article[style] {
        display: block;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box;
    }

    article h1 { font-size: 1.8rem; }

    /* Os artigos guardados no CMS incluem tabelas com min-width inline. */
    article .content table {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
        table-layout: fixed;
        font-size: 0.86rem;
    }

    article .content th,
    article .content td {
        padding: 9px 7px !important;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    article .content > div[style*="overflow-x: auto"] {
        display: block;
        width: 100% !important;
        max-width: none !important;
        overflow-x: visible !important;
    }

    article .content > article section,
    article .content > article section[style] {
        width: 100% !important;
        max-width: none !important;
        box-sizing: border-box;
    }

    article .content img,
    article .content iframe,
    article .content video {
        max-width: 100% !important;
        height: auto;
    }
}

/* Artigos Recentes no final do post */
.recent-posts-section { margin-top: 50px; border-top: 2px solid #eee; padding-top: 30px; }
.recent-posts-section h3 { margin-bottom: 20px; font-size: 1.5rem; color: #222; }
.recent-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.recent-item { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.recent-item img { width: 100%; height: 120px; object-fit: cover; }
.recent-item h4 { font-size: 1rem; margin: 10px; line-height: 1.2; height: 2.4em; overflow: hidden; }
.recent-item h4 a { text-decoration: none; color: #333; }
.recent-item p { font-size: 0.85rem; color: #666; margin: 0 10px 10px 10px; height: 3em; overflow: hidden; }

@media (max-width: 768px) {
    .recent-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .recent-grid { grid-template-columns: 1fr; }
}

/* Botões de Compartilhamento */
.share-buttons { margin: 20px 0; display: flex; flex-wrap: wrap; gap: 10px; }
.share-btn { padding: 8px 15px; border-radius: 4px; text-decoration: none; color: white; font-size: 0.9rem; border: none; cursor: pointer; transition: opacity 0.2s; font-family: inherit; }
.share-btn:hover { opacity: 0.8; }
.fb { background: #3b5998; }
.wa { background: #25d366; }
.tw { background: #1da1f2; }
.copy { background: #6c757d; }


/* Correção estrutural definitiva para artigos em ecrãs pequenos. */
@media screen and (max-width: 600px) {
    html body .container,
    html body .article-shell,
    html body .article-body {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        box-sizing: border-box !important;
    }

    html body .article-shell {
        padding-top: 12px !important;
        padding-bottom: 12px !important;
        border-radius: 0 !important;
    }

    html body .article-body {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        overflow: visible !important;
    }

    html body .article-body > article,
    html body .article-body > article[style] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    html body .article-body > article > section,
    html body .article-body > article > div,
    html body .article-body > article > footer {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}


/* Responsividade dos artigos gerados pelo CMS.
   Mantém a largura total no telemóvel mesmo quando o HTML do artigo contém
   estilos inline antigos com max-width, width ou margens automáticas. */
.article-page,
.article-shell {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
}

.article-shell .article-body {
    min-width: 0;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

.article-shell .article-body img,
.article-shell > a > img,
.article-shell img.featured {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    object-fit: contain !important;
    box-sizing: border-box;
}

@media screen and (max-width: 600px) {
    .article-page,
    .article-shell {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }

    .article-shell .article-body,
    .article-shell .article-body > *,
    .article-shell .article-body section,
    .article-shell .article-body footer,
    .article-shell .article-body div {
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    /* Corrige artigos HTML gerados com max-width/width inline. */
    .article-shell .article-body [style*="max-width"],
    .article-shell .article-body [style*="width:"] {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }

    .article-shell .article-body img,
    .article-shell > a > img,
    .article-shell img.featured {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .article-shell .article-body iframe,
    .article-shell .article-body video {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    .article-shell .article-body pre,
    .article-shell .article-body code {
        max-width: 100%;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }
}
