:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --page-gradient: linear-gradient(
    140deg,
    rgba(209, 236, 224, 0.65) 0%,
    rgba(214, 232, 247, 0.62) 45%,
    rgba(231, 224, 246, 0.6) 70%,
    rgba(237, 232, 244, 0.66) 100%
  );
  --panel: #ffffff;
  --border: #e5e7eb;
  --edge-purple: #7c3aed;
  --edge-red: #ef4444;
  --edge-fuchsia: #e879f9;
  --text: #0f172a;
  --muted: #6b7280;
  --assistant: #f3f4f6;
  --user: #111827;
  --user-text: #ffffff;
  --accent: #10a37f;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--page-gradient), var(--bg);
  color: var(--text);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: clamp(20px, 4vh, 36px) clamp(16px, 3vw, 32px);
  overflow-x: hidden;
  overflow-y: auto;
}

.chat-app {
  width: min(960px, 90vw);
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(135deg, rgba(124, 58, 237, 0.65), rgba(239, 68, 68, 0.55), rgba(232, 121, 249, 0.65)) border-box;
  border-radius: 20px;
  border: 1px solid transparent;
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(124, 58, 237, 0.08),
    0 0 28px rgba(232, 121, 249, 0.12);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: min(900px, 90vh);
  max-height: 90vh;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(124, 58, 237, 0.2);
  background: #ffffff;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0ea5e9, #10a37f);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.brand p {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.status-stack {
  display: grid;
  gap: 4px;
  text-align: right;
}

.status-line {
  font-size: 0.75rem;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(232, 121, 249, 0.3);
  background: #f8fafc;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(16, 163, 127, 0.6);
}

.chat-body {
  flex: 1;
  padding: 28px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.intro-copy {
  display: grid;
  gap: 4px;
}

.intro-panel {
  align-self: flex-start;
  margin: 0;
  padding-left: 2px;
}

.intro-kicker {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.intro-copy h2 {
  margin: 4px 0 4px;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.intro-copy p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
  line-height: 1.6;
}

.message-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

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

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar.assistant {
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 700;
}

.bubble {
  max-width: 70ch;
  padding: 14px 18px;
  border-radius: 18px;
  line-height: 1.6;
  font-size: 0.95rem;
  border: 1px solid transparent;
  unicode-bidi: plaintext;
}

.bubble.assistant {
  background: var(--assistant);
  border-color: #e5e7eb;
}

.bubble.user {
  background: var(--user);
  color: var(--user-text);
}

.meta {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.chat-footer {
  border-top: 1px solid rgba(239, 68, 68, 0.18);
  padding: 18px 24px calc(24px + env(safe-area-inset-bottom));
  background: #ffffff;
  display: grid;
  gap: 10px;
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 16px;
  padding: 10px 14px;
  background: #f9fafb;
  flex-wrap: wrap;
}

.input-shell input {
  flex: 1 1 200px;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  padding: 6px 2px;
  color: var(--text);
}

.input-shell input:focus {
  outline: none;
}

#micBtn {
  border: none;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #111827;
  min-width: 42px;
  padding: 0 8px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 5;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

#micBtn .voice-wave-icon {
  width: 26px;
  height: 26px;
  display: block;
  color: currentColor;
}

#micBtn:hover {
  background: rgba(16, 163, 127, 0.12);
  color: var(--accent);
  border-color: rgba(16, 163, 127, 0.4);
}

#micBtn[aria-pressed="true"] {
  background: rgba(17, 24, 39, 0.08);
  color: #111827;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.35);
}

#micBtn.is-listening {
  background: rgba(17, 24, 39, 0.08);
  color: #111827;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.35);
}

#micBtn.is-listening .voice-wave-icon {
  color: #111827;
}

#micBtn.is-listening::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(16, 163, 127, 0.18);
  transform: translate(16px, -14px);
}

#micBtn:disabled {
  cursor: not-allowed;
  color: #94a3b8;
  background: #f8fafc;
  border-color: rgba(148, 163, 184, 0.45);
  box-shadow: none;
}

.voice-helper {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}

.voice-helper:empty {
  display: none;
}

.send-btn {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--edge-purple), var(--edge-red), var(--edge-fuchsia));
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 18px rgba(124, 58, 237, 0.24);
}

.send-btn:disabled {
  cursor: not-allowed;
  background: #cbd5e1;
  box-shadow: none;
}

.send-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(239, 68, 68, 0.28);
}

.cancel-btn {
  border: 1px solid rgba(148, 163, 184, 0.6);
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.cancel-btn:hover {
  background: rgba(248, 250, 252, 0.9);
  border-color: rgba(100, 116, 139, 0.7);
  color: #0f172a;
}

.cancel-btn:disabled {
  cursor: not-allowed;
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.45);
  background: #f8fafc;
}

.footer-hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.compliance-panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #f8fafc;
  display: grid;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.compliance-panel strong {
  color: var(--text);
  font-weight: 600;
}

.compliance-panel ul {
  margin: 6px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}
