@font-face {
  font-family: "Noto Sans Devanagari";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("vendor/noto-deva-400.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Sans Devanagari";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("vendor/noto-deva-700.woff2") format("woff2");
}

:root {
  --ink: #1c2530;
  --muted: #6b7785;
  --line: #e4e8ee;
  --bg: #f6f8fb;
  --card: #ffffff;
  --accent: #c0392b;        /* Amar Ujala red-ish */
  --accent-soft: #fdecea;
  --vec: #2563eb;           /* semantic = blue */
  --fts: #0f9d58;           /* keyword = green */
  --shadow: 0 1px 3px rgba(20,30,45,.08), 0 6px 18px rgba(20,30,45,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }  /* author display rules otherwise override the hidden attr */
body {
  font-family: "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari",
               system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  padding: .7rem 1.2rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand .logo { font-size: 1.7rem; }
.brand .title { font-weight: 700; font-size: 1.05rem; }
.brand .subtitle { color: var(--muted); font-size: .82rem; }

.tabs { display: flex; gap: .25rem; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: .5rem .8rem; border-radius: 8px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: .9rem;
}
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- panels ---------- */
main { max-width: 1040px; margin: 0 auto; padding: 1.4rem 1.2rem 4rem; }
.panel { display: none; }
.panel.active { display: block; }
.placeholder {
  color: var(--muted); background: var(--card); border: 1px dashed var(--line);
  border-radius: 12px; padding: 3rem; text-align: center;
}

/* ---------- search hero ---------- */
.search-hero { display: flex; flex-direction: column; gap: .8rem; }
.searchbar { display: flex; gap: .5rem; }
.searchbar input {
  flex: 1; font: inherit; font-size: 1.05rem;
  padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); box-shadow: var(--shadow);
}
.searchbar input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.searchbar button {
  font: inherit; font-weight: 700; color: #fff; background: var(--accent);
  border: 0; border-radius: 10px; padding: 0 1.4rem; cursor: pointer;
}
.searchbar button:hover { filter: brightness(.95); }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.modes { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.mode {
  border: 0; background: transparent; font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--muted); padding: .4rem .8rem; border-radius: 8px; cursor: pointer;
}
.mode.active { background: var(--vec); color: #fff; }
.trust { color: var(--muted); font-size: .8rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: .35rem .8rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- status ---------- */
.status { color: var(--muted); font-size: .88rem; min-height: 1.2rem; margin: 1rem 0 .4rem; }
.status .win { color: var(--vec); font-weight: 600; }

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; gap: .9rem; }
.card {
  display: grid; grid-template-columns: 1fr 200px; gap: 1rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem; box-shadow: var(--shadow);
}
.card-meta { color: var(--muted); font-size: .78rem; letter-spacing: .02em; text-transform: uppercase; }
.card-headline { margin: .25rem 0 .2rem; font-size: 1.15rem; line-height: 1.3; }
.card-sub { color: var(--ink); font-weight: 600; font-size: .92rem; margin-bottom: .15rem; }
.card-byline { color: var(--muted); font-size: .82rem; }
.card-snippet { margin: .5rem 0 .4rem; font-size: .92rem; color: #333; }
.card-tags { display: flex; flex-wrap: wrap; gap: .35rem; }

.card-clip { display: block; }
.card-clip img {
  width: 100%; height: 100%; max-height: 240px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
}
.card-clip.empty { display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .8rem; border: 1px dashed var(--line); border-radius: 8px; }

/* signal + info badges */
.badge {
  font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px;
  border: 1px solid transparent;
}
.badge.vec { color: var(--vec); background: #eaf0fe; }
.badge.fts { color: var(--fts); background: #e8f6ee; }
.badge.both { color: #7c3aed; background: #f1ebfe; }
.badge.eds { color: var(--accent); background: var(--accent-soft); }

@media (max-width: 640px) {
  .card { grid-template-columns: 1fr; }
  .card-clip img { max-height: 200px; }
  .controls { flex-direction: column; align-items: flex-start; }
}

/* ---------- Browse (F2) ---------- */
.ed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.ed-card {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: .6rem; cursor: pointer; font: inherit; text-align: center; box-shadow: var(--shadow);
}
.ed-card:hover { border-color: var(--accent); transform: translateY(-2px); transition: .15s; }
.ed-card img {
  width: 100%; aspect-ratio: 3934 / 6117; object-fit: cover; object-position: top;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
}
.ed-name { font-weight: 700; margin-top: .5rem; }
.ed-meta { color: var(--muted); font-size: .8rem; }

.page-bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-title { font-weight: 700; }
.page-nav { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; }
.btn-ghost {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: .35rem .7rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost:disabled { opacity: .4; cursor: default; }
#page-select { font: inherit; padding: .35rem; border-radius: 8px; border: 1px solid var(--line); }

.page-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.2rem; align-items: start; }
.page-frame-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .5rem; }
.page-frame { position: relative; display: block; line-height: 0; }
#page-img { width: 100%; height: auto; display: block; border-radius: 6px; }
.overlay { position: absolute; inset: 0; pointer-events: none; }  /* exactly cover the page image */
.region-box {
  position: absolute; pointer-events: auto; cursor: pointer;
  border: 2px solid rgba(37, 99, 235, .55); background: rgba(37, 99, 235, .07);
  border-radius: 3px; padding: 0; transition: background .12s, border-color .12s;
}
.region-box:hover { background: rgba(37, 99, 235, .18); border-color: var(--vec); }
.region-box.active { background: rgba(192, 57, 43, .16); border-color: var(--accent); border-width: 3px; }

.region-detail {
  position: sticky; top: 80px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem; max-height: calc(100vh - 110px); overflow: auto; box-shadow: var(--shadow);
}
.rd-hint { color: var(--muted); font-size: .9rem; }
.rd-headline { margin: 0 0 .4rem; font-size: 1.1rem; }
.rd-sub { font-weight: 600; margin-bottom: .3rem; }
.rd-byline { color: var(--muted); font-size: .82rem; margin-bottom: .5rem; }
.rd-body { font-size: .92rem; color: #333; white-space: pre-wrap; }

@media (max-width: 760px) {
  .page-layout { grid-template-columns: 1fr; }
  .region-detail { position: static; max-height: none; }
}

/* ---------- Same story (F3) ---------- */
.tab-intro { color: var(--muted); margin: 0 0 1rem; }
.story-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.story-card {
  display: grid; grid-template-columns: 80px 1fr; gap: .7rem; align-items: start;
  text-align: left; font: inherit; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: .7rem; box-shadow: var(--shadow);
}
.story-card:hover { border-color: var(--accent); transform: translateY(-2px); transition: .15s; }
.story-card img { width: 80px; height: 80px; object-fit: cover; object-position: top;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.story-noimg { display: flex; align-items: center; justify-content: center; color: var(--muted);
  font-size: .75rem; border: 1px dashed var(--line); border-radius: 8px; min-height: 80px; }
.story-hl { font-weight: 700; font-size: .95rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.story-badges { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .4rem; }
.story-sec { color: var(--muted); font-size: .78rem; text-transform: capitalize; }

.story-cols { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: start; }
.story-col {
  flex: 0 0 240px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: .6rem; box-shadow: var(--shadow);
}
.story-col-head { font-weight: 700; font-size: .85rem; margin-bottom: .5rem; text-align: center; }
.story-col img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); display: block; }

/* ---------- At a glance (F4) ---------- */
.g-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.g-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem; text-align: center; box-shadow: var(--shadow); }
.g-num { font-size: 1.9rem; font-weight: 800; color: var(--accent); line-height: 1; }
.g-lbl { color: var(--muted); font-size: .82rem; margin-top: .35rem; }

.g-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-bottom: 1.2rem; }
.g-panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.g-panel h3 { margin: 0 0 .8rem; font-size: 1.05rem; }
.g-note { color: var(--muted); font-size: .82rem; }

.pipeline { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.pstep { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: .45rem .6rem; font-size: .8rem; font-weight: 600; text-align: center; line-height: 1.2; }
.parrow { color: var(--muted); font-weight: 700; }

.g-replace ul { margin: 0; padding-left: 1.1rem; }
.g-replace li { margin-bottom: .55rem; font-size: .9rem; }
.g-scale { font-size: 1rem; line-height: 1.6; margin: 0; }
.g-scale .g-note { display: block; margin-top: .5rem; }

.g-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.g-table th, .g-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.g-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.g-table .g-sub { color: var(--muted); font-size: .78rem; }
.g-table .win-row { background: var(--accent-soft); }

.bars { display: flex; flex-direction: column; gap: .45rem; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: .6rem; font-size: .85rem; }
.bar-lbl { color: var(--ink); text-transform: capitalize; }
.bar-track { background: var(--bg); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--vec); border-radius: 999px; }
.bar-val { text-align: right; color: var(--muted); }

@media (max-width: 760px) { .g-grid2 { grid-template-columns: 1fr; } }

/* ===================== Ask AI (RAG) ===================== */
.ask-answer { margin-top: .6rem; }
.ask-answer-label, .ask-sources-label {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: .4rem;
}
.ask-answer-body {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--vec);
  border-radius: 12px; padding: 1rem 1.2rem; box-shadow: var(--shadow);
  font-size: 1.08rem; line-height: 1.7;
}
.cite { color: var(--vec); cursor: pointer; font-weight: 700; font-size: .72em; }
.ask-sources { margin-top: 1.2rem; display: grid; gap: .5rem; }
.src { display: flex; gap: .6rem; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem .9rem; }
.src.flash { border-color: var(--accent); background: var(--accent-soft); }
.src-n { color: var(--vec); font-weight: 700; }
.src-head { font-weight: 600; }
.src-meta { color: var(--muted); font-size: .78rem; margin: .15rem 0; }
.src-snip { color: var(--ink); font-size: .85rem; opacity: .85; }

/* ===================== Dashboard ===================== */
.dash-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: .7rem; }
.dash-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem; box-shadow: var(--shadow); text-align: center; }
.dc-val { font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.dc-label { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.dash-note { color: var(--muted); font-size: .82rem; margin: .7rem 0 1rem; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.dash-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.dash-box.wide { grid-column: 1 / -1; }
.dash-box h3 { margin: 0 0 .8rem; font-size: 1rem; }
.ent-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.ent-col h4 { margin: 0 0 .5rem; font-size: .82rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em; }
.ent-item { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; font-size: .9rem; }
.ent-rank { color: var(--muted); font-size: .75rem; width: 1.1rem; }
.ent-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ent-count { color: var(--accent); font-weight: 700; font-size: .82rem; }
.bar-row { display: flex; align-items: center; gap: .6rem; margin: .3rem 0; font-size: .88rem; }
.bar-label { width: 32%; text-align: right; color: var(--ink); }
.bar-track { flex: 1; background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--vec); border-radius: 6px; }
.bar-val { width: 2.5rem; color: var(--muted); font-size: .8rem; }
.senti-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; font-size: .78rem; }
.senti { color: #fff; text-align: center; line-height: 26px; font-weight: 600; }
.senti.neg { background: #d9534f; } .senti.neu { background: #9aa6b2; } .senti.pos { background: #2e9e5b; }
.senti-legend { margin-top: .5rem; color: var(--muted); font-size: .8rem; display: flex; gap: .8rem; align-items: center; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .25rem; }
.dot.neg { background: #d9534f; } .dot.neu { background: #9aa6b2; } .dot.pos { background: #2e9e5b; }
.vol-chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: .5rem; }
.vol-bar { flex: 1; background: var(--vec); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .82; }
.vol-bar:hover { opacity: 1; background: var(--accent); }

/* ===================== Graph ===================== */
.graph-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin-bottom: .6rem; flex-wrap: wrap; }
.graph-ctl { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: .5rem; }
.graph-canvas { height: 70vh; min-height: 460px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }

/* ===================== Compose ===================== */
.compose-wrap { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; }
.compose-editor { display: flex; flex-direction: column; gap: .6rem; }
.note-title { font: inherit; font-size: 1.2rem; font-weight: 700; padding: .7rem .9rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.note-body { font: inherit; min-height: 50vh; padding: .9rem; resize: vertical;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); line-height: 1.7; }
.compose-actions { display: flex; align-items: center; gap: .7rem; }
.btn-primary { font: inherit; font-weight: 700; color: #fff; background: var(--accent);
  border: 0; border-radius: 10px; padding: .6rem 1rem; cursor: pointer; }
.status.inline { margin: 0; }
.compose-side { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem; box-shadow: var(--shadow); align-self: start; }
.side-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
  margin: 0 0 .5rem; }
.compose-side .side-h:nth-of-type(2) { margin-top: 1rem; }
.suggest-item { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.si-head { font-weight: 600; font-size: .9rem; }
.si-meta { color: var(--muted); font-size: .75rem; margin: .1rem 0; }
.si-snip { font-size: .82rem; opacity: .85; }
.ent-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.ent-chip { font-size: .8rem; padding: .2rem .55rem; border-radius: 20px; border: 1px solid var(--line);
  background: var(--bg); }
.ent-chip.person { border-color: #2563eb; color: #2563eb; }
.ent-chip.place { border-color: #059669; color: #059669; }
.ent-chip.org { border-color: #b45309; color: #b45309; }

@media (max-width: 860px) {
  .dash-cards, .dash-grid, .compose-wrap, .ent-cols { grid-template-columns: 1fr; }
}

/* ===================== Media (photos & ads) ===================== */
.media-kind { border: 0; background: transparent; font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--muted); padding: .4rem .8rem; border-radius: 8px; cursor: pointer; }
.media-kind.active { background: var(--accent); color: #fff; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .7rem; margin-top: .6rem; }
.media-cell { display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); text-decoration: none; }
.media-cell img { width: 100%; height: 150px; object-fit: cover; display: block; background: var(--bg); }
.media-meta { display: block; padding: .4rem .55rem; font-size: .72rem; color: var(--muted); }
.media-cell:hover { border-color: var(--accent); }
.media-more { text-align: center; margin: 1.2rem 0; }
@media (max-width: 860px) { .dash-cards { grid-template-columns: repeat(2, 1fr); } }

/* ===================== Mobile polish ===================== */
/* guard against accidental sideways scroll; clip (not hidden) keeps sticky header working */
html, body { overflow-x: clip; }

@media (max-width: 720px) {
  /* header stacks: brand on top, tabs as their own row. safe-area pads notch/landscape */
  .topbar { flex-direction: column; align-items: stretch; flex-wrap: nowrap;
            gap: .55rem;
            padding: .6rem max(.8rem, env(safe-area-inset-right)) .6rem max(.8rem, env(safe-area-inset-left)); }
  .brand { gap: .55rem; }
  .brand .logo { font-size: 1.4rem; }
  .brand .title { font-size: .98rem; }
  .brand .subtitle { font-size: .76rem; }
  /* 9 tabs become one swipeable strip instead of a tall wrapped block */
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
          gap: .15rem; margin: 0 -.8rem; padding: 0 .8rem .15rem; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  /* #1 — 44px min tap targets for touch */
  .tab { flex: 0 0 auto; white-space: nowrap; min-height: 44px; padding: .55rem .8rem; }
  .mode, .media-kind { min-height: 40px; display: inline-flex; align-items: center; }
  .btn-ghost, .searchbar button, .chip { min-height: 40px; display: inline-flex;
            align-items: center; justify-content: center; }
  main { padding: 1rem .8rem 3rem; }
  .searchbar input { font-size: 16px; }   /* >=16px stops iOS zoom-on-focus */
  /* #6 — breathing room between mode toggles and the trust line */
  .controls { gap: .55rem; }
  /* #2 — let wide tables/panels scroll inside their card instead of stretching the page */
  .g-panel, .dash-box, .g-table { overflow-x: auto; }
  /* #3 — Photos & Ads as a 2-up gallery rather than one big column */
  .media-grid { grid-template-columns: repeat(2, 1fr); }
  .media-cell img { height: 130px; }
}
@media (max-width: 420px) {
  /* search button drops below the input and gets real tap height */
  .searchbar { flex-direction: column; }
  .searchbar button { padding: .8rem; min-height: 44px; }
}
