:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f4;
  --text: #17191c;
  --muted: #6b7178;
  --line: #e6e8e5;
  --accent: #15a05a;
  --accent-ink: #ffffff;
  --accent-soft: #e5f6ec;
  --video: #e2463c;
  --video-soft: #fdeceb;
  --tg: #2aabee;
  --danger: #d93a3a;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(20, 24, 28, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --bg-soft: #1b1e21;
    --text: #eceeef;
    --muted: #9aa1a8;
    --line: #2a2e32;
    --accent: #2fc274;
    --accent-ink: #0b1a11;
    --accent-soft: #173023;
    --video: #ff6b61;
    --video-soft: #3a1d1b;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 var(--font); }
a { color: inherit; }
img { max-width: 100%; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* Шапка */
.site-header { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); z-index: 10; }
.site-header > .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; text-decoration: none; }
.logo-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 800; letter-spacing: -.02em; }
.site-header nav { display: flex; align-items: center; gap: 20px; }
.site-header nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.site-header nav a:hover, .site-header nav a.active { color: var(--text); }
.site-header nav form { margin: 0; }

.site-footer { border-top: 1px solid var(--line); margin-top: 80px; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; padding: 24px 16px; }

/* Головна */
.hero { padding: 64px 0 40px; max-width: 720px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 16px; }
.hero p { font-size: 19px; color: var(--muted); margin: 0; }
section { margin-top: 40px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-head h2 { font-size: 24px; margin: 0; }
.section-head > a:not(.btn) { color: var(--muted); text-decoration: none; }
.page-title { font-size: 36px; margin: 40px 0 24px; letter-spacing: -.01em; }
.empty { color: var(--muted); padding: 32px; background: var(--bg-soft); border-radius: var(--radius); text-align: center; }

/* Картки */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
.card { display: flex; flex-direction: column; text-decoration: none; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--bg); transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-cover { aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--accent-soft), var(--bg-soft)); display: grid; place-items: center; position: relative; overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-cover span { font-size: 54px; font-weight: 800; color: var(--accent); opacity: .6; }
.card-cover.is-video::after { content: "▶"; position: absolute; width: 54px; height: 54px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; font-size: 20px; padding-left: 4px; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body h3 { margin: 4px 0 0; font-size: 19px; line-height: 1.3; }
.card-body p { margin: 0; color: var(--muted); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-body time { color: var(--muted); font-size: 13px; margin-top: auto; padding-top: 6px; }

.tag { align-self: flex-start; display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.tag-guide { background: var(--accent-soft); color: var(--accent); }
.tag-video { background: var(--video-soft); color: var(--video); }

/* Стаття (як у Teletype) */
.post { max-width: 700px; margin: 48px auto 0; }
.post-header h1 { font-size: clamp(30px, 5vw, 42px); line-height: 1.15; letter-spacing: -.02em; margin: 14px 0 12px; }
.post-header .subtitle { font-size: 20px; color: var(--muted); margin: 0 0 16px; }
.post-meta { color: var(--muted); font-size: 15px; margin-bottom: 28px; }
.post-meta address { display: inline; font-style: normal; font-weight: 600; color: var(--text); }
.post figure { margin: 28px 0; }
.post .cover img { border-radius: var(--radius); width: 100%; }
.video, .post-body div[data-youtube-video] { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; margin: 28px 0; }
.video iframe, .post-body div[data-youtube-video] iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.post-body { font-size: 19px; line-height: 1.75; }
.post-body > :first-child { margin-top: 0; }
.post-body p { margin: 0 0 1.1em; }
.post-body h2 { font-size: 28px; line-height: 1.25; margin: 1.8em 0 .6em; letter-spacing: -.01em; }
.post-body h3 { font-size: 22px; line-height: 1.3; margin: 1.5em 0 .5em; }
.post-body a { color: var(--accent); text-underline-offset: 3px; }
.post-body img { display: block; border-radius: 10px; margin: 28px auto; height: auto; }
.post-body blockquote { margin: 1.5em 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--accent); font-family: var(--serif); font-style: italic; font-size: 21px; }
.post-body blockquote p { margin: 0; }
.post-body ul, .post-body ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.post-body li p { margin: 0 0 .35em; }
.post-body hr { border: 0; text-align: center; margin: 2.4em 0; }
.post-body hr::after { content: "• • •"; color: var(--muted); letter-spacing: .6em; }
.post-body code { background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; font-size: .88em; }
.post-body pre { background: var(--bg-soft); padding: 16px 18px; border-radius: 10px; overflow-x: auto; font-size: 15px; line-height: 1.55; }
.post-body pre code { background: none; padding: 0; }

.post-actions { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }

/* Кнопки */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: 500 15px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--bg-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.07); }
.btn-tg { background: var(--tg); border-color: var(--tg); color: #fff; }
.btn-tg:hover { background: var(--tg); filter: brightness(1.07); }
.btn-danger { color: var(--danger); }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.link-btn:hover { color: var(--text); }

/* Вхід і адмінка */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-box h1 { display: flex; align-items: center; gap: 10px; margin: 0; }
.login-box p { margin: 0 0 8px; color: var(--muted); }
.login-box input { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.login-box .btn { justify-content: center; padding: 12px; }
.error { background: var(--video-soft); color: var(--video); padding: 10px 14px; border-radius: 10px; font-size: 15px; }

.admin-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; text-decoration: none; border-bottom: 1px solid var(--line); }
.admin-row:last-child { border-bottom: 0; }
.admin-row:hover { background: var(--bg-soft); }
.admin-row strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .muted { font-size: 14px; }
.status { font-size: 13px; font-weight: 600; min-width: 108px; }
.status-published { color: var(--accent); }
.status-draft { color: var(--muted); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .post { margin-top: 28px; }
  .post-body { font-size: 18px; }
  .admin-row { flex-wrap: wrap; gap: 6px 10px; }
  .admin-row strong { flex-basis: 100%; order: -1; }
  .status { min-width: 0; }
}

/* Вкладки розділів */
.site-header .cat-tabs { display: block; border-top: 1px solid var(--line); }
.cat-tabs .wrap { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-top: 8px; padding-bottom: 8px; }
.cat-tabs .wrap::-webkit-scrollbar { display: none; }
.cat-tabs a { flex: none; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 15px; padding: 6px 14px; border-radius: 99px; white-space: nowrap; }
.cat-tabs a:hover { color: var(--text); background: var(--bg-soft); }
.cat-tabs a.active { color: var(--accent-ink); background: var(--accent); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.cat-tile { display: flex; flex-direction: column; gap: 4px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; background: linear-gradient(160deg, var(--accent-soft), transparent 70%); transition: transform .15s, box-shadow .15s; }
.cat-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.cat-tile strong { font-size: 19px; margin-top: 6px; }
.cat-tile .muted { font-size: 14px; }
.cat-icon { font-size: 28px; line-height: 1; }
.cat-count { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--accent); }

.cat-head { margin-bottom: 24px; }
.cat-head .page-title { margin-bottom: 6px; }
.cat-head > p { margin: 0 0 18px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { text-decoration: none; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.pill:hover { color: var(--text); }
.pill.active { border-color: var(--text); color: var(--text); font-weight: 600; }

.tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tags a { text-decoration: none; }
.cat-label { font-size: 13px; color: var(--muted); font-weight: 500; }

/* Telegram-канал і підтримка */
.tg-icon { width: 18px; height: 18px; flex: none; }
.btn-sm { padding: 7px 14px; font-size: 14px; }
.btn-lg { padding: 12px 20px; font-size: 16px; }
.site-header nav .btn-tg { color: #fff; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.footer-links { display: flex; gap: 20px; }

.cta-box { display: flex; flex-direction: column; gap: 16px; padding: 22px; border-radius: var(--radius); background: linear-gradient(150deg, color-mix(in srgb, var(--tg) 16%, transparent), var(--bg-soft)); border: 1px solid var(--line); margin-bottom: 20px; }
.cta-box strong { font-size: 19px; }
.cta-box p { margin: 6px 0 0; color: var(--muted); font-size: 16px; }
.cta-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.share-link { font-size: 15px; text-decoration: none; }

.support-fab { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px; text-decoration: none; box-shadow: var(--shadow); transition: transform .15s; }
.support-fab:hover { transform: translateY(-2px); }
.site-footer { padding-bottom: 60px; }

@media (max-width: 600px) {
  .site-header nav { gap: 14px; }
  .site-header nav .btn-tg { padding: 7px 10px; }
  .site-header nav .btn-tg span { display: none; }
  .support-fab { right: 14px; bottom: 14px; padding: 12px 14px; }
  .support-fab span { display: none; }
  .site-footer .wrap { flex-direction: column; gap: 10px; }
  .hero-actions .btn { flex: 1; justify-content: center; }
}
