:root {
  --cream: #f4efe7;
  --card: #fffdf9;
  --ink: #1f2a37;
  --navy: #16243a;
  --accent: #b45309;
  --accent-dark: #97440a;
  --muted: #6b5e50;
  --rule: #d9cfc1;
  --rule-strong: #c4b7a4;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 10% -10%, rgba(180, 83, 9, 0.1), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(22, 36, 58, 0.09), transparent 42%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 10;
  padding: 10px 16px;
  font-size: 13px;
  color: #fffdf9;
  text-decoration: none;
  background: var(--navy);
  border-radius: 0 0 10px 10px;
  transition: top 0.18s ease;
}

.skip-link:focus {
  top: 0;
}

::selection {
  background: rgba(180, 83, 9, 0.22);
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.brand-mark {
  display: inline-block;
  width: 11px;
  height: 11px;
  background: var(--accent);
  transform: rotate(45deg);
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  max-width: 260px;
  overflow: hidden;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 11px;
  background: rgba(255, 253, 249, 0.6);
}

.badge--live {
  color: #1f6b4a;
  border-color: #bcd4c6;
  background: #edf5f0;
}

.badge--demo {
  color: #7a5414;
  border-color: #ecd9b4;
  background: #fdf6e8;
}

.hero {
  padding: 46px 0 34px;
  border-bottom: 1px solid var(--rule);
}

.eyebrow {
  margin: 0 0 16px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: clamp(38px, 6vw, 62px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.lead {
  max-width: 560px;
  margin: 0;
  font-size: 17px;
  line-height: 1.55;
  color: var(--muted);
}

.ideas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.ideas-label {
  margin-right: 2px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.idea {
  padding: 7px 12px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: rgba(255, 253, 249, 0.72);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.idea:hover {
  color: var(--navy);
  background: var(--card);
  border-color: var(--navy);
}

.idea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.panel {
  margin-top: 34px;
  padding: 26px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 26px 60px -46px rgba(22, 36, 58, 0.55);
}

.formats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.format {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  font: inherit;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.format:hover {
  border-color: var(--rule-strong);
  transform: translateY(-1px);
}

.format.is-active {
  border-color: var(--navy);
  background: #f8f4ec;
  box-shadow: inset 0 0 0 1px var(--navy);
}

.format.is-active::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.format-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #efe7da;
  color: var(--navy);
  transition: background 0.18s ease, color 0.18s ease;
}

.format.is-active .format-icon {
  background: var(--navy);
  color: #fff;
}

.format-title {
  font-size: 15px;
  font-weight: 600;
}

.format-sub {
  font-size: 12px;
  color: var(--muted);
}

.format:focus-visible,
.cta:focus-visible,
.download:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field {
  position: relative;
  display: block;
  margin-top: 22px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 98px;
  padding: 16px 16px 30px;
  font: inherit;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: #fbf8f2;
  border: 1px solid var(--rule);
  border-radius: 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22, 36, 58, 0.08);
}

.counter {
  position: absolute;
  right: 14px;
  bottom: 12px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}

.counter.is-near {
  color: var(--accent);
  font-weight: 600;
}

.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 18px;
  padding: 16px 46px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fffdf9;
  background: var(--navy);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.18s ease, opacity 0.18s ease;
}

.cta:hover:not(:disabled) {
  background: #1e3149;
}

.cta:disabled {
  opacity: 0.55;
  cursor: progress;
}

.cta-format {
  font-weight: 400;
  opacity: 0.75;
}

.cta-arrow {
  position: absolute;
  right: 20px;
  font-size: 18px;
  line-height: 1;
  opacity: 0.75;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.cta:hover:not(:disabled) .cta-arrow {
  transform: translateX(3px);
  opacity: 1;
}

.status {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}

.status.is-busy::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  vertical-align: 1px;
  background: var(--accent);
  border-radius: 50%;
  animation: forma-pulse 1s ease-in-out infinite;
}

@keyframes forma-pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.75);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.status.is-error {
  color: #9b2c2c;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}

.result {
  margin-top: 30px;
  padding: 26px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.result[hidden] {
  display: none;
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.result-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.result-head h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.15;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.result-meta .chip {
  padding: 3px 9px;
  background: #f6f0e7;
  border: 1px solid #e7ddce;
  border-radius: 999px;
}

.result-note {
  margin: 10px 0 0;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #7a5414;
  background: #fdf6e8;
  border: 1px solid #ecd9b4;
  border-radius: 9px;
}

.result-note[hidden] {
  display: none;
}

.result-actions {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.retry {
  padding: 9px 14px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.18s ease;
}

.retry:hover {
  background: #f3ece1;
}

.retry[hidden] {
  display: none;
}

.download {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: var(--accent);
  border-radius: 10px;
  transition: background 0.18s ease;
}

.download-icon {
  font-size: 15px;
  line-height: 1;
  opacity: 0.85;
}

.download:hover {
  background: var(--accent-dark);
}

.download[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.5;
}

.result-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 26px;
  padding-top: 20px;
}

.outline-title {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

#outline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#outline-list li {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.35;
}

#outline-list .n {
  display: grid;
  width: 22px;
  height: 22px;
  min-width: 22px;
  place-items: center;
  font-family: var(--serif);
  font-size: 10.5px;
  color: var(--navy);
  background: #efe7da;
  border-radius: 50%;
}

#outline-list .d {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.preview {
  min-height: 420px;
  overflow: hidden;
  background: #f8f4ec;
  border: 1px solid var(--rule);
  border-radius: 12px;
}

.preview--docx,
.preview--pptx {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 740px;
}

.preview-caption {
  flex: none;
  margin: 0;
  padding: 10px 14px;
  font-size: 11px;
  color: var(--muted);
  background: #f1eae0;
  border-bottom: 1px solid var(--rule);
}

.preview-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 20px;
  background: #ece4d7;
}

/* --- макет Word (A4) --- */

.doc-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.doc-page {
  display: flex;
  flex-direction: column;
  width: 580px;
  max-width: 100%;
  aspect-ratio: 210 / 297;
  padding: 40px 40px 48px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #e2d8c8;
  box-shadow: 0 6px 20px rgba(22, 36, 58, 0.08);
  font-family: var(--sans);
}

.doc-page--first {
  padding-top: 76px;
}

.doc-page-head {
  display: flex;
  align-items: baseline;
  margin-bottom: 22px;
  padding-bottom: 8px;
  font-size: 10px;
  border-bottom: 1px solid var(--rule);
}

.doc-page-brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.doc-page-label {
  color: var(--muted);
}

.doc-page-body {
  flex: 1 0 auto;
}

.doc-page-foot {
  margin-top: auto;
  padding-top: 16px;
  font-size: 10px;
  text-align: center;
  color: var(--muted);
}

.doc-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.16;
  font-weight: 700;
}

.doc-subtitle {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--accent);
}

.doc-meta {
  margin: 30px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.doc-heading {
  margin: 22px 0 10px;
  padding-bottom: 7px;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.25;
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}

.doc-page-body > .doc-heading:first-child {
  margin-top: 0;
}

.doc-text {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
}

.doc-bullet {
  position: relative;
  margin: 0 0 7px;
  padding-left: 22px;
  font-size: 13px;
  line-height: 1.45;
}

.doc-bullet::before {
  content: "—";
  position: absolute;
  left: 4px;
  color: var(--accent);
}

.doc-table-wrap {
  margin: 12px 0 16px;
  overflow: hidden;
}

.doc-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
}

.doc-table th,
.doc-table td {
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
  border: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.doc-table th {
  font-weight: 600;
  color: #fff;
  background: var(--navy);
}

.doc-table tbody tr:nth-child(even) {
  background: #f3ede4;
}

/* --- макет PDF (A4) --- */

.pdf-page--first {
  padding-top: 44px;
}

.pdf-page .doc-title {
  font-family: var(--sans);
  font-size: 27px;
  line-height: 1.2;
}

.pdf-page .doc-subtitle {
  margin-top: 10px;
  font-size: 13px;
}

.pdf-page .doc-meta {
  margin-top: 26px;
  margin-bottom: 14px;
}

.pdf-rule {
  height: 2px;
  background: var(--accent);
}

.pdf-page .doc-heading {
  margin: 20px 0 10px;
  padding: 0;
  font-family: var(--sans);
  font-size: 17px;
  border-bottom: 0;
}

.pdf-page .doc-heading::after {
  content: "";
  display: block;
  width: 32%;
  height: 2px;
  margin-top: 6px;
  background: var(--accent);
}

.pdf-page .doc-text {
  font-size: 12.5px;
}

/* --- макет PowerPoint (16:9) --- */

.slides-preview {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slide {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  container-type: inline-size;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ded3c2;
  box-shadow: 0 5px 16px rgba(22, 36, 58, 0.09);
  font-family: var(--sans);
}

.slide--cover {
  background: var(--navy);
}

.slide-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1.2cqw;
  background: var(--accent);
}

.slide-brand {
  position: absolute;
  top: 4.65cqw;
  left: 6.75cqw;
  font-size: 1.15cqw;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #d9985a;
}

.slide-cover-title {
  position: absolute;
  top: 16.5cqw;
  left: 6.75cqw;
  width: 86.5cqw;
  margin: 0;
  font-family: var(--serif);
  font-size: 4.17cqw;
  font-weight: 700;
  line-height: 1.03;
  letter-spacing: -0.01em;
  color: #fff;
}

.slide-cover-rule {
  position: absolute;
  top: 34.1cqw;
  left: 6.75cqw;
  width: 9.75cqw;
  height: 0.45cqw;
  background: var(--accent);
}

.slide-cover-subtitle {
  position: absolute;
  top: 36.45cqw;
  left: 6.75cqw;
  width: 86.5cqw;
  margin: 0;
  font-size: 1.67cqw;
  line-height: 1.35;
  color: #eadfd0;
}

.slide-cover-meta {
  position: absolute;
  top: 49.5cqw;
  left: 6.75cqw;
  width: 86.5cqw;
  margin: 0;
  font-size: 1.15cqw;
  color: #9aa7b8;
}

.slide-heading {
  position: absolute;
  top: 4.65cqw;
  left: 6.75cqw;
  width: 86.5cqw;
  margin: 0;
  font-family: var(--serif);
  font-size: 3.125cqw;
  font-weight: 700;
  line-height: 1.08;
  color: var(--ink);
}

.slide-rule {
  position: absolute;
  top: 12.15cqw;
  left: 6.75cqw;
  width: 6.375cqw;
  height: 0.41cqw;
  background: var(--accent);
}

.slide-body {
  position: absolute;
  top: 14.85cqw;
  left: 6.75cqw;
  width: 86.5cqw;
  height: 36cqw;
  overflow: hidden;
}

.slide-p {
  margin: 0 0 0.62em;
  line-height: 1.16;
}

.slide-bullets {
  margin: 0;
  padding: 0;
  list-style: none;
}

.slide-bullets li {
  position: relative;
  margin: 0 0 0.42em;
  padding-left: 1.2em;
  line-height: 1.14;
}

.slide-bullets li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.slide-foot-rule {
  position: absolute;
  top: 52.35cqw;
  left: 6.75cqw;
  width: 86.5cqw;
  height: 1px;
  background: var(--rule);
}

.slide-foot {
  position: absolute;
  top: 53.25cqw;
  left: 6.75cqw;
  display: flex;
  justify-content: space-between;
  width: 86.5cqw;
  font-size: 0.885cqw;
  color: var(--muted);
}

.slide-foot-brand {
  font-weight: 700;
}

.slide-table-wrap {
  position: absolute;
  top: 14.6cqw;
  left: 6.75cqw;
  width: 86.5cqw;
}

.slide-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.slide-table th,
.slide-table td {
  padding: 0.55cqw 0.75cqw;
  text-align: left;
  vertical-align: middle;
  border: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.slide-table th {
  font-weight: 600;
  color: #fff;
  background: var(--navy);
}

.slide-table tbody tr:nth-child(even) {
  background: #f3ede4;
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 18px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--rule);
}

@media (max-width: 820px) {
  .result-body {
    grid-template-columns: 1fr;
  }

  .result-head {
    flex-direction: column;
  }

  .preview {
    min-height: 320px;
  }
}

@media (max-width: 620px) {
  .page {
    padding: 0 18px 48px;
  }

  .formats {
    grid-template-columns: 1fr;
  }

  .format {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .format-sub {
    margin-left: auto;
  }

  .foot {
    flex-direction: column;
  }
}

@media (max-width: 460px) {
  .topbar {
    flex-wrap: wrap;
    padding: 18px 0;
  }

  .badge {
    max-width: 160px;
  }

  .panel,
  .result {
    padding: 18px;
  }
}

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