:root {
    --bg: #f6f2ea;
    --surface: #fffdf9;
    --ink: #24211b;
    --muted: #746e63;
    --line: #e4ddd0;
    --accent: #0f766e;
    --accent-dark: #0b5d57;
    --accent-soft: #e3f2ef;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --success: #166534;
    --success-soft: #e8f5ec;
    --info: #1d4ed8;
    --info-soft: #e8eefc;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(36, 33, 27, 0.05), 0 8px 24px rgba(36, 33, 27, 0.04);
    --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    line-height: 1.65;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--accent-dark);
}

img {
    max-width: 100%;
    height: auto;
}

code {
    font-family: var(--mono);
    font-size: 0.9em;
    background: #efe9dd;
    padding: 0.12em 0.38em;
    border-radius: 5px;
}

.wrap {
    width: min(100% - 40px, 860px);
    margin-inline: auto;
}

/* ---------- Public layout ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 249, 0.82);
    backdrop-filter: blur(8px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-block: 18px;
}

.brand {
    display: flex;
    flex-direction: column;
    color: var(--ink);
    text-decoration: none;
}

.brand-name {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-tagline {
    color: var(--muted);
    font-size: 0.78rem;
}

.site-nav a {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.site-nav a:hover {
    color: var(--accent);
}

.main {
    padding-block: 48px 80px;
}

.hero {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--line);
}

.hero h1 {
    margin: 0 0 12px;
    font-family: var(--serif);
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.hero-tagline {
    margin: 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.post-list {
    display: grid;
}

.post-card {
    padding: 30px 0;
    border-bottom: 1px solid var(--line);
}

.post-card:first-child {
    padding-top: 0;
}

.post-card h2 {
    margin: 6px 0 10px;
    font-family: var(--serif);
    font-size: 1.55rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.post-card h2 a {
    color: var(--ink);
    text-decoration: none;
}

.post-card h2 a:hover {
    color: var(--accent);
}

.meta {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.excerpt {
    margin: 0 0 14px;
    color: #4c473e;
}

.read-more {
    font-size: 0.88rem;
    font-weight: 650;
    text-decoration: none;
}

.read-more:hover {
    text-decoration: underline;
}

.post {
    padding: clamp(24px, 5vw, 56px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.post-header {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}

.post-header h1 {
    margin: 8px 0 0;
    font-family: var(--serif);
    font-size: clamp(1.9rem, 4.5vw, 2.7rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.post-body {
    font-size: 1.04rem;
    line-height: 1.85;
}

.post-body p {
    margin: 0 0 1.35em;
}

.post-body h2 {
    margin: 2em 0 0.7em;
    font-family: var(--serif);
    font-size: 1.55rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.post-body h3 {
    margin: 1.8em 0 0.6em;
    font-family: var(--serif);
    font-size: 1.22rem;
    line-height: 1.3;
}

.post-body ul {
    margin: 0 0 1.35em;
    padding-left: 1.4em;
}

.post-body li {
    margin-bottom: 0.35em;
}

.post-footer {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    font-size: 0.9rem;
}

.empty-state {
    padding: 64px 24px;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

.empty-state h1,
.empty-state h2 {
    margin: 0 0 8px;
    color: var(--ink);
    font-family: var(--serif);
}

.empty-state p {
    margin: 8px 0;
}

.empty-state .btn {
    margin-top: 10px;
}

.error-code {
    margin: 0 0 8px;
    color: var(--accent);
    font-family: var(--serif);
    font-size: 4rem;
    line-height: 1;
}

.site-footer {
    padding-block: 26px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
}

.footer-inner a {
    color: var(--muted);
}

/* ---------- Buttons & forms ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--accent-dark);
    background: var(--accent-dark);
    color: #fff;
}

.btn-secondary {
    border-color: #d8d0c1;
    background: transparent;
    color: var(--ink);
}

.btn-secondary:hover {
    border-color: #d8d0c1;
    background: #efe9dd;
    color: var(--ink);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--accent);
}

.btn-ghost:hover {
    border-color: transparent;
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.btn-danger {
    border-color: var(--danger);
    background: var(--danger);
}

.btn-danger:hover {
    border-color: #8f1c13;
    background: #8f1c13;
}

.btn-danger-outline {
    border-color: #e5b8b3;
    background: transparent;
    color: var(--danger);
}

.btn-danger-outline:hover {
    border-color: #e5b8b3;
    background: var(--danger-soft);
    color: var(--danger);
}

.btn-small {
    padding: 6px 11px;
    font-size: 0.78rem;
}

.btn-block {
    width: 100%;
}

.stack {
    display: grid;
    gap: 20px;
}

.field {
    display: grid;
    gap: 7px;
}

.field label {
    font-size: 0.84rem;
    font-weight: 700;
}

.label-note {
    color: var(--muted);
    font-weight: 400;
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #d8d0c1;
    border-radius: 8px;
    background: #fffdf9;
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
}

textarea {
    resize: vertical;
    line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus,
.btn:focus-visible,
.linklike:focus-visible {
    outline: 2px solid rgba(15, 118, 110, 0.35);
    outline-offset: 1px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.form-card {
    padding: clamp(20px, 4vw, 34px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-narrow {
    max-width: 640px;
}

.hint {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.hint code,
.usage code {
    font-size: 0.82rem;
}

.usage {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.confirm-title {
    margin: 8px 0 0;
    font-family: var(--serif);
    font-size: 1.3rem;
    font-weight: 700;
}

/* ---------- Notices ---------- */

.notice {
    margin-bottom: 20px;
    padding: 12px 15px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.9rem;
}

.notice-success {
    border-color: #bfe0c9;
    background: var(--success-soft);
    color: #14532d;
}

.notice-error {
    border-color: #f3c2bd;
    background: var(--danger-soft);
    color: #7a1a12;
}

.notice-info {
    border-color: #c9d6fa;
    background: var(--info-soft);
    color: #1e3a8a;
}

/* ---------- Admin ---------- */

.admin-body {
    background: #f4f1ea;
}

.admin-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #24211b;
    color: #f6f2ea;
}

.admin-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
    width: min(100% - 40px, 1040px);
    margin-inline: auto;
    padding-block: 14px;
}

.admin-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: #fff;
    font-family: var(--serif);
    font-size: 1.1rem;
    text-decoration: none;
}

.admin-brand span {
    color: #b8b2a7;
    font-family: var(--sans);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
}

.admin-nav a {
    color: #cfc9bd;
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none;
}

.admin-nav a:hover,
.admin-nav a.is-active {
    color: #fff;
}

.admin-nav a.is-active {
    padding-bottom: 2px;
    border-bottom: 2px solid #6ee7d8;
}

.logout-form {
    margin: 0;
}

.linklike {
    padding: 0;
    border: 0;
    background: none;
    color: #cfc9bd;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}

.linklike:hover {
    color: #fff;
}

.admin-main {
    width: min(100% - 40px, 1040px);
    margin-inline: auto;
    padding-block: 40px 80px;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.page-head h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: 2rem;
    letter-spacing: -0.02em;
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
}

.table th {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-align: left;
    text-transform: uppercase;
}

.table td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.table tr:last-child td {
    border-bottom: 0;
}

.table .slug {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.76rem;
}

.table .actions {
    text-align: right;
    white-space: nowrap;
}

.actions-col {
    text-align: right !important;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-published {
    background: var(--success-soft);
    color: var(--success);
}

.badge-draft {
    background: #ece7dc;
    color: var(--muted);
}

/* ---------- Login ---------- */

.auth-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: radial-gradient(1200px 600px at 50% -10%, #e7efe9 0%, var(--bg) 55%);
}

.auth-wrap {
    width: min(100%, 440px);
}

.auth-card {
    padding: clamp(26px, 6vw, 40px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(36, 33, 27, 0.08);
}

.auth-brand {
    display: inline-block;
    margin-bottom: 26px;
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
}

.auth-card h1 {
    margin: 0 0 8px;
    font-family: var(--serif);
    font-size: 1.65rem;
    letter-spacing: -0.01em;
}

.auth-sub {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 0.9rem;
}

.auth-back {
    margin: 24px 0 0;
    font-size: 0.82rem;
    text-align: center;
}

.auth-back a {
    color: var(--muted);
    text-decoration: none;
}

.auth-back a:hover {
    color: var(--accent);
}

.flag-preview {
    display: block;
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f0ebe0;
    color: var(--ink);
    font-family: var(--mono);
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
    .wrap,
    .admin-bar-inner,
    .admin-main {
        width: min(100% - 28px, 100%);
    }

    .main {
        padding-block: 32px 56px;
    }

    .post {
        border-radius: 10px;
    }

    .page-head {
        align-items: flex-start;
    }

    .admin-nav {
        gap: 12px 16px;
    }

    .hero h1 {
        font-size: 2rem;
    }
}
