:root {
  --bg: #0a0e17;
  --bg-glow: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(34, 211, 238, 0.08), transparent);
  --fg: #e7ecf3;
  --card-bg: #10151f;
  --card-bg-raised: #141b28;
  --border: #232c3d;
  --border-strong: #2f3a4f;
  --accent: #22d3ee;
  --accent-dim: #0e7490;
  --accent-fg: #04141a;
  --muted: #8b96a8;
  --error: #ff6b6b;
  --success: #34d399;
  --success-fg: #04140d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg) var(--bg-glow);
  color: var(--fg);
  min-height: 100vh;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 2rem;
  background: rgba(16, 21, 31, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header .brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(52, 211, 153, 0.08);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.live-badge .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.layout {
  max-width: 640px;
  margin: 1.5rem auto;
  padding: 0 1rem 3rem;
  display: grid;
  gap: 1.25rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 8px 24px rgba(0, 0, 0, 0.2);
}

.card h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.chat-card {
  display: flex;
  flex-direction: column;
  height: 75vh;
  max-height: 800px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-log {
  flex: 1;
  min-height: 0; /* required so this flex child can actually shrink and scroll instead of growing with content */
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 0.75rem;
  margin: 0.85rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-message {
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  max-width: 85%;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.45;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 500;
}

.chat-message.assistant {
  align-self: flex-start;
  background: var(--card-bg-raised);
  border: 1px solid var(--border);
}

.chat-message.assistant.flagged {
  border-color: var(--success);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.25);
}

.chat-message .inline-action {
  display: block;
  margin-top: 0.6rem;
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

input[type="text"] {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--card-bg-raised);
  color: var(--fg);
  font-size: 0.92rem;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

input[type="text"]::placeholder { color: var(--muted); }

button, .button {
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: filter 0.15s ease, transform 0.05s ease;
}

button:hover, .button:hover { filter: brightness(1.1); }
button:active, .button:active { transform: translateY(1px); }

.button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.button.ghost:hover { color: var(--fg); border-color: var(--muted); filter: none; }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.attach-wrapper { position: relative; }

.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  background: var(--card-bg-raised);
  color: var(--fg);
  border: 1px solid var(--border-strong);
}

.icon-button:hover { border-color: var(--accent); color: var(--accent); filter: none; }

.send-button {
  font-size: 1rem;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
}

.send-button:hover { filter: brightness(1.1); }

.attach-menu {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0;
  background: var(--card-bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  min-width: 230px;
  overflow: hidden;
  z-index: 10;
}

.attach-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 1rem;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--fg);
  font-size: 0.9rem;
  cursor: pointer;
}

.attach-menu-item:hover { background: var(--bg); }

.status { margin-top: 0.6rem; font-size: 0.9rem; color: var(--muted); }
.status.error { color: var(--error); }
.status.success { color: var(--success); }

.hidden { display: none !important; }
