:root {
    color-scheme: light;
    --ink: #20201e;
    --muted: #66635d;
    --paper: #f7f4ee;
    --panel: #ffffff;
    --line: #d7c8b3;
    --accent: #9e3f24;
    --accent-dark: #702915;
    --blue: #315f78;
    --green: #4d6f42;
    font-family: "Segoe UI", Arial, sans-serif;
}

html {
    scroll-behavior: smooth;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
}

a {
    color: inherit;
}

button,
.button {
    align-items: center;
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--accent-dark);
}

.button.secondary {
    background: #2f4e5e;
}

.topbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    justify-content: space-between;
    padding: 14px clamp(18px, 4vw, 56px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 800;
    text-decoration: none;
}

.topbar nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    justify-content: center;
    text-align: center;
}

.topbar form {
    margin: 0;
}

.topbar button {
    background: transparent;
    color: var(--ink);
    min-height: auto;
    padding: 0;
}

.flash,
.errors {
    background: #fff3d4;
    border: 1px solid #d2a84f;
    border-radius: 8px;
    margin: 20px auto 0;
    max-width: 1100px;
    padding: 12px 16px;
}


.errors {
    background: #ffe8e2;
    border-color: #d28a78;
}


.eyebrow {
    color: var(--accent);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 10px;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    line-height: 1.05;
    margin: 0;
}

.lede {
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    line-height: 1.55;
    max-width: 640px;
}

.milestone {
    background: var(--panel);
    border: 1px solid #e2d8c8;
    border-radius: 8px;
    padding: 18px;
}

.milestone.is-clickable {
    cursor: pointer;
}

.milestone.is-clickable:hover {
    border-color: var(--accent);
}

.milestone time {
    color: var(--blue);
    display: inline-block;
    font-weight: 800;
    margin-right: 10px;
}

.milestone span {
    color: var(--green);
    font-size: .86rem;
    font-weight: 800;
    text-transform: uppercase;
}

.milestone p {
    line-height: 1.55;
    margin: 10px 0 0;
}

.milestone-thumbnail {
    background: #f7f4ee;
    border-radius: 6px;
    display: block;
    margin-bottom: 14px;
    max-height: 260px;
    max-width: 100%;
    object-fit: contain;
    width: min(100%, 420px);
}

.milestone button {
    margin-top: 14px;
}

.milestone .milestone-media-button {
    border-radius: 5px;
    font-size: .86rem;
    min-height: 32px;
    padding: 7px 11px;
}

.modal {
    align-items: center;
    background: rgba(0, 0, 0, .72);
    display: none;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    z-index: 30;
}

.modal.is-open {
    display: flex;
}

.modal-panel {
    background: #111;
    border-radius: 8px;
    color: #fff;
    max-height: 90vh;
    max-width: 960px;
    padding: 18px;
    position: relative;
    width: 100%;
}

.modal-close {
    background: #fff;
    color: #111;
    min-height: 34px;
    padding: 6px 12px;
    position: absolute;
    right: 14px;
    top: 14px;
    z-index: 2;
}

.modal img,
.modal video,
.modal iframe {
    aspect-ratio: 16 / 9;
    border: 0;
    max-height: 70vh;
    object-fit: contain;
    width: 100%;
}

#modalCaption {
    line-height: 1.55;
    padding: 14px 4px 0;
}

.modal-link-button {
    border-radius: 5px;
    display: table;
    font-size: .78rem;
    letter-spacing: .08em;
    margin-top: 16px;
    min-height: 28px;
    padding: 5px 9px;
    text-transform: uppercase;
}

.admin-header,
.stats-grid,
.danger-zone,
.filter-panel,
.import-map-form,
.auth-panel,
.milestone-form,
.table-wrap {
    margin: 28px auto;
    max-width: 1100px;
    padding: 0 20px;
}

.admin-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.header-actions,
.modal-actions {
    align-items: center;
    display: flex;
    gap: 10px;
}

.filter-panel form {
    align-items: end;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding: 16px;
}

.filter-search {
    grid-column: span 2;
}

.filter-actions {
    display: flex;
    gap: 10px;
}

.mapping-grid {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 20px;
}

.mapping-grid label span {
    color: var(--accent);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.import-preview {
    padding: 0;
}

.import-preview h2 {
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.import-actions {
    margin-top: 18px;
}

.sort-link {
    align-items: center;
    color: var(--ink);
    display: inline-flex;
    font-weight: 800;
    gap: 6px;
    min-height: 30px;
    text-decoration: none;
}

.sort-link:hover {
    color: var(--accent);
}

.sort-link span {
    background: #fff;
    border: 1px solid #cfbea8;
    border-radius: 999px;
    color: var(--accent);
    display: inline-flex;
    font-size: .82rem;
    height: 24px;
    justify-content: center;
    line-height: 1;
    width: 24px;
}

.sort-link:not(.is-active) span {
    display: none;
}

.stats-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.admin-section-header {
    margin: 28px auto 12px;
    max-width: 1100px;
    width: 100%;
}

.admin-section-header h2 {
    color: var(--ink);
    font-size: 1.15rem;
    margin: 0;
}

.subscriber-stats {
    margin-top: 0;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 20px;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: 0 12px 28px rgba(32, 32, 30, .12);
    transform: translateY(-2px);
}

.stat-card.total {
    background: #2f4e5e;
    color: #fff;
}

.stat-card span {
    color: var(--muted);
    font-weight: 800;
}

.stat-card.total span {
    color: #eaf3f5;
}

.stat-card strong {
    font-size: 2.6rem;
    line-height: 1;
}

.auth-panel {
    max-width: 440px;
}

.stacked-form,
.milestone-form {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 18px;
    padding: 22px;
}

.stacked-form.plain {
    border: 0;
    padding: 0;
}

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

label {
    display: grid;
    font-weight: 800;
    gap: 8px;
}

input,
select,
textarea {
    border: 1px solid #cfc3b3;
    border-radius: 6px;
    font: inherit;
    padding: 10px 12px;
    width: 100%;
}

textarea {
    resize: vertical;
}

.wysiwyg {
    display: grid;
    gap: 8px;
}

.wysiwyg-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wysiwyg-toolbar button {
    background: #2f4e5e;
    border-radius: 5px;
    min-height: 34px;
    min-width: 36px;
    padding: 7px 10px;
}

.wysiwyg-editor {
    background: #fff;
    border: 1px solid #cfc3b3;
    border-radius: 6px;
    line-height: 1.55;
    min-height: 180px;
    padding: 10px 12px;
}

.wysiwyg-editor:focus,
.wysiwyg-source:focus {
    outline: 2px solid rgba(49, 95, 120, .25);
    outline-offset: 2px;
}

.wysiwyg-source {
    display: none;
    font-family: Consolas, "Courier New", monospace;
    min-height: 180px;
}

.wysiwyg.is-html .wysiwyg-editor {
    display: none;
}

.wysiwyg.is-html .wysiwyg-source {
    display: block;
}

.wide {
    grid-column: 1 / -1;
}

.checkbox {
    align-items: center;
    display: flex;
    font-weight: 500;
}

.checkbox input {
    width: auto;
}

table {
    background: #fff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid #e9dfd2;
    padding: 13px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #ece3d6;
}

.status {
    border-radius: 999px;
    display: inline-block;
    font-size: .8rem;
    font-weight: 800;
    padding: 4px 9px;
}

.status.published {
    background: #e0f0dc;
    color: #315723;
}

.status.draft {
    background: #efe6ce;
    color: #76530c;
}

.actions {
    display: flex;
    gap: 12px;
}

.actions form {
    margin: 0;
}

.actions button {
    background: transparent;
    color: var(--accent);
    min-height: auto;
    padding: 0;
}

.empty {
    font-size: 1.2rem;
}

.table-empty {
    color: var(--muted);
    font-weight: 800;
    padding: 34px 18px;
    text-align: center;
}

.admin-modal-panel {
    background: #fff;
    color: var(--ink);
    max-width: 520px;
}

.admin-modal-panel h2 {
    margin-bottom: 22px;
    padding-right: 46px;
}

.danger-zone {
    background: #fff;
    border: 1px solid #d28a78;
    border-radius: 8px;
    padding: 20px;
}

.danger-zone h2 {
    color: var(--accent-dark);
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.danger-zone p {
    color: var(--muted);
}

.pagination-wrap {
    margin: 18px auto 56px;
    max-width: 1100px;
    padding: 0 20px;
}

.pagination-wrap nav {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(32, 32, 30, .08);
    padding: 12px;
}

.pagination-wrap nav > div:first-child {
    display: none;
}

.pagination-wrap nav > div:last-child {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.pagination-wrap span,
.pagination-wrap a {
    align-items: center;
    border-radius: 6px;
    display: inline-flex;
    font-weight: 800;
    justify-content: center;
    min-height: 36px;
    min-width: 36px;
    margin-right: 6px;
    padding: 8px 11px;
    text-decoration: none;
}

.pagination-wrap a {
    background: #f7f4ee;
    border: 1px solid #e3d6c5;
    color: var(--ink);
}

.pagination-wrap a:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pagination-wrap [aria-current="page"] span {
    background: var(--blue);
    border: 1px solid var(--blue);
    color: #fff;
}

.pagination-wrap [aria-disabled="true"] span {
    background: #f1ece4;
    border: 1px solid #e3d6c5;
    color: #9a9082;
}

@media (max-width: 760px) {
    .admin-header,
    .header-actions,
    .modal-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .milestone-form {
        grid-template-columns: 1fr;
    }

    .filter-panel form {
        grid-template-columns: 1fr;
    }

    .mapping-grid {
        grid-template-columns: 1fr;
    }

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

