/* Libyan Academy Research Platform — design system v2
   Mobile-first · RTL/LTR via logical properties · light/dark · gold identity #c8a24d #e6c36a #9b7626 */
:root {
  --gold: #c8a24d; --gold-l: #e6c36a; --gold-d: #9b7626; --gold-bg: #fbf6ea;
  --ink: #1b2230; --ink-2: #3a4456; --muted: #6b7384; --faint: #9aa1ad;
  --bg: #f7f6f2; --surface: #ffffff; --surface-2: #fbfaf7; --line: #e7e2d6; --line-2: #efebe1;
  --ok: #2c7a4d; --ok-bg: #eaf5ee; --err: #b0332a; --err-bg: #fbecea; --info-bg: #f3efe3;
  --shadow-1: 0 1px 2px rgba(27,34,48,.06), 0 1px 1px rgba(27,34,48,.04);
  --shadow-2: 0 6px 24px rgba(27,34,48,.08), 0 2px 6px rgba(27,34,48,.05);
  --r-s: 8px; --r-m: 12px; --r-l: 18px;
  --header-h: 64px; --side-w: 252px;
  --fs-0: .95rem; --fs-1: 1.12rem; --fs-2: 1.35rem; --fs-3: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); --fs-4: clamp(1.9rem, 1.3rem + 2.6vw, 3rem);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #ecebe6; --ink-2: #c9cbd1; --muted: #9aa1ad; --faint: #737a87;
  --bg: #12151c; --surface: #1a1e27; --surface-2: #1f2430; --line: #2c3240; --line-2: #252a35;
  --gold-bg: #2a2416; --ok-bg: #16281e; --err-bg: #2d1a18; --info-bg: #24211a;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 8px 28px rgba(0,0,0,.45);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body { margin: 0; font-family: "Cairo", "Segoe UI", Tahoma, sans-serif; font-size: 1rem; line-height: 1.75; color: var(--ink); background: var(--bg); min-height: 100vh; }
img, svg { max-width: 100%; }
a { color: var(--gold-d); text-underline-offset: 3px; text-decoration-thickness: 1px; }
:root[data-theme="dark"] a { color: var(--gold-l); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--gold-l); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .6em; color: var(--ink); }
h1 { font-size: var(--fs-3); font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: var(--fs-2); font-weight: 700; margin-top: 1.8em; }
h3 { font-size: var(--fs-1); font-weight: 700; }
code { font-size: .85em; background: var(--info-bg); padding: .1em .4em; border-radius: 5px; }
mark { background: color-mix(in srgb, var(--gold-l) 45%, transparent); color: inherit; padding: 0 .1em; border-radius: 3px; }
small { font-size: .85em; }
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
[dir="rtl"] .ic-flip { transform: scaleX(-1); }
[dir="ltr"] .ic-flip-ltr { transform: scaleX(-1); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: -999px; top: 8px; z-index: 100; background: var(--surface); padding: .5rem 1rem; border-radius: var(--r-s); }
.skip:focus { inset-inline-start: 8px; }
.muted, .fine { color: var(--muted); }
.fine { font-size: .85rem; }

/* ---------- Header ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--header-h); display: flex; align-items: center; gap: .75rem;
  padding: 0 clamp(.75rem, 2vw, 1.5rem); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--gold-d), var(--gold-l), var(--gold-d)); opacity: .9; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); min-width: 0; }
.brand strong { display: block; font-size: 1.02rem; line-height: 1.3; white-space: nowrap; }
.brand small { display: block; font-size: .74rem; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30ch; }
.brand-mark { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 30%, var(--gold-l), var(--gold-d)); color: #fff; box-shadow: 0 2px 8px rgba(155,118,38,.35); }
.brand-mark svg { width: 20px; height: 20px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none; flex: none; padding: 0; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.icon-btn .ic { width: 1.3rem; height: 1.3rem; }
.menu-btn { display: none; }
.top-search { flex: 1; max-width: 560px; margin-inline: auto; position: relative; }
.top-search input { width: 100%; height: 42px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  padding-inline: 2.6rem 3.2rem; font: inherit; color: var(--ink); }
.top-search input:focus { outline: none; border-color: var(--gold); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold-l) 25%, transparent); }
.top-search > .ic { position: absolute; inset-inline-start: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.kbd { position: absolute; inset-inline-end: .7rem; top: 50%; transform: translateY(-50%); font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 .4rem; line-height: 1.6; background: var(--surface); }
.top-actions { display: flex; align-items: center; gap: .25rem; margin-inline-start: auto; }
.top-actions .txt-link { font-size: .9rem; text-decoration: none; padding: .35rem .7rem; border-radius: 8px; color: var(--ink-2); white-space: nowrap; display: inline-flex; gap: .35rem; align-items: center; }
.top-actions .txt-link:hover { background: var(--surface-2); color: var(--ink); }
.theme-dark-only { display: none; }
:root[data-theme="dark"] .theme-dark-only { display: inline; }
:root[data-theme="dark"] .theme-light-only { display: none; }

/* Suggestions dropdown */
.suggest { position: absolute; inset-inline: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  box-shadow: var(--shadow-2); padding: .4rem; z-index: 60; max-height: min(70vh, 460px); overflow: auto; }
.suggest[hidden] { display: none; }
.suggest h6 { margin: .4rem .6rem .2rem; font-size: .72rem; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.suggest a { display: flex; gap: .6rem; align-items: center; padding: .45rem .6rem; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .92rem; }
.suggest a .ic { color: var(--gold-d); }
.suggest a:hover, .suggest a.active { background: var(--gold-bg); }
.suggest .s-meta { margin-inline-start: auto; color: var(--muted); font-size: .78rem; white-space: nowrap; }
.suggest .s-all { justify-content: center; color: var(--gold-d); font-weight: 600; border-top: 1px solid var(--line-2); border-radius: 0 0 8px 8px; margin-top: .3rem; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); max-width: 1440px; margin: 0 auto; }
.sidenav { position: sticky; top: var(--header-h); align-self: start; height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 1.2rem .8rem 2rem; display: flex; flex-direction: column; gap: 2px; }
.sidenav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .8rem; color: var(--ink-2); text-decoration: none; border-radius: 10px; font-weight: 500; font-size: .95rem; }
.sidenav a .ic { color: var(--faint); }
.sidenav a:hover { background: var(--surface); color: var(--ink); }
.sidenav a:hover .ic { color: var(--gold-d); }
.sidenav a.on { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-1); }
.sidenav a.on .ic { color: var(--gold-d); }
.sidenav a.on::before { content: ""; width: 3px; align-self: stretch; margin-inline-start: -.8rem; margin-inline-end: .1rem; border-radius: 3px; background: var(--gold); }
.nav-label { font-size: .72rem; font-weight: 700; color: var(--faint); padding: 1rem .8rem .3rem; letter-spacing: .03em; }
.drawer-head { display: none; }
.overlay { display: none; }
main { padding: clamp(1rem, 3vw, 2.2rem) clamp(1rem, 3vw, 2.5rem) 4rem; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem 1.5rem; justify-content: space-between; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 2rem 1rem 2.5rem; border-top: 1px solid var(--line); }

/* ---------- Buttons ---------- */
input, select, textarea, button { font: inherit; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; border: 1px solid var(--gold-d); background: var(--gold-d); color: #fff;
  padding: .45rem 1.1rem; border-radius: 10px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
button:hover, .btn:hover { background: #876620; border-color: #876620; color: #fff; }
.btn.ghost, button.btn.ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); font-weight: 600; }
.btn.ghost:hover { border-color: var(--gold); color: var(--ink); background: var(--gold-bg); }
.btn.danger, button.btn.danger { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.btn.danger:hover { background: var(--err); color: #fff; border-color: var(--err); }
.btn.sm, button.sm { min-height: 32px; padding: .2rem .7rem; font-size: .85rem; border-radius: 8px; }
button.link { background: none; border: 0; color: var(--gold-d); padding: 0; min-height: 0; font-weight: 500; text-decoration: underline; }
button[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.is-loading::after { content: ""; position: absolute; width: 1.1em; height: 1.1em; border: 2px solid #fff; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.ghost.is-loading::after { border-color: var(--gold-d); border-inline-end-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1rem 0; }

/* ---------- Forms ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: .5rem .8rem; color: var(--ink); max-width: 100%; min-height: 42px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold-l) 22%, transparent); }
input[type=checkbox], input[type=radio] { width: 1.1rem; height: 1.1rem; accent-color: var(--gold-d); }
input[type=file] { padding: .6rem; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface-2); width: 100%; }
.card-form { display: grid; gap: 1rem; max-width: 30rem; background: var(--surface); border: 1px solid var(--line); padding: clamp(1.1rem, 3vw, 1.8rem); border-radius: var(--r-l); margin: 1.2rem 0; box-shadow: var(--shadow-1); }
.card-form.wide { max-width: 52rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-form.wide > h2, .card-form.wide > .full, .card-form.wide > p.actions, .card-form.wide > label:has(textarea), .card-form.wide > button { grid-column: 1 / -1; }
.card-form h1, .card-form h2 { margin: 0; }
.card-form label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.card-form label input, .card-form label select, .card-form label textarea { width: 100%; font-weight: 400; }
.card-form label.check { display: flex; gap: .55rem; align-items: center; }
.card-form small { color: var(--muted); font-weight: 400; }
.ask { display: grid; gap: .7rem; max-width: 48rem; }
.ask textarea { width: 100%; }

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1rem 0 1.4rem; padding: .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-1); }
.filters .grow { flex: 1 1 16rem; min-width: 0; }
.filters .year { width: 7.5rem; }
.filters select { min-width: 9rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: 0; background: var(--surface-2); gap: 2px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .3rem .85rem; font-size: .88rem; border-radius: 7px; color: var(--ink-2); white-space: nowrap; }
.seg input:checked + span { background: var(--ink); color: var(--surface); font-weight: 700; }
:root[data-theme="dark"] .seg input:checked + span { background: var(--gold-d); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--gold-l); }

/* Search layout: filters panel + results */
.search-hero { position: relative; margin-bottom: 1rem; }
.search-hero form.main-q { display: flex; gap: .5rem; flex-wrap: wrap; }
.search-hero .q-box { flex: 1 1 18rem; position: relative; }
.search-hero .q-box input { width: 100%; min-height: 50px; font-size: 1.05rem; padding-inline-start: 2.8rem; border-radius: 12px; }
.search-hero .q-box > .ic { position: absolute; inset-inline-start: 1rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-hero button { min-height: 50px; padding-inline: 1.6rem; border-radius: 12px; }
.search-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.filter-panel { position: sticky; top: calc(var(--header-h) + 1rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 1rem; box-shadow: var(--shadow-1); }
.filter-panel > summary { list-style: none; cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel .fp-body { display: grid; gap: .9rem; margin-top: .9rem; }
.filter-panel label { display: grid; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.filter-panel select, .filter-panel input { width: 100%; }
.filter-panel .years { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.toolbar .count { color: var(--muted); font-size: .92rem; }
.toolbar .count strong { color: var(--ink); }
.toolbar .tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.toolbar select { min-height: 36px; padding-block: .2rem; font-size: .9rem; }
.chips-active { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.chip-x { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .5rem .15rem .7rem; border-radius: 999px; background: var(--gold-bg); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); color: var(--ink); font-size: .84rem; text-decoration: none; }
.chip-x .ic { width: .95em; height: .95em; }
.chip-x:hover { border-color: var(--gold-d); }
.chip-clear { font-size: .84rem; padding: .15rem .4rem; }

/* ---------- Content blocks ---------- */
.hero { padding: clamp(1.4rem, 4vw, 3rem) clamp(1rem, 3vw, 2.5rem); margin: 0 0 1.5rem; border-radius: var(--r-l); position: relative; overflow: hidden;
  background: radial-gradient(1200px 300px at 100% 0%, color-mix(in srgb, var(--gold-l) 22%, transparent), transparent),
              linear-gradient(135deg, var(--surface), var(--surface-2)); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.hero h1 { font-size: var(--fs-4); margin-bottom: .3em; max-width: 22ch; }
.lead { color: var(--ink-2); font-size: var(--fs-1); max-width: 46rem; margin-top: 0; }
.search-big { display: flex; align-items: stretch; margin: 1.4rem 0 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .35rem; box-shadow: var(--shadow-2); max-width: 46rem; position: relative; }
.search-big:focus-within { border-color: var(--gold); }
.search-big > .ic { align-self: center; margin-inline: .7rem .2rem; color: var(--muted); width: 1.4rem; height: 1.4rem; }
.search-big input { flex: 1; border: 0 !important; box-shadow: none !important; background: transparent !important; font-size: var(--fs-1); padding: .5rem .4rem !important; min-width: 0; }
.search-big button { border-radius: 10px; padding-inline: 1.6rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin: 0 0 .6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 1rem 1.1rem; display: flex; gap: .8rem; align-items: center; box-shadow: var(--shadow-1); text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--gold); }
.stat .ic { width: 2.4rem; height: 2.4rem; padding: .5rem; border-radius: 10px; background: var(--gold-bg); color: var(--gold-d); }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin: 1rem 0 .4rem; }
.ledger > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: .9rem 1.1rem; box-shadow: var(--shadow-1); }
.ledger dt { color: var(--muted); font-size: .85rem; }
.ledger dd { margin: 0; font-size: 1.8rem; font-weight: 800; color: var(--gold-d); line-height: 1.2; font-variant-numeric: tabular-nums; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .8rem; margin: 1rem 0 0; }
.quick a { display: flex; gap: .8rem; align-items: flex-start; padding: 1rem; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-1); transition: transform .15s, border-color .15s; }
.quick a:hover { border-color: var(--gold); transform: translateY(-2px); }
.quick .ic { width: 2.2rem; height: 2.2rem; padding: .45rem; border-radius: 10px; background: var(--gold-bg); color: var(--gold-d); }
.quick strong { display: block; }
.quick span { color: var(--muted); font-size: .85rem; line-height: 1.5; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.section-head h2 { margin: 0 0 .6rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; padding: 0; margin: .6rem 0; }
.chips a { text-decoration: none; color: var(--ink-2); border: 1px solid var(--line); background: var(--surface); padding: .15rem .8rem; border-radius: 999px; font-size: .87rem; }
.chips a:hover { border-color: var(--gold); color: var(--ink); background: var(--gold-bg); }
.chips a.computed { border-style: dashed; }
.chips small { color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; font-weight: 700; padding: .05rem .55rem; border-radius: 6px; background: var(--gold-bg); color: var(--gold-d); }
.tag.t-thesis { background: #e9f0f8; color: #2f5379; }
.tag.t-project { background: #e9f4ec; color: #35654a; }
.tag.lock { background: var(--err-bg); color: var(--err); }
:root[data-theme="dark"] .tag.t-thesis { background: #1d2a3a; color: #9cc0e6; }
:root[data-theme="dark"] .tag.t-project { background: #1a2b22; color: #9fd1b2; }

/* Result cards */
.results { display: grid; gap: .8rem; }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 1rem 1.15rem; box-shadow: var(--shadow-1); transition: border-color .15s, box-shadow .15s; }
.doc:hover { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); box-shadow: var(--shadow-2); }
.doc h3 { font-size: 1.08rem; margin: .35rem 0 .2rem; line-height: 1.5; }
.doc h3 a { color: var(--ink); text-decoration: none; }
.doc h3 a:hover { color: var(--gold-d); text-decoration: underline; }
.doc-meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; align-items: center; color: var(--muted); font-size: .84rem; margin: 0; }
.doc-meta .ic { width: 1em; height: 1em; }
.authors { margin: .15rem 0; font-size: .9rem; color: var(--ink-2); }
.snippet { margin: .35rem 0 0; color: var(--ink-2); font-size: .93rem; line-height: 1.7; }
.why { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .78rem; color: var(--muted); margin: .5rem 0 0; }
.why span { display: inline-flex; gap: .3rem; align-items: center; }

/* Document page */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.6rem; align-items: start; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: clamp(1.1rem, 3vw, 2rem); box-shadow: var(--shadow-1); }
.doc-title { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); margin: .4rem 0 .6rem; line-height: 1.45; }
.prose { max-width: 70ch; line-height: 1.95; }
.meta-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 1.1rem; box-shadow: var(--shadow-1); position: sticky; top: calc(var(--header-h) + 1rem); }
.meta-card dl { margin: 0; display: grid; gap: .7rem; }
.meta-card dt { font-size: .78rem; color: var(--muted); font-weight: 700; }
.meta-card dd { margin: 0; font-size: .93rem; }
.meta-card .actions { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin: 1rem 0 0; }
.meta-card .actions .btn { width: 100%; }
.cite-box { margin-top: 1rem; }
.cite-box pre { white-space: pre-wrap; font-size: .82rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .7rem; margin: .4rem 0; direction: ltr; text-align: left; font-family: ui-monospace, Consolas, monospace; }

/* Researchers */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.person { display: flex; gap: .85rem; align-items: flex-start; padding: 1rem; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-1); transition: border-color .15s, transform .15s; }
.person:hover { border-color: var(--gold); transform: translateY(-2px); }
.avatar { width: 48px; height: 48px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: var(--gold-d); background: var(--gold-bg); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); font-size: 1.05rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; }
.person .p-body { display: grid; gap: .1rem; min-width: 0; }
.person strong { font-size: 1rem; line-height: 1.45; }
.person span { font-size: .84rem; color: var(--muted); }
.person .count { color: var(--gold-d); font-weight: 700; }
.profile { display: flex; gap: 1.2rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: clamp(1rem, 3vw, 1.6rem); box-shadow: var(--shadow-1); flex-wrap: wrap; }
.profile h1 { margin: 0; font-size: var(--fs-2); }
.profile .p-info { flex: 1; min-width: 14rem; }
.pager { display: flex; gap: .4rem; justify-content: center; align-items: center; margin: 1.6rem 0; flex-wrap: wrap; }
.pager a, .pager span { min-width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0 .7rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink-2); font-size: .9rem; }
.pager a:hover { border-color: var(--gold); }
.pager .cur { background: var(--gold-d); border-color: var(--gold-d); color: #fff; font-weight: 700; }
.pager .gap { border: 0; background: none; }

/* Layout helpers */
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.8rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
.grid3 > section, .two > section, .two > aside, .two > div { min-width: 0; }
.panel, .grid3 > section, .coverage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 1.1rem 1.3rem; margin: 1.2rem 0; box-shadow: var(--shadow-1); }
.grid3 > section { margin: 0; }
.panel h2, .grid3 > section h2, .coverage h2 { margin-top: 0; font-size: var(--fs-1); }

/* Feedback */
.flash, .notice { padding: .75rem 1rem; border-radius: var(--r-m); margin: 0 0 1rem; border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; }
.flash { border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-bg); }
.flash.error { border-color: color-mix(in srgb, var(--err) 35%, transparent); background: var(--err-bg); }
.notice { border-color: color-mix(in srgb, var(--gold) 40%, transparent); background: var(--info-bg); font-size: .93rem; }
.toasts { position: fixed; inset-inline-end: 1rem; bottom: 1rem; z-index: 80; display: grid; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toasts .flash { margin: 0; box-shadow: var(--shadow-2); background: var(--surface); animation: toast-in .25s ease-out; }
.toasts .flash.ok { border-inline-start: 4px solid var(--ok); }
.toasts .flash.error { border-inline-start: 4px solid var(--err); }
.toasts .flash button { margin-inline-start: auto; background: none; border: 0; color: var(--muted); min-height: 0; padding: 0; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-m); }
.ok-line { color: var(--ok); font-weight: 700; }
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page .code { font-size: 5rem; font-weight: 800; color: var(--gold); margin: 0; line-height: 1; }
.results-h small { color: var(--muted); font-weight: 400; font-size: .85rem; }

/* Recommendations */
.recs { list-style: none; padding: 0; margin: 0; counter-reset: rec; display: grid; gap: .6rem; }
.recs > li { padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); counter-increment: rec; }
.rec-head { display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: baseline; }
.rec-head::before { content: counter(rec); width: 1.6rem; height: 1.6rem; border-radius: 50%; display: inline-grid; place-items: center; background: var(--gold-bg); color: var(--gold-d); font-weight: 800; font-size: .85rem; }
.rec-head a { font-weight: 700; }
.score { margin-inline-start: auto; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--surface-2); border: 1px solid var(--line); padding: 0 .5rem; border-radius: 6px; }
.reasons { margin: .4rem 0 0; padding-inline-start: 1.2rem; font-size: .9rem; color: var(--ink-2); }

/* Bars */
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; }
.bars li { display: grid; grid-template-columns: minmax(6rem, 11rem) 1fr 2.5rem; gap: .7rem; align-items: center; font-size: .88rem; }
.bars .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .n { text-align: end; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 700; }
progress { appearance: none; -webkit-appearance: none; width: 100%; height: .6rem; border: 0; background: var(--line-2); border-radius: 99px; overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line-2); border-radius: 99px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--gold-d), var(--gold-l)); border-radius: 99px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--gold-d), var(--gold-l)); border-radius: 99px; }

/* Tables */
.scroll { overflow-x: auto; border-radius: var(--r-m); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; margin: .6rem 0 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
th, td { padding: .6rem .8rem; border-bottom: 1px solid var(--line-2); text-align: start; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 700; font-size: .8rem; background: var(--surface-2); }
tbody tr:hover td { background: color-mix(in srgb, var(--gold-bg) 55%, transparent); }
tr.is-selected td { background: var(--gold-bg); }
table.dense { font-size: .8rem; }
td.err { color: var(--err); max-width: 22rem; }
tr.st-failed td { background: var(--err-bg); }
tr.st-partial td { background: var(--info-bg); }
td.row-actions { white-space: nowrap; }
.row-actions { display: flex; gap: .4rem; align-items: center; }
.col-check { width: 2.5rem; text-align: center; }
.bulkbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem .8rem; background: var(--gold-bg); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); border-radius: var(--r-m); margin: .5rem 0; position: sticky; top: calc(var(--header-h) + .5rem); z-index: 5; }
.bulkbar[hidden] { display: none; }
.bulkbar select { min-height: 36px; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem 1rem; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { border-color: var(--gold); color: var(--ink); font-weight: 700; }
.judge-row { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line-2); }
.sources li { margin-bottom: .35rem; }
.answer { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--gold); padding: 1.1rem 1.3rem; border-radius: var(--r-m); box-shadow: var(--shadow-1); }
details.collapse { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); margin: 1rem 0; box-shadow: var(--shadow-1); }
details.collapse > summary { cursor: pointer; padding: 1rem 1.2rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; list-style: none; }
details.collapse > summary::-webkit-details-marker { display: none; }
details.collapse[open] > summary { border-bottom: 1px solid var(--line-2); }
details.collapse > .card-form { border: 0; box-shadow: none; margin: 0; max-width: none; }

/* Knowledge graph */
.graph-wrap { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); height: min(72vh, 680px); box-shadow: var(--shadow-1); overflow: hidden; }
#kg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.kg-info { position: absolute; inset-block-end: .8rem; inset-inline-start: .8rem; background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .8rem; font-size: .88rem; max-width: 22rem; }
.kg-info:empty { display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; list-style: none; padding: 0; font-size: .85rem; color: var(--ink-2); }
.dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; margin-inline-end: .35rem; vertical-align: middle; }
.n-researcher { background: #9b7626; } .n-document { background: #3d5a80; } .n-keyword { background: #e6c36a; } .n-specialty { background: #7a8b6f; } .n-school { background: #1f2633; }

.to-top { position: fixed; inset-inline-start: 1rem; bottom: 1rem; z-index: 30; width: 44px; height: 44px; border-radius: 50%; padding: 0; min-height: 0; box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity .2s; }
.to-top.show { opacity: 1; pointer-events: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .search-layout { grid-template-columns: 1fr; }
  .filter-panel { position: static; }
  .doc-layout { grid-template-columns: 1fr; }
  .meta-card { position: static; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  :root { --header-h: 58px; }
  .shell { grid-template-columns: 1fr; }
  .menu-btn { display: inline-grid; }
  .sidenav { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 70; width: min(84vw, 300px); height: 100vh; height: 100dvh; background: var(--surface);
    box-shadow: var(--shadow-2); transform: translateX(110%); transition: transform .25s ease; padding-top: .5rem; }
  [dir="ltr"] .sidenav { transform: translateX(-110%); }
  body.nav-open .sidenav { transform: none; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: .4rem .5rem .8rem .8rem; border-bottom: 1px solid var(--line-2); margin-bottom: .5rem; font-weight: 700; }
  .overlay { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(10,12,18,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .overlay { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .brand small { display: none; }
  .top-search { display: none; }
  .top-search.open { display: block; position: absolute; inset-inline: .6rem; top: calc(var(--header-h) + .4rem); max-width: none; }
  .search-toggle { display: inline-grid; }
  .two, .grid3 { grid-template-columns: 1fr; }
  .card-form.wide { grid-template-columns: 1fr; }
  .top-actions .txt-link span { display: none; }
}
@media (min-width: 901px) { .search-toggle { display: none; } }
@media (max-width: 640px) {
  .brand strong { font-size: .95rem; }
  main { padding-inline: .8rem; }
  .hero { border-radius: var(--r-m); }
  .search-big { flex-wrap: wrap; }
  .search-big button { width: 100%; }
  .filters { padding: .7rem; }
  .filters .year, .filters select { flex: 1 1 45%; min-width: 0; }
  .seg { width: 100%; }
  .seg label { flex: 1; text-align: center; }
  /* tables become stacked cards */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack { border: 0; background: none; }
  table.stack tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); margin-bottom: .6rem; padding: .4rem .2rem; }
  table.stack td { border: 0; padding: .3rem .8rem; display: flex; gap: .8rem; justify-content: space-between; align-items: center; text-align: end; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 700; text-align: start; }
  table.stack td.col-check { justify-content: flex-start; }
  table.stack td.col-check::before { content: none; }
  .bars li { grid-template-columns: minmax(5rem, 8rem) 1fr 2rem; }
  .meta-card .actions { grid-template-columns: 1fr 1fr; }
  .toolbar { align-items: stretch; }
  .toolbar .tools { width: 100%; }
  .toolbar .tools > * { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print {
  .topbar, .sidenav, .foot, .meta-card .actions, .actions, .to-top, .toasts, .filters, .filter-panel, .pager, .overlay { display: none !important; }
  .shell, .doc-layout { display: block; }
  body { background: #fff; color: #000; }
  .detail, .meta-card, .doc { box-shadow: none; border: 0; padding: 0; }
  a { color: #000; text-decoration: none; }
}
