/* Inter font face similar to deno.com/deploy */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("https://rsms.me/inter/font-files/InterVariable.woff2?v=4.0")
    format("woff2");
}

:root {
  --font-sans:
    Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji",
    "Segoe UI Symbol", "Noto Color Emoji";
  --bg-grad-1: #0f172a; /* slate-900 */
  --bg-grad-2: #0b1224;
  --bg-grad-3: #0a0f1f;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --muted: #9aa4b2;
  --text: #e5e7eb; /* gray-200 */
  --accent: #4f46e5; /* indigo-600 */
  --accent-2: #06b6d4; /* cyan-500 */
}

html, body {
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(
      1200px 600px at 10% -10%,
      rgba(13, 148, 136, 0.10),
      transparent 60%
    ),
    radial-gradient(
    800px 500px at 90% -10%,
    rgba(79, 70, 229, 0.12),
    transparent 60%
  ),
    linear-gradient(
    180deg,
    var(--bg-grad-1),
    var(--bg-grad-2) 30%,
    var(--bg-grad-3)
  );
  min-height: 100%;
}

/* Page containers */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Cards and surface elements */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  backdrop-filter: saturate(140%) blur(10px);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  color: var(--text);
  text-decoration: none;
  transition:
    transform 0.12s ease,
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.btn.icon {
  padding: 8px 10px;
  min-width: auto;
}
.btn.primary {
  background: linear-gradient(
    180deg,
    rgba(79, 70, 229, 0.9),
    rgba(37, 99, 235, 0.9)
  );
  color: white;
  border-color: rgba(255, 255, 255, 0.18);
}
.btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14); /* subtle outline on dark */
}
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.22);
}
.btn.ghost:active {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.26);
}

/* Focus and disabled parity with light theme */
.btn:focus,
.btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-color: rgba(255, 255, 255, 0.28);
}
.btn:disabled,
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  margin-bottom: 12px;
}
.header .meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}
.header .avatar {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  border: 1px solid var(--card-border);
}

/* Chat layout */
/* Full-height page structure for chat so the composer is visible initially */
.page-chat {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* allow inner content to shrink and scroll */
}
.chat-shell {
  display: grid;
  grid-template-rows: 1fr auto;
  row-gap: 16px;
  flex: 1;
  min-height: 0; /* ensure messages area can scroll within viewport */
}
.messages {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message {
  padding: 12px 14px;
  border-radius: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.message.user {
  align-self: flex-end;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.message.assistant {
  align-self: flex-start;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--card-border);
  align-items: center; /* vertically center button relative to textarea */
  position: relative; /* anchor mention dropdown */
}
.composer textarea {
  resize: none;
  min-height: 54px;
  max-height: 200px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  outline: none;
}
.composer button {
  min-width: 100px;
}
/* Smaller, centered send button with icon */
.composer .send-btn {
  min-width: auto;
  padding: 8px 12px;
  justify-self: center; /* center horizontally within its grid cell */
  display: inline-flex;
  align-items: center;
  justify-content: center; /* center icon + text */
  gap: 8px;
}

/* Utility */
.center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero {
  padding: 120px 24px 80px;
  text-align: center;
  /* Ensure the hero area stretches to the bottom of the screen
     to avoid any visible demarcation in the background gradient */
  min-height: 100vh;
  box-sizing: border-box;
}
.hero h1 {
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}
.hero p {
  color: var(--muted);
  font-size: 18px;
}

/* Username row & chat layout */
.chat-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.username-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  width: 100%;
}

.username-slot {
  display: inline-flex;
  align-items: center;
}

.username-chip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 16px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.username-chip.filled {
  background: rgba(255, 255, 255, 0.08);
}

.username-chip.active {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.username-chip.empty {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.02);
}

.username-chip-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.username-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
}

.username-avatar.placeholder {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.06);
}

.username-handle {
  color: var(--text);
  font-weight: 500;
}

.reload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.reload-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.reload-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.username-input {
  min-width: 160px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: inherit;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.username-input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.username-input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.16);
  outline-offset: 2px;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

/* Spinner for refreshing */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.btn.icon.spin svg {
  animation: spin 900ms linear infinite;
}
.reload-btn.spin svg {
  animation: spin 900ms linear infinite;
}
