:root {
  --bg: #06070d;
  --bg-soft: #0c0e18;
  --panel: rgba(20, 23, 38, 0.72);
  --panel-2: rgba(28, 32, 52, 0.6);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1fb;
  --muted: #9aa3c0;
  --muted-2: #6b7393;
  --brand: #7c5cff;
  --brand-2: #4ea8ff;
  --brand-3: #21d4a8;
  --accent-grad: linear-gradient(120deg, #8b6dff 0%, #5b8dff 45%, #3bd6c6 100%);
  --radius: 18px;
  --shadow: 0 30px 80px -30px rgba(20, 10, 60, 0.8);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Manrope', var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== ФОН ===== */
.bg-orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; }
.orb-1 { width: 560px; height: 560px; background: #6d4bff; top: -160px; left: -120px; }
.orb-2 { width: 520px; height: 520px; background: #1f7bff; top: 8%; right: -160px; opacity: 0.4; }
.orb-3 { width: 600px; height: 600px; background: #15c2a0; bottom: -260px; left: 30%; opacity: 0.28; }
.grid-overlay {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
}

/* ===== ШАПКА ===== */
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 28px;
  padding: 20px clamp(18px, 5vw, 56px);
  max-width: 1280px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.brand:focus-visible { outline: 2px solid rgba(124,92,255,0.6); outline-offset: 4px; border-radius: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 800; font-size: 22px; color: #fff;
  box-shadow: 0 8px 24px -6px rgba(124, 92, 255, 0.7);
}
.brand-text { font-family: var(--font-head); font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.brand-text span { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topnav { display: flex; gap: 26px; margin-left: 18px; }
.topnav a { color: var(--muted); font-weight: 500; font-size: 14.5px; transition: color .2s; }
.topnav a:hover { color: var(--text); }
.topbar-badge {
  margin-left: auto; font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--stroke); border-radius: 999px; padding: 8px 14px;
  background: var(--panel-2); backdrop-filter: blur(8px);
}

/* ===== БАННЕР АКТИВНОЙ ГЕНЕРАЦИИ ===== */
.gen-banner {
  position: relative; z-index: 10;
  max-width: 1280px; margin: 0 auto 8px;
  padding: 0 clamp(18px, 5vw, 56px);
}
.gen-banner[hidden] { display: none !important; }
.gen-banner-inner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-radius: 14px;
  border: 1px solid rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.14);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px -12px rgba(124, 92, 255, 0.5);
}
.gen-banner-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-3); box-shadow: 0 0 10px var(--brand-3);
  animation: genPulse 1.3s ease-in-out infinite;
}
@keyframes genPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.85); } }
.gen-banner-text { font-size: 14px; font-weight: 600; white-space: nowrap; }
.gen-banner-text strong { color: #c9bcff; }
.gen-banner-msg {
  flex: 1; min-width: 120px; color: var(--muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gen-banner-link {
  margin-left: auto; background: none; border: none; padding: 0;
  color: #c9bcff; font-weight: 600; font-size: 14px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;
}
.gen-banner-link:hover { color: #fff; }

/* ===== VIEWS ===== */
.view { display: none; position: relative; z-index: 2; }
.view.active { display: block; animation: fade .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== HERO ===== */
.hero-inner { max-width: 920px; margin: 0 auto; padding: clamp(30px, 7vh, 70px) 20px 30px; text-align: center; }
.pill {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--muted); font-weight: 500;
  border: 1px solid var(--stroke); border-radius: 999px; padding: 8px 16px;
  background: var(--panel-2); backdrop-filter: blur(10px); margin-bottom: 26px;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-3); box-shadow: 0 0 12px var(--brand-3); }
.hero-title {
  font-family: var(--font-head); font-weight: 800;
  font-size: clamp(40px, 7vw, 76px); line-height: 1.02; letter-spacing: -0.03em;
  margin: 0 0 22px;
}
.hero-title .grad { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { font-size: clamp(15px, 1.6vw, 18px); color: var(--muted); max-width: 640px; margin: 0 auto 34px; line-height: 1.6; }

/* ===== COMPOSER ===== */
.composer {
  background: var(--panel); border: 1px solid var(--stroke-strong);
  border-radius: 24px; padding: 18px; box-shadow: var(--shadow);
  backdrop-filter: blur(20px); text-align: left;
}
.composer-types { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  font-size: 13.5px; font-weight: 500; color: var(--muted);
  border: 1px solid var(--stroke); border-radius: 999px; padding: 9px 16px;
  background: rgba(255,255,255,0.02); transition: all .18s;
}
.chip:hover { color: var(--text); border-color: var(--stroke-strong); }
.chip.active { color: #fff; background: rgba(124,92,255,0.18); border-color: rgba(124,92,255,0.6); box-shadow: inset 0 0 0 1px rgba(124,92,255,0.3); }
.composer-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: .06em; margin: 0 4px 8px;
}
.composer-label .req {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: none;
  color: #fff; background: var(--accent-grad);
  padding: 3px 9px; border-radius: 999px;
}
.composer-input {
  width: 100%; border: 1px solid var(--stroke-strong); outline: none; resize: none;
  background: rgba(255,255,255,0.04); color: var(--text);
  font-family: var(--font); font-size: 18px; line-height: 1.5;
  padding: 14px 16px; border-radius: 14px; transition: border-color .15s, background .15s;
}
.composer-input:focus { border-color: rgba(124,92,255,0.7); background: rgba(255,255,255,0.06); }
.composer-input::placeholder { color: var(--muted-2); }
.composer-hint { font-size: 13px; color: var(--muted); margin: 10px 4px 2px; line-height: 1.5; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.link-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 500;
  padding: 8px 10px; border-radius: 10px; transition: all .18s;
}
.link-toggle:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.link-toggle svg { transition: transform .2s; }
.link-toggle.open svg { transform: rotate(45deg); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--accent-grad); color: #fff; font-weight: 700; font-size: 15.5px;
  border: none; border-radius: 14px; padding: 14px 24px;
  box-shadow: 0 14px 34px -12px rgba(124, 92, 255, 0.8);
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 20px 44px -14px rgba(124, 92, 255, 0.9); filter: saturate(1.1); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary.sm { padding: 10px 18px; font-size: 14px; border-radius: 11px; }

.btn-ghost {
  background: rgba(255,255,255,0.04); color: var(--text); font-weight: 600; font-size: 14.5px;
  border: 1px solid var(--stroke-strong); border-radius: 13px; padding: 13px 22px; transition: all .18s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); border-color: var(--stroke-strong); }
.btn-ghost.sm { padding: 10px 16px; font-size: 14px; border-radius: 11px; }

.meta-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--stroke);
}
.meta-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.meta-grid input {
  background: rgba(255,255,255,0.03); border: 1px solid var(--stroke);
  border-radius: 10px; padding: 11px 13px; color: var(--text); font-size: 14.5px; font-family: var(--font); outline: none;
  transition: border-color .15s;
}
.meta-grid input:focus { border-color: rgba(124,92,255,0.6); }
.meta-grid select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-color: #161a2e; color: #fff;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%239aa3c0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  border: 1px solid var(--stroke-strong);
  border-radius: 10px; padding: 11px 38px 11px 13px; font-size: 14.5px; font-family: var(--font);
  outline: none; cursor: pointer;
}
.meta-grid select:focus { border-color: rgba(124,92,255,0.7); }
.meta-grid select option { background-color: #161a2e; color: #fff; padding: 8px; }
.meta-full { grid-column: 1 / -1; }
.meta-grid input::placeholder { color: var(--muted-2); }

/* ===== TRUST ===== */
.trust-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 30px; }
.trust {
  display: flex; flex-direction: column; gap: 2px; text-align: center;
  background: var(--panel-2); border: 1px solid var(--stroke); border-radius: 14px; padding: 14px 22px; min-width: 150px;
}
.trust b { font-family: var(--font-head); font-size: 17px; }
.trust span { font-size: 12.5px; color: var(--muted); }

/* ===== SECTIONS ===== */
.section-h { font-family: var(--font-head); font-weight: 800; font-size: clamp(26px, 3.4vw, 38px); text-align: center; letter-spacing: -0.02em; margin: 0 0 40px; }
.how, .features { max-width: 1120px; margin: 0 auto; padding: clamp(60px, 9vh, 110px) 20px 0; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step { background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 26px; backdrop-filter: blur(10px); }
.step-n { font-family: var(--font-head); font-weight: 800; font-size: 32px; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 14px; }
.step h3 { margin: 0 0 8px; font-size: 19px; font-family: var(--font-head); }
.step p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.6; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding-bottom: 100px; }
.fcard { background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 26px; backdrop-filter: blur(10px); transition: transform .2s, border-color .2s; }
.fcard:hover { transform: translateY(-4px); border-color: var(--stroke-strong); }
.fic { font-size: 30px; margin-bottom: 14px; }
.fcard h3 { margin: 0 0 8px; font-size: 18px; font-family: var(--font-head); }
.fcard p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ===== МОИ ДОКУМЕНТЫ ===== */
.docs-wrap { max-width: 880px; margin: 0 auto; padding: clamp(30px, 6vh, 60px) 20px 80px; }
.docs-list { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; }
.docs-empty { color: var(--muted); text-align: center; padding: 48px 20px; background: var(--panel); border: 1px dashed var(--stroke-strong); border-radius: 18px; font-size: 15px; }
.doc-card {
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--stroke-strong); border-radius: 16px;
  padding: 18px 20px; box-shadow: var(--shadow); backdrop-filter: blur(16px); transition: border-color .15s, transform .15s;
}
.doc-card:hover { border-color: rgba(124,92,255,0.45); transform: translateY(-1px); }
.doc-main { min-width: 0; }
.doc-title { font-family: var(--font-head); font-weight: 700; font-size: 17px; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.doc-tag { background: rgba(124,92,255,0.16); color: #c9bcff; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.doc-verified { color: #6ddf9c; font-weight: 600; }
.doc-acts { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.btn-icon-del {
  background: none; border: 1px solid var(--stroke); color: var(--muted); width: 36px; height: 36px;
  border-radius: 10px; cursor: pointer; font-size: 15px; transition: all .15s;
}
.btn-icon-del:hover { border-color: #ff6b6b; color: #ff6b6b; background: rgba(255,107,107,0.08); }
@media (max-width: 560px) {
  .doc-card { flex-direction: column; align-items: stretch; }
  .doc-acts { justify-content: space-between; }
}

/* ===== PLAN ===== */
.plan-wrap { max-width: 820px; margin: 0 auto; padding: clamp(30px, 6vh, 60px) 20px 80px; }
.back-link { background: none; border: none; color: var(--muted); font-size: 14.5px; font-weight: 500; padding: 8px 0; margin-bottom: 14px; transition: color .15s; }
.back-link:hover { color: var(--text); }
.plan-title { font-family: var(--font-head); font-weight: 800; font-size: clamp(28px, 4vw, 40px); margin: 0 0 10px; letter-spacing: -0.02em; }
.plan-sub { color: var(--muted); margin: 0 0 28px; font-size: 15.5px; }
.plan-card { background: var(--panel); border: 1px solid var(--stroke-strong); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.plan-field { margin-bottom: 20px; }
.plan-field > label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); font-weight: 600; margin-bottom: 8px; }
.plan-field input, .plan-field textarea {
  width: 100%; background: rgba(255,255,255,0.03); border: 1px solid var(--stroke); border-radius: 11px;
  padding: 12px 14px; color: var(--text); font-size: 15px; font-family: var(--font); outline: none; resize: vertical; line-height: 1.5;
}
.plan-field input:focus, .plan-field textarea:focus { border-color: rgba(124,92,255,0.55); }
.plan-chapters { display: flex; flex-direction: column; gap: 16px; }
.chapter-block { background: rgba(255,255,255,0.02); border: 1px solid var(--stroke); border-radius: 14px; padding: 16px 18px; }
.chapter-block .ch-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chapter-block .ch-num { font-family: var(--font-head); font-weight: 800; font-size: 14px; color: var(--brand-2); white-space: nowrap; }
.chapter-block input.ch-title { font-weight: 600; }
.sub-list { display: flex; flex-direction: column; gap: 8px; padding-left: 14px; margin-top: 8px; }
.sub-list input { font-size: 14px; }
.plan-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; flex-wrap: wrap; }

/* ===== LOADING ===== */
.view-loading { min-height: 70vh; display: none; place-items: center; padding: 60px 20px; }
.view-loading.active { display: grid; }
.loader-card { text-align: center; max-width: 560px; width: 100%; }
.loader-ring { position: relative; width: 150px; height: 150px; margin: 0 auto 26px; }
.loader-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 7; }
.ring-fg { fill: none; stroke: url(#g); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 276.46; stroke-dashoffset: 276.46; transition: stroke-dashoffset .5s ease; stroke: #7c5cff; }
.loader-pct { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 30px; }
.loader-title { font-family: var(--font-head); font-weight: 800; font-size: 26px; margin: 0 0 8px; }
.loader-msg { color: var(--brand-2); font-size: 15px; margin: 0 0 24px; font-weight: 500; min-height: 22px; }
.loader-log { list-style: none; padding: 0; margin: 0; text-align: left; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.loader-log li { color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 9px; opacity: 0; animation: logIn .3s forwards; }
.loader-log li::before { content: "✓"; color: var(--brand-3); font-weight: 700; }
@keyframes logIn { to { opacity: 1; } }

/* ===== EDITOR ===== */
.view-editor { min-height: 100vh; }
.editor-topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px clamp(14px, 4vw, 36px);
  background: rgba(8, 9, 16, 0.85); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke);
}
.editor-topbar .back-link { margin: 0; }
.editor-toolbar { display: flex; align-items: center; gap: 4px; margin: 0 auto; background: var(--panel-2); border: 1px solid var(--stroke); border-radius: 12px; padding: 5px; }
.editor-toolbar button { width: 34px; height: 32px; border: none; background: transparent; color: var(--muted); border-radius: 8px; font-size: 14px; transition: all .15s; }
.editor-toolbar button:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.tb-sep { width: 1px; height: 20px; background: var(--stroke); margin: 0 4px; }
.editor-actions { display: flex; gap: 10px; }

.editor-stage { padding: 30px 16px 80px; display: flex; justify-content: center; }
.paper {
  width: 210mm; min-height: 297mm;
  background: #fff; color: #111;
  padding: 20mm 10mm 20mm 30mm;
  box-shadow: 0 30px 90px -20px rgba(0,0,0,0.7);
  font-family: 'Times New Roman', Georgia, serif; font-size: 14pt; line-height: 1.5; text-align: justify;
  outline: none; border-radius: 2px;
}
.paper:focus { box-shadow: 0 30px 90px -20px rgba(0,0,0,0.7), 0 0 0 2px rgba(124,92,255,0.4); }
.paper h1 { font-size: 16pt; font-weight: bold; text-align: center; text-transform: uppercase; margin: 1.4em 0 0.8em; line-height: 1.2; page-break-before: always; }
.paper h1:first-child { margin-top: 0; }
.paper h2 { font-size: 14pt; font-weight: bold; text-align: center; margin: 1em 0 0.6em; line-height: 1.2; }
.paper p { margin: 0 0 0; text-indent: 15mm; }
.paper p.ref { text-indent: 0; padding-left: 15mm; text-indent: -15mm; margin-bottom: 4px; }
.paper p.tcap { text-indent: 0; margin: 8px 0 2px; }
.paper table { width: 100%; border-collapse: collapse; margin: 4px 0 14px; font-size: 12pt; }
.paper th, .paper td { border: 1px solid #000; padding: 4px 8px; text-align: left; vertical-align: top; }
.paper th { font-weight: bold; text-align: center; background: #f3f3f3; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #15182a; border: 1px solid var(--stroke-strong); color: var(--text);
  padding: 13px 22px; border-radius: 12px; font-size: 14.5px; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .3s; z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255,90,90,0.5); }

/* ===== RESPONSIVE ===== */
@media (max-width: 860px) {
  .topnav { display: none; }
  .steps, .feature-grid { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
  .paper { width: 100%; padding: 16mm 10mm 16mm 18mm; }
}

/* ===== PRINT (PDF) ===== */
@media print {
  body * { visibility: hidden; }
  .paper, .paper * { visibility: visible; }
  .paper { position: absolute; inset: 0; box-shadow: none; width: 100%; padding: 20mm 10mm 20mm 30mm; }
  @page { size: A4; margin: 0; }
}
