/* Plain CSS, no framework or build step. The whole frontend is three static
   files plus a generated config, which is all a CDN-hosted SPA needs. */

:root {
  --bg: #0f1521;
  --surface: #18212f;
  --surface-raised: #1f2a3a;
  --border: #2c3a4e;
  --text: #e8edf5;
  --text-muted: #9aa8bd;
  --accent: #4f8ef7;
  --accent-hover: #6ba0f9;
  --user-bubble: #2a4a7c;
  --danger: #ff8a8a;
  --danger-bg: #3a1f24;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}

.view { height: 100%; }
.centred { display: grid; place-items: center; padding: 24px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Login ---------------- */

.card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.card__title { margin: 0 0 4px; font-size: 1.5rem; }
.card__subtitle { margin: 0 0 24px; color: var(--text-muted); font-size: 0.9rem; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input, textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}

/* Visible focus ring retained for keyboard users. */
input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- Buttons ---------------- */

.button {
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.button--primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
}
.button--primary:hover:not(:disabled) { background: var(--accent-hover); }

.button--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  font-size: 0.85rem;
}
.button--ghost:hover { color: var(--text); border-color: var(--text-muted); }

.button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------------- Errors ---------------- */

.error {
  margin: 0 0 16px;
  color: var(--danger);
  font-size: 0.875rem;
}

.error--banner {
  margin: 0;
  padding: 10px 20px;
  background: var(--danger-bg);
  border-top: 1px solid var(--border);
}

/* ---------------- Chat shell ---------------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 820px;
  margin: 0 auto;
}

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.app__title { margin: 0; font-size: 1.1rem; }
.app__meta { margin: 0; color: var(--text-muted); font-size: 0.78rem; }
.app__actions { display: flex; align-items: center; gap: 12px; }

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: auto;
  color: var(--text-muted);
  text-align: center;
}

/* ---------------- Message bubbles ---------------- */

.message {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: var(--radius);
  /* pre-wrap preserves the model's newlines and indentation while the text
     itself is inserted as textContent, never as HTML. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message--user {
  align-self: flex-end;
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}

.message--assistant {
  align-self: flex-start;
  background: var(--surface-raised);
  border-bottom-left-radius: 4px;
}

.message__role {
  display: block;
  margin-bottom: 3px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Typing indicator shown while waiting on Bedrock. */
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.3s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* Respect users who have asked the OS to reduce motion. */
@media (prefers-reduced-motion: reduce) {
  .typing span { animation: none; }
  .button { transition: none; }
}

/* ---------------- Composer ---------------- */

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.composer__input {
  flex: 1;
  resize: none;
  max-height: 160px;
}

.composer .button--primary { width: auto; flex-shrink: 0; }

@media (max-width: 560px) {
  .message { max-width: 92%; }
  .app__header { padding: 12px 16px; }
  .transcript, .composer { padding: 16px; }
}
