/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --primary:       #1A56DB;
  --primary-dark:  #1145B0;
  --primary-light: #EBF2FF;
  --accent:        #D97706;
  --accent-bg:     #FEF3C7;
  --success:       #059669;
  --success-bg:    #D1FAE5;
  --danger:        #DC2626;
  --bg:            #F0F4FF;
  --surface:       #FFFFFF;
  --text:          #111827;
  --text-muted:    #6B7280;
  --text-light:    #9CA3AF;
  --border:        #E5E7EB;
  --radius:        14px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10);
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Noto Sans Oriya', 'Noto Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  /* Constrain to phone width on desktop */
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul { list-style: none; }
img { display: block; max-width: 100%; }

/* ── Boot loader ───────────────────────────────────────────────────────────── */
.boot-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: 20px;
}
.boot-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Screen wrapper ────────────────────────────────────────────────────────── */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ───────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-back {
  font-size: 22px;
  color: #fff;
  padding: 4px 8px 4px 0;
  line-height: 1;
}
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}
.topbar-lang {
  font-size: 13px;
  opacity: .85;
  white-space: nowrap;
}

/* ── Screen content (scrollable body) ─────────────────────────────────────── */
.screen-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

/* ── Language select screen ────────────────────────────────────────────────── */
.lang-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 20px;
  background: var(--primary);
}
.lang-main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lang-about {
  width: 100%;
  max-width: 320px;
  text-align: center;
  padding-top: 20px;
  margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,.15);
}
.lang-about-text {
  color: rgba(255,255,255,.7);
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 6px;
}
.lang-about-founder {
  color: rgba(255,255,255,.55);
  font-size: 12px;
  font-weight: 600;
}
.lang-logo {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  margin-bottom: 6px;
}
.lang-tagline {
  color: rgba(255,255,255,.75);
  font-size: 14px;
  text-align: center;
  margin-bottom: 40px;
}
.lang-title {
  color: rgba(255,255,255,.85);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .03em;
  margin-bottom: 16px;
}
.lang-btns {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 300px;
}
.lang-btn {
  background: #fff;
  color: var(--primary);
  font-size: 20px;
  font-weight: 700;
  padding: 18px 24px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow-md);
  transition: background .15s, transform .1s;
  min-height: 64px;
}
.lang-btn:active { transform: scale(.97); background: var(--primary-light); }

/* ── Home screen ───────────────────────────────────────────────────────────── */
.home-greeting {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.home-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.topic-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 100px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  transition: box-shadow .15s, transform .1s;
  text-align: left;
  border: 2px solid transparent;
}
.topic-card:active {
  transform: scale(.97);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.topic-card-icon { font-size: 28px; line-height: 1; }
.topic-card.full-width { grid-column: 1 / -1; }

/* ── Intake screen ─────────────────────────────────────────────────────────── */
.intake-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
}
.intake-dot {
  height: 6px;
  flex: 1;
  border-radius: 3px;
  background: var(--border);
  transition: background .3s;
}
.intake-dot.active { background: var(--primary); }

.intake-question {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}
.intake-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.intake-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.intake-opt {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  color: var(--text);
  transition: border-color .15s, background .15s;
  min-height: 52px;
  display: flex;
  align-items: center;
}
.intake-opt:active, .intake-opt.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.intake-skip {
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px 0;
}
.intake-skip-all {
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 10px 0;
  margin-top: 4px;
}

/* ── Results screen ────────────────────────────────────────────────────────── */
.ai-intro-box {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 15px;
  color: var(--text);
  min-height: 60px;
}
.ai-intro-loading {
  color: var(--text-muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-intro-loading .spinner {
  width: 20px;
  height: 20px;
  border-width: 2px;
  flex-shrink: 0;
}

.result-cards { display: flex; flex-direction: column; gap: 14px; }

.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.result-card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}
.result-card-summary {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.result-card-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.result-meta-row {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.result-meta-row strong { color: var(--text); }

.verify-badge {
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
}

.docs-section { font-size: 13px; color: var(--text-muted); }
.docs-section strong { color: var(--text); display: block; margin-bottom: 4px; }
.docs-list { display: flex; flex-direction: column; gap: 3px; }
.docs-list li::before { content: "• "; color: var(--primary); }
.docs-list li { padding-left: 14px; position: relative; }
.docs-list li::before { position: absolute; left: 0; }

.portal-btn {
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  display: block;
  width: 100%;
  min-height: 48px;
  transition: background .15s;
}
.portal-btn:active { background: var(--primary-dark); }

.results-no-results {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

/* ── Chat open button (floating) ───────────────────────────────────────────── */
.chat-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 16px rgba(26,86,219,.4);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 20;
  transition: background .15s, transform .1s;
}
.chat-fab:active { transform: scale(.96); background: var(--primary-dark); }
.chat-fab-icon { font-size: 20px; }

/* ── Chat screen ───────────────────────────────────────────────────────────── */
.chat-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-bubble-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-bubble-row.user { align-items: flex-end; }
.chat-bubble-row.assistant { align-items: flex-start; }

.chat-bubble {
  max-width: 82%;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-bubble.user {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  background: var(--surface);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.chat-bubble p { margin-bottom: 6px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul { padding-left: 16px; margin: 4px 0; }
.chat-bubble li { margin-bottom: 2px; }

.chat-feedback {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}
.chat-feedback-btn {
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  transition: background .15s;
}
.chat-feedback-btn:active, .chat-feedback-btn.voted {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  align-self: flex-start;
  box-shadow: var(--shadow);
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce .8s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .30s; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}

.chat-input-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  outline: none;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn {
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.chat-send-btn:active { background: var(--primary-dark); }
.chat-send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* ── Open chat button (on results screen) ──────────────────────────────────── */
.open-chat-btn {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  width: 100%;
  text-align: center;
  margin-top: 10px;
  min-height: 48px;
  transition: background .15s;
}
.open-chat-btn:active { background: var(--primary); color: #fff; }

/* ── Footer note ───────────────────────────────────────────────────────────── */
.footer-note {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ── Safe-area for iPhones / Android bottom bar ────────────────────────────── */
.chat-input-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.chat-fab       { bottom: calc(20px + env(safe-area-inset-bottom)); }
