/* Documentation styles for Photon Framework */
:root {
  --doc-sidebar-width: 260px;
  --doc-header-height: 3.5rem;
  --doc-gap: 2rem;

  /* ===== АДАПТИВ: единые брейкпоинты =====
     1280+  десктоп, сайдбар закреплён
     1024+  малый десктоп / горизонтальный планшет
     768+   планшет, сайдбар выезжает
     480+   крупный телефон
     <480   телефон
  */
  --doc-max-width: 960px;
  --doc-pad-y: 2.5rem;
  --doc-pad-x: 3rem;
  --doc-radius: 12px;
  --doc-tap: 44px; /* минимальная площадь касания */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--doc-header-height) + 1rem);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--pk-text, #1d1d1f);
  background: var(--pk-bg, #ffffff);
  padding-top: var(--doc-header-height);
  /* защита от горизонтального «уезда» на узких экранах */
  overflow-x: hidden;
  min-height: 100vh;
}

/* Длинные слова / идентификаторы не должны рвать вёрстку */
.doc-content p, .doc-content li, .doc-content td, .doc-content th,
.doc-sidebar__link, .doc-header__brand, .doc-callout, .doc-step__content {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Изображения никогда не вылезают за контейнер */
.doc-content img, .doc-content svg, .doc-content video, .doc-content iframe {
  max-width: 100%;
}
.doc-content img, .doc-content video {
  height: auto;
}

a { color: var(--pk-primary, #5755d9); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== HEADER ===== */
.doc-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--doc-header-height);
  min-height: var(--doc-header-height);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1.5rem;
  z-index: 100;
}

.theme-dark .doc-header {
  background: rgba(0, 0, 0, 0.72);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.doc-header__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--pk-text, #1d1d1f);
  text-decoration: none;
  min-width: 0;
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-header__brand:hover { text-decoration: none; }

.doc-header__logo {
  width: 200px;
  height: 1.6rem;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.doc-header__logo img {
  width: 200px;
  height: 100%;
  object-fit: contain;
  display: block;
}

.doc-header__links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  min-width: 0;
}

.doc-header__link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--pk-text-secondary, #6e6e73);
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.doc-header__link:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--pk-text, #1d1d1f);
  text-decoration: none;
}
.doc-header__link svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ===== LAYOUT ===== */
.doc-layout {
  display: flex;
  min-height: calc(100vh - var(--doc-header-height));
  /* место под закреплённый сайдбар */
  padding-left: var(--doc-sidebar-width);
  width: 100%;
}

/* ===== SIDEBAR ===== */
.doc-sidebar {
  width: var(--doc-sidebar-width);
  flex-shrink: 0;
  position: fixed;
  top: var(--doc-header-height);
  left: 0;
  bottom: 0;
  background: rgba(245, 245, 247, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  padding: 1rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  z-index: 50;
}

.theme-dark .doc-sidebar {
  background: rgba(30, 30, 30, 0.5);
  border-right-color: rgba(255, 255, 255, 0.06);
}

.doc-sidebar__group { margin-bottom: 0.5rem; }

.doc-sidebar__title {
  display: block;
  padding: 0.35rem 1.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a1a1a6;
}

.doc-sidebar__link {
  display: block;
  padding: 0.35rem 1.25rem;
  font-size: 0.85rem;
  color: #6e6e73;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.doc-sidebar__link:hover {
  background: rgba(87, 85, 217, 0.06);
  color: #1d1d1f;
  text-decoration: none;
}
.doc-sidebar__link.active {
  background: rgba(87, 85, 217, 0.1);
  color: var(--pk-primary, #5755d9);
  border-left-color: var(--pk-primary, #5755d9);
}

.theme-dark .doc-sidebar__link:hover { color: #f5f5f7; }

/* ===== MAIN CONTENT ===== */
.doc-content {
  flex: 1 1 auto;
  min-width: 0;              /* критично: иначе таблицы/код распирают флекс */
  margin: 0 auto;            /* центрирование в свободной области */
  padding: var(--doc-pad-y) var(--doc-pad-x);
  max-width: var(--doc-max-width);
  width: 100%;
}

.page-logo {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0 2rem;
}
.page-logo img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(87, 85, 217, 0.15);
}

.doc-content h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.doc-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.doc-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.doc-content p { margin-bottom: 0.75rem; color: #6e6e73; }
.doc-content ul, .doc-content ol { margin: 0.5rem 0 0.75rem 1.5rem; color: #6e6e73; }
.doc-content li { margin-bottom: 0.25rem; }

/* ===== COMPONENT DEMO BOX ===== */
.demo-box {
  background: rgba(245, 245, 247, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1rem 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
}

.theme-dark .demo-box {
  background: rgba(30, 30, 30, 0.5);
  border-color: rgba(255, 255, 255, 0.06);
}

/* В колоночной раскладке элементы тянутся на всю ширину контейнера.
   Без align-items: stretch флекс считает ширину по контенту
   (shrink-to-fit) и grid-демо вроде .footer--complete раздувается до 800+px */
.demo-box--column {
  flex-direction: column;
  align-items: stretch;
}
.demo-box--column > * {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.demo-box--gap-lg { gap: 1.5rem; }

/* Демо-блоки не должны вылезать за границы контента ни при каких условиях */
.demo-box { max-width: 100%; overflow-x: clip; }
.demo-box--column > .code-block { max-width: 100%; }

/* Демо-блоки photon-tw: перенос строк + прокрутка как страховка.
   Без flex-wrap: wrap набор кнопок/ссылок не переносится и обрезается */
.doc-content .pt-demo {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.doc-content .pt-demo > * { min-width: 0; max-width: 100%; }
.doc-content .pt-demo pre,
.doc-content .pt-demo code { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 1023px) {
  .doc-content .pt-demo { flex-wrap: wrap !important; }
}

/* Демо переносятся, а не прокручиваются по горизонтали */
@media (max-width: 767px) {
  .doc-content .pt-demo .pt-flex { flex-wrap: wrap !important; }
  .doc-content .pt-demo .pt-flex-nowrap { flex-wrap: nowrap !important; }
  .doc-content .pt-demo .pt-grid-cols-2,
  .doc-content .pt-demo .pt-grid-cols-3,
  .doc-content .pt-demo .pt-grid-cols-4,
  .doc-content .pt-demo .pt-grid-cols-5,
  .doc-content .pt-demo .pt-grid-cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .doc-content .pt-demo .pt-justify-between { justify-content: flex-start !important; }
}

/* Тонкий скроллбар в демо-блоках, если всё же пришлось прокручивать */
.doc-content .pt-demo { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.18) transparent; }
.theme-dark .doc-content .pt-demo { scrollbar-color: rgba(255,255,255,0.18) transparent; }

/* ===== SCROLLBAR (Photon style, doc only) ===== */
html {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}
.theme-dark html {
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}
.theme-dark ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}
.theme-dark ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ===== CODE BLOCKS ===== */
.code-block {
  position: relative;
  margin: 0.5rem 0 1.5rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.code-block pre {
  margin: 0;
  padding: 1.25rem 1rem;
  background: #1d1d1f;
  color: #f5f5f7;
  font-family: 'SF Mono', 'Fira Code', 'Roboto Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-x: auto;
  tab-size: 2;
}

.theme-dark .code-block {
  border-color: rgba(255, 255, 255, 0.06);
}

.theme-dark .code-block pre {
  background: #0a0a0a;
}

.code-block__copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.code-block__copy:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.code-block__copy.copied {
  background: var(--pk-success, #32b643);
  color: #fff;
}

/* Inline code in docs */
.doc-content code:not(pre code) {
  font-family: 'SF Mono', 'Fira Code', 'Roboto Mono', monospace;
  font-size: 0.8em;
  padding: 0.15em 0.45em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--pk-primary, #5755d9);
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.theme-dark .doc-content code:not(pre code) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.06);
}

/* ===== TABS IN DOCS ===== */
.doc-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.doc-tab {
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: #6e6e73;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.doc-tab:hover { color: #1d1d1f; }
.doc-tab.active {
  color: var(--pk-primary, #5755d9);
  border-bottom-color: var(--pk-primary, #5755d9);
}

/* ===== RESPONSIVE ===== */
.doc-sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.65rem;
  left: 0.75rem;
  z-index: 110;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  font-size: 1.1rem;
  align-items: center;
  justify-content: center;
  color: var(--pk-text, #1d1d1f);
}
.doc-sidebar-toggle:hover { background: rgba(255, 255, 255, 0.95); }

.doc-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 80;
}
.doc-sidebar-overlay.open { display: block; }

@media (max-width: 1024px) {
  .doc-sidebar-toggle { display: flex; }

  .doc-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    z-index: 90;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }
  .doc-sidebar.open { transform: translateX(0); }
}

/* ===== SVG ICON PAGE ===== */
.svg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.svg-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(245, 245, 247, 0.3);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.svg-item:hover {
  background: rgba(87, 85, 217, 0.06);
  border-color: var(--pk-primary, #5755d9);
  transform: translateY(-2px);
}
.svg-item svg { width: 28px; height: 28px; color: var(--pk-text, #1d1d1f); }
.svg-item span { font-size: 0.72rem; color: #6e6e73; text-align: center; }
.svg-item .svg-copied {
  font-size: 0.62rem;
  color: var(--pk-success, #32b643);
  opacity: 0;
  transition: opacity 0.2s;
}
.svg-item .svg-copied.show { opacity: 1; }

.theme-dark .svg-item { background: rgba(30, 30, 30, 0.3); }

/* ===== QUICK START ===== */
.quick-start code {
  font-family: 'SF Mono', monospace;
  font-size: 0.85rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.feature-card {
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(245, 245, 247, 0.3);
}
.feature-card h3 { font-size: 1rem; margin-bottom: 0.3rem; border: none; }
.feature-card p { font-size: 0.85rem; margin: 0; }

.theme-dark .feature-card { background: rgba(30, 30, 30, 0.3); }

/* ===== IMAGE PLACEHOLDERS (doc only) ===== */
.doc-content img {
  background: linear-gradient(135deg, rgba(87,85,217,0.08), rgba(50,182,67,0.08));
  color: #6e6e73;
  font-size: 0.75rem;
  text-align: center;
  position: relative;
}
.theme-dark .doc-content img {
  background: linear-gradient(135deg, rgba(87,85,217,0.12), rgba(50,182,67,0.12));
  color: #a1a1a6;
}
.doc-content img[src$=".jpg"],
.doc-content img[src*="picsum"] {
  min-height: 80px;
}
.doc-content .pk-gallery-item img {
  background: linear-gradient(135deg, #667eea, #764ba2);
  min-height: auto;
}
.doc-content img[src*="photon-logo"] {
  background: none;
  min-height: auto;
}
.doc-content .page-logo img {
  background: none;
}

/* ===== CAROUSEL PLACEHOLDERS (doc only) ===== */
.doc-content .carousel__slide {
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-content .carousel__slide[style*="flex-end"] {
  align-items: flex-end;
}
/* ===== PHOTON-TW DEMO STYLES ===== */
.doc-content .pt-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  background: rgba(245, 245, 247, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1rem 0 1.5rem;
}
.theme-dark .pt-demo {
  background: rgba(30, 30, 30, 0.5);
  border-color: rgba(255, 255, 255, 0.06);
}
.pt-demo--col { flex-direction: column; }
.pt-demo--gap-lg { gap: 1.5rem; }
.pt-demo__label {
  font-size: 0.72rem;
  color: #a1a1a6;
  margin-top: 0.25rem;
  text-align: center;
  width: 100%;
}
.pt-demo-box {
  background: rgba(87, 85, 217, 0.06);
  border: 1px solid rgba(87, 85, 217, 0.12);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
  min-width: 60px;
}
.theme-dark .pt-demo-box {
  background: rgba(87, 85, 217, 0.12);
  border-color: rgba(87, 85, 217, 0.2);
}

.doc-content .carousel__slide .carousel__placeholder {
  font-size: 2.5rem;
  font-weight: 200;
  letter-spacing: 0.4em;
  opacity: 0.6;
  color: #fff;
  text-align: center;
  user-select: none;
}

/* ===== IMPROVED DEMO CARDS ===== */
.doc-content .demo-card {
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.5));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 16px;
  padding: 2rem;
  margin: 1.5rem 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  transition: box-shadow 0.3s, transform 0.3s;
}
.theme-dark .demo-card {
  background: linear-gradient(135deg, rgba(30,30,30,0.9), rgba(30,30,30,0.5));
  border-color: rgba(255,255,255,0.06);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* ===== CODE BLOCK ENHANCEMENTS ===== */
.code-block {
  box-shadow: 0 4px 20px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  border-radius: 12px;
}
.code-block pre {
  padding: 1.5rem 1.25rem;
  font-size: 0.85rem;
  line-height: 1.6;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  tab-size: 2;
}
.theme-dark .code-block pre {
  background: linear-gradient(135deg, #0a0a0f, #0f0f1a);
}
.code-block pre code {
  color: #e4e4e7;
}
.code-block pre code .tag { color: #ff79c6; }
.code-block pre code .attr { color: #50fa7b; }
.code-block pre code .string { color: #f1fa8c; }
.code-block pre code .comment { color: #6272a4; font-style: italic; }
.code-block pre code .keyword { color: #ff79c6; }
.code-block pre code .number { color: #bd93f9; }
.code-block::before {
  content: '';
  display: block;
  height: 28px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px 12px 0 0;
  background-image: radial-gradient(circle 6px at 16px 14px, #ff5f56 100%, transparent 0),
                    radial-gradient(circle 6px at 38px 14px, #ffbd2e 100%, transparent 0),
                    radial-gradient(circle 6px at 60px 14px, #27c93f 100%, transparent 0);
  background-size: 80px 28px;
  background-repeat: no-repeat;
}

/* ===== BEAUTIFUL TABLES ===== */
.doc-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1rem 0 1.5rem;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.06);
}
.theme-dark .doc-content table {
  border-color: rgba(255,255,255,0.06);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.doc-content table thead {
  background: rgba(87,85,217,0.06);
}
.theme-dark .doc-content table thead {
  background: rgba(87,85,217,0.1);
}
.doc-content table th {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  color: #6e6e73;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.doc-content table td {
  border-bottom: 1px solid rgba(0,0,0,0.04);
  color: #1d1d1f;
}
.theme-dark .doc-content table td {
  color: #e4e4e7;
  border-bottom-color: rgba(255,255,255,0.04);
}
.doc-content table tbody tr:last-child td {
  border-bottom: none;
}
.doc-content table tbody tr:hover {
  background: rgba(87,85,217,0.03);
}
.theme-dark .doc-content table tbody tr:hover {
  background: rgba(87,85,217,0.06);
}

/* ===== CALLOUT / ALERT BOXES ===== */
.doc-callout {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  margin: 1rem 0 1.5rem;
  border-left: 4px solid var(--pk-primary, #5755d9);
  background: rgba(87,85,217,0.04);
  font-size: 0.9rem;
  color: #1d1d1f;
}
.theme-dark .doc-callout {
  background: rgba(87,85,217,0.08);
  color: #e4e4e7;
}
.doc-callout--success { border-left-color: var(--pk-success, #32b643); background: rgba(50,182,67,0.04); }
.doc-callout--warning { border-left-color: var(--pk-warning, #ffb700); background: rgba(255,183,0,0.04); }
.doc-callout--error { border-left-color: var(--pk-error, #e85600); background: rgba(232,86,0,0.04); }
.doc-callout__icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 0.1rem; }

/* ===== BETTER PT-DEMO STYLING ===== */
.doc-content .pt-demo {
  background: linear-gradient(135deg, rgba(245,245,247,0.7), rgba(245,245,247,0.3));
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 1.75rem;
  margin: 1.25rem 0 1.75rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}
.theme-dark .pt-demo {
  background: linear-gradient(135deg, rgba(30,30,30,0.6), rgba(30,30,30,0.2));
  border-color: rgba(255,255,255,0.06);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* ===== DOC CONTENT ENHANCEMENTS ===== */
.doc-content h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #1d1d1f, #5755d9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.theme-dark .doc-content h1 {
  background: linear-gradient(135deg, #f5f5f7, #5755d9);
  -webkit-background-clip: text;
  background-clip: text;
}
.doc-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid rgba(87,85,217,0.15);
}
.theme-dark .doc-content h2 {
  border-bottom-color: rgba(87,85,217,0.25);
}
.doc-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
  color: var(--pk-primary, #5755d9);
}
.doc-content p {
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 0.85rem;
  color: #3a3a3c;
}
.theme-dark .doc-content p {
  color: #a1a1a6;
}
.doc-content ul, .doc-content ol {
  margin: 0.5rem 0 1rem 1.5rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #3a3a3c;
}
.theme-dark .doc-content ul, .theme-dark .doc-content ol {
  color: #a1a1a6;
}
.doc-content li { margin-bottom: 0.35rem; }
.doc-content strong {
  color: #1d1d1f;
}
.theme-dark .doc-content strong {
  color: #f5f5f7;
}

/* ===== TAG / BADGE STYLING IN DOCS ===== */
.doc-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(87,85,217,0.1);
  color: var(--pk-primary, #5755d9);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== STEPPER / NUMBERED LIST ===== */
.doc-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  margin: 0.5rem 0;
  border-radius: 10px;
  background: rgba(245,245,247,0.3);
  border: 1px solid rgba(0,0,0,0.04);
}
.theme-dark .doc-step {
  background: rgba(30,30,30,0.3);
  border-color: rgba(255,255,255,0.04);
}
.doc-step__number {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--pk-primary, #5755d9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}
.doc-step__content { flex: 1; }
.doc-step__content h4 { margin: 0 0 0.25rem; font-size: 0.95rem; }
.doc-step__content p { margin: 0; font-size: 0.85rem; }

/* ===== COMPARISON TABLE ===== */
.doc-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.doc-compare__col {
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(245,245,247,0.4);
  min-width: 0;
  overflow: hidden;
}
/* Длинные имена классов / идентификаторы в примерах не рвут сетку */
.doc-compare__col pre,
.doc-compare__col code { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.theme-dark .doc-compare__col {
  background: rgba(30,30,30,0.4);
  border-color: rgba(255,255,255,0.06);
}
.doc-compare__col h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6e6e73;
}
.doc-compare__col--good { border-left: 3px solid var(--pk-success, #32b643); }
.doc-compare__col--bad { border-left: 3px solid var(--pk-error, #e85600); }

/* ===== BEAUTIFUL GRID NAV ===== */
.doc-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.doc-nav-grid a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(245,245,247,0.4);
  text-decoration: none;
  color: #1d1d1f;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.theme-dark .doc-nav-grid a {
  background: rgba(30,30,30,0.4);
  border-color: rgba(255,255,255,0.06);
  color: #e4e4e7;
}
.doc-nav-grid a:hover {
  background: var(--pk-primary, #5755d9);
  color: #fff;
  border-color: var(--pk-primary, #5755d9);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(87,85,217,0.25);
  text-decoration: none;
}
.doc-nav-grid a .nav-icon {
  font-size: 1.2rem;
  width: 1.5rem;
  text-align: center;
}

/* ===== PARAMETER TABLE STYLING ===== */
.doc-param-table { font-size: 0.88rem; }
.doc-param-table td:first-child {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  color: var(--pk-primary, #5755d9);
}
.doc-param-table td:nth-child(2) {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  color: #6e6e73;
}

/* ===== LAYOUT SAFEGUARDS (override Tailwind preflight) ===== */
.doc-layout { display: flex !important; padding-left: var(--doc-sidebar-width); }
.doc-sidebar { position: fixed !important; width: var(--doc-sidebar-width) !important; flex-shrink: 0 !important; }
.doc-content {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin: 0 auto !important;
  max-width: var(--doc-max-width) !important;
}
.doc-header { position: fixed !important; }
.doc-content .pt-demo { display: flex !important; }
.doc-content .pt-demo--col { flex-direction: column !important; }
.doc-sidebar-toggle { display: none !important; }

/* Кнопка выезда сайдбара — только на планшете и мобильных */
@media (max-width: 1024px) {
  .doc-sidebar-toggle { display: flex !important; }
}

/* ===== SIDEBAR SEARCH ===== */
.sidebar-search {
  padding: 0.5rem 0.75rem 0.75rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 0.5rem;
  position: relative;
}
.theme-dark .sidebar-search {
  border-bottom-color: rgba(255,255,255,0.06);
}
.sidebar-search__input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  font-family: inherit;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.6);
  color: #1d1d1f;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.theme-dark .sidebar-search__input {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
  color: #e4e4e7;
}
.sidebar-search__input:focus {
  border-color: var(--pk-primary, #5755d9);
  box-shadow: 0 0 0 2px rgba(87,85,217,0.15);
}
.sidebar-search__input::placeholder {
  color: #a1a1a6;
}
.sidebar-search__results {
  display: none;
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  top: calc(100% - 0.25rem);
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 280px;
  overflow-y: auto;
  z-index: 60;
}
.theme-dark .sidebar-search__results {
  background: #2d2d2d;
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.sidebar-search__item {
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  color: #3a3a3c;
  transition: background 0.15s;
}
.theme-dark .sidebar-search__item {
  color: #c0c0c5;
  border-bottom-color: rgba(255,255,255,0.04);
}
.sidebar-search__item:hover {
  background: rgba(87,85,217,0.06);
}
.theme-dark .sidebar-search__item:hover {
  background: rgba(87,85,217,0.12);
}
.sidebar-search__item:last-child {
  border-bottom: none;
}
.sidebar-search__item strong {
  color: var(--pk-primary, #5755d9);
}
.sidebar-search__item--link {
  display: block;
  text-decoration: none;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.theme-dark .sidebar-search__item--link {
  border-bottom-color: rgba(255,255,255,0.04);
}
.sidebar-search__page {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  color: #1d1d1f;
  margin-bottom: 0.1rem;
}
.theme-dark .sidebar-search__page {
  color: #e4e4e7;
}
.sidebar-search__sub {
  display: block;
  font-weight: 400;
  font-size: 0.72rem;
  color: #8e8e93;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.theme-dark .sidebar-search__sub {
  color: #6e6e73;
}
.sidebar-search__empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: #a1a1a6;
}
.sidebar-search__tag {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #a1a1a6;
  background: rgba(0,0,0,0.04);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.theme-dark .sidebar-search__tag {
  background: rgba(255,255,255,0.06);
  color: #6e6e73;
}

/* ============================================================
   ТАБЛИЦЫ: горизонтальная прокрутка вместо «уезда» за экран
   Обёртка .doc-table-wrap добавляется скриптом doc.js
   ============================================================ */
.doc-table-wrap {
  margin: 1rem 0 1.5rem;
  border-radius: var(--doc-radius);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
  /* подсказка о прокрутке */
  background:
    linear-gradient(to right, #fff 30%, rgba(255,255,255,0)) left center,
    linear-gradient(to left, #fff 30%, rgba(255,255,255,0)) right center,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.12), rgba(0,0,0,0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.12), rgba(0,0,0,0)) right center;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.theme-dark .doc-table-wrap {
  background:
    linear-gradient(to right, #1e1e1e 30%, rgba(30,30,30,0)) left center,
    linear-gradient(to left, #1e1e1e 30%, rgba(30,30,30,0)) right center,
    radial-gradient(farthest-side at 0 50%, rgba(255,255,255,0.14), rgba(255,255,255,0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(255,255,255,0.14), rgba(255,255,255,0)) right center;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.doc-table-wrap table { margin: 0 !important; }
.doc-table-wrap.is-scrollable { box-shadow: inset -1px 0 0 rgba(0,0,0,0.05); }

/* ============================================================
   АДАПТИВНОСТЬ ДОКУМЕНТАЦИИ
   ============================================================ */

/* ---------- Десктоп: 1280+ ---------- */
@media (min-width: 1280px) {
  :root { --doc-max-width: 1080px; --doc-pad-x: 3.5rem; }
  .doc-content h1 { font-size: 2.6rem; }
}

/* ---------- Малый десктоп / нетбук: 1024–1279 ---------- */
@media (min-width: 1024px) and (max-width: 1279px) {
  :root { --doc-pad-x: 2.25rem; }
}

/* ---------- Планшет: 768–1023 ---------- */
@media (max-width: 1023px) {
  :root {
    --doc-pad-y: 1.75rem;
    --doc-pad-x: 1.5rem;
    --doc-max-width: 100%;
  }

  /* Сайдбар выезжает (правила выше), убираем резервирование места */
  .doc-layout { padding-left: 0 !important; }

  /* Освобождаем место под кнопку-бургер в шапке */
  .doc-header { padding-left: 3.25rem; }

  .doc-content h1 { font-size: 1.9rem; }
  .doc-content h2 { font-size: 1.45rem; }
  .doc-content h3 { font-size: 1.1rem; }

  .demo-box,
  .doc-content .demo-card { padding: 1.25rem; }
  .doc-content .pt-demo { padding: 1.25rem; }

  /* Колонки сравнения в одну линию */
  .doc-compare { grid-template-columns: 1fr; }

  /* Крупные области касания */
  .doc-sidebar__link { padding-top: 0.5rem; padding-bottom: 0.5rem; }
}

/* ---------- Планшет, альбомная ориентация ---------- */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
  .doc-sidebar { width: 240px; }
  :root { --doc-sidebar-width: 240px; }
}

/* ---------- Планшет, портретная: сетки в 2 колонки ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
  .doc-compare { grid-template-columns: 1fr 1fr; }
}

/* ---------- Телефон: <768 ---------- */
@media (max-width: 767px) {
  :root {
    --doc-pad-y: 1.25rem;
    --doc-pad-x: 1.1rem;
    --doc-header-height: 3.25rem;
  }

  .doc-header { padding: 0 0.6rem 0 3.1rem; }
  .doc-header__link-text { display: none; }
  .doc-header__link { padding: 0.45rem; }
  .doc-header__brand { font-size: 1.05rem; gap: 0.45rem; }

  .doc-content h1 { font-size: 1.7rem; line-height: 1.25; }
  .doc-content h2 { font-size: 1.3rem; margin-top: 2rem; }
  .doc-content h3 { font-size: 1.05rem; }
  .doc-content p,
  .doc-content ul,
  .doc-content ol { font-size: 0.95rem; }
  .doc-content ul,
  .doc-content ol { margin-left: 1.15rem; }

  /* Сетки → одна колонка */
  .doc-compare,
  .doc-nav-grid,
  .feature-grid,
  .svg-grid { grid-template-columns: 1fr; }
  .doc-nav-grid { gap: 0.6rem; }

  /* Демо-блоки: одна колонка, чтобы ничего не вылезало */
  .demo-box { padding: 1rem; gap: 0.6rem; }
  .doc-content .demo-card { padding: 1.1rem; border-radius: 14px; }
  .doc-content .pt-demo { padding: 1rem; }

  /* Табы прокручиваются горизонтально */
  .doc-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.25rem;
  }
  .doc-tabs::-webkit-scrollbar { display: none; }
  .doc-tab { white-space: nowrap; padding: 0.55rem 0.75rem; }

  /* Код: не обрезаем кнопкой */
  .code-block pre { padding: 1rem 0.85rem; font-size: 0.78rem; }
  .code-block__copy { top: 0.4rem; right: 0.4rem; padding: 0.3rem 0.55rem; font-size: 0.68rem; }

  /* Таблицы чуть компактнее */
  .doc-content table { font-size: 0.85rem; }
  .doc-content th, .doc-content td { padding: 0.55rem 0.7rem; }

  /* Шаги и колонки параметров */
  .doc-step { padding: 0.85rem 1rem; gap: 0.75rem; }

  /* Сайдбар шире на телефоне — меньше пустого места */
  .doc-sidebar { width: min(86vw, 320px); }

  /* Кнопка «вверх» не перекрывает контент справа */
  .back-to-top { bottom: 1rem; right: 1rem; }
}

/* ---------- Узкий телефон: <480 ---------- */
@media (max-width: 479px) {
  :root {
    --doc-pad-y: 1rem;
    --doc-pad-x: 0.85rem;
  }

  .doc-content h1 { font-size: 1.45rem; }
  .doc-content h2 { font-size: 1.18rem; }
  .doc-content h3 { font-size: 1rem; }

  .demo-box,
  .doc-content .demo-card,
  .doc-content .pt-demo { padding: 0.85rem; }

  .doc-content table { font-size: 0.8rem; }
  .doc-content th, .doc-content td { padding: 0.45rem 0.55rem; }

  .doc-callout { padding: 0.8rem 0.9rem; gap: 0.6rem; }
  .doc-step { flex-direction: column; gap: 0.5rem; }
  .doc-step__number { width: 1.6rem; height: 1.6rem; font-size: 0.7rem; }

  .page-logo img { width: 60px; height: 60px; }

  /* Текст в кнопке GitHub прячем, оставляем иконку */
  .doc-header__link-text { display: none !important; }
  .doc-sidebar__link { font-size: 0.9rem; }
}

/* ---------- Очень узкие (iPhone SE и уже) ---------- */
@media (max-width: 359px) {
  :root { --doc-pad-x: 0.6rem; }
  .doc-content h1 { font-size: 1.3rem; }
  .doc-header__brand span:not(.doc-header__logo) { display: none; }
}

/* ---------- Ландшафт на телефоне: экономия высоты ---------- */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 480px) {
  .doc-sidebar { top: 0; height: 100vh; }
  .doc-content h1 { font-size: 1.4rem; }
  .demo-box { padding: 0.75rem; }
}

/* ---------- Крупные экраны: шире контент ---------- */
@media (min-width: 1600px) {
  :root { --doc-max-width: 1180px; --doc-pad-x: 4rem; }
}

/* ---------- Уважение к настройкам «уменьшить движение» ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Повышенный контраст ---------- */
@media (prefers-contrast: more) {
  .doc-sidebar, .doc-header { backdrop-filter: none; }
  .doc-content p, .doc-content li { color: #000; }
  .theme-dark .doc-content p, .theme-dark .doc-content li { color: #fff; }
}

/* ============================================================
   ПЕЧАТЬ
   ============================================================ */
@media print {
  .doc-header, .doc-sidebar, .doc-sidebar-toggle, .doc-sidebar-overlay,
  .back-to-top, .code-block__copy { display: none !important; }
  body { padding-top: 0; background: #fff; }
  .doc-layout { padding-left: 0 !important; display: block !important; }
  .doc-content { max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .doc-table-wrap { overflow: visible !important; }
  .code-block, .demo-box, .doc-callout, .doc-step, table { break-inside: avoid; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.75em; color: #666; }
}
