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

:root {
  --navy: #1F4E79;
  --navy-light: #2d6aa0;
  --navy-bg: #e8f0f8;
  --gray-bg: #f3f4f6;
  --border: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --white: #ffffff;
  --green: #16a34a;
  --red: #dc2626;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--gray-bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 1280px;
}

/* ================================================================
   HOME PAGE
   ================================================================ */

#home-page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: var(--navy);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#home-page.fade-out {
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

.home-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(45, 106, 160, 0.6) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(31, 78, 121, 0.8) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(15, 40, 70, 0.9) 0%, transparent 55%);
}

.home-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 28px;
  padding: 40px;
  max-width: 760px;
  width: 100%;
}

.home-badge {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 5px 16px;
  border-radius: 999px;
}

.home-logo {
  display: flex;
  align-items: center;
  gap: 16px;
}

.home-logo-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.home-logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.home-logo-brand {
  font-size: 32px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.home-logo-product {
  font-size: 18px;
  font-weight: 400;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.5px;
}

.home-tagline {
  font-size: 18px;
  color: rgba(255,255,255,0.75);
  line-height: 1.6;
  font-weight: 300;
  max-width: 480px;
}

/* ---- Cards ---- */
.home-cards {
  display: flex;
  gap: 18px;
  width: 100%;
  margin-top: 4px;
}

.home-card {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  padding: 28px 24px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.home-card:hover {
  background: rgba(255,255,255,0.13);
  border-color: rgba(255,255,255,0.28);
  transform: translateY(-3px);
}

.home-card-featured {
  background: rgba(255,255,255,0.11);
  border-color: rgba(255,255,255,0.25);
}

.home-card-featured:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.4);
}

.home-card-pill {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.9);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}

.home-card-icon {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  flex-shrink: 0;
}

.home-card-icon svg {
  width: 20px;
  height: 20px;
}

.home-card-body {
  flex: 1;
}

.home-card-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.home-card-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  line-height: 1.6;
}

.home-card-arrow {
  font-size: 20px;
  color: rgba(255,255,255,0.35);
  align-self: flex-end;
  transition: color 0.2s, transform 0.2s;
}

.home-card:hover .home-card-arrow {
  color: rgba(255,255,255,0.8);
  transform: translateX(4px);
}

.home-footer {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.3px;
}

/* ================================================================
   APP SHELL
   ================================================================ */

#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  animation: appFadeIn 0.35s ease forwards;
}

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

/* Back button in header */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.home-back-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.home-back-btn:hover {
  background: rgba(255,255,255,0.22);
}

/* ---- BANNER ---- */
.banner {
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  padding: 10px 16px;
  font-weight: 500;
  border-bottom: 1px solid #fcd34d;
}
.hidden { display: none !important; }

/* ---- HEADER ---- */
header {
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  flex-shrink: 0;
}

.wordmark {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.mode-toggle {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  padding: 6px 20px;
  border-radius: 999px;
  border: 2px solid var(--white);
  background: transparent;
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.toggle-btn.active {
  background: var(--white);
  color: var(--navy);
}
.toggle-btn:not(.active):hover {
  background: rgba(255,255,255,0.15);
}

/* ---- MODE PANELS ---- */
.mode-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ====== CHAT MODE ====== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 68%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--navy);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Markdown inside bubbles */
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 4px 0 6px 18px; padding: 0; }
.msg li { margin-bottom: 3px; }
.msg strong { color: var(--navy); }
.answer-body p { margin: 0 0 6px; }
.answer-body p:last-child { margin-bottom: 0; }
.answer-body ul { margin: 4px 0 6px 18px; padding: 0; }
.answer-body li { margin-bottom: 3px; }

/* Loading dots */
.loading-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.loading-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--navy);
  animation: bounce 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
#chat-input:focus { border-color: var(--navy); }

#chat-send-btn {
  padding: 10px 22px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#chat-send-btn:hover { background: var(--navy-light); }
#chat-send-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ====== LIVE ASSIST MODE ====== */
.live-instruction {
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  padding: 10px 24px;
  font-size: 13px;
  color: #1e40af;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.live-instruction-text {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.instruction-divider {
  color: #93c5fd;
  font-weight: 300;
  user-select: none;
}
.info-icon {
  font-size: 15px;
  font-weight: 700;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #1e40af;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.live-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.listen-btn {
  padding: 9px 22px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.15s;
}
.listen-btn.start {
  background: var(--navy);
  color: var(--white);
}
.listen-btn.start:hover { background: var(--navy-light); }
.listen-btn.stop {
  background: var(--red);
  color: var(--white);
}
.listen-btn.stop:hover { opacity: 0.85; }

.mic-icon { font-size: 16px; }

.listening-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}

.pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

/* ---- SPLIT PANELS ---- */
.live-panels {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.live-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.transcript-panel {
  flex: 0 0 60%;
  border-right: 1px solid var(--border);
}

.answers-panel {
  flex: 0 0 40%;
}

.panel-title {
  background: var(--navy);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 10px 18px;
  flex-shrink: 0;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  background: var(--white);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Transcript lines */
.transcript-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f0;
}
.transcript-line:last-child {
  border-bottom: none;
}
.transcript-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}
.transcript-text {
  flex: 1;
}
.transcript-line.interim {
  color: var(--text-muted);
  font-style: italic;
  border-bottom: none;
  padding: 3px 0 3px 6px;
}
.transcript-line.transcript-triggered {
  background: #eff6ff;
  border-left: 3px solid var(--navy);
  padding-left: 10px;
  border-radius: 0 4px 4px 0;
  border-bottom-color: #dbeafe;
}
.transcript-triggered .transcript-time {
  color: var(--navy);
}
.transcript-warning {
  font-size: 13px;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.transcript-error {
  font-size: 13px;
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 8px 12px;
}

/* Answer cards */
.answer-card {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-left: 4px solid var(--navy);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  animation: fadeIn 0.35s ease;
  flex-shrink: 0;
  margin-bottom: 12px;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.answer-trigger {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
  border-bottom: 1px solid #e0f2fe;
  padding-bottom: 6px;
}
.answer-body strong { color: var(--navy); }
