:root {
  --bg: #07111f;
  --bg-deep: #030914;
  --panel: rgba(9, 19, 35, 0.84);
  --panel-strong: rgba(7, 15, 28, 0.96);
  --surface: rgba(14, 30, 53, 0.84);
  --line: rgba(118, 164, 230, 0.16);
  --line-strong: rgba(118, 164, 230, 0.28);
  --text: #edf7ff;
  --text-soft: #8da7c6;
  --text-dim: #6d86a5;
  --accent: #52c3ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --content-width: 1480px;
  --sidebar-width: 300px;
  --editor-width: 540px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Outfit", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(82, 195, 255, 0.12), transparent 24%),
    radial-gradient(circle at 80% 0%, rgba(36, 130, 240, 0.12), transparent 22%),
    linear-gradient(180deg, #06101d 0%, #081323 44%, #040c18 100%);
  overflow-x: hidden;
}

body.drawer-open,
body.nav-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

textarea {
  resize: vertical;
}

.page-grid {
  position: fixed;
  inset: -100%;
  z-index: -1;
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
                    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: grid-move 20s linear infinite;
  pointer-events: none;
}

@keyframes grid-move {
  0% { transform: translateX(0); }
  100% { transform: translateX(-60px); }
}

.topbar {
  position: sticky;
  top: 18px;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(260px, 420px) auto;
  align-items: center;
  gap: 16px;
  width: min(calc(100% - 28px), var(--content-width));
  margin: 18px auto 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(7, 16, 30, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 30px;
  object-fit: cover;
  box-shadow: 0 16px 32px rgba(82, 195, 255, 0.22);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.brand-copy strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

.brand-copy small {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.topbar-search input,
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: rgba(13, 26, 47, 0.88);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.topbar-search input {
  min-height: 48px;
  padding: 0 16px;
}

.topbar-search input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-dim);
}

.topbar-search input:focus,
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(82, 195, 255, 0.08);
  background: rgba(16, 32, 56, 0.98);
}

.button,
.ghost-action,
.toolbar-button,
.mini-button,
.icon-toggle {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover,
.ghost-action:hover,
.toolbar-button:hover,
.mini-button:hover,
.icon-toggle:hover {
  transform: translateY(-1px);
}

.button {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  cursor: pointer;
}

.button-primary {
  color: #06101c;
  font-weight: 600;
  background: linear-gradient(135deg, #8ce0ff, #3bb6ff);
  box-shadow: 0 18px 34px rgba(82, 195, 255, 0.2);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 22px;
  width: min(calc(100% - 28px), var(--content-width));
  margin: 22px auto 34px;
  align-items: start;
}

.chapters-panel {
  position: sticky;
  top: 112px;
}

.chapters-card,
.article-shell,
.editor-drawer {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.chapters-card {
  padding: 22px;
  border-radius: var(--radius-lg);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 10px;
  color: #6ed7ff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.ghost-action,
.toolbar-button,
.mini-button,
.icon-toggle {
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  background: rgba(14, 29, 52, 0.88);
}

.ghost-action,
.toolbar-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
}

.icon-toggle {
  position: relative;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 16px;
}

.mobile-nav-toggle,
.close-editor {
  display: none;
}

.mobile-nav-toggle span,
.close-editor span {
  position: absolute;
  left: 50%;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  transform: translateX(-50%);
}

.mobile-nav-toggle span:nth-child(1) {
  top: 14px;
}

.mobile-nav-toggle span:nth-child(2) {
  top: 22px;
}

.mobile-nav-toggle span:nth-child(3) {
  top: 30px;
}

.close-editor span:nth-child(1) {
  top: 22px;
  transform: translateX(-50%) rotate(45deg);
}

.close-editor span:nth-child(2) {
  top: 22px;
  transform: translateX(-50%) rotate(-45deg);
}

.page-nav,
.editor-page-list {
  display: grid;
  gap: 10px;
}

.page-nav a,
.editor-page-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid rgba(118, 164, 230, 0.12);
  border-radius: 18px;
  background: rgba(11, 23, 41, 0.92);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.page-nav a:hover,
.editor-page-item:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.page-nav a.is-active,
.editor-page-item.is-active {
  border-color: rgba(82, 195, 255, 0.34);
  background: rgba(15, 33, 56, 0.98);
}

.page-nav a.is-editing {
  box-shadow: inset 0 0 0 1px rgba(82, 195, 255, 0.2);
}

.page-nav strong,
.editor-page-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
}

.page-nav small,
.editor-page-meta,
.page-position-label,
.field span,
.save-note {
  color: var(--text-soft);
}

.page-nav small,
.editor-page-meta {
  line-height: 1.5;
}

.article-shell {
  min-height: calc(100vh - 180px);
  padding: 34px 40px 46px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at top right, rgba(82, 195, 255, 0.08), transparent 26%),
    linear-gradient(180deg, rgba(10, 21, 39, 0.96), rgba(5, 13, 24, 0.98));
}

.article-head {
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(118, 164, 230, 0.1);
}

.article-kicker {
  margin: 0;
  color: #6ed7ff;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.article-head h1 {
  margin: 14px 0 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.6rem, 4vw, 4.4rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.article-summary {
  max-width: 70ch;
  margin: 18px 0 0;
  color: var(--text-soft);
  font-size: 1.02rem;
  line-height: 1.85;
}

.rich-body {
  font-size: 1rem;
  line-height: 1.86;
}

.article-body {
  margin-top: 34px;
}

.chapter-block {
  scroll-margin-top: 126px;
}

.chapter-block + .chapter-block {
  margin-top: 48px;
  padding-top: 42px;
  border-top: 1px solid rgba(118, 164, 230, 0.1);
}

.chapter-label {
  margin: 0;
  color: #6ed7ff;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.chapter-block > h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.9rem, 2.4vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.chapter-summary {
  max-width: 70ch;
  margin: 14px 0 0;
  color: var(--text-soft);
  font-size: 0.98rem;
  line-height: 1.8;
}

.chapter-content {
  margin-top: 26px;
}

.video-row {
  display: flex;
  gap: 24px;
  justify-content: center; /* Центрируем видео в строке */
  margin: 32px 0;
  width: 100%;
}

.video-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 50%; /* Занимают до 50% пространства, чтобы оба влезли */
  max-width: 440px; /* Ограничиваем максимальный размер */
  gap: 16px;
}

.video-item iframe,
.video-item video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(82, 195, 255, 0.3);
  border-radius: var(--radius-lg);
  background: #000;
  display: block;
  box-shadow: 0 0 20px rgba(82, 195, 255, 0.15), inset 0 0 15px rgba(82, 195, 255, 0.05);
  object-fit: cover;
  outline: none;
}

.video-caption {
  padding: 10px 20px;
  color: var(--accent);
  font-size: 0.95rem;
  text-align: center;
  font-weight: 500;
  background: rgba(14, 30, 53, 0.4); /* Стеклянный эффект */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(82, 195, 255, 0.3); /* Голубая обводка */
  border-radius: var(--radius-md); /* Прямоугольник с закругленными краями */
  box-shadow: 0 0 15px rgba(82, 195, 255, 0.15), inset 0 0 10px rgba(82, 195, 255, 0.05); /* Голубое свечение */
}

.rich-body > :first-child {
  margin-top: 0;
}

.rich-body h1,
.rich-body h2,
.rich-body h3,
.rich-body h4 {
  margin: -0.3em 0 0.55em;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.rich-body h1 {
  font-size: 2.1rem;
}

.rich-body h2 {
  font-size: 1.68rem;
}

.rich-body h3 {
  font-size: 1.32rem;
}

.rich-body p,
.rich-body div,
.rich-body ul,
.rich-body ol,
.rich-body blockquote,
.rich-body pre,
.rich-body hr,
.rich-body figure {
  margin: 1em 0;
}

.rich-body p,
.rich-body div,
.rich-body li {
  color: #deebff;
}

.rich-body ul,
.rich-body ol {
  padding-left: 1.35rem;
}

.rich-body li + li {
  margin-top: 0.45rem;
}

.rich-body blockquote {
  padding: 18px 20px;
  border: 1px solid rgba(82, 195, 255, 0.18);
  border-left: 4px solid rgba(82, 195, 255, 0.42);
  border-radius: 20px;
  color: #dcecff;
  background: rgba(82, 195, 255, 0.08);
}

.rich-body a {
  color: #82dfff;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.rich-body strong {
  color: #f4fbff;
}

.rich-body code {
  padding: 0.16em 0.42em;
  border-radius: 10px;
  color: #d8f2ff;
  font-size: 0.92em;
  background: rgba(82, 195, 255, 0.1);
}

.rich-body pre {
  overflow: auto;
  padding: 18px 20px;
  border: 1px solid rgba(118, 164, 230, 0.14);
  border-radius: 22px;
  color: #e7f6ff;
  background: rgba(3, 10, 19, 0.94);
}

.rich-body pre code {
  padding: 0;
  background: transparent;
}

.rich-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6rem 0;
}

.rich-body th, .rich-body td {
  padding: 12px;
  border: 1px solid rgba(118, 164, 230, 0.15);
  text-align: left;
}

.rich-body th {
  background: rgba(82, 195, 255, 0.05);
  color: var(--text);
}

.rich-body hr {
  border: 0;
  border-top: 1px solid rgba(118, 164, 230, 0.14);
}

.rich-body img {
  display: block;
  max-width: min(100%, 980px);
  margin: 1.4rem 0;
  border-radius: 22px;
  border: 1px solid rgba(118, 164, 230, 0.16);
  box-shadow: 0 24px 46px rgba(0, 0, 0, 0.28);
}

.empty-state {
  display: grid;
  gap: 10px;
  padding: 28px;
  margin-top: 12px;
  border: 1px dashed rgba(118, 164, 230, 0.18);
  border-radius: 24px;
  color: var(--text-soft);
  background: rgba(10, 21, 38, 0.72);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 44;
  opacity: 0;
  visibility: hidden;
  background: rgba(3, 9, 20, 0.54);
  backdrop-filter: blur(6px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.scrim.is-visible {
  opacity: 1;
  visibility: visible;
}

.editor-drawer {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(calc(100vw - 24px), var(--editor-width));
  height: calc(100vh - 36px);
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(82, 195, 255, 0.12), transparent 24%),
    linear-gradient(180deg, rgba(8, 18, 33, 0.98), rgba(5, 12, 23, 0.98));
  transform: translateX(calc(100% + 34px));
  transition: transform 240ms ease;
}

.editor-drawer.is-open {
  transform: translateX(0);
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid rgba(118, 164, 230, 0.1);
}

.editor-head h2 {
  margin: 6px 0 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.36rem;
}

.editor-scroll {
  overflow: auto;
  padding: 20px 24px 28px;
}

.editor-section {
  display: grid;
  gap: 14px;
  padding-bottom: 24px;
}

.editor-section + .editor-section {
  border-top: 1px solid rgba(118, 164, 230, 0.08);
  padding-top: 22px;
}

.field {
  display: grid;
  gap: 8px;
}

.field input,
.field textarea {
  padding: 14px 16px;
}

.editor-page-item {
  gap: 10px;
}

.editor-page-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.editor-page-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 10px;
}

.mini-button[data-tone="danger"] {
  color: #ff9b9b;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-surface {
  width: 100%;
  min-height: 340px;
  padding: 18px 18px 24px;
  border: 1px solid rgba(118, 164, 230, 0.12);
  border-radius: 24px;
  outline: none;
  background: rgba(6, 14, 26, 0.88);
  color: var(--text);
  font-family: monospace;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
}

.editor-surface:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(82, 195, 255, 0.08);
}

.save-row {
  display: flex;
  align-items: center;
  min-height: 24px;
}

.save-note {
  line-height: 1.6;
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .chapters-panel {
    position: fixed;
    top: 18px;
    left: 18px;
    bottom: 18px;
    z-index: 48;
    width: min(calc(100vw - 32px), 340px);
    transform: translateX(calc(-100% - 28px));
    transition: transform 240ms ease;
  }

  body.nav-open .chapters-panel {
    transform: translateX(0);
  }

  .mobile-nav-toggle,
  .close-editor {
    display: inline-flex;
  }
}

@media (max-width: 760px) {
  .topbar,
  .layout {
    width: min(calc(100% - 18px), var(--content-width));
  }

  .article-shell {
    padding: 24px 20px 30px;
    min-height: auto;
  }

  .article-head h1 {
    font-size: 2.4rem;
  }

  .editor-drawer {
    top: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    height: calc(100vh - 24px);
    border-radius: 24px;
  }
}
