:root {
    --bg: #f6e7d3;
    --bg-deep: #1f1713;
    --surface: rgba(255, 248, 240, 0.9);
    --surface-strong: #fff6ee;
    --ink: #211813;
    --ink-soft: #5f5046;
    --brand: #d9481a;
    --brand-dark: #992c0a;
    --accent: #ffcc48;
    --danger: #a81e1e;
    --border: rgba(33, 24, 19, 0.14);
    --shadow: 0 18px 40px rgba(56, 31, 12, 0.13);
    --radius: 22px;
    --radius-sm: 14px;
    --display: "Arial Black", Impact, Haettenschweiler, sans-serif;
    --body: "Trebuchet MS", "Gill Sans", sans-serif;
    --mono: "Courier New", monospace;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(255, 204, 72, 0.45), transparent 30%),
        radial-gradient(circle at top right, rgba(217, 72, 26, 0.25), transparent 28%),
        linear-gradient(160deg, #f8ecdd 0%, #f6e7d3 54%, #edd3bf 100%);
    color: var(--ink);
    font-family: var(--body);
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(33, 24, 19, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(33, 24, 19, 0.03) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    opacity: 0.4;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

.site-shell {
    position: relative;
    z-index: 1;
    width: min(1240px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.2rem 0 3rem;
}

.site-header,
.site-footer,
.hero-panel,
.filter-panel,
.message-card,
.admin-panel,
.auth-card,
.stat-card,
.message-hero {
    backdrop-filter: blur(12px);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 6px);
    background: rgba(255, 250, 244, 0.75);
    box-shadow: var(--shadow);
}

.brand-lockup {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.brand-mark {
    font-family: var(--display);
    font-size: clamp(1.45rem, 2.5vw, 2.4rem);
    line-height: 0.95;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.brand-tagline,
.muted,
.microcopy,
.site-footer p,
.filter-panel p,
.page-intro p,
.admin-row p,
.message-card p {
    color: var(--ink-soft);
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.site-nav a {
    padding: 0.65rem 0.95rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(33, 24, 19, 0.08);
    font-weight: 700;
}

.site-nav a:hover,
.site-nav a:focus-visible {
    background: var(--accent);
}

.page-shell {
    padding-top: 1.5rem;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
    gap: 1.4rem;
    padding: clamp(1.4rem, 3vw, 2.5rem);
    border-radius: calc(var(--radius) + 10px);
    background:
        linear-gradient(145deg, rgba(255, 251, 247, 0.94), rgba(255, 234, 214, 0.88)),
        radial-gradient(circle at 20% 20%, rgba(255, 204, 72, 0.42), transparent 25%);
    border: 1px solid rgba(153, 44, 10, 0.14);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.hero-copy h1,
.page-intro h1,
.section-heading h2,
.message-tools h2,
.admin-panel h2,
.admin-header h1,
.auth-card h1,
.empty-state h1,
.empty-state h2 {
    margin: 0;
    font-family: var(--display);
    text-transform: uppercase;
    line-height: 0.94;
    letter-spacing: 0.02em;
}

.hero-copy h1 {
    font-size: clamp(2.7rem, 7vw, 5.7rem);
    max-width: 11ch;
}

.hero-text {
    max-width: 40rem;
    font-size: 1.08rem;
    margin: 1rem 0 0;
}

.eyebrow {
    margin: 0 0 0.4rem;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.78rem;
    color: var(--brand-dark);
}

.hero-search,
.admin-search,
.button-row,
.hero-actions,
.message-card-actions,
.filter-actions,
.button-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.hero-search {
    margin-top: 1.25rem;
    align-items: center;
}

.search-input,
.text-input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(33, 24, 19, 0.15);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--ink);
    padding: 1rem 1.05rem;
    font: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.search-input {
    min-width: min(32rem, 100%);
}

.search-input.compact {
    min-width: 0;
}

textarea {
    min-height: 190px;
    resize: vertical;
    line-height: 1.6;
}

.message-editor.large {
    min-height: 260px;
}

.field-label {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    display: inline-block;
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.9rem 1.2rem;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn:hover,
.btn:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 14px 24px rgba(95, 34, 10, 0.18);
}

.btn-primary {
    background: linear-gradient(180deg, #f56f2f, #d64814);
    color: #fff9f4;
    box-shadow: 0 10px 20px rgba(212, 72, 20, 0.22);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    border-color: rgba(33, 24, 19, 0.12);
}

.btn-ghost {
    background: transparent;
    color: var(--brand-dark);
    border-color: rgba(153, 44, 10, 0.25);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    border-color: rgba(132, 39, 10, 0.18);
}

.btn-danger {
    background: linear-gradient(180deg, #c94040, #971d1d);
    color: #fff7f7;
}

.btn.small {
    padding: 0.65rem 0.95rem;
    font-size: 0.92rem;
}

.hero-stat-panel {
    display: grid;
    gap: 0.9rem;
    align-content: center;
}

.stat-card {
    padding: 1.25rem;
    border-radius: var(--radius);
    background: rgba(33, 24, 19, 0.92);
    color: #fff2e8;
    box-shadow: 0 12px 24px rgba(24, 13, 8, 0.2);
}

.stat-card.tilt {
    transform: rotate(-2deg);
}

.stat-number {
    display: block;
    font-family: var(--display);
    font-size: 2.3rem;
    line-height: 0.95;
    margin-bottom: 0.35rem;
}

.content-grid,
.admin-grid {
    display: grid;
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    gap: 1.4rem;
    align-items: start;
    margin-top: 1.5rem;
}

.admin-grid.single-column {
    grid-template-columns: 1fr;
    justify-items: center;
}

.filter-panel,
.admin-panel,
.auth-card,
.message-hero,
.message-card,
.flash,
.empty-state,
.page-intro {
    border: 1px solid rgba(33, 24, 19, 0.1);
    border-radius: var(--radius);
    background: rgba(255, 250, 244, 0.8);
    box-shadow: var(--shadow);
}

.filter-panel,
.admin-panel,
.auth-card,
.page-intro,
.empty-state {
    padding: 1.2rem;
}

.admin-grid.single-column > .admin-panel {
    width: min(100%, 1120px);
    margin-inline: auto;
}

.filter-panel-top {
    margin-bottom: 1rem;
}

.filter-group {
    border: 0;
    padding: 0;
    margin: 0 0 1rem;
}

.filter-group legend {
    font-family: var(--display);
    text-transform: uppercase;
    font-size: 1rem;
    margin-bottom: 0.6rem;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0;
}

.filter-option.locked {
    color: var(--brand-dark);
    font-weight: 700;
}

.filter-option input {
    inline-size: 1rem;
    block-size: 1rem;
}

.section-block {
    margin-top: 1.75rem;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-heading p {
    margin: 0.35rem 0 0;
}

.text-link {
    color: var(--brand-dark);
    font-weight: 800;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.compact-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.message-card {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 1.05rem;
    transform-origin: center;
    animation: lift-in 0.55s ease both;
}

.message-card:nth-child(2n) {
    animation-delay: 0.04s;
}

.message-card:nth-child(3n) {
    animation-delay: 0.08s;
}

.message-card-meta,
.tag-row,
.button-row.compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pill,
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 204, 72, 0.22);
    border: 1px solid rgba(153, 44, 10, 0.12);
    font-size: 0.86rem;
    font-weight: 800;
}

.pill-secondary {
    background: rgba(255, 255, 255, 0.74);
    border-color: rgba(33, 24, 19, 0.1);
}

.tag {
    background: rgba(255, 255, 255, 0.72);
}

.message-card h3,
.admin-row h3 {
    margin: 0;
    font-size: 1.1rem;
}

.message-card p,
.admin-row p,
.message-preview {
    margin: 0;
    line-height: 1.6;
}

.page-intro,
.admin-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
}

.message-layout {
    display: grid;
    gap: 1.6rem;
}

.message-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
    gap: 1.25rem;
    padding: 1.35rem;
}

.message-preview {
    font-size: 1.08rem;
}

.message-preview-shell {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.message-text {
    white-space: pre-line;
    line-height: 1.6;
    margin-bottom: 15px;
}

.branding-toggle-row {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.branding-toggle {
    inline-size: 1rem;
    block-size: 1rem;
    accent-color: var(--brand);
}

.branding-preview {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding-top: 0.3rem;
    color: var(--ink-soft);
}

.branding-preview[hidden] {
    display: none;
}

.branding-divider {
    display: inline-block;
    color: rgba(33, 24, 19, 0.35);
    font-size: 1rem;
    line-height: 1;
}

.branding-preview-text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-line;
}

.message-tools {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.button-stack {
    flex-direction: column;
}

.button-stack .btn {
    width: 100%;
}

.tag-row.spacious {
    gap: 0.75rem;
}

.admin-grid {
    margin-top: 1.2rem;
}

.admin-form-column,
.admin-list-column {
    display: grid;
    gap: 1.2rem;
}

.stacked-form {
    display: grid;
    gap: 0.85rem;
}

.inline-form {
    margin-top: 0.9rem;
}

.admin-table {
    display: grid;
    gap: 0.85rem;
}

.admin-row {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid rgba(33, 24, 19, 0.08);
}

.admin-row:first-child {
    border-top: 0;
    padding-top: 0;
}

.admin-row-copy {
    display: grid;
    gap: 0.35rem;
}

.warning-panel {
    background: linear-gradient(160deg, rgba(255, 241, 232, 0.92), rgba(255, 222, 196, 0.9));
}

.flash {
    margin-top: 1rem;
    padding: 1rem 1.2rem;
    font-weight: 700;
}

.flash-message {
    margin: 0;
}

.flash-list {
    margin: 0.75rem 0 0;
    padding-left: 1.15rem;
    font-weight: 600;
}

.flash-list li + li {
    margin-top: 0.45rem;
}

.flash-success {
    border-color: rgba(42, 110, 64, 0.2);
    background: rgba(225, 249, 228, 0.94);
}

.flash-warning {
    border-color: rgba(166, 104, 7, 0.2);
    background: rgba(255, 244, 214, 0.96);
}

.flash-error {
    border-color: rgba(168, 30, 30, 0.2);
    background: rgba(255, 235, 235, 0.94);
}

.status-box,
.status-success {
    width: min(100%, 1120px);
    margin: 1rem auto 0;
    padding: 1.1rem 1.25rem;
    border-radius: 20px;
    border-left: 6px solid #c94040;
    border-top: 1px solid rgba(33, 24, 19, 0.08);
    border-right: 1px solid rgba(33, 24, 19, 0.08);
    border-bottom: 1px solid rgba(33, 24, 19, 0.08);
    background: rgba(255, 236, 236, 0.96);
    box-shadow: 0 16px 34px rgba(95, 34, 10, 0.14);
}

.status-box h2 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    line-height: 1;
    text-transform: uppercase;
}

.status-summary {
    margin: 0 0 0.6rem;
    font-weight: 800;
    line-height: 1.55;
}

.status-list {
    margin: 0.85rem 0 0;
    padding-left: 1.35rem;
}

.status-list li {
    margin-top: 0.55rem;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.status-success {
    border-left-color: #2f8f53;
    background: rgba(231, 250, 235, 0.97);
}

.status-success p {
    margin: 0;
    font-weight: 800;
}

.chaos-note {
    margin: 0.85rem 0 0;
    color: var(--ink-soft);
    font-style: italic;
}

.preview-table {
    overflow-x: auto;
}

.preview-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: rgba(255, 255, 255, 0.72);
    border-radius: 18px;
    overflow: hidden;
}

.preview-grid th,
.preview-cell,
.preview-row-error {
    padding: 0.85rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(33, 24, 19, 0.08);
}

.preview-grid th {
    font-family: var(--display);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: rgba(255, 246, 238, 0.96);
}

.preview-cell {
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.preview-cell-invalid,
.preview-row-error {
    background: #ffe5e5;
    color: #7b1f1f;
}

.preview-correction,
.preview-error-text {
    display: block;
    margin-top: 0.35rem;
    line-height: 1.5;
}

.preview-actions {
    margin-top: 1rem;
    justify-content: center;
}

.empty-state {
    display: grid;
    gap: 0.8rem;
    text-align: center;
    padding: 2rem 1.4rem;
}

.auth-card {
    width: min(520px, 100%);
    margin: 4rem auto;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.4rem;
    flex-wrap: wrap;
}

.site-footer {
    margin-top: 2rem;
    text-align: center;
    padding: 1rem 0 0.5rem;
}

.preview-table {
    display: grid;
    gap: 0.85rem;
}

.preview-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.75);
}

.preview-row p {
    margin: 0.3rem 0 0;
    color: var(--ink-soft);
    line-height: 1.5;
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 20;
    padding: 0.95rem 1.1rem;
    border-radius: 16px;
    background: rgba(33, 24, 19, 0.94);
    color: #fff3ea;
    box-shadow: 0 16px 30px rgba(14, 7, 4, 0.28);
    animation: toast-in 0.25s ease;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes lift-in {
    from {
        opacity: 0;
        transform: translateY(14px) rotate(0.35deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .hero-panel,
    .content-grid,
    .message-hero,
    .admin-grid,
    .page-intro,
    .admin-header,
    .site-header {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .site-nav {
        width: 100%;
    }

    .site-nav a {
        flex: 1 1 150px;
        text-align: center;
    }
}

@media (max-width: 640px) {
    .site-shell {
        width: min(100% - 1rem, 100%);
    }

    .hero-copy h1 {
        font-size: 2.6rem;
    }

    .hero-search,
    .button-row,
    .hero-actions,
    .message-card-actions,
    .filter-actions,
    .button-row.compact {
        flex-direction: column;
    }

    .btn,
    .button-row .btn,
    .hero-actions .btn {
        width: 100%;
        text-align: center;
    }
}
