:root {
  --bg: #111111;
  --panel: #1b1b1b;
  --bubble: #232424;
  --accent: #ffd90a;
  --accent-dark: #212121;
  --text: #f7f7f7;
  --muted: #dbdbdb;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: 'Montserrat', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 217, 10, 0.14), transparent 24%),
    linear-gradient(180deg, #161616 0%, #111111 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom) + 18px);
}

.back-to-site {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--muted);
  border-radius: 12px;
  color: var(--text);
  background: var(--panel);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.back-to-site:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.back-to-site:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.chat-shell {
  width: min(100%, 720px);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: end;
  gap: 12px;
}

.message-row-user {
  grid-template-columns: minmax(0, 1fr) 56px;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.bubble {
  position: relative;
  max-width: 520px;
  padding: 18px 22px;
  border-radius: 16px;
  line-height: 1.3;
  box-shadow: var(--shadow);
  animation: rise 280ms ease;
  word-break: break-word;
}

.bubble::after {
  content: '';
  position: absolute;
  top: 12px;
  width: 18px;
  height: 18px;
  transform: rotate(45deg);
}

.bubble-bot {
  background: var(--bubble);
  color: var(--text);
}

.bubble-bot::after {
  left: -8px;
  background: var(--bubble);
}

.bubble-user {
  justify-self: end;
  background: var(--accent);
  color: var(--accent-dark);
  font-weight: 800;
  text-align: center;
  transform-origin: right bottom;
  animation: userSend 320ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.bubble-user::after {
  right: -8px;
  background: var(--accent);
}

.bubble p {
  margin: 0;
}

.bubble p + p {
  margin-top: 6px;
}

.bubble strong {
  font-weight: 800;
}

.choice-grid,
.inline-form {
  margin-left: 68px;
  width: calc(100% - 68px);
  display: grid;
  gap: 14px;
  animation: rise 280ms ease;
}

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

.choice-grid-single {
  grid-template-columns: 1fr;
}

.choice-button,
.submit-button {
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

.choice-button {
  min-height: 58px;
  padding: 14px 18px;
  -webkit-tap-highlight-color: transparent;
}

.consultant-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.choice-button:hover,
.submit-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.choice-button:disabled,
.submit-button:disabled {
  opacity: 0.8;
  cursor: default;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) 110px;
}

.input-options {
  margin: 12px 0 0 68px;
  width: calc(100% - 68px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  animation: rise 280ms ease;
}

.input-option-button {
  min-height: 54px;
  font-size: 15px;
}

.text-input {
  width: 100%;
  min-height: 58px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: #222323;
  color: var(--text);
  font: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.text-input:focus {
  border-color: rgba(255, 217, 10, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 217, 10, 0.12);
}

.submit-button {
  min-height: 58px;
}

.bubble-typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding-block: 20px;
}

.bubble-typing span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  animation: typingBounce 900ms infinite ease-in-out;
}

.bubble-typing span:nth-child(2) {
  animation-delay: 120ms;
}

.bubble-typing span:nth-child(3) {
  animation-delay: 240ms;
}

.helper-text {
  margin-left: 68px;
  color: #ffbfbf;
  font-size: 14px;
}

.is-hidden {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes userSend {
  from {
    opacity: 0;
    transform: translateX(22px) scale(0.92);
  }

  70% {
    transform: translateX(-3px) scale(1.01);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .page {
    padding-inline: 10px;
  }

  .message-row,
  .message-row-user {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
  }

  .message-row-user .avatar {
    order: 2;
  }

  .message-row-user .bubble-user {
    order: 1;
  }

  .avatar {
    width: 44px;
    height: 44px;
  }

  .choice-grid,
  .inline-form,
  .input-options,
  .helper-text {
    margin-left: 54px;
    width: calc(100% - 54px);
  }

  .choice-grid,
  .input-options {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .bubble {
    padding: 16px 18px;
    max-width: none;
    border-radius: 15px;
  }

  .bubble::after {
    top: 10px;
    width: 14px;
    height: 14px;
  }

  .bubble-bot::after {
    left: -6px;
  }

  .bubble-user::after {
    right: -6px;
  }

  .choice-button,
  .submit-button,
  .text-input {
    min-height: 54px;
    font-size: 16px;
  }

  .submit-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .page {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-inline: 8px;
  }

  .chat-log {
    gap: 12px;
  }

  .message-row,
  .message-row-user {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 8px;
  }

  .message-row-user {
    grid-template-columns: minmax(0, 1fr) 38px;
  }

  .avatar {
    width: 38px;
    height: 38px;
  }

  .choice-grid,
  .inline-form,
  .input-options,
  .helper-text {
    margin-left: 46px;
    width: calc(100% - 46px);
  }

  .bubble {
    padding: 14px 14px 15px;
    font-size: 15px;
    line-height: 1.35;
  }

  .choice-button,
  .submit-button {
    min-height: 50px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 15px;
  }

  .text-input {
    min-height: 50px;
    padding-inline: 14px;
    border-radius: 12px;
    font-size: 16px;
  }

  .helper-text {
    font-size: 13px;
  }

  .bubble-typing {
    min-height: 50px;
    padding-block: 16px;
  }

  .bubble-typing span {
    width: 8px;
    height: 8px;
  }
}

@media (max-width: 380px) {
  .message-row,
  .message-row-user {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .message-row-user {
    grid-template-columns: minmax(0, 1fr) 34px;
  }

  .avatar {
    width: 34px;
    height: 34px;
  }

  .choice-grid,
  .inline-form,
  .input-options,
  .helper-text {
    margin-left: 42px;
    width: calc(100% - 42px);
  }

  .bubble {
    padding: 13px 12px 14px;
    font-size: 14px;
  }
}
