html, body { height: 100%; margin: 0; }

.page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-main { flex: 1 0 auto; }
.page-container { padding-top: 24px; padding-bottom: 24px; }

/* Header */
.blog-appbar { padding-inline: 16px; gap: 12px; }
.blog-title-link { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; min-width: 0; }
.blog-title { font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blog-tagline { opacity: 0.7; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blog-search { max-width: 320px; }
.blog-search-toggle { display: none; }
.blog-search-mobile-row { display: none; padding: 8px 16px; border-bottom: 1px solid var(--mud-palette-divider); }
.logout-form { display: inline; margin: 0; padding: 0; }

/* Footer */
.blog-footer {
    margin-top: 48px;
    padding: 24px 0;
    border-top: 1px solid var(--mud-palette-table-lines);
}
.blog-footer-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }

/* Featured / cards */
.featured-section .article-card .article-card-hero { height: 360px; }
.article-card { display: flex; flex-direction: column; height: 100%; transition: transform .18s ease, box-shadow .18s ease; }
.article-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,0,0,0.18); }
.article-card-hero {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid var(--mud-palette-divider);
}
.article-card-title { margin: 8px 0; line-height: 1.25; font-weight: 700; color: var(--mud-palette-text-primary); word-break: break-word; }
.article-card-summary { margin-bottom: 12px; opacity: 0.85; }
.article-card-meta { display: flex; gap: 4px; flex-wrap: wrap; opacity: 0.7; margin-bottom: 8px; }
.article-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* Tag chip */
.tag-chip { cursor: pointer; }

/* Article detail */
.article-detail { max-width: 760px; margin: 0 auto; }
.article-hero { margin: 0 0 24px; }
.article-hero img { width: 100%; height: auto; max-height: 480px; object-fit: cover; border-radius: 12px; display: block; }
.article-header h1 { margin: 0 0 8px; line-height: 1.15; font-size: clamp(1.6rem, 5vw, 2.6rem); word-break: break-word; }
.article-summary { opacity: 0.8; margin-bottom: 12px; }
.article-meta { display: flex; gap: 4px; flex-wrap: wrap; opacity: 0.7; margin-bottom: 12px; }
.article-tags { margin-bottom: 24px; display: flex; gap: 6px; flex-wrap: wrap; }
.article-nav { display: flex; align-items: center; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--mud-palette-divider); flex-wrap: wrap; gap: 8px; }

/* Markdown body */
.markdown-body { font-size: 1.05rem; line-height: 1.75; color: var(--mud-palette-text-primary); overflow-wrap: break-word; word-wrap: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin-top: 1.6em; margin-bottom: 0.4em; line-height: 1.25; }
.markdown-body h1 { font-size: 1.9rem; }
.markdown-body h2 { font-size: 1.5rem; }
.markdown-body h3 { font-size: 1.25rem; }
.markdown-body p { margin: 0 0 1em; }
.markdown-body img { max-width: 100%; height: auto; border-radius: 8px; }
.markdown-body pre {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 8px;
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.55;
    -webkit-overflow-scrolling: touch;
}
.markdown-body code { background: var(--mud-palette-action-default-hover); padding: 1px 6px; border-radius: 4px; font-size: 0.92em; word-break: break-word; }
.markdown-body pre code { background: transparent; padding: 0; word-break: normal; }
.markdown-body blockquote {
    margin: 1em 0;
    padding: 8px 16px;
    border-left: 3px solid var(--mud-palette-primary);
    background: var(--mud-palette-action-default-hover);
    border-radius: 4px;
}
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1em 0; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { border: 1px solid var(--mud-palette-divider); padding: 8px 12px; text-align: left; }
.markdown-body a { color: var(--mud-palette-primary); overflow-wrap: anywhere; }
.markdown-body hr { border: 0; border-top: 1px solid var(--mud-palette-divider); margin: 2em 0; }

.markdown-textarea textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; font-size: 0.92rem !important; line-height: 1.55 !important; }
.markdown-editor-panel { padding-top: 8px; }
.markdown-preview { padding: 16px; border: 1px solid var(--mud-palette-divider); border-radius: 8px; min-height: 300px; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 16px;
    background: transparent;
    color: var(--mud-palette-text-secondary);
}
.empty-state .mud-icon-root { font-size: 3rem; opacity: 0.5; margin-bottom: 8px; }

/* Login */
.login-container { padding: 48px 0; }

/* Image admin */
.image-tile { padding: 8px; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--mud-palette-divider); }
.image-tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; }
.image-tile-meta { display: flex; flex-direction: column; }
.image-tile-meta .filename { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.image-tile-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.hero-thumb { width: 100%; max-height: 200px; object-fit: cover; border-radius: 6px; }

.muted { opacity: 0.7; }

/* Error overlay (dev) */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #b00020; color: #fff; padding: 12px 16px; z-index: 9999; }
#blazor-error-ui.visible { display: block; }

/* ---------- Mobile (<= 600px) ---------- */
@media (max-width: 600px) {
    .blog-appbar { padding-inline: 8px; gap: 4px; }
    .blog-tagline { display: none; }
    .blog-title { font-size: 1.15rem; }
    .blog-search-desktop { display: none; }
    .blog-search-toggle { display: inline-flex; }
    .blog-search-mobile-row { display: block; }

    .page-container { padding-top: 16px; padding-bottom: 16px; }

    .featured-section .article-card .article-card-hero { height: auto; aspect-ratio: 16 / 9; }

    .article-detail { padding: 0; }
    .article-hero img { border-radius: 8px; max-height: 280px; }
    .article-header h1 { font-size: 1.6rem; }

    .markdown-body { font-size: 1rem; line-height: 1.65; }
    .markdown-body h1 { font-size: 1.5rem; }
    .markdown-body h2 { font-size: 1.25rem; }
    .markdown-body h3 { font-size: 1.1rem; }
    .markdown-body pre { font-size: 0.82rem; padding: 12px; }

    .blog-footer { margin-top: 32px; padding: 16px 0; }

    .login-container { padding: 24px 0; }
}

/* Tablet tweaks */
@media (max-width: 900px) {
    .blog-search { max-width: 220px; }
}
