:root {
  --bg: #0a0f1f;
  --bg-accent: #0b243f;
  --bg-soft: #0f1a2d;
  --card: #0f1628;
  --card-border: rgba(255, 255, 255, 0.06);
  --text: #e8eefc;
  --muted: #9fb0d9;
  --accent: #9efcff;
  --accent-2: #6e7bff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Space Grotesk", "Inter", -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, rgba(110, 123, 255, 0.16), transparent 30%),
    radial-gradient(circle at 70% 0%, rgba(158, 252, 255, 0.18), transparent 28%),
    linear-gradient(145deg, var(--bg), var(--bg-soft) 40%, var(--bg-accent));
  min-height: 100vh;
  margin: 0;
  padding: 24px clamp(16px, 4vw, 48px);
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  width: 380px;
  height: 380px;
  filter: blur(120px);
  opacity: 0.4;
}

.orb-a {
  background: #6e7bff;
  top: -60px;
  left: 15%;
}

.orb-b {
  background: #9efcff;
  bottom: -120px;
  right: 10%;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(20px, 4vw, 32px);
  margin-top: 8px;
}

.side-intro {
  position: relative;
  padding: clamp(18px, 2vw, 26px);
  border: 1px solid var(--card-border);
  background: linear-gradient(135deg, rgba(158, 252, 255, 0.05), rgba(110, 123, 255, 0.04));
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.language-switch {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.flag {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 16px;
}

.flag.active {
  outline: 2px solid rgba(158, 252, 255, 0.6);
  background: rgba(158, 252, 255, 0.12);
}

.welcome {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.15;
}

.lede {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 18px;
  max-width: 60ch;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: rgba(15, 22, 40, 0.85);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: clamp(18px, 3vw, 24px);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.icon-accent {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(110, 123, 255, 0.15);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

md-filled-text-field,
md-filled-button {
  --md-sys-color-primary: #9efcff;
  --md-sys-color-on-primary: #041026;
  color: var(--text);
}

.text-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  width: 100%;
}

.text-field input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  outline: none;
  width: 100%;
}

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

.chat-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  width: 100%;
}

.chat-field input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  outline: none;
  width: 100%;
}

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

.send-button {
  --md-sys-color-primary: #9efcff;
  --md-sys-color-on-primary: #041026;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  min-height: 52px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(120deg, #9efcff, #6e7bff);
  color: #041026;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
  box-shadow: var(--shadow);
}

.hidden-element {
  display: none !important;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
  min-height: 20px;
}

.hidden {
  display: none !important;
}

.loading {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 10;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #9efcff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.typing {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  padding: 8px 0;
}

.typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1s infinite;
}

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

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

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.chat-log {
  background: rgba(9, 13, 26, 0.5);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 12px;
  min-height: 360px;
  max-height: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.message .avatar {
  min-width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: rgba(158, 252, 255, 0.12);
  border: 1px solid var(--card-border);
}

.message .avatar .material-symbols-outlined {
  font-size: 22px;
  color: #9efcff;
}

.message.user .avatar {
  background: rgba(110, 123, 255, 0.2);
}

.bubble {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  line-height: 1.45;
}

.message.user .bubble {
  background: rgba(110, 123, 255, 0.12);
}

.thumb-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.thumb-row img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  object-fit: cover;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
  align-items: stretch;
}

.chat-form button {
  height: 100%;
}

.turns {
  padding: 8px 12px;
  background: rgba(158, 252, 255, 0.12);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: #d7f7ff;
  font-weight: 600;
}

.turns + .chat-log {
  margin-top: 12px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-form button,
  .chat-form md-filled-button,
  #chat-input {
    width: 100%;
  }
}
