:root {
  --text: #1a1a2e;
  --text-muted: #5a5a72;
  --bg: #ffffff;
  --bg-light: #f5f6f8;
  --panel-bg: #faf9f7;
  --accent: #00538a;
  --accent-hover: #004070;
  --border: #d8dae0;
  --focus: #0066cc;
  --bubble-user: #00538a;
  --bubble-assistant: #f5f6f8;
  --success: #1a8754;
  --warning: #c87b0a;
  --error: #c0392b;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100dvh;
  color: var(--text);
  background: var(--bg-light);
}

/* ── Two-column shell ──────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: 1fr minmax(340px, 440px);
  height: 100dvh;
}

/* ── Left: Demo stage ──────────────────────────── */

.demo-stage {
  overflow-y: auto;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.demo-card {
  position: relative;
  padding: 2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.demo-card .health-dot {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
}

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.demo-card h1 {
  margin: 0 0 0.6rem;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}

.demo-card .subtitle {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* ── Health dot ────────────────────────────────── */

.health-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.3s;
}

.health-dot.ok { background: var(--success); }
.health-dot.degraded { background: var(--warning); }
.health-dot.down { background: var(--error); }

/* ── Question sections ─────────────────────────── */

.question-sections {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.q-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.q-group summary {
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.q-group summary:hover {
  background: var(--bg-light);
}

.q-group[open] > summary {
  border-bottom-color: var(--border);
}

.q-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
}

.q-list li {
  border-bottom: 1px solid #eeedf0;
}

.q-list li:last-child {
  border-bottom: none;
}

.q-btn {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  text-align: left;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
}

.q-btn:hover {
  background: rgba(0, 83, 138, 0.06);
}

.q-btn:active {
  background: rgba(0, 83, 138, 0.12);
}

/* ── Right: Chat panel ─────────────────────────── */

.chat-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--panel-bg);
  height: 100dvh;
}

.chat-header {
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.chat-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.2;
}

/* ── Messages ──────────────────────────────────── */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  animation: fadeIn 0.2s ease;
}

.message.user { align-items: flex-end; }
.message.assistant { align-items: flex-start; }

.bubble {
  max-width: 90%;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 0.9rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .bubble {
  background: var(--bubble-user);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble p { margin: 0 0 0.4rem; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0.2rem 0 0.4rem; padding-left: 1.25rem; }
.bubble li { margin-bottom: 0.2rem; line-height: 1.45; }

.welcome-bubble {
  background: var(--bg) !important;
  border: 1px dashed var(--border) !important;
}

/* ── Response accordions ───────────────────────── */

.resp-accordion {
  margin: 0.4rem 0 0.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.resp-accordion summary {
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 83, 138, 0.04);
  transition: background 0.12s;
}

.resp-accordion summary:hover {
  background: rgba(0, 83, 138, 0.08);
}

/* Custom disclosure triangle */
.resp-accordion summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--accent);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.resp-accordion[open] > summary::before {
  transform: rotate(90deg);
}

/* Remove default marker in webkit/other browsers */
.resp-accordion summary::-webkit-details-marker { display: none; }

.resp-body {
  padding: 0.4rem 0.7rem 0.5rem;
  font-size: 0.88rem;
  line-height: 1.5;
  border-top: 1px solid var(--border);
}

.resp-body p { margin: 0 0 0.35rem; }
.resp-body p:last-child { margin-bottom: 0; }
.resp-body ul, .resp-body ol { margin: 0.15rem 0 0.35rem; padding-left: 1.1rem; }
.resp-body li { margin-bottom: 0.15rem; }

/* ── Copy button (hover-revealed) ──────────────── */

.message.assistant {
  position: relative;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  margin-top: 0.2rem;
  font: inherit;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.12s, border-color 0.12s;
}

.message.assistant:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn:hover {
  background: rgba(0, 83, 138, 0.06);
  border-color: var(--border);
  color: var(--accent);
}

.copy-btn.copied {
  opacity: 1;
  color: var(--success);
}

/* ── Option chips (clarifying questions) ────────── */

.option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.2rem;
}

.option-chip {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--accent);
  background: var(--bg);
  border: 1.5px solid var(--accent);
  border-radius: 20px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.option-chip:hover {
  background: var(--accent);
  color: #ffffff;
}

.option-chip:active {
  background: var(--accent-hover);
  color: #ffffff;
}

/* ── Typing indicator ──────────────────────────── */

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 0 1rem 0.4rem;
  align-items: center;
}

.typing-indicator[hidden] { display: none; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

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

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

/* ── Chat form / input ─────────────────────────── */

.chat-form {
  flex-shrink: 0;
  padding: 0.75rem 1rem 0.5rem;
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
}

.input-row textarea {
  flex: 1;
  resize: none;
  overflow-y: auto;
  min-height: 40px;
  max-height: 150px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
}

.input-row textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.input-row textarea::placeholder { color: var(--text-muted); }

.input-row button {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.input-row button:hover { background: var(--accent-hover); }
.input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.input-hint {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Focus visible ─────────────────────────────── */

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.input-row textarea:focus-visible { outline: none; }

/* ── Screen reader only ────────────────────────── */

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

/* ── Reduced motion ────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .dot, .message { animation: none; }
}

/* ── High contrast mode ────────────────────────── */

@media (forced-colors: active) {
  .health-dot { forced-color-adjust: none; }
  .bubble { border: 1px solid; }
  .input-row button { border: 1px solid ButtonText; }
}

/* ── Mobile: stack columns ─────────────────────── */

@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .demo-stage {
    max-height: 40vh;
    padding: 1rem;
  }
  .chat-panel {
    height: auto;
    min-height: 60vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
