/* ---------- Theme variables ---------- */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1b1f24;
    --muted: #6b7280;
    --accent: #d62839;
    --border: #e3e6ea;
    --shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
[data-theme="dark"] {
    --bg: #0f1216;
    --surface: #181c22;
    --text: #e8eaed;
    --muted: #9aa3ae;
    --border: #2a3039;
    --shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: min(1100px, 92%); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 0;
}
.logo { font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px; }
.logo span { color: var(--accent); }
.header-tools { display: flex; gap: .5rem; align-items: center; }
#searchBox {
    padding: .5rem .9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text);
    width: 220px;
    max-width: 45vw;
}
.icon-btn {
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    font-size: 1rem;
}
.nav {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    padding-bottom: .5rem;
}
.nav a {
    padding: .35rem .9rem;
    border-radius: 999px;
    font-size: .92rem;
    white-space: nowrap;
    color: var(--muted);
}
.nav a:hover { color: var(--text); }
.nav a.active { background: var(--accent); color: #fff; }

/* ---------- Layout ---------- */
main { padding: 1.5rem 0 3rem; min-height: 70vh; }
.section-title { margin: 0 0 1.2rem; font-size: 1.6rem; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform .15s;
}
.card:hover { transform: translateY(-3px); }
.card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--border); }
.card-body { padding: 1rem; }
.card h3 { margin: .4rem 0; font-size: 1.1rem; line-height: 1.3; }
.card p { margin: 0 0 .6rem; color: var(--muted); font-size: .95rem; }
small { color: var(--muted); }
.tag {
    display: inline-block;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: .15rem .6rem;
    border-radius: 999px;
}

.featured { flex-direction: row; margin-bottom: 1.5rem; }
.featured img { width: 55%; aspect-ratio: auto; height: 100%; min-height: 280px; }
.featured-body { padding: 1.5rem; display: flex; flex-direction: column; justify-content: center; }
.featured h2 { font-size: 1.8rem; line-height: 1.25; margin: .6rem 0; }
.featured p { color: var(--muted); }

/* ---------- Pagination ---------- */
.pagination { display: flex; justify-content: center; gap: .4rem; margin-top: 2rem; }
.pagination a {
    min-width: 38px;
    text-align: center;
    padding: .4rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.pagination a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Article page ---------- */
.article { max-width: 760px; margin: 0 auto; }
.article h1 { font-size: 2.2rem; line-height: 1.2; margin: .6rem 0; }
.meta { color: var(--muted); }
.hero { width: 100%; border-radius: 12px; margin: 1rem 0 1.5rem; }
.body p { font-size: 1.08rem; margin: 0 0 1.1rem; }
.related { max-width: 760px; margin: 2.5rem auto 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.related li { margin: .4rem 0; }
.related a:hover { color: var(--accent); }

/* ---------- Forms / admin ---------- */
.form { display: grid; gap: 1rem; background: var(--surface); padding: 1.25rem; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 2rem; }
.form.narrow { max-width: 360px; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
.form input, .form select, .form textarea {
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.btn {
    background: var(--accent);
    color: #fff;
    border: 0;
    padding: .65rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    justify-self: start;
}
.btn.danger { background: #6b7280; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.alert { padding: .7rem 1rem; border-radius: 8px; }
.alert.error { background: #fde8ea; color: #9b1c2c; }
.alert.ok { background: #e3f6e8; color: #1c6b34; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table td { padding: .6rem; border-bottom: 1px solid var(--border); }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 1.5rem 0; text-align: center; color: var(--muted); font-size: .9rem; }
.site-footer p { margin: .2rem 0; }
.site-footer a { text-decoration: underline; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
    .featured { flex-direction: column; }
    .featured img { width: 100%; min-height: 0; aspect-ratio: 16 / 9; }
    .featured h2 { font-size: 1.4rem; }
    .article h1 { font-size: 1.7rem; }
    .row { grid-template-columns: 1fr; }
}
