:root {
    --cms-red: #ff5b33;
    --cms-red-deep: #f04824;
    --cms-ink: #24252d;
    --cms-soft: #fff6ee;
    --cms-line: rgba(36, 37, 45, 0.1);
    --cms-card: #ffffff;
    --cms-muted: #646775;
    --cms-shadow: 0 24px 48px rgba(29, 16, 9, 0.12);
    --cms-radius: 28px;
}

* {
    box-sizing: border-box;
}

.cms-body,
.admin-body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--cms-ink);
    background:
        radial-gradient(circle at top left, rgba(255, 213, 150, 0.82), transparent 28%),
        linear-gradient(180deg, #fff0d7 0%, #fff7f2 38%, #fff 100%);
}

.cms-shell,
.admin-shell {
    min-height: 100vh;
}

.cms-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    margin: 1rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--cms-red), #ff6a3d);
    box-shadow: var(--cms-shadow);
}

.cms-brand,
.admin-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    text-decoration: none;
    color: #fff;
}

.cms-brand img,
.admin-brand img,
.login-card img {
    width: 68px;
    height: 68px;
    object-fit: cover;
    border-radius: 24px;
    box-shadow: 0 16px 30px rgba(255, 205, 137, 0.28);
}

.cms-brand strong,
.admin-brand span {
    display: block;
    font-size: 1rem;
}

.cms-brand small {
    display: block;
    opacity: 0.86;
}

.cms-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.cms-nav a,
.cms-cta,
.cms-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cms-nav a {
    padding: 0.8rem 1rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.cms-nav a.is-active,
.cms-nav a:hover,
.cms-cta:hover,
.cms-button:hover {
    transform: translateY(-1px);
}

.cms-cta,
.cms-button {
    padding: 0.9rem 1.2rem;
    background: var(--cms-ink);
    color: #fff;
    border: 0;
    cursor: pointer;
    box-shadow: 0 18px 32px rgba(36, 37, 45, 0.16);
}

.cms-button--ghost {
    background: transparent;
    color: var(--cms-red-deep);
    border: 1px solid rgba(255, 91, 51, 0.24);
    box-shadow: none;
}

.cms-page {
    padding: 1rem 1rem 4rem;
    max-width: 1240px;
    margin: 0 auto;
}

.page-hero,
.list-hero {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 2rem;
}

.page-hero__media,
.article-hero,
.post-card,
.info-card,
.stats-panel,
.admin-panel,
.admin-table-card,
.login-card,
.simple-form,
.editor-form,
.empty-state,
.stat-card {
    border-radius: var(--cms-radius);
    background: var(--cms-card);
    box-shadow: var(--cms-shadow);
}

.page-hero__media img,
.article-hero img,
.post-card img {
    width: 100%;
    display: block;
    object-fit: cover;
}

.page-hero__media img,
.article-hero img {
    border-radius: var(--cms-radius);
    min-height: 320px;
    max-height: 480px;
}

.page-hero h1,
.list-hero h1,
.article-header h1,
.login-card h1,
.admin-header h1 {
    margin: 0.2rem 0 0.8rem;
    font-family: "Fraunces", serif;
    font-size: clamp(2rem, 3vw, 3.8rem);
    line-height: 0.98;
}

.page-hero__lead,
.list-hero p,
.article-header__excerpt,
.info-card p,
.post-card p,
.login-card label span,
.simple-form label span,
.editor-form label span {
    color: var(--cms-muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

.page-sections,
.post-grid,
.stat-grid,
.admin-columns {
    display: grid;
    gap: 1.25rem;
}

.page-sections,
.stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 2rem;
}

.post-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.info-card,
.post-card__body,
.article-shell,
.stats-panel,
.login-card,
.simple-form,
.editor-form,
.admin-panel,
.admin-table-card,
.stat-card {
    padding: 1.4rem;
}

.content-cluster {
    margin-top: 2rem;
}

.section-heading {
    margin-bottom: 1.2rem;
}

.eyebrow {
    display: inline-flex;
    padding: 0.42rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 91, 51, 0.1);
    color: var(--cms-red-deep);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.stats-panel {
    display: grid;
    gap: 1rem;
}

.stats-panel div,
.stat-card {
    padding: 1rem;
    border: 1px solid var(--cms-line);
}

.stats-panel strong,
.stat-card strong {
    display: block;
    font-size: 1.2rem;
}

.toolbar,
.toolbar-form--admin {
    margin-bottom: 1.5rem;
}

.toolbar-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.toolbar-form input,
.toolbar-form select,
.simple-form input,
.simple-form select,
.simple-form textarea,
.editor-form input,
.editor-form select,
.editor-form textarea,
.login-card input {
    width: 100%;
    border: 1px solid rgba(36, 37, 45, 0.12);
    border-radius: 18px;
    padding: 0.9rem 1rem;
    font: inherit;
    background: #fff;
}

.toolbar-form input,
.toolbar-form select {
    width: auto;
    min-width: 220px;
}

.post-card {
    overflow: hidden;
}

.post-card img {
    aspect-ratio: 16 / 11;
}

.post-card__body span,
.article-meta,
.table-actions a,
.table-actions button,
.admin-list-item span {
    color: var(--cms-muted);
    font-size: 0.92rem;
}

.post-card__body h2,
.post-card__body h3,
.info-card h2,
.admin-panel h2 {
    margin: 0.4rem 0 0.6rem;
    font-family: "Fraunces", serif;
}

.post-card__body a,
.admin-list-item,
.table-actions a {
    color: inherit;
    text-decoration: none;
}

.article-shell {
    max-width: 920px;
    margin: 0 auto 2rem;
}

.article-header {
    margin-bottom: 1.4rem;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.article-content {
    line-height: 1.8;
    font-size: 1.02rem;
}

.article-content h2 {
    font-family: "Fraunces", serif;
    margin-top: 2rem;
}

.article-content h3,
.article-content h4 {
    font-family: "Fraunces", serif;
    margin-top: 1.4rem;
}

.article-content ul {
    padding-left: 1.2rem;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2rem 0;
}

.article-content table th,
.article-content table td {
    border: 1px solid var(--cms-line);
    padding: 0.75rem;
    text-align: left;
}

.article-content blockquote {
    padding: 1rem 1.2rem;
    border-left: 4px solid var(--cms-red);
    background: rgba(255, 91, 51, 0.08);
    border-radius: 0 18px 18px 0;
}

.article-content pre {
    padding: 1rem;
    border-radius: 18px;
    background: #231f20;
    color: #fff;
    overflow: auto;
}

.article-content .article-callout {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: var(--cms-soft);
    border: 1px solid rgba(255, 91, 51, 0.16);
}

.article-content .article-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.1rem;
    border-radius: 999px;
    background: var(--cms-red);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
}

.article-content .article-video iframe {
    width: 100%;
    min-height: 360px;
    border: 0;
    border-radius: 18px;
}

.article-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.4rem 0;
}

.article-stat-grid div {
    padding: 1rem;
    border-radius: 20px;
    background: var(--cms-soft);
}

.article-stat-grid strong {
    display: block;
    font-size: 1.4rem;
}

.article-chart {
    width: 100%;
    max-height: 320px;
    margin: 1.5rem 0;
}

.cms-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem;
    margin: 0 1rem 1rem;
    border-radius: 28px;
    background: #231f20;
    color: rgba(255, 255, 255, 0.88);
}

.cms-footer__links {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.cms-footer a {
    color: #fff;
    text-decoration: none;
}

.admin-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
}

.admin-sidebar {
    min-height: 100vh;
    padding: 1.4rem;
    background: #231f20;
    color: #fff;
}

.admin-sidebar nav {
    display: grid;
    gap: 0.55rem;
    margin-top: 1.5rem;
}

.admin-sidebar nav a {
    color: rgba(255, 255, 255, 0.86);
    text-decoration: none;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
}

.admin-main {
    padding: 1.5rem;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-list-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--cms-line);
}

.admin-list-item:last-child {
    border-bottom: 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 1rem 0.6rem;
    border-bottom: 1px solid var(--cms-line);
    vertical-align: top;
}

.table-actions {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.table-actions form {
    margin: 0;
}

.table-actions button {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
    gap: 1.2rem;
}

.editor-main,
.editor-side,
.simple-form,
.login-card {
    display: grid;
    gap: 1rem;
}

.editor-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.9rem;
}

.editor-toolbar__group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.35rem;
    border-radius: 999px;
    background: rgba(255, 245, 238, 0.9);
    border: 1px solid rgba(255, 91, 51, 0.08);
}

.editor-toolbar button,
.editor-tabs button {
    border: 1px solid var(--cms-line);
    background: #fff;
    border-radius: 999px;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        background 0.2s ease,
        color 0.2s ease;
}

.editor-toolbar button:hover,
.editor-tabs button:hover,
.editor-tabs button.is-active {
    background: var(--cms-red);
    color: #fff;
    transform: translateY(-1px);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.checkbox-row input {
    width: auto;
}

.image-preview-card {
    padding: 1rem;
    border-radius: 22px;
    background: var(--cms-soft);
}

.image-preview-card img {
    width: 100%;
    display: block;
    border-radius: 18px;
    margin-bottom: 0.8rem;
}

.ai-panel {
    padding: 1.2rem;
    margin: 0.4rem 0 1rem;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 244, 235, 0.98), #fff);
    border: 1px solid rgba(255, 91, 51, 0.12);
    box-shadow: 0 14px 30px rgba(29, 16, 9, 0.08);
}

.ai-panel h2 {
    margin: 0.35rem 0 0;
    font-family: "Fraunces", serif;
    font-size: 1.4rem;
}

.ai-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ai-panel__hint {
    margin: 0.35rem 0 0;
    color: var(--cms-muted);
    font-size: 0.92rem;
}

.editor-workspace {
    padding: 1.2rem;
    border-radius: 26px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 91, 51, 0.08);
}

.editor-tabs {
    display: flex;
    gap: 0.55rem;
    margin-bottom: 1rem;
}

.editor-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
}

.editor-stage[data-mode="write"] {
    grid-template-columns: 1fr;
}

.editor-stage[data-mode="write"] .editor-pane--preview {
    display: none;
}

.editor-stage[data-mode="preview"] {
    grid-template-columns: 1fr;
}

.editor-stage[data-mode="preview"] .editor-pane--write {
    display: none;
}

.editor-pane {
    display: grid;
    gap: 0.55rem;
}

.editor-pane > span,
.editor-preview__header span {
    font-weight: 700;
}

.editor-pane textarea {
    min-height: 540px;
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.6;
    resize: vertical;
}

.editor-preview__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.editor-preview {
    min-height: 540px;
    padding: 1.2rem;
    border-radius: 22px;
    border: 1px solid var(--cms-line);
    background: linear-gradient(180deg, #fff, #fffaf6);
    overflow: auto;
}

.editor-preview h1,
.editor-preview h2,
.editor-preview h3,
.editor-preview h4 {
    font-family: "Fraunces", serif;
    margin-top: 1.4rem;
}

.editor-preview figure,
.editor-preview table,
.editor-preview .article-callout,
.editor-preview .article-video,
.editor-preview blockquote,
.editor-preview pre {
    margin: 1.2rem 0;
}

.editor-preview figure img {
    border-radius: 18px;
}

.editor-preview table {
    width: 100%;
    border-collapse: collapse;
}

.editor-preview table th,
.editor-preview table td {
    border: 1px solid var(--cms-line);
    padding: 0.75rem;
    text-align: left;
}

.editor-preview blockquote {
    padding: 1rem 1.2rem;
    border-left: 4px solid var(--cms-red);
    background: rgba(255, 91, 51, 0.08);
    border-radius: 0 18px 18px 0;
}

.editor-preview pre {
    padding: 1rem;
    border-radius: 18px;
    background: #231f20;
    color: #fff;
    overflow: auto;
}

.editor-preview .article-callout {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: var(--cms-soft);
    border: 1px solid rgba(255, 91, 51, 0.16);
}

.editor-preview .article-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.1rem;
    border-radius: 999px;
    background: var(--cms-red);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
}

.editor-preview .article-video iframe {
    width: 100%;
    min-height: 360px;
    border: 0;
    border-radius: 18px;
}

.editor-preview__empty {
    min-height: 100%;
    display: grid;
    place-content: center;
    text-align: center;
    color: var(--cms-muted);
}

.flash {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 18px;
}

.flash-success {
    background: rgba(72, 201, 124, 0.14);
    color: #1c7a45;
}

.flash-error {
    background: rgba(240, 72, 36, 0.12);
    color: #aa3518;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-card {
    width: min(460px, 100%);
}

.empty-state {
    padding: 2rem;
    text-align: center;
}

.empty-state--full {
    min-height: 60vh;
    display: grid;
    place-content: center;
}

@media (max-width: 1120px) {
    .cms-topbar,
    .page-hero,
    .list-hero,
    .post-grid,
    .page-sections,
    .editor-grid,
    .admin-shell,
    .admin-columns {
        grid-template-columns: 1fr;
    }

    .cms-topbar {
        border-radius: 36px;
    }

    .cms-nav {
        width: 100%;
    }

    .admin-sidebar {
        min-height: auto;
    }
}

@media (max-width: 720px) {
    .cms-topbar,
    .cms-footer {
        margin: 0.75rem;
        padding: 1rem;
        border-radius: 28px;
    }

    .cms-brand img,
    .admin-brand img,
    .login-card img {
        width: 56px;
        height: 56px;
        border-radius: 18px;
    }

    .cms-nav {
        gap: 0.45rem;
    }

    .cms-nav a,
    .cms-cta,
    .cms-button {
        width: 100%;
    }

    .page-sections,
    .post-grid,
    .article-stat-grid,
    .stat-grid,
    .editor-split,
    .editor-stage {
        grid-template-columns: 1fr;
    }

    .ai-panel__header,
    .editor-preview__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .editor-preview,
    .editor-pane textarea {
        min-height: 360px;
    }

    .toolbar-form input,
    .toolbar-form select {
        min-width: 100%;
    }

    .table-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .cms-footer {
        flex-direction: column;
    }
}
