:root {
  --bg: #020403;
  --bg-soft: #050807;
  --bg-deep: #07110d;
  --surface: rgba(5, 14, 11, 0.84);
  --surface-strong: rgba(7, 17, 13, 0.94);
  --surface-muted: rgba(255, 255, 255, 0.035);
  --accent: #10c986;
  --accent-strong: #00e0a4;
  --accent-deep: #0b5d46;
  --accent-soft: rgba(16, 201, 134, 0.1);
  --line: rgba(16, 201, 134, 0.22);
  --line-soft: rgba(255, 255, 255, 0.07);
  --text: #f3f7f5;
  --text-muted: #a9bbb4;
  --text-dark: #03130c;
  --danger: #ffb7b7;
  --danger-line: rgba(255, 138, 138, 0.22);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 22px 54px rgba(16, 201, 134, 0.1);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-sans: "Segoe UI Variable", "Segoe UI", "IBM Plex Sans", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100vh;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(0, 224, 164, 0.14), transparent 22%),
    radial-gradient(circle at 88% 16%, rgba(16, 201, 134, 0.12), transparent 24%),
    radial-gradient(circle at 55% 100%, rgba(11, 93, 70, 0.22), transparent 28%),
    linear-gradient(180deg, #020403 0%, #06100c 52%, #020403 100%);
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 24px;
  isolation: isolate;
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.app-shell::before {
  background:
    linear-gradient(120deg, transparent 0%, rgba(0, 224, 164, 0.05) 46%, transparent 54%),
    linear-gradient(90deg, transparent 0%, rgba(16, 201, 134, 0.035) 50%, transparent 100%);
  mask-image: radial-gradient(circle at center, black, transparent 88%);
}

.app-shell::after {
  background-image:
    radial-gradient(circle at 20% 22%, rgba(16, 201, 134, 0.22) 0 1px, transparent 1.5px),
    radial-gradient(circle at 78% 72%, rgba(0, 224, 164, 0.18) 0 1px, transparent 1.5px);
  background-size: 220px 220px, 260px 260px;
  opacity: 0.5;
}

.background-grid {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(16, 201, 134, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 201, 134, 0.045) 1px, transparent 1px),
    linear-gradient(transparent 0%, rgba(0, 224, 164, 0.04) 48%, transparent 100%);
  background-size: 46px 46px, 46px 46px, 100% 220px;
  mask-image: radial-gradient(circle at center, black, transparent 88%);
}

.chat-app {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.chat-card {
  position: relative;
  width: min(860px, 100%);
  height: min(88vh, 920px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at top center, rgba(0, 224, 164, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(8, 18, 14, 0.92), rgba(4, 11, 9, 0.96)),
    var(--surface);
  box-shadow: var(--shadow), 0 0 52px rgba(16, 201, 134, 0.08);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.chat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(16, 201, 134, 0.12);
}

.chat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(0, 224, 164, 0.04), transparent),
    radial-gradient(circle at top right, rgba(16, 201, 134, 0.08), transparent 24%);
  opacity: 0.7;
}

.chat-card__header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01)),
    rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(20px);
}

.chat-card__brand {
  display: flex;
  align-items: center;
}

.chat-card__logo {
  height: 32px;
  width: auto;
  opacity: 0.95;
}

.chat-card__identity {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.chat-card__avatar {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  object-fit: cover;
  object-position: center 10%;
  border: 1px solid rgba(16, 201, 134, 0.28);
  background: linear-gradient(180deg, rgba(0, 224, 164, 0.06), rgba(0, 0, 0, 0.12));
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(16, 201, 134, 0.08);
}

.chat-card__copy {
  min-width: 0;
}

.chat-card__copy strong {
  display: block;
  font-size: 1.18rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.chat-card__copy p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-card__status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 8px;
  color: #d7f9ea;
  font-size: 0.95rem;
  font-weight: 500;
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #48ffbb;
  box-shadow: 0 0 18px rgba(72, 255, 187, 0.7);
}

.chat-card__reset,
.quick-option,
.action-link,
.retry-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 201, 134, 0.08);
  color: var(--text);
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.chat-card__reset {
  min-height: 42px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.chat-card__reset:hover,
.quick-option:hover,
.action-link:hover,
.retry-button:hover,
.button:hover {
  transform: translateY(-1px);
}

.chat-card__messages {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(16, 201, 134, 0.32) transparent;
}

.chat-card__messages::-webkit-scrollbar {
  width: 10px;
}

.chat-card__messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-card__messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(16, 201, 134, 0.22);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.message--user {
  justify-content: flex-end;
}

.message__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  flex: 0 0 auto;
  border: 1px solid rgba(16, 201, 134, 0.26);
}

.message__bubble {
  max-width: min(78%, 560px);
  padding: 15px 17px;
  border-radius: 20px;
  line-height: 1.58;
  font-size: 0.97rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message--bot .message__bubble,
.message--typing .message__bubble {
  color: var(--text);
  border: 1px solid rgba(16, 201, 134, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015)),
    rgba(16, 201, 134, 0.06);
  border-bottom-left-radius: 6px;
}

.message--user .message__bubble {
  color: var(--text-dark);
  background: linear-gradient(135deg, #0ca16b 0%, #10c986 55%, #00e0a4 100%);
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-accent);
}

.message--system .message__bubble {
  max-width: 100%;
  color: #ffe4e4;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015)),
    rgba(180, 74, 74, 0.1);
  border: 1px solid var(--danger-line);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

.message__actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.chat-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: -4px 0 18px 44px;
  max-width: 640px;
}

.chat-option-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(16, 201, 134, 0.35);
  border-radius: 16px;
  background: rgba(5, 24, 18, 0.9);
  color: #f3f7f5;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.4;
  text-align: left;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.chat-option-button:hover {
  border-color: rgba(16, 201, 134, 0.8);
  background: rgba(16, 201, 134, 0.14);
  transform: translateY(-1px);
}

.option-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #10c986;
  color: #02100b;
  font-weight: 700;
  font-size: 13px;
  flex: 0 0 auto;
}

.option-label {
  color: #f3f7f5;
}

.disabled-options {
  opacity: 0.45;
  pointer-events: none;
}

.message-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(16, 201, 134, 0.35);
  border-radius: 16px;
  background: rgba(5, 24, 18, 0.9);
  color: #defff0;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  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;
}

.quick-option,
.action-link,
.retry-button {
  min-height: 42px;
  padding: 10px 15px;
}

.quick-option:hover,
.action-link:hover,
.retry-button:hover {
  background: rgba(16, 201, 134, 0.16);
  border-color: rgba(16, 201, 134, 0.4);
}

.action-link {
  color: #defff0;
}

.chat-card__composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px 24px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0.008)),
    rgba(0, 0, 0, 0.08);
}

.chat-card__composer input {
  min-width: 0;
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid rgba(16, 201, 134, 0.14);
  border-radius: 18px;
  outline: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.012)),
    var(--surface-muted);
  color: var(--text);
}

.chat-card__composer input::placeholder {
  color: var(--text-muted);
}

.chat-card__composer input:focus {
  border-color: rgba(16, 201, 134, 0.42);
  box-shadow:
    0 0 0 3px rgba(16, 201, 134, 0.12),
    0 0 18px rgba(16, 201, 134, 0.08);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: 18px;
}

.button--primary {
  color: var(--text-dark);
  background: linear-gradient(135deg, var(--accent) 0%, #50f0b8 58%, #00e0a4 100%);
  box-shadow: var(--shadow-accent);
}

.button:disabled,
.quick-option:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

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

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 18px;
  }

  .chat-app {
    min-height: calc(100vh - 36px);
  }

  .chat-card {
    width: 92vw;
    height: min(88vh, 920px);
  }
}

@media (max-width: 640px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    padding: 0;
  }

  .chat-app {
    min-height: 100dvh;
  }

  .chat-card {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .chat-card__header {
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 14px;
    padding: 16px;
  }

  .chat-card__brand {
    display: none;
  }

  .chat-card__avatar {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .chat-card__copy p {
    white-space: normal;
  }

  .chat-card__messages {
    padding: 16px;
  }

  .chat-options {
    margin-left: 0;
    max-width: 100%;
  }

  .chat-card__composer {
    grid-template-columns: 1fr auto;
    padding: 14px 16px 16px;
  }

  .button {
    padding: 0 18px;
  }

  .message__bubble {
    max-width: 88%;
  }

  .chat-option-button {
    width: 100%;
    justify-content: flex-start;
  }
}
