/* === reset === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { max-width: 100%; height: auto; display: block; }

/* === theme tokens === */
/* Темная тема (по умолчанию, точно из smyslokod.ru) */
:root, html[data-theme="dark"] {
  --bg:               rgb(20 20 19);
  --bg-section:       rgb(25 24 23);
  --bg-card:          rgb(27 26 25);
  --bg-card-hover:    rgb(34 33 32);
  --bg-elev:          rgb(36 34 32);

  --text:             rgb(237 233 227);
  --text-sub:         rgb(168 162 158);
  --text-dim:         rgb(107 101 96);

  --accent:           rgb(217 119 87);
  --accent-hover:     rgb(232 138 107);
  --accent-glow:      rgba(217, 119, 87, 0.05);

  --border:           rgb(40 38 36);
  --border-hover:     rgb(58 55 52);

  --header-bg:        rgba(20, 20, 19, 0.7);
  --code-color:       var(--accent);

  --max-content: 1200px;
  --max-narrow: 720px;
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 16px;
}

/* Светлая тема (для тех, кто переключил) */
html[data-theme="light"] {
  --bg:               rgb(252 250 247);
  --bg-section:       rgb(245 242 237);
  --bg-card:          rgb(255 254 251);
  --bg-card-hover:    rgb(248 245 240);
  --bg-elev:          rgb(241 237 230);

  --text:             rgb(28 27 25);
  --text-sub:         rgb(86 82 76);
  --text-dim:         rgb(140 134 126);

  --accent:           rgb(184 90 56);
  --accent-hover:     rgb(165 75 44);
  --accent-glow:      rgba(184, 90, 56, 0.08);

  --border:           rgb(228 222 213);
  --border-hover:     rgb(208 200 188);

  --header-bg:        rgba(252, 250, 247, 0.85);
  --code-color:       var(--accent);
}

html { transition: background-color .2s ease, color .2s ease; }

/* === base === */
html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.font-head {
  font-family: "Instrument Serif", "Iowan Old Style", "Apple Garamond", Baskerville, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -0.005em;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color .15s ease, border-color .15s ease;
}
a:hover { color: var(--accent); }

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

/* === header === */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.logo {
  font-family: "Instrument Serif", serif;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.logo-tag {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-left: 10px;
  vertical-align: middle;
}
.site-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}
.site-nav a {
  padding: 8px 14px;
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color .15s, border-color .15s, background-color .15s;
}
.site-nav a:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sub);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  transition: color .15s, border-color .15s, background-color .15s;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--bg-card);
}
.theme-toggle svg { width: 16px; height: 16px; }
html[data-theme="dark"] .theme-toggle-sun  { display: inline-block; }
html[data-theme="dark"] .theme-toggle-moon { display: none; }
html[data-theme="light"] .theme-toggle-sun  { display: none; }
html[data-theme="light"] .theme-toggle-moon { display: inline-block; }

@media (max-width: 640px) {
  .header-row { height: auto; padding: 12px 0; flex-direction: column; align-items: flex-start; gap: 10px; }
  .site-nav { flex-wrap: wrap; gap: 6px; }
}

/* === hero === */
.hero {
  padding: 64px 0 32px;
}
.hero h1 {
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  font-size: clamp(36px, 7vw, 68px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  max-width: 900px;
  color: var(--text);
}
.hero-lead {
  font-size: 18px;
  color: var(--text-sub);
  max-width: var(--max-narrow);
  margin: 0 0 28px;
  line-height: 1.55;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.hero-meta span {
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 5px 12px;
  border-radius: 999px;
}

@media (max-width: 640px) { .hero-lead { font-size: 16px; } }

/* === sections === */
.guides, .extras, .tiers {
  padding: 56px 0;
}
.extras { background: var(--bg-section); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.tiers { border-top: 1px solid var(--border); }

.section-title {
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  color: var(--text);
}
.section-sub {
  color: var(--text-sub);
  max-width: var(--max-narrow);
  margin: 0 0 32px;
  font-size: 16px;
  line-height: 1.55;
}
.section-sub a { color: var(--text); border-bottom: 1px solid var(--border-hover); }
.section-sub a:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 640px) { .section-title { font-size: 28px; } }

/* === cards === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 1024px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .card-grid { grid-template-columns: 1fr; } }

.card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: inherit;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
  height: 100%;
}
.card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  box-shadow: 0 0 30px var(--accent-glow);
}
.card:hover .card-title { color: var(--accent); }

.card-tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(40, 38, 36, 0.6);
  padding: 4px 10px;
  border-radius: 999px;
  align-self: flex-start;
  margin-bottom: 14px;
}
.card-title {
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--text);
  transition: color .15s ease;
}
.card-desc {
  color: var(--text-sub);
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.55;
  flex: 1;
}
.card-meta {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
  align-items: center;
}
.card-meta-dot { color: var(--text-dim); opacity: 0.6; }

/* === extras grid === */
.extras-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 720px) { .extras-grid { grid-template-columns: 1fr; } }
.extra-card {
  display: block;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: inherit;
  transition: border-color .2s ease, background-color .2s ease;
}
.extra-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}
.extra-card h3 {
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.extra-card p { margin: 0 0 14px; color: var(--text-sub); font-size: 14px; line-height: 1.55; }
.extra-link {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
}

/* === tier table === */
.tier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tier-table th, .tier-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-sub);
}
.tier-table th {
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-card);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tier-table tr:last-child td { border-bottom: none; }
.tier-table tr:hover td { background: rgba(34, 33, 32, 0.4); color: var(--text); }
.tier-table td:first-child { color: var(--accent); font-weight: 600; font-family: "Plus Jakarta Sans", sans-serif; }

/* === article === */
.article {
  padding: 56px 0 96px;
}
.article .container {
  max-width: var(--max-narrow);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 32px;
  letter-spacing: 0.04em;
}
.back-link:hover { color: var(--accent); }

.article-meta {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.article-meta a {
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
}
.article-meta a:hover { color: var(--accent); }
.meta-tag {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

/* === prose === */
.prose {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
}
.prose > * + * { margin-top: 1em; }
.prose h1 {
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  font-size: clamp(34px, 5vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 32px;
  color: var(--text);
}
.prose h2 {
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 56px 0 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text);
}
.prose h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 18px;
  line-height: 1.3;
  margin: 36px 0 8px;
  font-weight: 700;
  color: var(--text);
}
.prose h4 {
  font-size: 15px;
  margin: 24px 0 6px;
  font-weight: 700;
  color: var(--text);
}
.prose p { margin: 0; color: var(--text); }
.prose p, .prose li { color: var(--text-sub); }
.prose strong { color: var(--text); font-weight: 600; }
.prose ul, .prose ol { padding-left: 20px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--text-dim); }
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 20px;
  color: var(--text-sub);
  font-style: italic;
  margin: 28px 0;
}
.prose code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  background: var(--bg-card);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.prose pre {
  background: var(--bg-card);
  color: var(--text);
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
}
.prose pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border: none;
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14.5px;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.prose th, .prose td {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  color: var(--text-sub);
}
.prose th {
  background: var(--bg-card);
  font-weight: 600;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.prose tr:last-child td { border-bottom: none; }
.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}
.prose a {
  color: var(--accent);
  border-bottom: 1px solid rgba(217, 119, 87, 0.3);
}
.prose a:hover { border-color: var(--accent); }

@media (max-width: 640px) {
  .prose { font-size: 16px; }
  .prose h1 { font-size: 28px; }
  .prose h2 { font-size: 24px; }
}

/* === footer === */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-section);
  padding: 32px 0;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.footer-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.footer-row a { color: var(--text-sub); }
.footer-row a:hover { color: var(--accent); }
