:root {
  --page-max: 1280px;
  --bg: #050505;
  --bg-soft: #0a0a0a;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-strong: rgba(255, 255, 255, 0.075);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f7;
  --muted: rgba(255, 255, 255, 0.62);
  --muted-strong: rgba(255, 255, 255, 0.76);
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.35);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Arial, sans-serif;
  --added: rgba(52, 199, 89, 0.18);
  --added-text: #9af0b4;
  --removed: rgba(255, 69, 58, 0.16);
  --removed-text: #ff9d97;
  --apple-blue: #0a84ff;
  --apple-blue-soft: rgba(10, 132, 255, 0.24);
}

body[data-theme="light"] {
  --bg: #f4f4f1;
  --bg-soft: #fcfcf8;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.88);
  --surface-hover: rgba(255, 255, 255, 0.96);
  --line: rgba(20, 20, 20, 0.1);
  --line-strong: rgba(20, 20, 20, 0.18);
  --text: #111111;
  --muted: rgba(17, 17, 17, 0.62);
  --muted-strong: rgba(17, 17, 17, 0.8);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.08);
  --added: rgba(52, 199, 89, 0.12);
  --added-text: #147a34;
  --removed: rgba(255, 69, 58, 0.12);
  --removed-text: #b3261e;
  --apple-blue-soft: rgba(10, 132, 255, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--text) 10%, transparent), transparent 22%),
    radial-gradient(circle at 85% 12%, color-mix(in srgb, var(--text) 5%, transparent), transparent 18%),
    radial-gradient(circle at 50% 100%, color-mix(in srgb, var(--text) 4%, transparent), transparent 20%),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 88%, #0a0a0a) 48%, var(--bg) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.5;
}

body::before {
  top: 8%;
  right: 8%;
  width: 240px;
  height: 240px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  animation: ambientFloat 16s ease-in-out infinite;
}

body::after {
  left: 10%;
  bottom: 6%;
  width: 300px;
  height: 300px;
  background: color-mix(in srgb, var(--apple-blue) 16%, transparent);
  animation: ambientFloat 22s ease-in-out infinite reverse;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

main,
header,
section,
aside,
div {
  position: relative;
  z-index: 1;
}

.landing-shell,
.auth-shell,
.workspace-shell,
.billing-shell,
.app-topbar {
  width: min(var(--page-max), calc(100% - 40px));
  margin-inline: auto;
}

.landing-shell,
.auth-shell {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 32px 0;
}

.landing-stage,
.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(360px, 0.96fr);
  align-items: center;
  gap: 32px;
}

.surface-panel {
  background: linear-gradient(180deg, var(--surface-strong), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
}

.surface-panel-large {
  padding: 36px;
}

.micro-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.micro-label::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
}

.hero-title,
.section-title {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: -0.055em;
}

.hero-title {
  font-size: clamp(4.8rem, 13vw, 10rem);
  line-height: 0.9;
}

.section-title {
  font-size: clamp(2.2rem, 5vw, 4.1rem);
  line-height: 0.93;
}

.hero-subtitle,
.section-text,
.help-line,
.status-line,
.brand-caption,
.account-chip,
.feature-copy p,
.billing-card-text,
.toggle-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
}

.landing-copy,
.auth-copy,
.auth-card,
.workspace-panel,
.billing-hero,
.billing-card {
  display: grid;
}

.landing-copy,
.auth-copy {
  gap: 24px;
}

.editor-stack {
  display: grid;
}

.hero-subtitle {
  max-width: 34rem;
  font-size: 1.02rem;
}

.hero-button,
.primary-button,
.secondary-button,
.ghost-button,
.auth-tab,
.token-link {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.hero-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.auth-tab:hover,
.token-link:hover {
  transform: translateY(-1px);
}

.hero-button,
.primary-button,
.secondary-button,
.ghost-button,
.nav-button {
  min-height: 56px;
  border-radius: 999px;
  padding: 0 22px;
}

.hero-button {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  color: color-mix(in srgb, var(--bg) 92%, #000);
  background: var(--text);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--text) 10%, transparent);
  animation: pulseButton 3.4s ease-in-out infinite;
}

.hero-button-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 94%, #000);
  color: var(--text);
}

.primary-button {
  background: var(--text);
  color: color-mix(in srgb, var(--bg) 92%, #000);
}

.secondary-button {
  background: color-mix(in srgb, var(--surface-strong) 85%, transparent);
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-button,
.ghost-link,
.nav-button {
  background: transparent;
  color: var(--muted-strong);
}

.ghost-button,
.nav-button {
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-button:hover,
.token-link:hover,
.ghost-button:hover {
  border-color: color-mix(in srgb, var(--apple-blue) 36%, var(--line));
  box-shadow: 0 0 0 4px var(--apple-blue-soft);
}

.landing-visual,
.signal-card {
  display: grid;
  place-items: center;
}

.signal-svg {
  width: min(100%, 640px);
  aspect-ratio: 1;
}

.signal-svg-compact {
  width: 160px;
  opacity: 0.92;
}

.signal-ring,
.signal-path,
.signal-line {
  stroke: color-mix(in srgb, var(--text) 88%, transparent);
  stroke-width: 1.5;
}

.signal-ring {
  fill: none;
  transform-origin: center;
  animation: drift 12s linear infinite;
}

.ring-2 {
  animation-duration: 16s;
  animation-direction: reverse;
}

.ring-3 {
  animation-duration: 9s;
}

.signal-path {
  stroke-dasharray: 12 12;
  animation: dash 18s linear infinite;
}

.feature-stack,
.pricing-preview,
.auth-form,
.workspace-panel,
.billing-grid {
  display: grid;
  gap: 14px;
}

.feature-row,
.pricing-item,
.billing-card {
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
}

.feature-row,
.pricing-item {
  display: flex;
  justify-content: space-between;
}

.feature-copy,
.pricing-item-copy {
  display: grid;
  gap: 6px;
}

.feature-tag,
.info-pill,
.char-meter,
.token-pill,
.account-chip,
.cache-badge,
.brand-mark,
.token-link {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
}

.feature-tag {
  align-self: center;
  padding-inline: 16px;
  min-width: 84px;
  justify-content: center;
  border-radius: 22px;
}

.feature-tag,
.info-pill,
.char-meter,
.cache-badge,
.brand-mark,
.account-chip {
  padding: 10px 14px;
}

.token-link,
.token-pill {
  gap: 10px;
  padding: 8px 10px 8px 14px;
}

.auth-card {
  gap: 20px;
  padding: 28px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--line);
}

.auth-tab {
  min-height: 46px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.auth-tab.active {
  background: var(--text);
  color: color-mix(in srgb, var(--bg) 92%, #000);
}

.input,
.editor-area,
.select,
.compare-preview {
  width: 100%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  color: var(--text);
  border-radius: 22px;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.input:focus,
.editor-area:focus,
.select:focus {
  border-color: color-mix(in srgb, var(--apple-blue) 50%, var(--line));
  background: color-mix(in srgb, var(--surface-hover) 96%, transparent);
  box-shadow: 0 0 0 4px var(--apple-blue-soft);
}

.input,
.select {
  height: 56px;
  padding: 0 18px;
}

.select {
  appearance: none;
  padding-right: 58px;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 24px;
  width: 10px;
  height: 10px;
  border-right: 1.5px solid var(--muted-strong);
  border-bottom: 1.5px solid var(--muted-strong);
  transform: translateY(-62%) rotate(45deg);
  pointer-events: none;
}

.input::placeholder,
.editor-area::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.editor-area,
.compare-preview {
  min-height: 420px;
  padding: 20px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow: hidden;
}

.editor-area {
  resize: vertical;
}

.editor-area.is-scrollable,
.compare-preview.is-scrollable {
  max-height: 520px;
  overflow: auto;
}

.compare-preview {
  font-size: 1rem;
}

.compare-preview:empty::before {
  content: "После генерации здесь появится новый текст";
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.editor-area::-webkit-scrollbar,
.compare-preview::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.editor-area::-webkit-scrollbar-track,
.compare-preview::-webkit-scrollbar-track {
  background: transparent;
}

.editor-area::-webkit-scrollbar-thumb,
.compare-preview::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.editor-area,
.compare-preview {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 16%, transparent) transparent;
}

.pricing-item-meta {
  display: grid;
  gap: 6px;
  text-align: right;
  white-space: nowrap;
  align-content: start;
}

.pricing-item-meta span,
.token-label,
.brand-caption {
  font-size: 0.88rem;
}

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

.brand-cluster,
.topbar-actions,
.panel-heading,
.editor-card-topline,
.action-row,
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.token-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
}

.workspace-shell {
  padding: 22px 0 42px;
}

.workspace-panel {
  gap: 18px;
}

.panel-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.char-meter {
  white-space: nowrap;
  color: var(--muted-strong);
}

.editor-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  transition: grid-template-columns 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.editor-stage.has-result {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.editor-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  transition:
    transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.35s ease;
}

.editor-stack .hidden-panel {
  display: none;
}

.editor-card-source {
  transform-origin: center left;
}

.editor-stage.has-result .editor-card-source {
  transform: translateX(-6px);
}

.editor-card-result {
  transform: translateX(16px);
  opacity: 0;
}

.editor-stage.has-result .editor-card-result {
  transform: translateX(0);
  opacity: 1;
}

.hidden-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.editor-stage.has-result .hidden-panel {
  max-height: none;
  overflow: visible;
  pointer-events: auto;
}

.editor-card-topline {
  justify-content: space-between;
}

.editor-card-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.control-block {
  display: grid;
  gap: 10px;
}

.control-block span {
  font-size: 0.92rem;
  color: var(--muted);
}

.toggle-row {
  width: fit-content;
  gap: 12px;
  cursor: pointer;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--text);
  transition: transform 0.2s ease;
}

.toggle-input:checked + .toggle-ui {
  background: color-mix(in srgb, var(--apple-blue) 30%, var(--surface));
  border-color: color-mix(in srgb, var(--apple-blue) 36%, var(--line));
}

.toggle-input:checked + .toggle-ui::after {
  transform: translateX(18px);
}

.help-line {
  min-height: 24px;
}

.action-row {
  flex-wrap: wrap;
}

.preview-added,
.preview-removed {
  border-radius: 7px;
  padding: 1px 0;
}

.preview-added {
  background: var(--added);
  color: var(--added-text);
}

.preview-removed {
  background: var(--removed);
  color: var(--removed-text);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.billing-shell {
  display: grid;
  gap: 20px;
  padding: 22px 0 42px;
}

.history-list,
.legal-stack {
  display: grid;
  gap: 18px;
}

.history-card {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.history-card-head,
.history-grid,
.history-column {
  display: grid;
}

.history-card-head {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.history-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.history-column {
  gap: 10px;
}

.history-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

.legal-notice {
  display: grid;
  gap: 14px;
  padding: 20px 22px;
}

.legal-copy {
  max-width: 860px;
 }

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

.billing-card {
  padding: 24px;
}

.billing-card-head,
.billing-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.billing-card-text {
  min-height: 52px;
}

.billing-price {
  font-size: 1.8rem;
  letter-spacing: -0.04em;
}

.theme-button {
  min-width: 92px;
}

.cache-badge {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  padding: 10px 14px;
}

.status-line {
  min-height: 24px;
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

@keyframes drift {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.015);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes dash {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: 240;
  }
}

@keyframes fadeLine {
  0%,
  100% {
    opacity: 0.16;
  }
  50% {
    opacity: 0.72;
  }
}

@keyframes pulseButton {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--text) 8%, transparent);
  }
  50% {
    box-shadow: 0 0 0 18px color-mix(in srgb, var(--text) 0%, transparent);
  }
}

@keyframes ambientFloat {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(12px, -18px, 0) scale(1.06);
  }
}

@media (max-width: 1120px) {
  .landing-stage,
  .auth-layout,
  .billing-grid,
  .history-grid {
    grid-template-columns: 1fr;
  }

  .editor-stage.has-result {
    grid-template-columns: 1fr;
  }

  .editor-stage.has-result .editor-card-source {
    transform: none;
  }
}

@media (max-width: 760px) {
  .landing-shell,
  .auth-shell,
  .workspace-shell,
  .billing-shell,
  .app-topbar {
    width: min(var(--page-max), calc(100% - 20px));
  }

  .surface-panel-large,
  .auth-card,
  .billing-card {
    padding: 22px;
  }

  .hero-title {
    font-size: clamp(4rem, 20vw, 6rem);
  }

  .landing-stage,
  .auth-layout,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .app-topbar,
  .panel-heading,
  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .feature-row,
  .pricing-item,
  .billing-card-head,
  .billing-card-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .pricing-item-meta {
    text-align: left;
  }
}
