/* ---------- Design tokens ---------- */
:root {
  --bg:           #f6f1e7;
  --bg-elevated:  #ffffff;
  --surface:      #fffdf8;
  --ink:          #1c2620;
  --ink-soft:     #4a5650;
  --ink-mute:     #7a857f;
  --line:         #e3dccc;
  --line-strong:  #c8c0ac;
  --accent:       #2b3a2f;
  --accent-hover: #3a4f3f;
  --accent-soft:  #d8e2d6;
  --warm:         #b6552c;
  --tag-bg:       #ece4cf;
  --shadow-sm:    0 1px 2px rgba(28,38,32,.06), 0 1px 3px rgba(28,38,32,.04);
  --shadow-md:    0 4px 12px rgba(28,38,32,.08), 0 2px 4px rgba(28,38,32,.04);
  --shadow-lg:    0 18px 40px rgba(28,38,32,.10), 0 6px 14px rgba(28,38,32,.06);
  --radius:       14px;
  --radius-sm:    8px;
  --maxw:         1200px;
  --serif:        ui-serif, "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, serif;
  --sans:         system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg:           #14181a;
  --bg-elevated:  #1c2123;
  --surface:      #20262a;
  --ink:          #ece6d6;
  --ink-soft:     #b9b6ac;
  --ink-mute:     #807d72;
  --line:         #2c3236;
  --line-strong:  #3c4248;
  --accent:       #b9d3a8;
  --accent-hover: #cfe2bf;
  --accent-soft:  #2a3a30;
  --warm:         #e08a5e;
  --tag-bg:       #2a3036;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
  --shadow-md:    0 6px 18px rgba(0,0,0,.45);
  --shadow-lg:    0 18px 40px rgba(0,0,0,.55);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
p { margin: 0 0 1em; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--bg-elevated);
  padding: 10px 16px; border-radius: 6px; z-index: 100;
}
.skip:focus { left: 12px; top: 12px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* Top bar */
.topbar { background: var(--accent); color: #f4ede0; font-size: 13px; }
[data-theme="dark"] .topbar { color: var(--ink); background: var(--bg-elevated); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; padding-top: 10px; padding-bottom: 10px; gap: 16px; }
.topbar a { color: inherit; opacity: .85; }
.topbar a:hover { opacity: 1; }
.topbar-links { display: flex; gap: 18px; flex-wrap: wrap; }
.social { display: flex; gap: 12px; align-items: center; }
.social a { display: inline-flex; padding: 4px; border-radius: 50%; }
.social svg { width: 16px; height: 16px; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.12); color: inherit;
  font-size: 12px; transition: background .15s;
}
.theme-toggle:hover { background: rgba(255,255,255,.22); }
[data-theme="dark"] .theme-toggle { background: var(--surface); border: 1px solid var(--line); }

.lang-switch {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 22px; padding: 0 8px;
  border-radius: 11px;
  background: rgba(255,255,255,.12); color: inherit !important;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-decoration: none; opacity: 1 !important;
  transition: background .15s;
}
.lang-switch:hover { background: rgba(255,255,255,.22); }
[data-theme="dark"] .lang-switch { background: var(--surface); border: 1px solid var(--line); }

/* Masthead */
.masthead { background: var(--bg-elevated); border-bottom: 1px solid var(--line); }
.masthead .wrap { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding-top: 28px; padding-bottom: 28px; gap: 16px; }
.brand { grid-column: 2; text-align: center; display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.brand-logo { font-family: var(--serif); font-size: clamp(28px, 4vw, 44px); font-weight: 700; letter-spacing: .04em; color: var(--ink); }
.brand-tag { font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--ink-mute); }
.masthead-end { grid-column: 3; display: flex; justify-content: flex-end; gap: 8px; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: var(--ink-soft); transition: background .15s, color .15s; }
.iconbtn:hover { background: var(--accent-soft); color: var(--ink); }
.iconbtn svg { width: 20px; height: 20px; }

.user-block { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.logout-form { margin: 0; padding: 0; }
.user-name {
  font-size: 11px; letter-spacing: .04em; font-weight: 500;
  color: var(--ink-mute); max-width: 90px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: none; line-height: 1;
}
.user-name:hover { color: var(--accent); }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,253,248,.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
[data-theme="dark"] .nav { background: rgba(20,24,26,.85); }
.nav .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav-list { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-list a {
  display: inline-block; padding: 16px 14px;
  color: var(--ink); font-size: 14.5px; font-weight: 500; letter-spacing: .01em;
  position: relative;
}
.nav-list a::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 10px;
  height: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform .2s ease;
}
.nav-list a:hover::after, .nav-list a[aria-current="page"]::after { transform: scaleX(1); }
.nav-list a[aria-current="page"] { color: var(--accent); }
.menu-btn { display: none; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.menu-btn svg { width: 22px; height: 22px; }
.nav-search {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px 6px 14px;
  min-width: 220px; transition: border-color .15s, background .15s;
}
.nav-search:focus-within { border-color: var(--accent); background: var(--bg-elevated); }
.nav-search svg { width: 16px; height: 16px; color: var(--ink-mute); flex: none; }
.nav-search input { border: 0; background: transparent; outline: none; font: inherit; color: var(--ink); width: 100%; padding: 4px 0; }
.nav-search input::placeholder { color: var(--ink-mute); }

/* Hero */
.hero { padding: 48px 0 16px; }
.hero-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 32px; align-items: stretch; }
.hero-card {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-elevated); box-shadow: var(--shadow-md);
  min-height: 460px; display: flex; isolation: isolate;
}
.hero-illu {
  position: absolute; inset: 0;
  background:
    radial-gradient(800px 400px at 70% 30%, #f4dcc7 0%, transparent 60%),
    linear-gradient(135deg, #cdd9c4 0%, #8aa093 100%);
  z-index: -1;
}
[data-theme="dark"] .hero-illu {
  background:
    radial-gradient(800px 400px at 70% 30%, #3d3328 0%, transparent 60%),
    linear-gradient(135deg, #1f2a23 0%, #2c3a31 100%);
}
.hero-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(255,255,255,.78) 100%);
  z-index: -1;
}
[data-theme="dark"] .hero-card::after {
  background: linear-gradient(180deg, transparent 50%, rgba(20,24,18,.72) 100%);
}
.hero-content { margin-top: auto; padding: 36px 36px 32px; color: #111; max-width: 640px; }
.hero-content .pill { background: rgba(255,255,255,.78); color: #111; }
.hero-content h1 { font-size: clamp(28px, 3.4vw, 40px); margin-bottom: 12px; color: #111; }
.hero-content p { color: rgba(20,20,20,.85); font-size: 17px; }
.hero-meta { display: flex; gap: 12px; align-items: center; color: rgba(20,20,20,.78); font-size: 13px; flex-wrap: wrap; }
[data-theme="dark"] .hero-content { color: #fff; }
[data-theme="dark"] .hero-content .pill { background: rgba(255,255,255,.18); color: #fff; }
[data-theme="dark"] .hero-content h1 { color: #fff; }
[data-theme="dark"] .hero-content p { color: rgba(255,255,255,.88); }
[data-theme="dark"] .hero-meta { color: rgba(255,255,255,.85); }

.hero-side { display: flex; flex-direction: column; gap: 16px; }
.side-card {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  transition: transform .15s ease, box-shadow .15s ease;
  display: block; color: inherit;
}
.side-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: inherit; }
.side-card .pill { font-size: 11px; }
.side-card h3 { font-size: 18px; margin: 8px 0 6px; color: var(--ink); }
.side-card:hover h3 { color: var(--accent); }
.side-card .meta { font-size: 12px; color: var(--ink-mute); }

/* Pills */
.pill {
  display: inline-block; padding: 4px 10px; font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  background: var(--tag-bg); color: var(--ink-soft); border-radius: 999px;
}
.pill.warm { background: #f4dcc7; color: #6e3617; }
[data-theme="dark"] .pill.warm { background: #3d2a1d; color: #e08a5e; }

/* Sections */
.section { padding: 48px 0; }
.section-head {
  display: flex; align-items: end; justify-content: space-between; gap: 16px;
  margin-bottom: 28px; border-bottom: 1px solid var(--line); padding-bottom: 14px;
}
.section-head h2 { font-size: clamp(22px, 2.4vw, 28px); margin: 0; }
.section-head a { font-size: 14px; color: var(--ink-soft); }
.section-head a:hover { color: var(--accent); }

.layout { display: grid; grid-template-columns: 1fr 320px; gap: 48px; padding: 16px 0 64px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }

.card {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.card-art { aspect-ratio: 16/9; background: linear-gradient(135deg, #cdd9c4, #8aa093); position: relative; overflow: hidden; }
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { font-size: 20px; margin: 4px 0 4px; color: var(--ink); }
.card a:hover h3 { color: var(--accent); }
.card p { color: var(--ink-soft); font-size: 14.5px; margin: 0; }
.card .meta { margin-top: auto; padding-top: 12px; display: flex; gap: 12px; align-items: center; color: var(--ink-mute); font-size: 12.5px; flex-wrap: wrap; }
.card .meta .dot { width: 3px; height: 3px; background: currentColor; border-radius: 50%; opacity: .6; }

.art-1 { background: linear-gradient(135deg,#d6cfa8,#a89c5e); }
.art-2 { background: linear-gradient(135deg,#cdd9c4,#7a9385); }
.art-3 { background: linear-gradient(135deg,#e6cdbe,#b6552c); }
.art-4 { background: linear-gradient(135deg,#c0c8d4,#5d6f86); }
.art-5 { background: linear-gradient(135deg,#dccfe0,#8e6c97); }
.art-6 { background: linear-gradient(135deg,#e8d8c0,#a07c4d); }
.art-7 { background: linear-gradient(135deg,#cad9c2,#5b7d62); }
.art-8 { background: linear-gradient(135deg,#b8b0a0,#6b6357); }
.card-art::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 80% at 30% 20%, rgba(255,255,255,.35), transparent 60%); }

/* Dark mode — dim the images to match the muted palette */
[data-theme="dark"] .card-art,
[data-theme="dark"] .recent .thumb,
[data-theme="dark"] .article-body img,
[data-theme="dark"] .cover img,
[data-theme="dark"] .hero-illu {
  filter: brightness(.5) contrast(1.05) saturate(.85);
  transition: filter .2s ease;
}
[data-theme="dark"] .card:hover .card-art,
[data-theme="dark"] .recent .item:hover .thumb {
  filter: brightness(.78) contrast(1.05) saturate(.85);
}
[data-theme="dark"] .card-art::after { background: radial-gradient(60% 80% at 30% 20%, rgba(255,255,255,.10), transparent 60%); }

aside.sidebar { display: flex; flex-direction: column; gap: 28px; }
.widget { background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.widget h4 {
  font-family: var(--sans); font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-mute); margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.widget ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.widget ul a { color: var(--ink); display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.widget ul a:hover { color: var(--accent); }
.widget ul .count { color: var(--ink-mute); font-size: 12px; }

.recent { display: grid; gap: 14px; }
.recent .item { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; color: inherit; }
.recent .item:hover h5 { color: var(--accent); }
.recent .thumb { width: 56px; height: 56px; border-radius: 8px; background: linear-gradient(135deg, #cdd9c4, #8aa093); }
.recent h5 { font-family: var(--serif); font-weight: 600; font-size: 14.5px; margin: 0 0 4px; line-height: 1.3; color: var(--ink); }
.recent .meta { color: var(--ink-mute); font-size: 12px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags a { background: var(--tag-bg); color: var(--ink-soft); padding: 5px 10px; border-radius: 999px; font-size: 12px; }
.tags a:hover { background: var(--accent-soft); color: var(--ink); }

.newsletter { background: var(--accent); color: #f4ede0; border-color: var(--accent); }
[data-theme="dark"] .newsletter { background: var(--accent-soft); color: var(--ink); border-color: var(--accent-soft); }
.newsletter h4 { color: inherit; opacity: .8; border-color: rgba(255,255,255,.18); }
[data-theme="dark"] .newsletter h4 { border-color: var(--line); }
.newsletter p { font-size: 14px; opacity: .92; }
.newsletter form { display: flex; gap: 8px; margin-top: 8px; }
.newsletter input {
  flex: 1; min-width: 0;
  padding: 10px 12px; border-radius: 8px; border: 0;
  font: inherit; background: rgba(255,255,255,.95); color: var(--ink);
}
[data-theme="dark"] .newsletter input { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.newsletter button {
  padding: 10px 14px; border-radius: 8px;
  background: #f4ede0; color: var(--accent); font-weight: 600;
  transition: transform .12s ease;
}
[data-theme="dark"] .newsletter button { background: var(--accent); color: #f4ede0; }
.newsletter button:hover { transform: translateY(-1px); }

/* AdSense slots — keep them subtle and capped */
.adslot {
  margin: 24px auto;
  text-align: center;
  max-width: 100%;
  position: relative;
}
.adslot::before {
  content: "Реклама";
  display: block;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 6px;
  opacity: .55;
}
[lang="en"] .adslot::before { content: "Advertisement"; }
.adslot .adsbygoogle {
  max-width: 100%;
  display: inline-block;
}
.adslot-rect {
  max-width: 320px;
  margin: 16px auto;
}
.adslot-rect .adsbygoogle {
  width: 300px;
  height: 250px;
}
.adslot-inline {
  max-width: 640px;
  margin: 24px auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.adslot-inline .adsbygoogle {
  max-height: 280px;
  overflow: hidden;
}

/* Article narrator (TTS) */
.narrator {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 14px; margin: 16px 0 24px;
  font-size: 14px; color: var(--ink-soft);
}
.narrator-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-elevated); border: 1px solid var(--line); color: var(--ink);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
  transition: background .15s, border-color .15s;
}
.narrator-btn:hover { background: var(--accent-soft); border-color: var(--line-strong); }
.narrator-play { background: var(--accent); color: #fff; border-color: var(--accent); }
.narrator-play:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.narrator-voice-wrap { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.narrator-voice-label { color: var(--ink-mute); font-size: 13px; }
.narrator-voice {
  font: inherit; font-size: 13px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-elevated); color: var(--ink); max-width: 240px;
}
.narrator-msg { color: var(--ink-mute); font-size: 13px; }

/* Single article body */
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 16px 0; }
.article-body figure { margin: 24px 0; }
.article-body figcaption { font-size: 13px; color: var(--ink-mute); text-align: center; padding-top: 6px; }
.article-body h2, .article-body h3 { margin-top: 32px; }
.article-body blockquote {
  margin: 24px 0; padding: 12px 20px; border-left: 3px solid var(--accent);
  color: var(--ink-soft); font-style: italic; background: var(--surface);
}
.article-body a { text-decoration: underline; text-underline-offset: 3px; }
.article-body ul, .article-body ol { padding-left: 24px; }
.article-body li { margin-bottom: 6px; }
.cover img { width: 100%; height: auto; border-radius: var(--radius); margin: 16px 0 32px; box-shadow: var(--shadow-md); }

/* Footer */
footer.site { background: var(--accent); color: #f4ede0; padding: 56px 0 28px; margin-top: 32px; }
[data-theme="dark"] footer.site { background: var(--bg-elevated); border-top: 1px solid var(--line); color: var(--ink); }
footer.site a { color: inherit; opacity: .85; }
footer.site a:hover { opacity: 1; color: inherit; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 40px; }
.footer-grid h5 { font-family: var(--sans); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; opacity: .7; margin: 0 0 14px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.footer-brand .brand-logo { color: inherit; font-size: 28px; }
.footer-brand p { font-size: 14px; opacity: .85; max-width: 36ch; margin-top: 10px; }
.footer-bottom {
  margin-top: 40px; padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.18);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 13px; opacity: .8;
}
[data-theme="dark"] .footer-bottom { border-color: var(--line); }

/* Responsive */
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .topbar-links { display: none; }
  .masthead .wrap { grid-template-columns: 1fr auto; padding-top: 18px; padding-bottom: 18px; }
  .brand { grid-column: 1; text-align: left; align-items: flex-start; }
  .masthead-end { grid-column: 2; }
  .nav-list { display: none; }
  .nav-search { display: none; }
  .menu-btn { display: inline-flex; }
  .nav .wrap { padding-top: 8px; padding-bottom: 8px; }
  .grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .hero-content { padding: 24px; }
  .nav.open .nav-list {
    display: flex; flex-direction: column;
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--bg-elevated); border-bottom: 1px solid var(--line);
    padding: 8px 16px 16px; gap: 0;
  }
  .nav.open .nav-list a { padding: 14px 6px; border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
