@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700&display=swap");

:root {
  --bg: #050c1f;
  --card: #0d162e;
  --border: #1b2742;
  --text: #e5ecff;
  --muted: #95a2c4;
  --accent: #4be1ec;
  --accent-2: #63a4ff;
  --shadow: 0 20px 60px rgba(4, 9, 24, 0.55);
  --radius: 18px;
}

* {
  box-sizing: border-box;
  font-family: "Manrope", "SF Pro Display", "Inter", system-ui, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 120% at 30% 20%, #142447, #050c1f 50%, #040815);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll {
  overflow: hidden;
}

body.keyboard-open .app-shell {
  padding-bottom: max(34px, env(safe-area-inset-bottom) + 20px);
}

.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  justify-content: center;
  padding: 20px 16px 40px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  transition: padding-bottom 0.2s ease;
}

.app-root {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-container {
  width: min(540px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 10px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 14px;
  border-radius: 16px;
  backdrop-filter: blur(8px);
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--accent), #7af9a6);
  box-shadow: 0 0 0 6px rgba(75, 225, 236, 0.08);
}

.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  background: #132a57;
  color: #9fc5ff;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #26457a;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 0.85rem;
}

.pill {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  background: #0ea5e9;
  color: #041221;
}

.pill.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.pill.ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pill.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #021020;
  box-shadow: 0 10px 30px rgba(75, 225, 236, 0.25);
}

.pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0.95;
}

.pill:active {
  transform: translateY(0);
  opacity: 0.9;
}

.pill.full-width {
  width: 100%;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

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

.app-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.app-header h1 {
  margin: 4px 0;
  letter-spacing: -0.3px;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
}

.app-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 3.4vw, 1.05rem);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.section-header h2 {
  margin: 4px 0 6px;
  font-size: clamp(1.2rem, 4vw, 1.5rem);
}

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7ea5ff;
}

.small {
  font-size: 0.9rem;
  color: var(--muted);
}

.language-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.chip {
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  font-size: 0.95rem;
}

.chip:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 164, 255, 0.6);
}

.chip.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #021020;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(99, 164, 255, 0.35);
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  align-items: stretch;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field input,
.field select {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 16px;
}

.field input::placeholder {
  color: #6f7da0;
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8'%3E%3Cpath fill='%23b9c8ff' d='M1 1l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.field.checkbox input {
  width: 18px;
  height: 18px;
}

.chat-card {
  overflow: hidden;
  position: relative;
}

.chat-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 50vh;
  flex: 1;
}

.chat-log,
.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  margin: 4px 0 6px;
  overflow-y: auto;
  padding-right: 4px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.chat-log::-webkit-scrollbar {
  width: 6px;
}

.chat-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 10px;
}

.chat-log,
.message-list {
  scrollbar-width: thin;
}

.chat-message,
.message {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  word-break: break-word;
}

.chat-message.user,
.message.user {
  align-self: flex-end;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #021020;
}

.chat-message.bot,
.message.bot {
  align-self: flex-start;
  background: #f97316;
  border: 1px solid rgba(0, 0, 0, 0.05);
  color: #2b1202;
  box-shadow: 0 10px 25px rgba(249, 115, 22, 0.25);
}

.message a.message-link {
  color: #bfe0ff;
  text-decoration: underline;
  word-break: break-all;
}

.chat-input-wrapper,
.message-input {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  position: sticky;
  bottom: 0;
  backdrop-filter: blur(6px);
}

#chat-input {
  flex: 1;
  resize: none;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  min-height: 56px;
  font-size: 16px;
}

#chat-input::placeholder {
  color: #6f7da0;
}

#chat-send {
  white-space: nowrap;
}

.app-footer {
  text-align: center;
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
}

.link-button {
  background: none;
  border: none;
  color: #9fc5ff;
  cursor: pointer;
  font-weight: 600;
  padding: 6px 8px;
}

.link-button:hover {
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.modal-sheet {
  position: relative;
  background: #0b1327;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px 24px;
  width: min(720px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
}

.modal-handle {
  width: 48px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  margin: 0 auto 12px;
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

#legal-content h2 {
  margin-top: 0;
}

#legal-content h3 {
  margin-bottom: 6px;
}

#legal-content p {
  color: #c6d3f5;
}

#legal-content ul {
  padding-left: 18px;
  color: #c6d3f5;
}

@media (max-width: 520px) {
  .app-shell {
    padding: max(16px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom) + 10px);
  }
  .app-container {
    gap: 12px;
  }
  .card {
    padding: 16px;
  }
  .brand-pill,
  .meta {
    width: 100%;
    justify-content: space-between;
  }
  .chat-log {
    max-height: 60vh;
  }
  .chat-input-wrapper {
    align-items: center;
  }
  .pill,
  .chip,
  .field input,
  .field select,
  #chat-input {
    font-size: 16px;
  }
}
