/* ============================================================
   Codex Guide RU — премиальный редакционный тех-гайд
   Тёмный verification workbench: slate + cyan, без шума.
   ============================================================ */

:root {
  --bg: #0b0f15;
  --bg-raised: #10151d;
  --surface: #131923;
  --surface-2: #19202c;
  --border: #232c3a;
  --border-strong: #2f3b4d;
  --text: #e7edf4;
  --text-soft: #aeb9c8;
  --text-mute: #7d8a9c;
  --accent: #5fd4e8;
  --accent-strong: #8ae6f5;
  --accent-dim: rgba(95, 212, 232, 0.12);
  --accent-line: rgba(95, 212, 232, 0.35);
  --you: #e8c47c;
  --ai: #5fd4e8;
  --ok: #6ee7a8;
  --code-bg: #0d1117;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;
  --header-h: 60px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(95, 212, 232, 0.28); }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button { cursor: pointer; font-family: inherit; }

img { max-width: 100%; height: auto; display: block; }

kbd {
  font-family: var(--font-mono);
  font-size: 0.72em;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-soft);
  white-space: nowrap;
}

code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--accent-strong);
  white-space: nowrap;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  background: var(--accent);
  color: #062029;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 0 0 8px 8px;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0; text-decoration: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(11, 15, 21, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.brand:hover { color: var(--text); text-decoration: none; }
.brand svg { flex-shrink: 0; }
.brand .brand-sub {
  color: var(--text-mute);
  font-weight: 450;
}

.site-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }

.site-nav a {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.site-nav a[aria-current="page"] {
  color: var(--accent-strong);
  background: var(--accent-dim);
}

.search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-mute);
  font-size: 13.5px;
  padding: 7px 12px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.search-btn:hover { border-color: var(--border-strong); color: var(--text-soft); }
.search-btn svg { opacity: 0.8; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 248px minmax(0, 720px);
  gap: 56px;
  justify-content: center;
}

main { min-width: 0; padding-bottom: 96px; }

/* ---------- TOC sidebar ---------- */
.toc {
  position: sticky;
  top: calc(var(--header-h) + 28px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 56px);
  overflow-y: auto;
  padding: 4px 12px 24px 0;
  font-size: 13.5px;
  scrollbar-width: thin;
}

.toc-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 20px 0 10px;
}

.toc ol {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}
.toc ol ol { margin: 2px 0 6px; padding-left: 12px; border-left: 1px solid var(--border); }

.toc a {
  display: block;
  color: var(--text-soft);
  padding: 4px 10px;
  border-radius: 6px;
  line-height: 1.45;
  transition: color 0.15s ease, background 0.15s ease;
}
.toc a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.toc a.active { color: var(--accent-strong); background: var(--accent-dim); }

.toc .toc-group > a { font-weight: 600; color: var(--text); }
.toc .toc-group > a.active { color: var(--accent-strong); }

/* mobile TOC */
.toc-mobile { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 64px 0 8px; }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
}
.kicker::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--accent-line);
}

h1 {
  font-size: clamp(34px, 5.5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 720;
  margin: 0 0 22px;
}

.lede {
  font-size: 19.5px;
  line-height: 1.6;
  color: var(--text-soft);
  max-width: 640px;
  margin: 0 0 14px;
}

/* meta strip — карточки фактов под hero */
.meta-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
}
.meta-strip li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.meta-strip strong {
  display: block;
  font-size: 15.5px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.01em;
}
.meta-strip span { font-size: 13px; color: var(--text-mute); }

/* source / verification panel */
.source-note {
  margin: 28px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-raised) 100%);
  padding: 18px 20px;
  font-size: 14px;
  color: var(--text-soft);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.source-note svg { flex-shrink: 0; margin-top: 3px; color: var(--accent); }
.source-note p { margin: 0 0 6px; }
.source-note p:last-child { margin: 0; }

/* ---------- Sections ---------- */
.section {
  margin-top: 72px;
  scroll-margin-top: calc(var(--header-h) + 24px);
}

h2 {
  font-size: clamp(26px, 3.6vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0 0 16px;
}

.section > .section-lede {
  font-size: 17.5px;
  color: var(--text-soft);
  max-width: 640px;
  margin: 0 0 8px;
}

h3 {
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: -0.012em;
  font-weight: 650;
  margin: 0 0 12px;
}

.entry {
  margin-top: 44px;
  scroll-margin-top: calc(var(--header-h) + 24px);
}

.entry p { color: var(--text-soft); margin: 0 0 14px; }
.entry p strong, .section p strong { color: var(--text); }

/* "How to use this section" */
.howto {
  margin: 22px 0 6px;
  padding: 14px 18px;
  border-left: 2px solid var(--accent-line);
  background: var(--bg-raised);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 15px;
  color: var(--text-soft);
}
.howto-label {
  display: block;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.howto p { margin: 0; }

/* ---------- Figures ---------- */
.figure {
  margin: 26px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.figure img { width: 100%; }
.figure figcaption {
  padding: 11px 16px;
  font-size: 13.5px;
  color: var(--text-mute);
  border-top: 1px solid var(--border);
}

/* ---------- You do / AI does ---------- */
.roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}
.role {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
}
.role h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.role h4::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
}
.role-you h4 { color: var(--you); }
.role-you h4::before { background: var(--you); }
.role-ai h4 { color: var(--ai); }
.role-ai h4::before { background: var(--ai); }
.role p { margin: 0; color: var(--text-soft); }

/* ---------- Prompt blocks ---------- */
.prompt {
  margin: 22px 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.prompt-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.prompt-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(95, 212, 232, 0.6);
  flex-shrink: 0;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 550;
  padding: 4px 11px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.copy-btn:hover { border-color: var(--accent-line); color: var(--accent-strong); }
.copy-btn.copied { border-color: var(--ok); color: var(--ok); }
.copy-btn svg { flex-shrink: 0; }

.prompt pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.62;
  color: #c9d6e3;
  tab-size: 2;
}
.prompt pre code { font-family: inherit; }

/* ---------- Deep-dive cards ---------- */
.dive-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 28px 0 0;
}
.dive-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.dive-card:hover {
  text-decoration: none;
  color: var(--text);
  border-color: var(--accent-line);
  background: var(--surface-2);
  transform: translateY(-2px);
}
.dive-card .dive-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.08em;
}
.dive-card h3 { margin: 0; font-size: 18px; }
.dive-card p { margin: 0; font-size: 14px; color: var(--text-soft); flex-grow: 1; }
.dive-card .dive-cta {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 4px;
}

/* inline next-page link */
.next-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 10px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 600;
  font-size: 15px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.next-link:hover {
  text-decoration: none;
  border-color: var(--accent-line);
  background: var(--surface-2);
}

/* breadcrumb on deep dives */
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 28px;
}
.crumb a { color: var(--text-soft); }
.crumb a:hover { color: var(--accent-strong); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-mute);
}
.footer-inner p { margin: 0 0 6px; max-width: 560px; }
.footer-nav { display: flex; flex-direction: column; gap: 6px; }
.footer-nav a { color: var(--text-soft); font-size: 14px; }

/* ---------- Search dialog ---------- */
.search-dialog {
  width: min(620px, calc(100vw - 32px));
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow);
}
.search-dialog::backdrop {
  background: rgba(4, 7, 11, 0.7);
  backdrop-filter: blur(3px);
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap svg { color: var(--text-mute); flex-shrink: 0; }
#search-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 16.5px;
  font-family: inherit;
}
#search-input::placeholder { color: var(--text-mute); }
.search-close {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-mute);
  font-size: 11.5px;
  padding: 3px 8px;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: 52vh;
  overflow-y: auto;
}
.search-results li a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}
.search-results li a:hover,
.search-results li.selected a {
  background: var(--surface-2);
  text-decoration: none;
}
.search-results li.selected a { outline: 1px solid var(--accent-line); }
.search-results .r-title { font-size: 15px; font-weight: 550; }
.search-results .r-meta {
  display: block;
  font-size: 12.5px;
  color: var(--text-mute);
  margin-top: 2px;
}
.search-results mark {
  background: rgba(95, 212, 232, 0.25);
  color: var(--accent-strong);
  border-radius: 3px;
  padding: 0 1px;
}
.search-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--text-mute);
  font-size: 14.5px;
}

/* ---------- Page-end nav ---------- */
.page-end {
  margin-top: 72px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  font-size: 14.5px;
  color: var(--text-mute);
}

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .layout {
    grid-template-columns: minmax(0, 720px);
  }
  .toc { display: none; }

  .toc-mobile {
    display: block;
    margin: 28px 0 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .toc-mobile summary {
    cursor: pointer;
    padding: 13px 16px;
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text-soft);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .toc-mobile summary::-webkit-details-marker { display: none; }
  .toc-mobile summary::after {
    content: "";
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--text-mute);
    border-bottom: 1.5px solid var(--text-mute);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
  }
  .toc-mobile[open] summary::after { transform: rotate(-135deg); }
  .toc-mobile ol {
    list-style: none;
    margin: 0;
    padding: 4px 12px 14px;
    font-size: 14px;
  }
  .toc-mobile ol ol { padding: 0 0 4px 14px; border-left: 1px solid var(--border); }
  .toc-mobile a { display: block; padding: 6px 8px; color: var(--text-soft); border-radius: 6px; }
  .toc-mobile a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
}

@media (max-width: 720px) {
  body { font-size: 16px; }
  .header-inner { padding: 0 16px; gap: 12px; }
  .brand .brand-sub { display: none; }
  .search-btn .search-hint { display: none; }
  .layout { padding: 0 18px; gap: 0; }
  .hero { padding: 40px 0 4px; }
  .meta-strip { grid-template-columns: 1fr; }
  .roles { grid-template-columns: 1fr; }
  .dive-grid { grid-template-columns: 1fr; }
  .section { margin-top: 56px; }
  .entry { margin-top: 36px; }
  .prompt pre { font-size: 12.5px; padding: 14px; }
  .source-note { flex-direction: column; gap: 8px; }
}
