:root {
  --accent: #ff6500;
  --primary: #1e3e62;
  --navy: #0b192c;
  --black: #000000;

  --page-bg: #f5f8fc;
  --surface: #ffffff;
  --surface-soft: #f1f5fb;
  --surface-muted: #e8edf6;
  --text: #101928;
  --text-soft: #5d6675;
  --border: #d7e1ef;
  --shadow: 0 20px 55px rgba(11, 25, 44, 0.16);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --motion-fast: 240ms;
  --motion-slow: 280ms;
}

/* Theme tokens are swapped via body.theme-dark. */
body.theme-dark {
  --page-bg: #0b192c;
  --surface: #1e3e62;
  --surface-soft: #23486f;
  --surface-muted: #35577b;
  --text: #f4f8ff;
  --text-soft: #d4dde9;
  --border: #2e5379;
  --shadow: 0 26px 60px rgba(0, 0, 0, 0.42);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: "Poppins", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 12%, rgba(30, 62, 98, 0.2), transparent 40%),
    radial-gradient(circle at 85% 88%, rgba(255, 101, 0, 0.17), transparent 40%),
    var(--page-bg);
  transition:
    background-color var(--motion-fast) ease,
    color var(--motion-fast) ease;
}

body.chat-open {
  overflow: hidden;
}

.landing-page {
  min-height: 100vh;
  padding: clamp(2rem, 4vw, 4rem);
  display: flex;
  align-items: center;
}

.hero {
  max-width: 760px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 700;
}

.hero h1 {
  margin: 0.75rem 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.07;
  color: var(--navy);
}

.hero p {
  margin: 0;
  max-width: 62ch;
  color: var(--text-soft);
}

body.theme-dark .hero h1 {
  color: #f8fafc;
}

.chat-launcher {
  position: fixed;
  right: clamp(1rem, 2vw, 1.5rem);
  bottom: clamp(1rem, 2vw, 1.5rem);
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff8440);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 26px rgba(255, 101, 0, 0.34);
  cursor: pointer;
  z-index: 1100;
  transition:
    transform var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease,
    opacity var(--motion-fast) ease;
}

.chat-launcher svg {
  width: 31px;
  height: 31px;
  position: relative;
  z-index: 2;
}

.chat-launcher:hover,
.chat-launcher:focus-visible {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 18px 30px rgba(255, 101, 0, 0.44);
  outline: none;
}

.launcher-glow {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.55);
  opacity: 0.4;
}

body.chat-open .chat-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.86);
}

/* Floating dialog: desktop card, mobile app shell. */
.chat-dialog {
  position: fixed;
  right: clamp(1rem, 2vw, 1.5rem);
  bottom: calc(clamp(1rem, 2vw, 1.5rem) + 78px);
  width: min(35vw, 540px);
  min-width: 360px;
  height: 80vh;
  max-height: 880px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
  z-index: 1200;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  pointer-events: none;
  transition:
    opacity var(--motion-slow) ease,
    transform var(--motion-slow) ease,
    background-color var(--motion-fast) ease,
    border-color var(--motion-fast) ease;
}

.chat-dialog.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-topbar {
  min-height: 60px;
  padding: 0.75rem 0.95rem;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 600;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.theme-switch {
  position: relative;
  width: 46px;
  height: 26px;
  display: inline-flex;
  align-items: center;
}

.theme-switch input {
  width: 0;
  height: 0;
  opacity: 0;
  position: absolute;
}

.switch-track {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: background-color var(--motion-fast) ease;
}

.switch-track::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform var(--motion-fast) ease;
}

.theme-switch input:checked + .switch-track {
  background: var(--accent);
}

.theme-switch input:checked + .switch-track::before {
  transform: translateX(20px);
}

.theme-switch input:focus-visible + .switch-track {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.chat-tagbar {
  padding: 0.8rem 0.95rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition:
    background-color var(--motion-fast) ease,
    border-color var(--motion-fast) ease;
}

.custom-select-wrap {
  position: relative;
}

.tag-select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 0.65rem 2.25rem 0.65rem 0.8rem;
  transition:
    border-color var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease,
    background-color var(--motion-fast) ease;
}

.tag-select:hover {
  border-color: rgba(30, 62, 98, 0.56);
}

.tag-select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 101, 0, 0.15);
}

.select-chevron {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: var(--text-soft);
  pointer-events: none;
}

.select-chevron svg {
  width: 100%;
  height: 100%;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  background:
    linear-gradient(180deg, rgba(255, 101, 0, 0.04), transparent 22%),
    var(--surface-soft);
  transition: background-color var(--motion-fast) ease;
}

body.theme-dark .chat-body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 30%),
    #17324f;
}

.welcome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 8px 22px rgba(11, 25, 44, 0.08);
}

.welcome-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), #ff863f);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.welcome-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 600;
}

.welcome-text {
  margin: 0.1rem 0 0;
  color: var(--text-soft);
  font-size: 0.87rem;
}

.message-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: min(92%, 460px);
}

.message-row--user {
  align-self: flex-end;
}

.message-row--bot {
  align-self: flex-start;
}

.message-bubble {
  border-radius: 16px;
  padding: 0.75rem 0.9rem;
  line-height: 1.45;
  border: 1px solid transparent;
  word-break: break-word;
}

.message-bubble--user {
  border-bottom-right-radius: 7px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), #ff8742);
}

.message-bubble--bot {
  border-bottom-left-radius: 7px;
  background: var(--surface);
  border-color: var(--border);
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.bubble-author {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
}

.language-badge {
  font-size: 0.68rem;
  padding: 0.14rem 0.42rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-soft);
}

.message-text {
  margin: 0;
  font-size: 0.92rem;
}

.message-text.is-editing {
  outline: 2px dashed rgba(255, 255, 255, 0.7);
  outline-offset: 3px;
  border-radius: 6px;
  padding: 1px;
}

.message-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.34rem;
}

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

.language-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.language-select {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.68rem;
  padding: 0.25rem 0.45rem;
  transition:
    border-color var(--motion-fast) ease,
    background-color var(--motion-fast) ease;
}

.language-select:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  transition:
    transform var(--motion-fast) ease,
    background-color var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    color var(--motion-fast) ease;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border);
  transform: translateY(-1px);
  outline: none;
}

.icon-btn.is-active {
  color: var(--accent);
  border-color: rgba(255, 101, 0, 0.35);
  background: rgba(255, 101, 0, 0.12);
}

.icon-btn.compact {
  width: 28px;
  height: 28px;
}

.icon-btn.topbar-btn {
  color: #fff;
}

.icon-btn.topbar-btn:hover,
.icon-btn.topbar-btn:focus-visible {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.17);
}

.icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  background: var(--navy);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity var(--motion-fast) ease,
    transform var(--motion-fast) ease;
}

.icon-btn[data-tooltip]:hover::after,
.icon-btn[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.chat-inputbar {
  padding: 0.78rem 0.95rem 0.95rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 0.7rem;
  transition:
    border-color var(--motion-fast) ease,
    background-color var(--motion-fast) ease;
}

.input-stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.chat-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  padding: 0.72rem 0.82rem;
  transition:
    border-color var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease,
    background-color var(--motion-fast) ease;
}

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

.chat-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 101, 0, 0.14);
}

.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(11, 25, 44, 0.12);
  max-height: 140px;
  overflow-y: auto;
}

.suggestion-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  padding: 0.45rem 0.52rem;
  font-family: inherit;
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
  transition: background-color var(--motion-fast) ease;
}

.suggestion-item:hover,
.suggestion-item:focus-visible {
  background: var(--surface-soft);
  outline: none;
}

.send-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), #ff8a47);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 20px rgba(255, 101, 0, 0.28);
  cursor: pointer;
  transition:
    transform var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease;
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

.send-btn:hover,
.send-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 13px 24px rgba(255, 101, 0, 0.36);
  outline: none;
}

.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: 1080px) {
  .chat-dialog {
    width: min(45vw, 500px);
  }
}

@media (max-width: 900px) {
  .chat-dialog {
    width: min(52vw, 460px);
    min-width: 320px;
  }
}

@media (max-width: 768px) {
  .landing-page {
    padding: 1.2rem;
    align-items: flex-start;
  }

  .hero h1 {
    margin-top: 0.4rem;
  }

  .chat-dialog {
    right: 0;
    bottom: 0;
    width: 100vw;
    min-width: 0;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
}
