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

:root {
  --bg: #07050b;
  --panel: rgba(16, 11, 24, .78);
  --panel-2: rgba(22, 14, 34, .9);
  --text: #f5f0ff;
  --muted: #91879f;
  --dim: #5f566a;
  --purple: #9b5cff;
  --purple-2: #c28cff;
  --border: rgba(177, 113, 255, .18);
  --border-strong: rgba(177, 113, 255, .38);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 8%, rgba(130, 57, 220, .14), transparent 31rem),
    radial-gradient(circle at 10% 80%, rgba(74, 35, 130, .10), transparent 28rem),
    var(--bg);
  font-family: Inter, system-ui, sans-serif;
}

button, input, textarea { font: inherit; }

button { cursor: pointer; }

.hidden { display: none !important; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.glow {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .11;
  pointer-events: none;
}

.glow-a { background: #7c3aed; top: -14rem; right: -10rem; }
.glow-b { background: #4c1d95; bottom: -16rem; left: -12rem; }

.shell {
  width: min(920px, 92vw);
  min-height: 100vh;
  margin: auto;
  padding: 28px 0 48px;
  position: relative;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  color: var(--purple-2);
  background: rgba(155, 92, 255, .08);
  box-shadow: 0 0 55px rgba(155, 92, 255, .13);
  font-size: 25px;
}

.login-card {
  width: min(420px, 100%);
  margin-top: 40px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.login-card label {
  display: block;
  margin: 0 0 9px 3px;
  color: var(--muted);
  font-size: 12px;
}

.password-row {
  display: flex;
  gap: 8px;
}

input, textarea {
  border: 1px solid var(--border);
  outline: none;
  color: var(--text);
  background: rgba(0, 0, 0, .2);
}

input {
  min-width: 0;
  flex: 1;
  padding: 13px 14px;
  border-radius: 13px;
}

input:focus, textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px rgba(155, 92, 255, .06);
}

.primary, .send {
  border: 0;
  color: white;
  background: linear-gradient(135deg, #8b4df3, #a965ff);
  box-shadow: 0 9px 25px rgba(126, 67, 220, .20);
}

.primary {
  padding: 0 18px;
  border-radius: 13px;
  font-weight: 600;
}

.small { min-width: 75px; }

.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple-2);
  box-shadow: 0 0 14px var(--purple);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.usage {
  color: var(--dim);
  font-size: 10px;
  letter-spacing: .08em;
}

.ghost, .icon-button {
  color: var(--muted);
  border: 1px solid var(--border);
  background: rgba(255,255,255,.02);
  border-radius: 10px;
}

.ghost {
  padding: 7px 11px;
  font-size: 11px;
}

.hero {
  margin: 18vh 0 38px;
}

.hero h2 {
  margin: 8px 0 8px;
  font-size: clamp(44px, 8vw, 82px);
  letter-spacing: -.065em;
  line-height: .98;
  background: linear-gradient(135deg, #fff, #b98aff 75%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p:last-child {
  margin: 0;
  color: var(--muted);
  max-width: 560px;
  font-size: 14px;
  line-height: 1.6;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
  max-height: 54vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.thread:empty {
  display: none;
}

.bubble {
  max-width: 84%;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.7;
}

.bubble.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #9b5cff);
  border-bottom-right-radius: 6px;
}

.bubble.model {
  align-self: flex-start;
  color: #eee7f7;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  border-bottom-left-radius: 6px;
}

.bubble-text {
  white-space: pre-wrap;
}

.sources {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.source-title {
  margin-bottom: 10px;
  color: var(--dim);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .18em;
}

.source {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  margin-top: 7px;
  color: #d9ccef;
  text-decoration: none;
  border: 1px solid rgba(177,113,255,.10);
  border-radius: 12px;
  background: rgba(255,255,255,.015);
  transition: .18s ease;
}

.source:hover {
  border-color: var(--border-strong);
  background: rgba(155,92,255,.06);
  transform: translateX(2px);
}

.source-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.source-arrow {
  margin-left: auto;
  color: var(--purple-2);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel-2);
  box-shadow: 0 25px 80px rgba(0,0,0,.22);
  backdrop-filter: blur(18px);
  transition: .2s ease;
}

.composer:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px rgba(155,92,255,.04), 0 25px 80px rgba(0,0,0,.25);
}

textarea {
  width: 100%;
  max-height: 190px;
  resize: none;
  padding: 12px 13px;
  border: 0;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
}

textarea:focus { box-shadow: none; }

.send {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 22px;
  transition: .18s ease;
}

.send:hover { transform: translateY(-2px); }

.send:disabled { opacity: .45; transform: none; cursor: wait; }

.composer-meta {
  display: flex;
  justify-content: space-between;
  margin: 9px 5px 0;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: .08em;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 22px 0;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: .13em;
}

.loading span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--purple-2);
  animation: pulse 1s infinite ease-in-out;
}

.loading span:nth-child(2) { animation-delay: .13s; }
.loading span:nth-child(3) { animation-delay: .26s; }

.loading em {
  margin-left: 5px;
  font-style: normal;
}

.error {
  min-height: 16px;
  margin: 9px 2px 0;
  color: #ff8fbd;
  font-size: 11px;
}

.center { text-align: center; }

@keyframes pulse {
  0%, 80%, 100% { transform: scale(.55); opacity: .35; }
  40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 600px) {
  .shell { width: 91vw; }
  .hero { margin-top: 13vh; }
  .hero h2 { letter-spacing: -.045em; }
  .composer-meta span:first-child { display: none; }
  .composer-meta { justify-content: flex-end; }
}
