:root {
    --forest: #0f3d2e;
    --forest-2: #164a38;
    --gold: #c9a227;
    --gold-2: #e3c15d;
    --paper: #f6f4ef;
    --ink: #1a1f1d;
    --muted: #5c6a63;
    --card: #ffffff;
    --border: rgba(15, 61, 46, 0.12);
    --shadow: 0 10px 30px rgba(15, 61, 46, 0.08);
}

html[data-theme="dark"] {
    --forest: #9ad4b9;
    --forest-2: #6fb896;
    --gold: #e3c15d;
    --gold-2: #f2dc98;
    --paper: #0f1412;
    --ink: #eef3f0;
    --muted: #a7b5ad;
    --card: #151c19;
    --border: rgba(233, 239, 235, 0.12);
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    font-size: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
}

body.nav-open,
body.admin-nav-open {
    overflow: hidden;
}

img, video {
    max-width: 100%;
    height: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

h1, h2, h3, .headline {
    font-family: Merriweather, Georgia, "Times New Roman", serif;
    color: var(--forest);
    letter-spacing: -0.02em;
    line-height: 1.2;
    word-wrap: break-word;
}

.headline {
    font-size: clamp(1.2rem, 1rem + 1.1vw, 1.95rem);
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .headline {
    color: var(--forest);
}

a { color: var(--forest-2); text-decoration-thickness: 0.08em; }
a:hover { color: var(--gold); }

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--forest-2);
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

.site-header, .site-footer {
    position: sticky;
    z-index: 20;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.site-header {
    top: 0;
    z-index: 100;
}

.site-footer {
    position: relative;
    border-top: 1px solid var(--border);
    border-bottom: none;
    margin-top: 4rem;
}

.header-inner, .footer-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.75rem clamp(0.75rem, 2vw, 1.25rem);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: space-between;
    position: relative;
}

.header-inner {
    flex-wrap: nowrap;
    min-height: 3.25rem;
    padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
}

.footer-inner {
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--forest);
    text-decoration: none;
    min-width: 0;
    flex-shrink: 1;
}

.brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(52vw, 14rem);
}

@media (min-width: 480px) {
    .brand-text { max-width: min(40vw, 20rem); }
}

@media (min-width: 768px) {
    .brand-text { max-width: none; white-space: normal; overflow: visible; text-overflow: clip; }
}

.brand-logo {
    border-radius: 8px;
    flex-shrink: 0;
}

.header-end {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.site-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.site-nav-toggle-icon {
    display: block;
    flex-shrink: 0;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-width: 0;
}

.site-nav a {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 0.55rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.site-nav a:hover { background: color-mix(in srgb, var(--gold) 22%, transparent); }

.nav-search { color: var(--forest-2) !important; }

.theme-toggle {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--ink);
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 767px) {
    .site-nav-toggle {
        display: inline-flex;
    }

    .site-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
        flex: none;
        gap: 0;
        padding: 0.35rem 0.75rem 1rem;
        margin: 0;
        background: color-mix(in srgb, var(--paper) 98%, var(--card));
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
        max-height: min(70vh, 28rem);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .site-header.is-nav-open .site-nav {
        display: flex;
    }

    .site-nav a {
        width: 100%;
        border-radius: 10px;
        padding: 0.65rem 0.75rem;
    }

    .site-header.is-nav-open .site-nav-toggle {
        border-color: var(--forest-2);
        color: var(--forest-2);
    }
}

@media (min-width: 768px) {
    .header-inner {
        gap: 1rem;
    }

    .site-nav {
        justify-content: center;
        gap: 0.5rem 0.65rem;
    }
}

.site-main {
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 1.5rem) clamp(0.75rem, 3vw, 1.25rem) max(3rem, calc(2rem + env(safe-area-inset-bottom, 0px)));
}

.muted { color: var(--muted); }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 900px) {
    .grid-hero { grid-template-columns: 2fr 1fr; align-items: start; }
}

.hero {
    overflow: hidden;
}

.hero img {
    width: 100%;
    height: auto;
    border-radius: 14px;
    display: block;
}

.pill {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--gold) 35%, transparent);
    color: var(--forest);
    font-weight: 700;
    font-size: 0.78rem;
}

.section-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin: 2rem 0 0.75rem;
}

.article-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.article-list a { text-decoration: none; color: inherit; }
.article-list li { padding: 0.35rem 0; border-bottom: 1px dashed var(--border); }

.latest-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}

.ad-placeholder {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    color: var(--muted);
    margin: 2rem 0;
}

form .field { margin-bottom: 0.85rem; }
label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], textarea, select {
    width: 100%;
    max-width: min(720px, 100%);
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--ink);
}

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: none;
    border-radius: 12px;
    padding: 0.65rem 1rem;
    min-height: 44px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, var(--forest), var(--forest-2));
    color: #fbfaf3;
    -webkit-tap-highlight-color: transparent;
}

button.secondary, .btn.secondary {
    background: transparent;
    color: var(--forest);
    border: 1px solid var(--border);
}

.alert { padding: 0.75rem 1rem; border-radius: 12px; border: 1px solid var(--border); margin: 1rem 0; }
.alert-error { background: color-mix(in srgb, #ff6b6b 12%, transparent); }
.alert-success { background: color-mix(in srgb, var(--gold) 18%, transparent); }

.article-body img { max-width: 100%; height: auto; border-radius: 12px; }

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.auth-card { width: min(520px, 100%); }

.admin-body { background: var(--paper); }

.admin-header {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(10px);
}

.admin-header-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.75rem clamp(0.75rem, 2vw, 1.25rem);
    padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    justify-content: space-between;
    position: relative;
    min-height: 3.25rem;
}

.admin-brand {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.admin-nav {
    display: flex;
    gap: 0.5rem 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.admin-nav a {
    font-weight: 600;
    text-decoration: none;
    padding: 0.5rem 0.45rem;
    border-radius: 8px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.admin-nav a:hover {
    background: color-mix(in srgb, var(--gold) 18%, transparent);
}

@media (max-width: 639px) {
    .admin-nav-toggle {
        display: inline-flex;
    }

    .admin-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
        padding: 0.35rem 0.75rem 1rem;
        background: color-mix(in srgb, var(--paper) 98%, var(--card));
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
        max-height: min(70vh, 22rem);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .admin-header.is-nav-open .admin-nav {
        display: flex;
    }

    .admin-header.is-nav-open .admin-nav-toggle {
        border-color: var(--forest-2);
        color: var(--forest-2);
    }

    .admin-nav a {
        width: 100%;
        padding: 0.65rem 0.75rem;
    }
}

.admin-main { max-width: 1180px; margin: 0 auto; padding: clamp(1rem, 3vw, 1.25rem); }

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    overscroll-behavior-x: contain;
}

.table { width: 100%; min-width: 36rem; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.table th, .table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { background: color-mix(in srgb, var(--forest) 8%, transparent); }

@media (max-width: 639px) {
    .table th:nth-child(3),
    .table td:nth-child(3) { white-space: nowrap; }
}

.inline-form { display: inline; }

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
}

@media (max-width: 639px) {
    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

.article-body {
    overflow-wrap: anywhere;
    word-break: break-word;
}
