:root,
[data-theme="light"] {
  --bg: #F8F5F1;
  --bg-alt: #EEE7E1;
  --text: #36374E;
  --muted: rgba(54, 55, 78, 0.72);
  --faint: rgba(54, 55, 78, 0.48);
  --border: rgba(54, 55, 78, 0.12);
  --surface: rgba(255, 255, 255, 0.68);
  --surface-strong: rgba(255, 255, 255, 0.86);
  --primary: #434081;
  --primary-2: #B66BB4;
  --peach: #F5B38A;
  --rose: #F07578;
  --soft-lilac: #F4E9F4;
  --soft-peach: #FEF4ED;
  --soft-rose: #FDEAEB;
  --soft-yellow: #FEF8E3;
  --shadow: 0 20px 60px rgba(54, 55, 78, 0.10);
  --shadow-soft: 0 10px 28px rgba(54, 55, 78, 0.08);
}

[data-theme="dark"] {
  --bg: #1F2031;
  --bg-alt: #2A2B40;
  --text: #F7F1EC;
  --muted: rgba(247, 241, 236, 0.76);
  --faint: rgba(247, 241, 236, 0.48);
  --border: rgba(247, 241, 236, 0.12);
  --surface: rgba(42, 43, 64, 0.72);
  --surface-strong: rgba(48, 49, 73, 0.92);
  --primary: #C08BD0;
  --primary-2: #F5B38A;
  --peach: #F5B38A;
  --rose: #F39BA0;
  --soft-lilac: rgba(182, 107, 180, 0.18);
  --soft-peach: rgba(245, 179, 138, 0.16);
  --soft-rose: rgba(240, 117, 120, 0.15);
  --soft-yellow: rgba(254, 248, 227, 0.10);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.26);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.20);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
}

button,
textarea {
  font: inherit;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
  z-index: 1000;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
}

.page-glow {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.75;
  pointer-events: none;
}

.page-glow-1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(245, 179, 138, 0.55), rgba(244, 233, 244, 0));
  left: -120px;
  top: 40px;
}

.page-glow-2 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(244, 233, 244, 0.9), rgba(254, 244, 237, 0));
  right: -160px;
  bottom: -120px;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 24px;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex: 0 0 auto;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-yandex {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #FF4A1C;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
}

.brand-heart {
  position: relative;
  width: 32px;
  height: 32px;
}

.lobe {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 10px;
}

.lobe-a {
  top: 1px;
  left: 7px;
  background: var(--soft-peach);
  transform: rotate(45deg);
}

.lobe-b {
  top: 7px;
  left: 1px;
  background: var(--primary);
  transform: rotate(45deg);
}

.lobe-c {
  top: 7px;
  right: 1px;
  background: var(--peach);
  transform: rotate(45deg);
}

.lobe-d {
  bottom: 1px;
  left: 7px;
  background: var(--primary-2);
  transform: rotate(45deg);
}

.brand-title {
  font-size: clamp(1.7rem, 1.4rem + 1.2vw, 3rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.theme-toggle {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(18px);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  flex: 1 1 auto;
  min-height: 0;
}

.intro-panel,
.chat-panel {
  border: 1px solid var(--border);
  border-radius: 32px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.intro-panel {
  min-height: 0;
  height: min(720px, calc(100svh - 120px));
  height: min(720px, calc(100dvh - 120px));
  overflow: hidden;
}

.intro-scroll {
  height: 100%;
  padding: 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.topic-label {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 16px;
}

.intro-panel h1 {
  margin: 0 0 16px;
  font-size: clamp(2.3rem, 1.6rem + 2vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  max-width: 11ch;
}

.lead {
  margin: 0 0 28px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 34ch;
}

.facts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 26px;
}

.fact-card {
  background: var(--soft-peach);
  border: 1px solid rgba(54, 55, 78, 0.06);
  border-radius: 24px;
  padding: 18px;
}

.fact-card.soft-lilac {
  background: var(--soft-lilac);
}

.fact-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.fact-text {
  color: var(--muted);
  line-height: 1.5;
}

.illustration-card {
  position: relative;
  margin-top: 24px;
  min-height: 250px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.04));
  overflow: hidden;
}

.balloon {
  position: absolute;
  border-radius: 999px;
  filter: blur(0.3px);
}

.balloon-left {
  width: 180px;
  height: 180px;
  background: radial-gradient(circle at 35% 35%, rgba(254,248,227,0.65), rgba(245,179,138,0.14));
  left: -40px;
  top: -30px;
}

.chat-illustration {
  position: absolute;
  inset: 0;
}

.bubble {
  position: absolute;
  border-radius: 32px;
  background: var(--primary);
  border: 4px solid rgba(182, 107, 180, 0.95);
  box-shadow: var(--shadow-soft);
}

.bubble-main {
  width: 170px;
  height: 132px;
  right: 42px;
  bottom: 44px;
  border-bottom-left-radius: 8px;
}

.bubble-main::after {
  content: "";
  position: absolute;
  left: 20px;
  bottom: -22px;
  width: 26px;
  height: 26px;
  background: var(--primary);
  border-left: 4px solid rgba(182, 107, 180, 0.95);
  border-bottom: 4px solid rgba(182, 107, 180, 0.95);
  transform: skewY(42deg);
}

.bubble-line {
  height: 6px;
  background: rgba(255,255,255,0.85);
  border-radius: 99px;
  width: 96px;
  margin: 26px auto 0;
}

.bubble-line.short {
  width: 54px;
  margin-top: 38px;
}

.spark {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--primary-2);
  clip-path: polygon(50% 0%, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0% 50%, 38% 38%);
}

.spark-a {
  right: 212px;
  bottom: 72px;
}

.spark-b {
  right: 198px;
  bottom: 48px;
  width: 8px;
  height: 8px;
}

.car {
  position: absolute;
  width: 120px;
  height: 54px;
  right: 8px;
  bottom: 18px;
  background: #F4B247;
  border-radius: 22px 30px 18px 18px;
  box-shadow: var(--shadow-soft);
}

.car::before,
.car::after {
  content: "";
  position: absolute;
  bottom: -9px;
  width: 24px;
  height: 24px;
  background: var(--text);
  border-radius: 999px;
}

.car::before {
  left: 14px;
}

.car::after {
  right: 14px;
}

.chat-panel {
  min-height: 0;
  height: min(720px, calc(100svh - 120px));
  height: min(720px, calc(100dvh - 120px));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.messages {
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: min(78%, 700px);
  padding: 16px 18px;
  border-radius: 26px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-soft);
}

.message.user {
  align-self: flex-end;
  background: var(--soft-rose);
  border-bottom-right-radius: 8px;
}

.message.bot {
  align-self: flex-start;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-bottom-left-radius: 8px;
}

.message.system {
  align-self: center;
  max-width: 100%;
  background: var(--soft-yellow);
  font-size: 14px;
}

.message.error {
  align-self: center;
  max-width: 100%;
  background: var(--soft-rose);
  color: var(--text);
}

.message.bot p {
  margin: 0 0 0.8em;
}

.message.bot p:last-child {
  margin-bottom: 0;
}

.message.bot strong {
  font-weight: 700;
}

.message.bot em {
  font-style: italic;
}

.message.bot ul,
.message.bot ol {
  margin: 0.6em 0 0.8em 1.2em;
  padding: 0;
}

.message.bot li + li {
  margin-top: 0.3em;
}

.message.bot code {
  padding: 0.15em 0.4em;
  border-radius: 8px;
  background: rgba(54, 55, 78, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

.message.bot pre {
  margin: 0.9em 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(54, 55, 78, 0.08);
  overflow-x: auto;
}

.message.bot pre code {
  padding: 0;
  background: transparent;
}

.message.bot blockquote {
  margin: 0.9em 0;
  padding-left: 1em;
  border-left: 3px solid var(--primary);
  color: var(--muted);
}

.message.bot a {
  color: var(--primary);
  text-decoration: underline;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: pulse 1.1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.35;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.chat-form {
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0), var(--bg-alt));
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

.composer-shell {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

.chat-form textarea {
  width: 100%;
  min-height: 68px;
  max-height: 160px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  padding: 20px 20px 16px;
  line-height: 1.6;
  overflow-y: auto;
}

.chat-form textarea::placeholder {
  color: var(--faint);
}

.chat-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, opacity 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: #383673;
}

.btn-secondary {
  background: var(--soft-lilac);
  color: var(--text);
}

.btn-secondary:hover {
  background: #eeddf0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    min-height: 100svh;
    min-height: 100dvh;
    padding: 16px 0 20px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .intro-panel {
    height: auto;
    min-height: 0;
  }

  .intro-scroll {
    overflow: visible;
  }

  .intro-panel h1 {
    max-width: 14ch;
  }

  .chat-panel {
    height: calc(100svh - 170px);
    height: calc(100dvh - 170px);
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  .brand-title {
    font-size: 2rem;
  }

  .intro-panel,
  .chat-panel {
    border-radius: 24px;
  }

  .intro-scroll {
    padding: 20px;
  }

  .messages {
    padding: 16px;
    gap: 12px;
  }

  .message {
    max-width: 92%;
    padding: 14px 16px;
  }

  .chat-form {
    padding: 14px;
  }

  .composer-shell {
    border-radius: 22px;
  }

  .chat-form textarea {
    min-height: 56px;
    max-height: 132px;
    padding: 16px 16px 14px;
  }

  .chat-actions {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 10px;
    margin-top: 12px;
  }

  .btn {
    width: 100%;
  }

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

  .illustration-card {
    min-height: 180px;
  }

  .bubble-main {
    width: 126px;
    height: 100px;
    right: 18px;
    bottom: 32px;
  }

  .bubble-line {
    width: 72px;
    margin-top: 20px;
  }

  .bubble-line.short {
    width: 42px;
    margin-top: 28px;
  }

  .car {
    width: 92px;
    height: 42px;
    right: 6px;
    bottom: 10px;
  }
}
