/* Guardian Library — dark-first research desk.
   Light is still supported for anyone whose OS explicitly asks for it, but
   dark is the design the palette was built around. */

:root {
  /* base */
  --bg:        #0b0e14;
  --bg-soft:   #0f131b;
  --panel:     #141924;
  --panel-2:   #1a2130;
  --line:      #232c3d;
  --line-soft: #1b2231;

  /* text */
  --ink:       #e8edf6;
  --ink-dim:   #b9c2d4;
  --muted:     #7d8798;

  /* brand: warm gold against cool navy */
  --gold:      #d8ab5f;
  --gold-dim:  #a37f42;
  --gold-soft: rgba(216, 171, 95, 0.12);

  /* interactive */
  --accent:      #6fa8ff;
  --accent-soft: rgba(111, 168, 255, 0.13);

  --warn:      #ff8a7a;
  --warn-soft: rgba(255, 138, 122, 0.12);
  --ok:        #5fd68a;
  --ok-soft:   rgba(95, 214, 138, 0.12);

  color-scheme: dark;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
}

/* Dark is the design. Light survives only for anyone who explicitly asks
   for it by setting data-theme="light" on <html>; the OS setting does not
   flip it, because the request was for a dark library. */
:root[data-theme="light"] {
    --bg: #f7f8fa;  --bg-soft: #f0f2f6;  --panel: #ffffff;  --panel-2: #f7f8fa;
    --line: #e3e7ee; --line-soft: #edf0f5;
    --ink: #131722; --ink-dim: #394152; --muted: #667085;
    --gold: #8a6524; --gold-dim: #a98a4d;
    --gold-soft: rgba(154, 116, 40, 0.10);
    --accent: #2563eb; --accent-soft: rgba(37, 99, 235, 0.09);
    --warn: #b42318; --warn-soft: rgba(180, 35, 24, .08);
    --ok: #027a48;   --ok-soft: rgba(2, 122, 72, .08);
    --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -16px rgba(16,24,40,.2);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 500px at 12% -8%, rgba(216,171,95,.055), transparent 60%),
    radial-gradient(900px 500px at 92% -4%, rgba(111,168,255,.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.6 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 22px; }


/* ---------------------------------------------------------------- masthead
   The house format: logo tile, THE, the wordmark in a high-contrast serif,
   tagline underneath. Sits above the nav rather than inside it, so the
   identity reads at a glance and the nav stays a working strip. */
.masthead {
  padding: 30px 22px 22px;
  text-align: center;
  border-bottom: 1px solid var(--line-soft);
  background:
    radial-gradient(620px 200px at 50% -40%, rgba(216,171,95,.10), transparent 70%);
}
.mh-inner {
  display: inline-flex; align-items: center; gap: 20px;
  color: inherit; text-decoration: none;
}
.mh-inner:hover { text-decoration: none; }

.mh-logo {
  width: 86px; height: 86px; flex-shrink: 0;
  border-radius: 16px; overflow: hidden;
  /* Near-black behind the gold, the way the tile reads on the Brief. */
  background: radial-gradient(circle at 50% 40%, #14100a 0%, #0a0a0a 70%);
  display: grid; place-items: center;
  box-shadow: 0 0 0 1px rgba(216,171,95,.30), 0 8px 26px -12px rgba(0,0,0,.9);
}
.mh-logo img {
  width: 100%; height: 100%; object-fit: contain;
  padding: 7px; display: block;
}
.mh-fallback {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  line-height: 1; text-align: center;
}
.mh-fb-name {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 15px; font-weight: 600; color: var(--gold);
}
.mh-fb-sub {
  font-size: 7px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold-dim); font-weight: 600;
}
@media (max-width: 620px) {
  .mh-fb-name { font-size: 11px; }
  .mh-fb-sub { font-size: 5.5px; letter-spacing: .16em; }
}

.mh-words { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.mh-the {
  font-size: 12px; font-weight: 700; letter-spacing: .42em;
  text-transform: uppercase; color: var(--gold);
  padding-left: 3px;
}
.mh-name {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 46px; font-weight: 800; line-height: 1.02;
  letter-spacing: -0.6px; color: var(--ink);
  white-space: nowrap;
}
.mh-tagline {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic; font-weight: 500;
  font-size: 15px; color: var(--muted);
  margin: 14px 0 0;
}

@media (max-width: 620px) {
  .masthead { padding: 22px 16px 16px; }
  .mh-inner { gap: 14px; }
  .mh-logo { width: 60px; height: 60px; border-radius: 12px; }
  .mh-name { font-size: 29px; white-space: normal; text-align: left; }
  .mh-the { font-size: 10px; letter-spacing: .34em; }
  .mh-tagline { font-size: 13.5px; margin-top: 10px; }
}

/* The nav is no longer the top element, so it stops carrying the brand. */
.topbar { top: 0; }
.topbar .wrap { justify-content: center; }
@media (min-width: 861px) { .topbar .wrap { justify-content: flex-start; } }

/* ---------------------------------------------------------------- topbar */
.topbar {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar .wrap { display: flex; align-items: center; gap: 20px; height: 62px; }

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 640; letter-spacing: -0.3px; color: var(--ink); font-size: 16.5px;
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--gold), var(--gold-dim));
  display: grid; place-items: center;
  color: #1a1206; font-weight: 800; font-size: 13px;
  box-shadow: 0 2px 8px -2px rgba(216,171,95,.5);
}

.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.topbar nav a {
  color: var(--muted); padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { background: var(--panel); color: var(--ink-dim); text-decoration: none; }
.topbar nav a.on {
  background: var(--gold-soft); color: var(--gold); font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(216,171,95,.22);
}
.spacer { flex: 1; }
.runstamp { font-size: 12px; color: var(--muted); }
.quiet { color: var(--muted); font-size: 13px; }
.warn { color: var(--warn); }

main { padding: 26px 22px 80px; }

/* ---------------------------------------------------------------- flash */
.flash {
  padding: 11px 15px; border-radius: var(--radius); margin-bottom: 16px;
  border: 1px solid var(--line); background: var(--panel); font-size: 14px;
}
.flash.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: var(--ok-soft); }
.flash.error { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-soft); }

/* ---------------------------------------------------------------- headings */
.shelfhead {
  font-size: 22px; font-weight: 640; margin: 4px 0 16px;
  letter-spacing: -0.4px;
}
.shelfhead .quiet { font-weight: 400; font-size: 14px; }

/* ---------------------------------------------------------------- filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
select, input[type=text], input[type=password], input[type=url], textarea {
  background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 11px; font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=text], input[type=url] { min-width: 210px; }
textarea { width: 100%; font-family: inherit; line-height: 1.55; resize: vertical; }

.btn {
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #1a1206; border: 0; border-radius: var(--radius-sm);
  padding: 8px 15px; font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost {
  background: var(--panel-2); color: var(--ink-dim);
  border: 1px solid var(--line); font-weight: 500;
}
.btn.ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn.danger { background: transparent; color: var(--warn); border: 1px solid var(--line); font-weight: 500; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 13px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel-2);
  transition: all .15s;
}
.chip:hover { text-decoration: none; color: var(--ink-dim); border-color: var(--muted); }
.chip.on {
  background: var(--accent-soft); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

/* ---------------------------------------------------------------- cards */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.card:hover {
  border-color: color-mix(in srgb, var(--gold) 34%, var(--line));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card.unseen { box-shadow: inset 3px 0 0 var(--gold); }
.card .thumb { display: block; aspect-ratio: 16/9; background: var(--bg-soft); overflow: hidden; }
.card .thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .35s ease;
}
.card:hover .thumb img { transform: scale(1.035); }
.card .body { padding: 13px 15px 14px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card h3 { margin: 0; font-size: 15px; line-height: 1.45; font-weight: 590; letter-spacing: -0.1px; }
.card h3 a { color: var(--ink); }
.card h3 a:hover { color: var(--gold); text-decoration: none; }
.card .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.card .sum { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.card .foot {
  margin-top: auto; display: flex; gap: 7px; align-items: center;
  padding-top: 8px; flex-wrap: wrap; border-top: 1px solid var(--line-soft);
}

.tag {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  padding: 3px 8px; border-radius: 5px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--muted); font-weight: 650;
}
.tag.video { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.tag.document { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.tag.promo { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.tag.also { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, transparent); cursor: help; }
.tag.podcast { color: #b58bff; border-color: rgba(181,139,255,.4); }

.fundname { font-weight: 600; color: var(--ink-dim); font-size: 12.5px; }

.star {
  cursor: pointer; background: none; border: 0; font-size: 16px;
  color: var(--muted); padding: 0 2px; transition: color .15s, transform .1s;
}
.star:hover { transform: scale(1.15); }
.star.on { color: var(--gold); }

/* ---------------------------------------------------------------- insights */
.ins-toggle {
  background: none; border: 0; color: var(--muted); font: inherit;
  font-size: 12.5px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 6px;
}
.ins-toggle:hover { background: var(--panel-2); color: var(--ink-dim); }
.ins-toggle .count {
  background: var(--gold-soft); color: var(--gold); font-weight: 700;
  border-radius: 999px; padding: 1px 7px; font-size: 11px;
}

.insights {
  /* a flex child of .foot: full width so it wraps onto its own line */
  width: 100%; flex-basis: 100%;
  border-top: 1px solid var(--line-soft); margin-top: 10px; padding-top: 11px;
}
.insight {
  padding: 9px 11px; border-radius: var(--radius-sm); background: var(--bg-soft);
  border-left: 2px solid var(--gold-dim); margin-bottom: 8px;
}
.insight .who {
  font-size: 12px; font-weight: 650; color: var(--gold);
  display: flex; align-items: center; gap: 7px;
}
.insight .who .at { color: var(--muted); font-weight: 400; }
.insight p {
  margin: 4px 0 0; font-size: 13.5px; line-height: 1.55;
  color: var(--ink-dim); white-space: pre-wrap;
}
.insight .kill {
  margin-left: auto; background: none; border: 0; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px;
}
.insight .kill:hover { color: var(--warn); }

.ins-form { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.ins-form textarea { font-size: 13.5px; min-height: 62px; }
.ins-form .row { display: flex; gap: 7px; align-items: center; }
.ins-form input[type=text] { min-width: 0; flex: 0 0 155px; font-size: 13px; padding: 6px 10px; }
.ins-empty { font-size: 13px; color: var(--muted); margin: 0 0 6px; }

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 19px 21px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 4px; font-size: 16.5px; font-weight: 620; letter-spacing: -0.2px; }
.panel .hint { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }

.nlpanel { margin-bottom: 20px; }
.nlpanel .row {
  display: flex; gap: 13px; align-items: baseline; padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.nlpanel .row:last-child { border-bottom: 0; }
.nlpanel .per { font-size: 12px; color: var(--muted); min-width: 64px; font-variant-numeric: tabular-nums; }
.nlpanel .who { font-size: 12.5px; font-weight: 600; min-width: 140px; color: var(--ink-dim); }
.nlpanel .what { font-size: 13.5px; flex: 1; }

/* ---------------------------------------------------------------- analysis */
.alist { display: flex; flex-direction: column; gap: 16px; }
.acard {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
}
.acard .head { display: flex; gap: 15px; align-items: flex-start; }
.acard .head img { width: 140px; border-radius: var(--radius-sm); flex-shrink: 0; }
.acard h3 { margin: 0 0 4px; font-size: 16px; line-height: 1.45; }
.acard .headline { font-size: 15px; font-weight: 640; color: var(--gold); margin: 13px 0 8px; }
.acard p.summary { margin: 0 0 12px; font-size: 14.5px; color: var(--ink-dim); }
.acard h4 {
  margin: 15px 0 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .7px; color: var(--muted); font-weight: 700;
}
.acard ul { margin: 0; padding-left: 20px; font-size: 14px; color: var(--ink-dim); }
.acard li { margin-bottom: 5px; }
.acard .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 720px) {
  .acard .cols { grid-template-columns: 1fr; }
  .acard .head img { display: none; }
}
.numbers { display: flex; flex-wrap: wrap; gap: 6px; }
.numbers span {
  font-size: 12.5px; padding: 4px 10px; border-radius: 6px;
  background: var(--bg-soft); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums; color: var(--ink-dim);
}

.nlsum {
  margin: 9px 0 2px; padding: 11px 13px; border-left: 2px solid var(--gold-dim);
  background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.nlsum .headline { font-weight: 640; color: var(--gold); margin-bottom: 5px; }
.nlsum p { margin: 0 0 6px; font-size: 13.5px; color: var(--ink-dim); }
.nlsum ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-dim); }
.nlsum li { margin-bottom: 3px; }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 700; border-bottom-color: var(--line);
}
td.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all; }

.formrow { display: flex; gap: 11px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 11px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }

.empty { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); font-size: 19px; margin: 0 0 8px; font-weight: 620; }

.pager { display: flex; gap: 10px; justify-content: center; margin-top: 26px; }
.disabled { opacity: .35; pointer-events: none; }

code {
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 5px; font-size: 12.5px;
  font-family: ui-monospace, Consolas, monospace;
}

/* ---------------------------------------------------------------- player */
.player {
  background: #000; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.player video { width: 100%; max-height: 72vh; display: block; background: #000; }
.watch-title {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 27px; font-weight: 700; letter-spacing: -0.3px;
  margin: 0 0 8px; line-height: 1.25;
}
@media (max-width: 620px) { .watch-title { font-size: 21px; } }

/* An in-house video has no YouTube thumbnail, so the card gets a branded
   tile rather than an empty grey box. */
.thumb.local {
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, #16110a 0%, #0a0a0a 72%);
}
.thumb.local img { width: 46%; height: auto; object-fit: contain; opacity: .92; }
.thumb.local .play {
  position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(216,171,95,.92); display: grid; place-items: center;
  color: #1a1206; font-size: 17px; padding-left: 3px;
}
.card .thumb { position: relative; }

.tag.uploaded {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  background: var(--gold-soft);
}

/* ---------------------------------------------------------------- sortbar
   Sorting and filtering the shelf. Works in the browser, so it is on the
   published copy too. */
.sortbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 15px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.sortbar label { display: flex; flex-direction: column; gap: 4px; }
.sb-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 700;
}
.sortbar select { min-width: 150px; }
.sortbar input[type=search] {
  background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 11px; font: inherit;
  font-size: 14px; min-width: 190px;
}
.sortbar input[type=search]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#sb-count { white-space: nowrap; }

@media (max-width: 620px) {
  .sortbar { gap: 9px; padding: 11px 12px; }
  /* flex-basis, not width: these are flex items, so width alone leaves them
     sharing a row and each ends up too narrow to read on a phone. */
  .sortbar label { flex: 1 1 100%; }
  .sortbar input[type=search] { flex: 1 1 100%; min-width: 0; }
  .sortbar select { width: 100%; min-width: 0; }
  .sortbar .spacer { display: none; }
  #sb-count { flex: 1 1 auto; }
}
