@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #0c0e26;
  --ink: #ffffff;
  --muted: rgba(234, 234, 234, 0.75);
  --card: #131a36;
  --accent: #6571e5;
  --accent-dark: #4f5bd3;
  --highlight: #39b9b7;
  --border: #222c52;
  --shadow: 0 30px 80px rgba(2, 3, 20, 0.7);
  --glow: rgba(101, 113, 229, 0.35);
  --safe-bottom: env(safe-area-inset-bottom, 12px);
  --app-height: 100svh;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: var(--app-height);
  height: var(--app-height);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--ink);
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 10% -10%, rgba(101, 113, 229, 0.28), transparent 72%),
    radial-gradient(820px 520px at 80% 5%, rgba(57, 185, 183, 0.18), transparent 72%),
    radial-gradient(720px 480px at 85% 85%, rgba(101, 113, 229, 0.18), transparent 72%),
    linear-gradient(180deg, #0c0e26 0%, #131a36 100%);
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(101, 113, 229, 0.06) 0,
      rgba(101, 113, 229, 0.06) 1px,
      transparent 1px,
      transparent 26px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(57, 185, 183, 0.04) 0,
      rgba(57, 185, 183, 0.04) 1px,
      transparent 1px,
      transparent 32px
    );
  pointer-events: none;
  z-index: -1;
}

.brand-flow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.95;
}

.flow-arrow {
  position: absolute;
  opacity: 0;
  animation: arrow-flow 6s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(57, 185, 183, 0.25));
}

.arrow-1 {
  left: 6%;
  top: 70%;
  width: 32px;
  height: 32px;
  color: #6571e5;
  animation-delay: 0s;
}

.arrow-2 {
  left: 14%;
  top: 45%;
  width: 26px;
  height: 26px;
  color: #39b9b7;
  animation-delay: 1.2s;
}

.arrow-3 {
  left: 10%;
  top: 22%;
  width: 22px;
  height: 22px;
  color: #a9e5bb;
  animation-delay: 2.8s;
}

.arrow-4 {
  left: 22%;
  top: 78%;
  width: 28px;
  height: 28px;
  color: #39b9b7;
  animation-delay: 0.6s;
}

.arrow-5 {
  left: 76%;
  top: 56%;
  width: 30px;
  height: 30px;
  color: #6571e5;
  animation-delay: 1.8s;
}

.arrow-6 {
  left: 86%;
  top: 32%;
  width: 24px;
  height: 24px;
  color: #a9e5bb;
  animation-delay: 0.3s;
}

.arrow-7 {
  left: 92%;
  top: 72%;
  width: 28px;
  height: 28px;
  color: #6571e5;
  animation-delay: 2.4s;
}

.arrow-8 {
  left: 78%;
  top: 18%;
  width: 26px;
  height: 26px;
  color: #39b9b7;
  animation-delay: 1.5s;
}

.arrow-9 {
  left: 89%;
  top: 85%;
  width: 22px;
  height: 22px;
  color: #6571e5;
  animation-delay: 3.2s;
}

.arrow-10 {
  left: 12%;
  top: 86%;
  width: 24px;
  height: 24px;
  color: #a9e5bb;
  animation-delay: 2s;
}

.arrow-11 {
  left: 50%;
  top: 12%;
  width: 20px;
  height: 20px;
  color: #6571e5;
  animation-delay: 0.9s;
}

.arrow-12 {
  left: 36%;
  top: 82%;
  width: 26px;
  height: 26px;
  color: #6571e5;
  animation-delay: 2.6s;
}

.shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  height: var(--app-height);
  min-height: var(--app-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(101, 113, 229, 0.45);
  animation: pulse 1.8s infinite;
}

.panel {
  background: rgba(19, 26, 54, 0.78);
  border-radius: 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  height: 100%;
  flex: 1;
  position: relative;
  backdrop-filter: blur(0.5px) saturate(1.01);
  -webkit-backdrop-filter: blur(0.5px) saturate(1.01);
  padding-bottom: 0;
}

.panel-header {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(19, 26, 54, 0.88);
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  box-shadow: 0 8px 18px rgba(2, 3, 20, 0.45);
  backdrop-filter: blur(8px);
}

.brand-logo {
  height: 20px;
  width: auto;
  filter: drop-shadow(0 0 8px rgba(121, 242, 192, 0.2));
}

.panel-header .title {
  color: var(--accent);
  font-weight: 600;
}

.panel-header .divider {
  opacity: 0.4;
}

.new-chat {
  margin-left: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #cfd6ff;
  border: none;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 0 10px rgba(207, 214, 255, 0.5);
  transition: color 0.2s ease, text-shadow 0.2s ease, transform 0.2s ease;
}

.new-chat:hover {
  color: #e6ebff;
  text-shadow: 0 0 14px rgba(230, 235, 255, 0.7);
  transform: translateY(-1px);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  padding-top: 46px;
  padding-bottom: 12px;
}

.message {
  display: flex;
}

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

.bubble {
  width: fit-content;
  max-width: min(900px, 100%);
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(19, 26, 54, 0.58);
  border: 1px solid rgba(101, 113, 229, 0.28);
  box-shadow: 0 12px 30px rgba(2, 3, 20, 0.5);
  backdrop-filter: blur(0.5px) saturate(1.02);
  -webkit-backdrop-filter: blur(0.5px) saturate(1.02);
  animation: rise 0.4s ease-out;
}

.message.user .bubble {
  background: rgba(101, 113, 229, 0.45);
  border: 1px solid rgba(101, 113, 229, 0.45);
  color: #ffffff;
  text-align: left;
  backdrop-filter: blur(0.5px) saturate(1.03);
  -webkit-backdrop-filter: blur(0.5px) saturate(1.03);
}

.message.pending .bubble {
  opacity: 0.7;
}

.status-label {
  margin-right: 10px;
}

.wave {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
}

.wave-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  animation: wave 1.2s ease-in-out infinite;
  transform: translateY(0);
}

.wave-dot:nth-child(2) {
  animation-delay: 0.12s;
}

.wave-dot:nth-child(3) {
  animation-delay: 0.24s;
}

.wave-dot:nth-child(4) {
  animation-delay: 0.36s;
}

.wave-dot:nth-child(5) {
  animation-delay: 0.48s;
}

.role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
  color: var(--muted);
}

.message.user .role {
  color: rgba(255, 255, 255, 0.75);
}

.text {
  white-space: normal;
  line-height: 1.45;
}

.text p {
  margin: 0 0 6px;
}

.text p:last-child {
  margin-bottom: 0;
}

.text ul,
.text ol {
  margin: 6px 0 6px 20px;
  padding: 0;
}

.text li {
  margin-bottom: 4px;
}

.text li:last-child {
  margin-bottom: 0;
}

.text li p {
  margin: 0;
}

.text code {
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95em;
  background: rgba(15, 107, 111, 0.1);
  padding: 2px 6px;
  border-radius: 6px;
}

.text pre {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(15, 107, 111, 0.08);
  overflow-x: auto;
}

.text table {
  width: max-content;
  max-width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.95rem;
}

.text th,
.text td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(27, 35, 38, 0.12);
  text-align: left;
  vertical-align: top;
}

.text th {
  font-weight: 600;
  color: var(--ink);
}

.text table tr:last-child td {
  border-bottom: none;
}

.text pre code {
  background: transparent;
  padding: 0;
  display: block;
  white-space: pre;
}

.text a {
  color: var(--accent);
  text-decoration: none;
}

.text a:hover {
  text-decoration: underline;
}

.text .obs-token {
  display: inline-flex;
  align-items: baseline;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid rgba(101, 113, 229, 0.35);
  background: rgba(101, 113, 229, 0.14);
  color: inherit;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: help;
}

.text .obs-token.missing {
  border-color: rgba(255, 123, 123, 0.45);
  background: rgba(255, 123, 123, 0.12);
}

.text .obs-token.verified {
  border-color: rgba(64, 166, 113, 0.55);
  background: rgba(64, 166, 113, 0.14);
}

.text .obs-token.mismatch {
  border-color: rgba(255, 123, 123, 0.7);
  background: rgba(255, 123, 123, 0.22);
}

.obs-tooltip {
  position: absolute;
  z-index: 9999;
  max-width: 320px;
  background: #0f1529;
  color: #f6f7fb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  pointer-events: none;
}

.obs-tooltip.hidden {
  display: none;
}

.obs-tip-title {
  font-weight: 700;
  margin-bottom: 2px;
}

.obs-tip-subtitle {
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 4px;
}

.obs-tip-value {
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.obs-tip-source,
.obs-tip-entity {
  color: rgba(255, 255, 255, 0.82);
}

.obs-tip-link a {
  color: #8ad4ff;
  text-decoration: underline;
}

.meta {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(34, 44, 82, 0.85);
  font-size: 0.82rem;
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(101, 113, 229, 0.2);
  border: 1px solid rgba(101, 113, 229, 0.35);
  color: #eaeaea;
  font-size: 0.76rem;
  white-space: nowrap;
  position: relative;
}

.meta-icon {
  font-size: 0.9rem;
  opacity: 0.8;
}

.meta-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  background: rgba(10, 13, 34, 0.95);
  border: 1px solid rgba(101, 113, 229, 0.4);
  color: #ffffff;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 5;
}

.meta-item[data-tooltip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: rgba(10, 13, 34, 0.95) transparent transparent transparent;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.meta-item[data-tooltip]:hover::after,
.meta-item[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 calc(10px + var(--safe-bottom));
  margin: 0;
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: transparent;
  z-index: 50;
  border-top: none;
  backdrop-filter: none;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

textarea {
  resize: vertical;
  min-height: 64px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  font-family: inherit;
  font-size: 1rem;
  background: rgba(27, 35, 68, 0.92);
  color: var(--ink);
  box-shadow: inset 0 2px 10px rgba(2, 3, 20, 0.6);
  flex: 1 1 auto;
  min-width: 0; /* prevent shrink-to-nothing on narrow screens */
  box-sizing: border-box;
}

textarea:focus {
  outline: 2px solid rgba(101, 113, 229, 0.45);
  border-color: rgba(101, 113, 229, 0.6);
}

.actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-self: stretch;
  justify-content: flex-end;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button#send {
  background: linear-gradient(135deg, #6b7bff, #7f8dff);
  color: #0c0e26;
  box-shadow: 0 10px 18px rgba(101, 113, 229, 0.25);
}

button:hover {
  transform: translateY(-1px);
}

.prompt-bank {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.28s ease, transform 0.28s ease;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.prompt-bank.hidden {
  display: none;
}

.prompt-bank.fading {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.prompt-bank.inline {
  margin-top: 6px;
}

.prompt-bank.intro .prompt-title {
  color: #f7f9fc;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.1px;
}

.caide-hi {
  color: #8ad4ff;
  font-weight: 800;
}

.prompt-bank.intro .prompt-body {
  color: #dfe4ff;
  line-height: 1.4;
  font-size: 0.95rem;
}

.prompt-bank.intro ul {
  margin: 6px 0 2px 18px;
  padding: 0;
  list-style: disc;
}

.prompt-bank.intro li {
  margin: 2px 0;
}

.prompt-bank.intro .prompt-body.secondary {
  color: #c5c9df;
  font-size: 0.92rem;
  margin-top: 4px;
}

.prompt-title {
  font-weight: 600;
  color: var(--muted);
}

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

.prompts button {
  background: rgba(27, 35, 68, 0.7);
  color: var(--ink);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(101, 113, 229, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(101, 113, 229, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(101, 113, 229, 0);
  }
}

@keyframes wave {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  50% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

@keyframes arrow-flow {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.8);
  }
  15% {
    opacity: 0.18;
  }
  85% {
    opacity: 0.18;
  }
  100% {
    opacity: 0;
    transform: translate(60px, -90px) scale(1.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow-arrow {
    animation: none;
    opacity: 0.1;
  }
  .pulse {
    animation: none;
  }
}

@media (max-width: 760px) {
  .panel {
    padding: 12px;
    padding-bottom: 0;
  }

  .messages {
    max-height: none;
    padding-bottom: 12px;
  }

  .panel-header {
    left: 12px;
    right: 12px;
  }

  .composer-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .actions {
    flex-direction: row;
    justify-content: flex-end;
  }

}
