:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --danger: #dc2626;
  --success: #16a34a;
  --border: #e2e8f0;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Noto Sans Devanagari", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg-soft);
  color: var(--text);
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Header */
.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  color: #fff;
  padding: calc(14px + var(--safe-top)) 8px 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  z-index: 10;
}

.header-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-title .bolt { color: var(--accent); font-size: 20px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,.08);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.hidden { visibility: hidden; }

.header-actions { display: flex; align-items: center; gap: 6px; }

/* Emergency steps box (gas smell, battery smoke) */
.emergency-box {
  background: #fef2f2;
  border: 2px solid var(--danger);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  color: #7f1d1d;
}
.emergency-box.hidden { display: none; }
.emergency-title { margin: 0 0 6px; font-weight: 700; font-size: 15px; color: var(--danger); }
.emergency-steps { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.emergency-steps li { margin: 3px 0; }

/* Repair Guide */
.btn-guide {
  display: block;
  width: 100%;
  margin: 4px 0 14px;
  background: var(--bg);
  color: #fff;
}
.btn-guide.hidden { display: none; }
.guide-cause { font-size: 18px; margin: 4px 0 12px; line-height: 1.35; }
.guide-pro {
  background: #fef2f2;
  border: 2px solid var(--danger);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
  color: #7f1d1d;
  font-size: 14px;
  line-height: 1.5;
}
.guide-pro.hidden { display: none; }
.guide-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 10px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-align: left;
}
.guide-option .category-chevron { transition: transform .2s; }
.guide-option.open .category-chevron { transform: rotate(180deg); }
.guide-panel { margin: 8px 0 0; }
.guide-panel.hidden { display: none; }
.guide-tools { list-style: none; padding: 0; }
.guide-tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.guide-tool-name { display: block; font-weight: 700; margin-bottom: 4px; }
.guide-tool-use { display: block; font-size: 14px; line-height: 1.5; color: var(--text-muted); }
.guide-note { font-size: 13px; color: var(--text-muted); margin: 16px 0 8px; line-height: 1.5; }

/* Mechanic card */
.btn-mechanic {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--bg);
}
.btn-mechanic.hidden { display: none; }
.mechanic-card {
  background: var(--surface);
  border: 2px dashed var(--text-muted);
  border-radius: 14px;
  padding: 14px 16px;
  user-select: text;
}
.mechanic-title { font-size: 18px; margin: 0 0 10px; }
.mechanic-row { margin: 0 0 10px; }
.mechanic-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
.mechanic-value { display: block; font-size: 15px; line-height: 1.45; }
.mechanic-list { margin: 2px 0 0; padding-left: 20px; font-size: 14.5px; line-height: 1.5; }
.mechanic-footer { font-size: 12px; color: var(--text-muted); margin: 10px 0 0; border-top: 1px solid var(--border); padding-top: 8px; }
.mechanic-actions { display: flex; gap: 10px; margin-top: 14px; }
.mechanic-actions .btn { flex: 1; }
.mech-status { margin: 10px 0 0; font-size: 14px; color: var(--success); }
.mech-status.error { color: var(--danger); }
.mech-status.hidden { display: none; }
.icon-btn.lang-btn {
  width: auto;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
}

/* Main / screens */
#main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(24px + var(--safe-bottom));
  background: var(--surface-2);
}

.screen {
  display: none;
  animation: fadeUp .28s ease;
}
.screen.active { display: block; }

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

.lead {
  color: var(--text-muted);
  font-size: 14.5px;
  margin: 4px 0 16px;
}

/* Search box (top of landing screen) */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 0 44px 0 42px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.search-icon {
  position: absolute;
  left: 14px;
  font-size: 15px;
  pointer-events: none;
}
.search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  padding: 14px 0;
  color: var(--text);
  user-select: text;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-clear {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}
.search-clear.hidden { display: none; }

.search-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}
.search-results.hidden { display: none; }
.search-result-cat {
  display: block;
  font-size: 11.5px;
  color: var(--accent-dark);
  font-weight: 600;
  margin-top: 3px;
}
.search-empty { text-align: center; margin: 8px 0 0; }

#home-default.hidden { display: none; }
#sections-default.hidden { display: none; }

/* Problem list cards */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Category sections (home screen groups, collapsible) */
.category-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.category-section + .category-section { margin-top: 14px; }

.category-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 10px 2px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.category-emoji { font-size: 16px; }
.category-title-hi { font-size: 14.5px; font-weight: 700; color: var(--text); letter-spacing: .2px; }
.category-title-en { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.category-count {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 2px;
}
.category-chevron {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
  transition: transform .2s ease;
}
.category-section.collapsed .category-chevron { transform: rotate(-90deg); }

.category-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .25s ease, opacity .2s ease;
  opacity: 1;
}
.category-section.collapsed .category-body {
  grid-template-rows: 0fr;
  opacity: 0;
}
.category-body > .card-list { overflow: hidden; min-height: 0; }

.problem-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  width: 100%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  transition: transform .12s ease, box-shadow .12s ease;
}
.problem-card:active {
  transform: scale(.97);
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
}

.problem-emoji {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.problem-text { flex: 1 1 auto; min-width: 0; }
.problem-title-hi { display: block; font-size: 16.5px; font-weight: 700; line-height: 1.3; }
.problem-title-en { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.problem-arrow { color: var(--text-muted); flex: 0 0 auto; font-size: 20px; }

/* Section picker cards (Ghar & Bijli vs Vehicle & Automotive) */
.section-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 18px;
  text-align: left;
  width: 100%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  transition: transform .12s ease, box-shadow .12s ease;
}
.section-card:active {
  transform: scale(.97);
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
}
.section-emoji {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}
.section-text { flex: 1 1 auto; min-width: 0; }
.section-title-hi { display: block; font-size: 18.5px; font-weight: 800; line-height: 1.3; }
.section-title-en { display: block; font-size: 13px; color: var(--text-muted); margin-top: 3px; }

.offline-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 22px;
}

/* Question screen */
.q-context {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 10px;
}

.q-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px 18px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  margin-bottom: 18px;
}

.q-text-hi { font-size: 19px; line-height: 1.45; margin: 0 0 8px; font-weight: 700; }
.q-text-en { font-size: 13.5px; color: var(--text-muted); margin: 0; line-height: 1.4; }

.option-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: border-color .12s ease, transform .12s ease, background .12s ease;
}
.option-btn .opt-en { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.option-btn:active {
  transform: scale(.97);
  border-color: var(--accent);
  background: #fffbeb;
}

.option-btn.option-escape {
  border-style: dashed;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13.5px;
  align-items: center;
}
.option-btn.option-escape:active {
  border-color: var(--text-muted);
  background: #eef2f7;
}

/* Compare screen ("pakka nahi pata") */
.compare-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.compare-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  width: 100%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.compare-card:active { transform: scale(.97); }
.compare-severity {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.compare-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.compare-cause-hi { font-size: 15px; font-weight: 700; line-height: 1.35; }
.compare-cause-en { font-size: 12px; color: var(--text-muted); }
.compare-cost { font-size: 12.5px; font-weight: 700; color: #047857; margin-top: 2px; }

/* Result screen */
.result-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 24px 20px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  text-align: center;
}

.result-icon { font-size: 40px; margin-bottom: 6px; }

.severity-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 800;
  padding: 9px 18px;
  border-radius: 999px;
  margin: 4px 0 14px;
}
.severity-badge .severity-emoji { font-size: 16px; }
.severity-badge.safe { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.severity-badge.caution { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.severity-badge.danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.alt-note {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-dark);
  margin: 0 0 4px;
}
.alt-note.hidden { display: none; }

.r-cause-hi { font-size: 19px; font-weight: 800; line-height: 1.4; margin: 4px 0 6px; color: var(--text); }
.r-cause-en { font-size: 13px; color: var(--text-muted); margin: 0 0 16px; }

.cost-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 14px;
  padding: 10px 20px;
  margin: 6px 0 20px;
}
.cost-label { font-size: 11.5px; color: #047857; font-weight: 600; }
.cost-value { font-size: 16px; font-weight: 800; color: #065f46; }

.steps-block { text-align: left; margin-top: 6px; }
.steps-block h3 { font-size: 14.5px; margin: 0 0 10px; color: var(--text); }

.steps-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.steps-list li {
  display: flex;
  gap: 10px;
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 12px;
}
.step-num {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.safety-note {
  margin-top: 20px;
  font-size: 12px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  line-height: 1.5;
}

.feedback-block { margin-top: 20px; }
.feedback-question { font-size: 13.5px; font-weight: 700; color: var(--text); margin: 0 0 10px; }
.feedback-buttons {
  display: flex;
  gap: 10px;
}
.feedback-buttons.hidden { display: none; }
.btn-feedback-yes { background: #dcfce7; color: #166534; }
.btn-feedback-yes:active { background: #bbf7d0; }
.btn-feedback-no { background: #fee2e2; color: #991b1b; }
.btn-feedback-no:active { background: #fecaca; }

.feedback-response {
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  line-height: 1.5;
}
.feedback-response.hidden { display: none; }
.feedback-response.feedback-resolved { background: #dcfce7; color: #166534; }
.feedback-response.feedback-exhausted { background: #fee2e2; color: #991b1b; }

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 15px 10px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #1a1200; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--bg); color: #fff; }
.btn-secondary:active { background: #020617; }

/* Install FAB */
.install-fab {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  background: var(--accent);
  color: #1a1200;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 14.5px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(217,119,6,.4);
  z-index: 20;
}
.install-fab.hidden { display: none; }

@media (min-width: 560px) {
  #main { max-width: 480px; margin: 0 auto; }
  .app-header > div, .install-fab { max-width: 480px; }
}

/* Legal links + first-use Terms notice */
.legal-links {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 10px 0 4px;
}
.legal-links a, .terms-read a { color: var(--accent-dark); }
.terms-notice {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}
.terms-notice.hidden { display: none; }
.terms-box {
  position: relative;
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  padding: 20px 18px 18px;
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
}
.terms-lang {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 13px;
}
.terms-title { font-size: 18px; margin: 0 56px 12px 0; line-height: 1.35; }
.terms-points { margin: 0 0 12px; padding-left: 20px; font-size: 14.5px; line-height: 1.5; }
.terms-points li { margin-bottom: 8px; }
.terms-age { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; line-height: 1.5; }
.terms-read { font-size: 14px; margin: 0 0 16px; }
.terms-box .btn { width: 100%; }

/* Nearby search: phone location status */
.service-loc { margin: 4px 0 12px; }
.service-loc-status { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--success); }
.service-loc-status:empty { display: none; }
.service-loc-status.error { color: var(--danger); }
.btn-loc-retry { margin-top: 8px; width: 100%; }
.btn-loc-retry.hidden { display: none; }

/* Nearby search: "contact your provider first" note (internet / DTH) */
.service-care { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: #eff6ff; color: #1e3a8a; font-size: 13.5px; line-height: 1.5; }
.service-care.hidden { display: none; }

/* Nearby search: buttons wait for a location or typed area */
#service-list .problem-card.is-waiting { opacity: 0.45; }
.service-loc-help { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.service-loc-help.hidden { display: none; }
.service-area { display: block; margin-top: 10px; }
.service-area.hidden { display: none; }
.service-area-label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; }
.service-area-input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 15px; background: var(--surface); }
