:root {
  color-scheme: dark;
  --bg: #07111d;
  --bg-accent: #0a1a2c;
  --panel: #121f31;
  --panel-strong: #17263a;
  --panel-soft: #0d1827;
  --ink: #f5f9fd;
  --muted: #9db1cb;
  --line: #29415f;
  --line-strong: #345782;
  --accent: #247aff;
  --accent-strong: #1d63d0;
  --accent-soft: rgba(36, 122, 255, 0.14);
  --success-soft: rgba(47, 122, 83, 0.22);
  --danger-soft: rgba(122, 46, 37, 0.26);
  --warning-soft: rgba(139, 106, 46, 0.24);
  --user: linear-gradient(135deg, rgba(36, 122, 255, 0.24) 0%, rgba(21, 58, 107, 0.9) 100%);
  --assistant: linear-gradient(180deg, rgba(11, 22, 38, 0.96) 0%, rgba(12, 21, 34, 0.98) 100%);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(36, 122, 255, 0.18), transparent 24%),
    radial-gradient(circle at 88% 14%, rgba(29, 214, 161, 0.1), transparent 18%),
    linear-gradient(180deg, #08111d 0%, var(--bg) 100%);
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 28px;
}

.auth-page-shell {
  min-height: calc(100vh - 52px);
  display: flex;
  align-items: center;
}

.hidden {
  display: none !important;
}

.auth-shell {
  display: flex;
  justify-content: center;
  width: 100%;
}

.auth-card {
  width: min(980px, 100%);
  padding: 30px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(18, 31, 49, 0.96), rgba(13, 24, 39, 0.98));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-header {
  margin-bottom: 18px;
}

.auth-title {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3vw, 2.9rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.auth-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-link-switch {
  text-decoration: none;
}

.auth-panel {
  margin-top: 12px;
}

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

.compact {
  gap: 10px;
}

.top-gap {
  margin-top: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

input,
textarea,
button {
  font: inherit;
}

.auth-card input,
.auth-card textarea,
.composer textarea {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  color: var(--ink);
  background: #0c1624;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}

.auth-card input::placeholder,
.auth-card textarea::placeholder,
.composer textarea::placeholder {
  color: #6f88a7;
}

.auth-error {
  min-height: 24px;
  margin-top: 14px;
  color: #ffb5aa;
  font-weight: 700;
}

.info-card {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(10, 18, 30, 0.9);
  border: 1px solid var(--line);
}

.hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.hero,
.chat,
.status-card,
.composer,
.message .bubble {
  border-radius: 24px;
}

.hero > div,
.chat {
  background: linear-gradient(180deg, rgba(18, 31, 49, 0.96), rgba(13, 24, 39, 0.98));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 28px;
}

.status-card {
  padding: 24px;
  background: linear-gradient(180deg, rgba(16, 27, 42, 0.98), rgba(10, 18, 30, 0.98));
  border: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: #8ec0ff;
  font-weight: 700;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(2rem, 3.2vw, 3.1rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.lede,
#status-copy,
.helper,
.file-note,
.message-meta,
.citation-strip,
.source-strip {
  color: var(--muted);
}

.lede {
  max-width: 58ch;
  font-size: 1rem;
}

.hero-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.mini-stat {
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(36, 122, 255, 0.12);
  border: 1px solid rgba(59, 127, 212, 0.4);
  color: #dcecff;
  font-size: 0.84rem;
  font-weight: 700;
}

.pill-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.82rem;
  font-weight: 700;
}

.pill-soft {
  background: rgba(19, 54, 99, 0.92);
  color: #dbeaff;
}

.status-title,
.panel-title {
  margin: 0;
  letter-spacing: -0.02em;
}

.status-title {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.ghost,
.send,
.upload-chip {
  border-radius: 14px;
  font: inherit;
}

.ghost,
.upload-chip {
  padding: 11px 14px;
  border: 1px solid #23384f;
  background: #223651;
  color: #f2f7fc;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.ghost:hover,
.upload-chip:hover,
.send:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.ghost:hover,
.upload-chip:hover {
  background: #29425f;
  border-color: #345782;
}

.ghost-danger {
  background: rgba(122, 46, 37, 0.22);
  border-color: rgba(158, 78, 69, 0.5);
  color: #ffd1c9;
}

.ghost.is-active {
  background: linear-gradient(135deg, #247aff, #3f8dff);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(36, 122, 255, 0.22);
}

.chat {
  padding: 18px;
}

.chat-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 6px 12px;
}

.panel-label {
  margin: 0 0 6px;
  color: #8ec0ff;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  font-weight: 700;
}

.panel-title {
  font-size: 1.28rem;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 420px;
  max-height: 58vh;
  overflow: auto;
  padding: 12px 8px 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(10, 18, 30, 0.9) 0%, rgba(8, 15, 25, 0.96) 100%);
  border: 1px solid rgba(35, 56, 79, 0.84);
}

.message {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.message.user {
  align-items: flex-end;
}

.message.assistant {
  align-items: flex-start;
}

.message .bubble {
  max-width: min(780px, 92%);
  padding: 16px 18px;
  white-space: pre-wrap;
  line-height: 1.5;
  border: 1px solid rgba(35, 56, 79, 0.8);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
}

.message.user .bubble {
  background: var(--user);
}

.message.assistant .bubble {
  background: var(--assistant);
}

.typing-message .bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 72px;
  max-width: fit-content;
  padding: 14px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(15, 27, 43, 0.98) 0%, rgba(11, 21, 34, 0.98) 100%);
}

.typing-message .source-strip {
  display: none;
}

.typing-message .citation-strip,
.typing-message .message-actions {
  display: none;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 12px;
}

.typing-indicator span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, #8ec0ff 0%, #d7ecff 100%);
  opacity: 0.35;
  animation: typingPulse 1.1s infinite ease-in-out;
  box-shadow: 0 0 0 1px rgba(142, 192, 255, 0.08);
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.32s;
}

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

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

.message-meta {
  font-size: 0.8rem;
  font-weight: 700;
}

.citation-strip,
.source-strip {
  font-size: 0.88rem;
  max-width: min(780px, 92%);
}

.citation-strip {
  color: #8ec0ff;
  font-weight: 700;
}

.message-actions {
  max-width: min(780px, 92%);
}

.message-action-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 10px;
  border: 1px solid rgba(59, 127, 212, 0.38);
  background: rgba(36, 122, 255, 0.12);
  color: #dcecff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.message-action-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
  background: rgba(36, 122, 255, 0.18);
  border-color: rgba(142, 192, 255, 0.52);
}
}

.composer {
  margin-top: 14px;
  padding: 18px;
  background: rgba(10, 18, 30, 0.82);
  border: 1px solid rgba(35, 56, 79, 0.84);
}

.composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.composer textarea {
  resize: vertical;
  min-height: 120px;
}

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.send {
  padding: 13px 18px;
  background: linear-gradient(135deg, #247aff, #3f8dff);
  border: 1px solid transparent;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.send:disabled {
  opacity: 0.6;
  cursor: progress;
}

.upload-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-weight: 700;
  background: rgba(35, 56, 79, 0.9);
}

.upload-chip input {
  display: none;
}

.file-note {
  font-size: 0.92rem;
  text-align: right;
}

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

  .shell {
    width: min(100vw - 18px, 1000px);
    margin: 10px auto 18px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-top,
  .chat-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .file-note {
    text-align: left;
  }

  .send {
    width: 100%;
  }
}
