/* Editorial news-site look: white pages, black type, thin rules, square corners,
   serif headlines over a sans-serif body. */
:root {
  --bg: #ffffff;
  --canvas: #ffffff;
  --panel: #ffffff;
  --line: #dcdcdc;
  --line-soft: #ececec;
  --ink: #141414;          /* headlines, rules, primary buttons */
  --text: #141414;
  --text-2: #3f3f42;
  --muted: #6e6e73;
  --primary: #141414;
  --primary-2: #000000;
  --primary-soft: #f2f2f2;
  --primary-line: #141414;
  --navy: #1f3864;         /* logo navy: book labels */
  --gold: #a8843f;         /* logo gold: Urdu name */
  --red: #b80000;          /* lecture labels, live states */
  --ok: #1a7f37;
  --hit-bg: #fff6d6;
  --hit-line: #141414;
  --mark: #ffe58a;
  --mark-current: #141414;
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: var(--font);
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  /* Inter first: it has no Arabic glyphs, so Urdu falls through to Nastaliq while Latin words stay readable. */
  --urdu: 'Inter', 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Urdu Typesetting', serif;
  --top-h: 72px;
  --green: #2f6e45;        /* rgb(47, 110, 69): buttons and accents */
  --green-dark: #24573a;   /* hover / pressed */
  --green-soft: #eaf3ed;   /* light hover background */
  --r-lg: 14px;   /* search box, chat box, panels */
  --r-md: 10px;   /* buttons, inputs, highlighted passages */
  --r-sm: 6px;    /* badges, small toggles */
  --r-pill: 999px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--ink); }
.ic { flex: none; }
.muted { color: var(--muted); }
.ur, .ur-inline { font-family: var(--urdu); }
[hidden] { display: none !important; }
.eyebrow { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ------------------------------------------------------------- masthead */
/* One row: brand left, page links centred; the active link's underline sits on the bottom rule. */
.masthead {
  height: var(--top-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch;
  gap: 16px; padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.brand-logo { width: 50px; height: 50px; border-radius: 50%; flex: none; object-fit: contain; background: var(--green, #2f6e45); }
.brand-text { display: flex; align-items: baseline; gap: 10px; min-width: 0; white-space: nowrap; }
.brand-text strong { font-family: var(--serif); font-size: 15px; font-weight: 600; letter-spacing: 0; color: var(--ink); }
.brand-ur { font-family: 'Noto Nastaliq Urdu', serif; font-size: 14px; color: var(--gold); line-height: 1; }
.navbar { display: flex; justify-content: center; gap: 8px; }
.navbar a {
  display: flex; align-items: center; gap: 8px; padding: 0 18px;
  font-size: 14px; font-weight: 400; color: var(--ink); text-decoration: none; white-space: nowrap;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.navbar a:hover { border-bottom-color: var(--line); }
.navbar a.active { border-bottom-color: var(--ink); }

/* ------------------------------------------------------------- layout */
.shell { display: grid; grid-template-columns: 420px 1fr; height: calc(100vh - var(--top-h)); }
.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* tabs (used for document type, view, search mode) */
.seg { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 10px 12px 9px; font-size: 13px; font-weight: 600;
  color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.seg button:hover { color: var(--ink); }
.seg button .n { font-weight: 400; }
.seg button.active { color: var(--ink); border-bottom-color: var(--ink); }

.side-controls { padding: 14px 18px 10px; display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; padding: 4px 11px; font-size: 12px; font-weight: 500; color: var(--ink);
}
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips .ic { margin-right: 4px; color: var(--muted); }
.title-filter { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px; border: 1px solid var(--line); background: #fff; }
.title-filter input { border: 0; outline: 0; flex: 1; font: inherit; font-size: 13px; background: transparent; min-width: 0; }
.title-filter:focus-within { border-color: var(--ink); }

.list-head {
  display: flex; justify-content: space-between; align-items: center; margin: 6px 18px 0; padding: 10px 0 8px;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-top: 2px solid var(--ink);
}
.sel-count { background: var(--ink); color: #fff; padding: 1px 6px; font-size: 11px; margin-left: 4px; }
.doc-list { overflow-y: auto; padding: 0 18px 24px; display: flex; flex-direction: column; flex: 1; }
.list-loading, .empty { color: var(--muted); padding: 28px 16px; text-align: center; }

.doc-card { padding: 14px 0 12px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.doc-card:hover .dc-title { text-decoration: underline; text-underline-offset: 3px; }
.doc-card.active { box-shadow: inset 4px 0 0 var(--ink); padding-left: 14px; }
.dc-top { display: flex; align-items: center; gap: 10px; }
.dc-top .sel { margin-left: auto; width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; }
.dc-title { font-family: var(--font); font-weight: 600; font-size: 14px; margin: 6px 0 6px; line-height: 1.3; color: var(--ink); }
.dc-title.ur { font-family: var(--urdu); font-weight: 400; font-size: 16px; line-height: 2.1; margin: 0 0 2px; }
.dc-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.dc-foot .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); white-space: nowrap; }
.sentinel { height: 1px; }

/* labels: small text, coloured by kind, no boxes */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.b-book { color: var(--navy); }
.b-lec { color: var(--red); }
.b-lang { color: var(--muted); font-weight: 500; padding-left: 10px; border-left: 1px solid var(--line); }

/* ------------------------------------------------------------- search bar */
.main-top { display: flex; align-items: center; gap: 16px; padding: 14px 28px; border-bottom: 1px solid var(--line); }
.searchbox {
  flex: 1; min-width: 0; max-width: 820px; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px;
  border: 2px solid var(--ink); background: #fff;
}
.searchbox input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 14px; background: transparent; }
.searchbox input::-webkit-search-cancel-button { display: none; }
.searchbox .clear { border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; padding: 4px; }
.seg-view { flex: none; margin-left: auto; border-bottom: 0; }
.seg-view button { flex: none; padding: 8px 14px; }
.icon-btn { border: 1px solid var(--line); background: #fff; width: 34px; height: 34px; display: grid; place-items: center; color: var(--ink); }
.icon-btn:hover { border-color: var(--ink); }
.back-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; }
.back-btn:hover { border-color: var(--green); color: var(--green); }
.back-btn[hidden] { display: none; }
.show-sm { display: none; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.results-wrap { overflow-y: auto; padding: 24px 28px 60px; display: flex; flex-direction: column; align-items: center; flex: 1; }
.results-wrap > * { width: 100%; max-width: 900px; }
.results-wrap.loading { opacity: .55; }

/* landing */
.welcome { padding: 8px 0 0; }
.welcome-icon { display: none; }
.welcome h2 { font-family: var(--font); font-weight: 600; font-size: 22px; line-height: 1.15; margin: 0 0 12px; padding-top: 12px; border-top: 2px solid var(--ink); color: var(--ink); }
.welcome p { color: var(--text-2); line-height: 1.6; margin: 0; font-size: 14px; max-width: 720px; }
.try { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 22px 0; }
.try > span { color: var(--muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; }
.try .chip.ur { font-size: 14px; line-height: 1.9; padding: 1px 12px; }
.tips { margin: 0; padding: 16px 0 0 18px; border-top: 1px solid var(--line); color: var(--text-2); line-height: 1.7; font-size: 13.5px; }

/* results */
.res-summary {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  border-top: 2px solid var(--ink); padding-top: 10px; margin-bottom: 4px; color: var(--text-2); font-size: 12.5px;
}
.res-summary strong { color: var(--ink); }
.seg-mode { border-bottom: 0; }
.seg-mode button { flex: none; padding: 4px 10px 5px; font-size: 12px; }
.seg-mode button:disabled { opacity: .4; cursor: not-allowed; }
.roman-note, .title-hits { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.roman-note .chip.ur { line-height: 1.9; padding: 0 12px; }
.title-hits .eyebrow { margin-right: 4px; }
.title-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.title-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-chip.ur { font-family: var(--urdu); line-height: 2; padding: 0 12px; }
.notice { border-left: 4px solid var(--red); background: #fbf3f3; color: var(--ink); padding: 10px 14px; font-size: 13px; margin: 10px 0; }
.notice code, .coming code { background: #f2f2f2; padding: 1px 5px; font-size: 13px; }

.res-card {
  text-align: start; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 18px 0; display: flex; flex-direction: column; gap: 6px; width: 100%;
}
.res-card:hover .rc-title { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.rc-title { font-family: var(--font); font-weight: 600; font-size: 14.5px; line-height: 1.35; margin: 0; color: var(--ink); }
.rc-title.ur { font-family: var(--urdu); font-weight: 400; font-size: 17px; line-height: 2; }
.res-card.lead .rc-title { font-size: 18px; }
.res-card.lead .rc-title.ur { font-size: 21px; }
.res-card.lead .snip { font-size: 14px; }
.snip { margin: 0; color: var(--text-2); line-height: 1.55; font-size: 13.5px; white-space: pre-line; }
.snip.ur { font-family: var(--urdu); font-size: 15px; line-height: 2.2; }
.rc-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.rc-meta > * + * { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line); }
.rc-meta .badge { font-size: 11.5px; }
.rc-meta .b-lang { border-left: 1px solid var(--line); }
.how { display: inline-flex; gap: 8px; }
.tag { font-size: 11px; font-weight: 600; color: var(--ink); }
.tag-kw::before, .tag-sem::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 5px; vertical-align: 0; }
.tag-kw::before { background: var(--ink); }
.tag-sem::before { background: var(--gold); }
mark { background: var(--mark); color: inherit; padding: 0 1px; }
mark.current { background: var(--mark-current); color: #fff; }

/* voice input */
.mic-btn { border: 0; background: transparent; color: var(--ink); width: 34px; height: 34px; display: grid; place-items: center; flex: none; }
.mic-btn:hover { background: var(--primary-soft); }
.mic-btn.listening { color: #fff; background: var(--red); animation: mic-pulse 1.2s ease-in-out infinite; }
.mic-btn.voice-error { color: var(--red); }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(184, 0, 0, .45); } 50% { box-shadow: 0 0 0 7px rgba(184, 0, 0, 0); } }
@media (prefers-reduced-motion: reduce) { .mic-btn.listening { animation: none; } }
.voice-lang { border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 12px; font-weight: 700; padding: 2px 7px; flex: none; min-width: 34px; line-height: 1.6; }
.voice-lang.ur { font-family: var(--urdu); font-weight: 400; font-size: 13px; line-height: 1.9; padding: 0 7px; }
.voice-lang:hover { border-color: var(--ink); }
.composer .mic-btn, .composer .voice-lang { align-self: center; }

/* ------------------------------------------------------------- reader (article page) */
.reader-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 22px 28px 16px; border-bottom: 1px solid var(--line);
}
.reader-empty { color: var(--muted); padding: 6px 0; }
.rh-main { min-width: 0; flex: 1; max-width: 900px; }
.rh-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.rh-meta .badge { font-size: 11.5px; }
.rh-title { font-family: var(--font); font-weight: 600; font-size: 22px; line-height: 1.15; margin: 8px 0 6px; color: var(--ink); }
.rh-title.ur { font-family: var(--urdu); font-weight: 400; font-size: 24px; line-height: 2; margin: 2px 0 0; }
.rh-path { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.rh-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.finder { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.finder span { margin-right: 4px; }
.ai-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; white-space: nowrap;
  background: var(--ink); border: 1px solid var(--ink); color: #fff; font-weight: 600;
}
.ai-btn:hover { background: #333; }

.reader-scroll { flex: 1; overflow-y: auto; padding: 28px 28px 80px; }
.paper { max-width: 760px; margin: 0; }
.paper:empty { display: none; }
.paper-body { font-family: var(--font); font-size: 14px; line-height: 1.6; color: #202020; }
.paper-body p { margin: 0 0 18px; }
.paper-body h3 { font-family: var(--font); font-weight: 600; font-size: 16px; margin: 30px 0 12px; color: var(--ink); }
.paper-body .ur { font-family: var(--urdu); font-size: 17px; line-height: 2.35; }
.paper-body h3.ur { font-size: 19px; }
.pg { display: flex; align-items: center; gap: 12px; margin: 34px 0 18px; font-family: var(--mono); color: var(--muted); font-size: 11px; font-weight: 500; }
.pg::before, .pg::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.pg::before { flex: 0 0 24px; }
.paper-body > .pg:first-child { margin-top: 0; }
.hit-block {
  background: var(--hit-bg); border-left: 4px solid var(--hit-line); padding: 18px 14px 2px;
  margin: 0 -18px 18px; scroll-margin-top: 24px;
}
.paper-ur .hit-block, .hit-block:dir(rtl) { border-left: 0; border-right: 4px solid var(--hit-line); }
.hit-block .pg { margin-top: 0; }

/* ------------------------------------------------------------- research */
.shell-research { grid-template-columns: 380px 1fr; }
.rs-side { padding: 18px; gap: 26px; overflow-y: auto; }
.rs-block { display: flex; flex-direction: column; gap: 12px; }
.rs-block .eyebrow { border-top: 2px solid var(--ink); padding-top: 8px; }
.scope-card { padding: 4px 0 12px; border-bottom: 1px solid var(--line); }
.scope-title { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.scope-title strong { font-weight: 600; }
.scope-title .ok { color: var(--ok); }
.scope-card p { margin: 6px 0 0 26px; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.scope-list { list-style: none; margin: 10px 0 6px; padding: 0; display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.scope-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.scope-list li .ur { line-height: 2; }
.scope-list button { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.link-btn { border: 0; background: transparent; color: var(--ink); padding: 0; font-size: 12.5px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.soft-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px;
  border: 1px solid var(--ink); color: var(--ink); text-decoration: none; font-weight: 600;
}
.soft-btn:hover { background: var(--ink); color: #fff; }
.threads-empty { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); font-size: 13px; line-height: 1.5; }
.threads-empty p { margin: 0; }

.prompts { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--line); min-width: 0; }
.prompt-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: -6px; min-width: 0; }
.prompt {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; padding: 6px 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 12px; font-weight: 500;
}
.prompt:hover { border-color: var(--ink); }
.prompt .ur-inline { line-height: 1.6; }

.chat { flex: 1; overflow-y: auto; padding: 28px 28px; display: flex; justify-content: center; align-items: stretch; }
.chat-inner { width: 100%; max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.coming { max-width: 860px; width: 100%; }
.coming-icon { display: none; }
.coming .tag { display: inline-block; font-size: 11px; font-weight: 600; color: #fff; background: var(--red); padding: 2px 8px; }
.coming h2 { font-family: var(--font); font-weight: 600; font-size: 22px; line-height: 1.15; margin: 0 0 12px; padding-top: 12px; border-top: 2px solid var(--ink); color: var(--ink); }
.coming p { color: var(--text-2); line-height: 1.6; margin: 0 0 12px; font-size: 14px; }
.coming .muted-p { color: var(--muted); font-size: 13px; margin: 0; }

.cite { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; font-family: var(--mono); font-size: 11px; font-weight: 500; white-space: nowrap; vertical-align: 1px; border: 1px solid; line-height: 1.6; }
.cite-book { color: var(--navy); border-color: var(--navy); }
.cite-lec { color: var(--red); border-color: var(--red); }
.cites { display: inline-flex; gap: 4px; flex-wrap: wrap; vertical-align: 1px; margin: 0 2px; }
a.cite { text-decoration: none; }
a.cite:hover { color: #fff; }
a.cite-book:hover { background: var(--navy); }
a.cite-lec:hover { background: var(--red); }

.composer-wrap { margin: 0 auto 16px; width: calc(100% - 56px); max-width: 860px; display: flex; flex-direction: column; gap: 8px; }
.composer { display: flex; align-items: flex-end; gap: 8px; background: #fff; border: 2px solid var(--ink); padding: 8px 8px 8px 16px; }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; font: inherit; font-size: 14px; line-height: 1.5; padding: 8px 0; background: transparent; max-height: 180px; min-width: 0; }
.send { width: 42px; height: 42px; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none; }
.send:disabled { background: #e6e6e6; color: var(--muted); cursor: not-allowed; }
.send.stop { background: var(--red); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.picker { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); }
.picker select { font: inherit; font-weight: 400; font-size: 12px; color: var(--ink); border: 1px solid var(--line); background: #fff; padding: 4px 8px; max-width: 220px; }
.privacy { text-align: end; }

/* conversation: the question reads like a headline, the answer like an article */
.msg-user {
  font-family: var(--font); font-size: 17px; font-weight: 600; line-height: 1.35; color: var(--ink);
  padding-top: 12px; border-top: 2px solid var(--ink); white-space: pre-wrap;
}
.msg-user.ur { font-family: var(--urdu); font-weight: 600; font-size: 24px; line-height: 2.1; }
.msg-ai { padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.ai-eyebrow { display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ai-eyebrow .ic { color: var(--gold); }
.ai-status { font-size: 13px; color: var(--muted); margin-top: 8px; }
.ai-status:empty { display: none; }
.ai-status .err { color: var(--red); font-weight: 600; }
.dots::after { content: '…'; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }
.ai-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.ai-log li { display: grid; grid-template-columns: 14px 1fr auto; gap: 6px; align-items: baseline; }
.ai-log .mark { color: var(--green); font-weight: 700; }
.ai-log li.now { color: #202020; }
.ai-log li.now .mark::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: pulse 1s ease-in-out infinite alternate; }
.ai-log .t { font-variant-numeric: tabular-nums; font-size: 12px; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
.ai-terms { font-size: 12px; color: var(--muted); margin-top: 6px; }
.ai-terms .ur { font-family: var(--urdu); font-size: 13px; }
.ai-body { margin-top: 12px; font-family: var(--font); font-size: 14px; line-height: 1.6; color: #202020; }
.ai-body p { margin: 0 0 16px; }
.ai-body ol, .ai-body ul { margin: 0 0 16px; padding-inline-start: 24px; }
.ai-body li { margin-bottom: 10px; }
.ai-body h4 { font-family: var(--font); font-weight: 600; margin: 20px 0 6px; font-size: 15px; color: var(--ink); }
.ai-body.ur { font-family: var(--urdu); font-size: 20px; line-height: 2.4; color: #1a1a1a; }
/* Nastaliq is optically much smaller than Latin: Urdu headings and lists need their own sizes. */
.ai-body.ur h4 { font-family: var(--urdu); font-weight: 600; font-size: 23px; line-height: 2.1; margin: 24px 0 4px; }
.ai-body.ur p, .ai-body.ur ul, .ai-body.ur ol { margin-bottom: 14px; }
.ai-body.ur li { margin-bottom: 6px; }
.ai-body.ur strong { font-weight: 600; }
.ai-body.ur .cite, .ai-body.ur .cites { vertical-align: middle; margin-inline: 3px; }
.ai-body.ur .cite { line-height: 1.7; }
.ai-sources { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; }
.ai-sources summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.ai-sources ol { margin: 10px 0 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 12px; }
.ai-sources a { color: inherit; text-decoration: none; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.ai-sources a:hover strong { text-decoration: underline; }
.ai-sources strong { font-family: var(--font); font-weight: 600; font-size: 13.5px; }
.ai-sources strong.ur { font-family: var(--urdu); font-weight: 400; line-height: 2; }
.ai-sources p { margin: 2px 0 0; color: var(--muted); line-height: 1.5; }
.ai-sources p.ur { font-family: var(--urdu); line-height: 2.1; }
.ai-foot { margin-top: 12px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ai-foot:empty { display: none; }

/* threads */
.threads-head { display: flex; justify-content: space-between; align-items: center; border-top: 2px solid var(--ink); padding-top: 8px; }
.threads-head .eyebrow { border: 0; padding: 0; }
.threads-head .link-btn { display: inline-flex; align-items: center; gap: 4px; }
.threads { display: flex; flex-direction: column; }
.thread { padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.thread:hover .t-title { text-decoration: underline; }
.thread.active { box-shadow: inset 4px 0 0 var(--ink); padding-left: 12px; }
.t-title { font-family: var(--font); font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.t-title.ur { font-family: var(--urdu); font-weight: 400; line-height: 2; }
.t-meta { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.t-del { border: 0; background: transparent; color: var(--muted); padding: 4px; display: grid; place-items: center; opacity: .45; }
.thread:hover .t-del, .t-del:focus-visible { opacity: 1; }
.t-del:hover { color: var(--red); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  .shell { grid-template-columns: 360px 1fr; }
  .shell-research { grid-template-columns: 330px 1fr; }
}
@media (max-width: 1060px) {
  .hide-sm { display: none; }
  .brand-ur { display: none; }
}
@media (max-width: 860px) {
  :root { --top-h: 60px; }
  .masthead { grid-template-columns: auto 1fr; padding: 0 12px; gap: 8px; }
  .mast-right, .brand-text { display: none; }
  .brand-logo { width: 42px; height: 42px; }
  .navbar { justify-content: flex-end; gap: 0; }
  .navbar a { padding: 0 12px; font-size: 14px; }
  .hide-xs { display: none; }
  .shell, .shell-research { grid-template-columns: minmax(0, 1fr); position: relative; }
  .sidebar {
    position: absolute; inset: 0 auto 0 0; width: min(400px, 92vw); z-index: 20;
    transform: translateX(-102%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2);
  }
  .side-open .sidebar { transform: none; }
  .rs-side { position: static; transform: none; width: auto; box-shadow: none; border-right: 0; border-bottom: 1px solid var(--line); max-height: 38vh; }
  .shell-research { grid-template-rows: auto 1fr; }
  .show-sm { display: grid; }
  .main-top { padding: 10px 16px; gap: 8px; flex-wrap: wrap; }
  .searchbox { order: 3; flex-basis: 100%; height: 44px; }
  .seg-view button { padding: 7px 10px; font-size: 13px; }
  .results-wrap { padding: 16px 16px 48px; }
  .chat { padding: 16px; }
  .welcome h2, .coming h2 { font-size: 19px; }
  .res-card.lead .rc-title { font-size: 16px; }
  .reader-head { padding: 14px 16px; flex-direction: column; align-items: stretch; }
  .rh-title { font-size: 19px; }
  .reader-scroll { padding: 16px 16px 60px; }
  .hit-block { margin: 0 -16px 18px; padding: 14px 16px 2px; }
  .prompts { padding: 10px 16px; }
  .composer-wrap { width: calc(100% - 32px); margin-bottom: 12px; }
  .msg-user { font-size: 16px; }
  .privacy { text-align: start; }
  .picker { flex-wrap: wrap; min-width: 0; width: 100%; }
  .picker select { flex: 1 1 140px; min-width: 0; max-width: none; }
}

/* Page numbers and locations: monospace */
.pnum { font-family: var(--mono); font-size: 11px; }

/* ------------------------------------------------------------- rounded corners */
.searchbox, .composer, .hit-block, .notice { border-radius: var(--r-lg); }
.title-filter, .soft-btn, .ai-btn, .icon-btn, .prompt, .doc-card.active, .thread.active,
.notice code, .coming code, select, textarea, input[type="text"], input[type="search"] { border-radius: var(--r-md); }
.chip, .title-chip, .sel-count, .coming .tag { border-radius: var(--r-pill); }
.cite, .voice-lang, .tag-kw::before, .tag-sem::before { border-radius: var(--r-sm); }
.mic-btn, .send, .searchbox .clear, .scope-list button, .t-del { border-radius: 50%; }
.composer textarea, .searchbox input { border-radius: 0; }
input[type="checkbox"] { border-radius: 4px; }
.doc-card.active, .thread.active { box-shadow: none; background: #f4f4f2; padding-left: 12px; padding-right: 10px; }
.hit-block { margin: 0 -14px 18px; }
.hit-block, .paper-ur .hit-block, .hit-block:dir(rtl) { border: 1px solid #ecd98f; padding: 18px 18px 2px; }

/* ------------------------------------------------------------- green buttons + hover */
button, a, .chip, .prompt, .soft-btn, .icon-btn, .voice-lang, .mic-btn, .send, .ai-btn, .seg button, .navbar a {
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
/* Solid green buttons with white text */
.send, .ai-btn, .chip.active, .sel-count { background: var(--green); border-color: var(--green); color: #fff; }
.send:hover:not(:disabled), .ai-btn:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.send:disabled { background: #e6e6e6; color: var(--muted); }
.send.stop { background: var(--red); }
.send.stop:hover { background: #8f0000; }
/* Outline buttons: green on hover */
.soft-btn { border-color: var(--green); color: var(--green); }
.soft-btn:hover { background: var(--green); border-color: var(--green); color: #fff; }
.chip:hover:not(.active), .prompt:hover, .icon-btn:hover, .voice-lang:hover, .title-chip:hover {
  border-color: var(--green); color: var(--green); background: var(--green-soft);
}
.mic-btn:hover, .searchbox .clear:hover { background: var(--green-soft); color: var(--green); }
.mic-btn.listening { background: var(--red); color: #fff; }
.link-btn:hover { color: var(--green); }
/* Tabs and nav: green underline */
.navbar a:hover { color: var(--green); border-bottom-color: var(--green-soft); }
.navbar a.active { color: var(--green); border-bottom-color: var(--green); }
.seg button:hover { color: var(--green); }
.seg button.active { color: var(--green); border-bottom-color: var(--green); }
/* Focus: green ring on the search and chat boxes */
.searchbox:focus-within, .composer:focus-within, .title-filter:focus-within {
  border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 110, 69, .15);
}
/* Selected document / thread */
.doc-card.active, .thread.active { background: var(--green-soft); box-shadow: inset 3px 0 0 var(--green); }
.doc-card:hover .dc-title, .thread:hover .t-title, .res-card:hover .rc-title { color: var(--green); }
input[type="checkbox"] { accent-color: var(--green); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ------------------------------------------------------------- suggestions dropdown */
.has-suggest { position: relative; }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 12px 32px rgba(20, 40, 28, .16);
  padding: 6px 0; max-height: 420px; overflow-y: auto; text-align: start;
}
.sg-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 14px; cursor: pointer; font-weight: 400; }
.sg-item > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-item b { font-weight: 600; }
.sg-item.active { background: var(--green-soft); color: var(--green); }
.sg-item .ic { flex: none; }
.sg-ur { font-family: var(--urdu); font-size: 15px; line-height: 1.9; color: #8a6a2a; }
.sg-tag { flex: none; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.sg-item:dir(rtl) { font-family: var(--urdu); font-size: 17px; line-height: 2; padding-top: 2px; padding-bottom: 2px; }
.sg-item:dir(rtl) b { font-weight: 600; }
/* voice in the title filter */
.title-filter .voice-lang-sm { font-size: 11px; padding: 1px 6px; min-width: 30px; line-height: 1.5; }
.title-filter .voice-lang-sm.ur { line-height: 1.8; }
.mic-sm { width: 28px; height: 28px; }

/* ------------------------------------------------------------- access code */
.nav-lock { margin-left: 2px; opacity: .55; }
@media (min-width: 861px) { .mast-right { display: flex; justify-content: flex-end; } }
.lock-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 13px; padding: 6px 12px; border-radius: var(--r-pill); }
.lock-link:hover { color: var(--green); background: var(--green-soft); }
body.page-unlock { overflow: auto; }
.unlock-page { min-height: calc(100vh - var(--top-h)); display: grid; place-items: center; padding: 32px 16px;
  background: radial-gradient(900px 400px at 50% 0%, #eaf3ed, transparent 70%), #fff; }
.unlock-card { width: 100%; max-width: 400px; text-align: center; background: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 28px 28px; box-shadow: 0 16px 40px rgba(20, 40, 28, .10); }
.unlock-logo { border-radius: 50%; }
.unlock-card h1 { font-size: 20px; margin: 14px 0 6px; color: var(--ink); }
.unlock-card p { color: var(--muted); font-size: 13.5px; line-height: 1.55; margin: 0 0 18px; }
.unlock-card p a { color: var(--green); font-weight: 600; }
.unlock-field { display: flex; align-items: center; gap: 10px; border: 2px solid var(--ink); border-radius: var(--r-lg); padding: 0 14px; height: 50px; }
.unlock-field:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 110, 69, .15); }
.unlock-field input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 18px; letter-spacing: .3em; background: transparent; font-family: var(--mono); }
.unlock-field input::placeholder { letter-spacing: 0; font-family: var(--font); font-size: 15px; }
.unlock-error { color: var(--red) !important; font-weight: 600; margin: 12px 0 0 !important; }
.unlock-btn { width: 100%; margin-top: 16px; border: 0; background: var(--green); color: #fff; font-weight: 600; font-size: 15px; padding: 13px; border-radius: var(--r-pill); }
.unlock-btn:hover:not(:disabled) { background: var(--green-dark); }
.unlock-btn:disabled { background: #d9d9d9; }
@media (max-width: 640px) { .lock-link span { display: none; } }

/* ------------------------------------------------------------- search scope: ticked documents / one book */
.scope-note {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; padding: 10px 14px;
  border-left: 4px solid var(--green); background: var(--green-soft); color: var(--ink); font-size: 13px;
  border-radius: var(--r-md);
}
.reader-head { flex-wrap: wrap; }
.rh-find { flex-basis: 100%; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.doc-find {
  flex: 1; min-width: 0; max-width: 560px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px;
}
.doc-find:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.doc-find input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 13.5px; background: transparent; color: var(--ink); }
.doc-find input::-webkit-search-cancel-button { display: none; }
.doc-find .clear { border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; padding: 4px; }
.doc-find-sum { font-size: 12.5px; color: var(--text-2); }
.doc-find-sum strong { font-family: var(--mono); font-weight: 600; }
.doc-hits {
  flex-basis: 100%; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); background: #fff;
  border-radius: var(--r-md);
}
.dh-item {
  display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: start; padding: 9px 14px;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
}
.dh-item:last-child { border-bottom: 0; }
.dh-item:hover { background: var(--green-soft); }
.dh-item .pnum { flex: none; font-family: var(--mono); font-size: 11.5px; color: var(--muted); min-width: 44px; }
.dh-item .snip { flex: 1; min-width: 0; margin: 0; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dh-item .snip.ur { font-family: var(--urdu); font-size: 14px; line-height: 2.1; }
.dh-item .tag { flex: none; }
@media (max-width: 860px) { .doc-find { max-width: none; } }

/* ------------------------------------------------------------- hide the library list (wide screens) */
.side-toggle { flex: none; }
.side-toggle[aria-expanded="false"] { background: var(--green); border-color: var(--green); color: #fff; }
.side-toggle[aria-expanded="false"]:hover { background: var(--green-dark); }
@media (min-width: 861px) {
  .shell { transition: grid-template-columns .2s ease; }
  .side-hidden .shell { grid-template-columns: 0 1fr; }
  .side-hidden .shell > .sidebar { visibility: hidden; overflow: hidden; border-right: 0; }
  .side-hidden .paper { margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { .shell { transition: none; } }

/* ------------------------------------------------------------- Ask AI: welcome examples + scope line */
.coming .lead-p { font-size: 15px; }
.try-head { margin: 22px 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.try-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; align-content: start; }
.coming .try { margin: 0; display: flex; align-items: flex-start; text-transform: none; letter-spacing: normal; flex-direction: column; gap: 4px; text-align: start; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--r-md); background: #fff; color: var(--ink); font: inherit; cursor: pointer; }
.try:hover { border-color: var(--green); background: var(--green-soft); }
.try strong { font-size: 14px; font-weight: 600; }
.coming .try span { text-transform: none; letter-spacing: normal; font-weight: 400; font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.coming .try.ur { text-align: right; }
.try.ur strong { font-family: var(--urdu); font-weight: 400; font-size: 17px; line-height: 1.9; }
.try.ur span { font-family: var(--urdu); font-size: 14px; line-height: 2; }
.try-tip { margin-top: 14px !important; font-size: 13px !important; color: var(--muted) !important; }
.try-tip a { color: var(--green); }
.scope-line { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text-2); }
.scope-line .ic { color: var(--green); flex: none; }
.scope-line a, .scope-line .link-btn { color: var(--green); font-size: 12px; font-weight: 600; }
.scope-line bdi { font-weight: 600; }
.scope-few { color: var(--ink); }
@media (max-width: 640px) { .coming .try:nth-child(n+4) { display: none; } }
