:root {
  --bg: #0b1220;
  --bg2: #121a2b;
  --card: #162033;
  --card-hover: #1b2740;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3ff;
  --muted: #9aabc8;
  --accent: #f0a500;
  --accent2: #22c55e;
  --danger: #f87171;
  --gujarat: linear-gradient(135deg, #f0a500 0%, #e85d04 45%, #9b2226 100%);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "DM Sans", "Noto Sans Gujarati", "Noto Sans Devanagari", system-ui, sans-serif;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(240, 165, 0, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 197, 94, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

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

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-t)) 14px calc(88px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--gujarat);
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.25rem; color: #1a1000;
  box-shadow: 0 8px 24px rgba(240, 165, 0, 0.25);
}
.brand h1 {
  margin: 0; font-size: 1.15rem; letter-spacing: -0.02em;
}
.tag { margin: 2px 0 0; color: var(--muted); font-size: 0.8rem; }

.lang-wrap select {
  appearance: none;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
}

.hero-strip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.18);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  color: #b7f0cb;
}
.hero-strip.warn {
  background: rgba(240, 165, 0, 0.1);
  border-color: rgba(240, 165, 0, 0.25);
  color: #ffd98a;
}
.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.cities {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.cities::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.chip.active {
  color: #1a1000;
  background: var(--gujarat);
  border-color: transparent;
}

.main { flex: 1; min-height: 0; }
.panel { display: none; animation: fade 0.2s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.panel-head h2 { margin: 0; font-size: 1rem; }

.btn {
  border: 0; border-radius: 999px; font: inherit; font-weight: 600;
  font-size: 0.82rem; padding: 8px 14px; cursor: pointer;
}
.btn.solid {
  background: var(--gujarat); color: #1a1000;
}
.btn.ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line);
}
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn.send { min-width: 72px; }

.search-row {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.search-row input, .composer input {
  flex: 1; min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  font-size: 0.95rem;
}
.search-row input:focus, .composer input:focus {
  outline: 2px solid rgba(240, 165, 0, 0.35);
  outline-offset: 1px;
}

.feed { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  transition: background 0.15s;
}
.card:active { background: var(--card-hover); }
.card a {
  color: inherit; text-decoration: none;
}
.card h3 {
  margin: 0 0 8px; font-size: 0.98rem; line-height: 1.35;
  letter-spacing: -0.01em;
}
.meta {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  color: var(--muted); font-size: 0.75rem;
}
.tag-pill {
  display: inline-block;
  background: rgba(240, 165, 0, 0.12);
  color: #ffd27a;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.summary {
  margin: 8px 0 0; color: var(--muted); font-size: 0.85rem;
}

.empty, .error, .muted {
  color: var(--muted); font-size: 0.9rem;
}
.error { color: var(--danger); }

.brief-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.55;
  box-shadow: var(--shadow);
  min-height: 180px;
}
.sources { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.source-link {
  color: #9ec5ff; font-size: 0.8rem; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.chat {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 240px; max-height: min(52dvh, 420px);
  overflow-y: auto;
  padding: 4px 2px 12px;
}
.bubble {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2a3a5c, #1d2b46);
  border: 1px solid rgba(255,255,255,0.1);
  border-bottom-right-radius: 6px;
}
.bubble .who {
  display: block; font-size: 0.7rem; font-weight: 700;
  color: var(--accent); margin-bottom: 4px; letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chips {
  display: flex; gap: 8px; overflow-x: auto;
  margin-bottom: 10px; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit; font-size: 0.78rem;
  cursor: pointer;
}

.composer {
  display: flex; gap: 8px;
  position: sticky; bottom: 0;
}

.tabbar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 0; width: min(560px, 100%);
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + var(--safe-b));
  z-index: 20;
}
.tab {
  background: transparent; border: 0; color: var(--muted);
  font: inherit; font-size: 0.72rem; font-weight: 600;
  padding: 8px 4px; border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab .ico { font-size: 1rem; line-height: 1; }
.tab.active {
  color: var(--text);
  background: rgba(240, 165, 0, 0.12);
}

.skeleton {
  height: 96px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--card), #1c2940, var(--card));
  background-size: 200% 100%;
  animation: sh 1.2s infinite linear;
}
@keyframes sh { to { background-position: -200% 0; } }

@media (min-width: 720px) {
  .app { padding-top: 24px; }
  body::before {
    content: "";
    position: fixed; inset: 0;
    background:
      radial-gradient(800px 400px at 20% 20%, rgba(240,165,0,0.06), transparent),
      radial-gradient(700px 400px at 80% 60%, rgba(34,197,94,0.05), transparent);
    pointer-events: none; z-index: -1;
  }
}
