/*
 * SolxLab public site theme: an editorial, journal-style look.
 * Loaded after the built stylesheet (index-*.css) and scoped to pages without the owner panel;
 * the panel uses admin-theme.css instead.
 *
 * Type:   Source Serif 4 for headings, titles and reading text; Source Sans 3 for the interface.
 * Colour: paper canvas, navy ink, hairline rules. Amber only marks the current section, link
 *         underlines and focus rings. Post types are told apart by a small coloured square, not a fill.
 * Layout: a two-tier masthead (logo, then the section links between rules), left-aligned headings,
 *         ruled lists, a sidebar on the home page, a light footer in four columns.
 * The add-on scripts (feed.js, sections.js, search.js, cite.js, buy.js, related.js, share.js, newsletter.js,
 * legal-links.js, masthead.js) find their places by the class names used here, so keep those names.
 */

body:not(:has(.admin)) {
  --navy: #13213A;
  --solar: #F2A007;
  --solar-ink: #8A5A00;
  --cream: #FFF4DC;
  --canvas: #FCFBF8;
  --card: #FFFFFF;
  --line: #E4E1DA;
  --line-strong: #CFCAC0;
  --ink: #13213A;
  --body: #26324A;
  --ink-muted: #6B7386;
  --wash: #F4F2EC;
  --t-model: #2F5BA8;
  --t-paper: #2A7048;
  --t-file: #5D4AA8;
  --t-job: #A8571C;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Source Sans Pro", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --display: var(--serif);

  /* re-point the built theme's tokens */
  --accent: var(--navy);
  --accent-ink: #0B1526;
  --text: var(--ink);
  --muted: var(--ink-muted);
  --border: var(--line);
  --surface: var(--card);
  --surface-2: var(--wash);
  --radius: 4px;
  --maxw: 1120px;
  --font: var(--sans);

  background: var(--canvas);
  color: var(--body);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}
html:has(body:not(:has(.admin))) { overflow-x: clip; background: #FCFBF8; }

body:not(:has(.admin)) {

  /* ---- type ----------------------------------------------------------- */
  h1, h2, h3, .post-title { font-family: var(--serif); color: var(--ink); text-wrap: balance; }
  h1 { font-weight: 600; letter-spacing: -.012em; }
  h2 { font-weight: 600; letter-spacing: -.005em; }
  a { color: var(--ink); }
  ::selection { background: rgba(242, 160, 7, .28); }
  :focus-visible { outline: 2px solid var(--solar); outline-offset: 2px; }
  .muted { color: var(--ink-muted); }

  /* the small capitals used for labels throughout */
  .kv-key, .sf-group legend, .contact-side h2, .fx-side h2, .fx-l, .detail-head .badge,
  .post-head .badge, .related .badge, .contact-form label > span:first-child {
    font-family: var(--sans); font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  }

  main.container { padding-top: 0; padding-bottom: 72px; }
  .container { max-width: var(--maxw); }

  /* ---- masthead -------------------------------------------------------
   * Row 1: logo, and Contact (or the owner's panel buttons) on the right.
   * Row 2: the section links between a navy rule and a hairline, with the date at the right (masthead.js). */
  .nav { position: static; background: var(--canvas); border-bottom: 0; }
  .nav-inner {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto;
    height: auto; padding: 22px 20px 0; row-gap: 18px; column-gap: 16px; align-items: center;
  }
  .brand { grid-column: 1; grid-row: 1; justify-self: start; display: inline-flex; align-items: center; line-height: 0; }
  .brand-logo { height: 32px; width: auto; display: block; }
  .nav-actions { grid-column: 2; grid-row: 1; }
  .nav-links {
    grid-column: 1 / -1; grid-row: 2; order: 0; width: auto; justify-self: stretch; justify-content: flex-start;
    display: flex; flex-wrap: nowrap; gap: 0 28px; padding: 0;
    border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line-strong);
  }
  .nav-link {
    position: relative; display: inline-block; padding: 10px 0 9px; border-radius: 0; background: none;
    font-size: .93rem; font-weight: 600; color: var(--ink-muted); letter-spacing: .01em;
  }
  .nav-link:hover { color: var(--ink); background: none; text-decoration: none; }
  .nav .nav-link.active { color: var(--ink); background: none; }
  .nav .nav-link.active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--solar);
  }
  /* Contact sits on the right of the logo row unless the owner's buttons are there */
  .nav-inner:not(:has(.nav-actions > *)) .nav-link[href="/contact"] {
    position: absolute; right: 20px; top: 22px; height: 32px; display: inline-flex; align-items: center;
    padding: 0; font-weight: 600; color: var(--ink);
    text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 5px;
  }
  .nav-inner:not(:has(.nav-actions > *)) .nav-link[href="/contact"]:hover { text-decoration-color: var(--solar); }
  .nav .nav-inner:not(:has(.nav-actions > *)) .nav-link[href="/contact"].active { text-decoration-color: var(--solar); text-decoration-thickness: 2px; }
  .nav .nav-inner:not(:has(.nav-actions > *)) .nav-link[href="/contact"].active::after { display: none; }
  .nav-date {
    grid-column: 2; grid-row: 2; justify-self: end; align-self: center; padding-top: 2px; pointer-events: none;
    font-size: .82rem; color: var(--ink-muted); white-space: nowrap; font-variant-numeric: tabular-nums;
  }
  .nav-actions .btn { height: 32px; }

  /* ---- buttons -------------------------------------------------------- */
  .btn {
    border-radius: 3px; font-family: var(--sans); font-weight: 600; font-size: .9rem;
    border-color: var(--line-strong); background: var(--card); color: var(--ink);
  }
  .btn:hover { background: var(--wash); border-color: var(--ink-muted); }
  .btn-primary { background: var(--navy); border-color: var(--navy); color: #FFFFFF; }
  .btn-primary:hover { background: #0B1526; border-color: #0B1526; }
  .btn-ghost { background: transparent; }
  .btn-sm { font-size: .82rem; padding: 5px 10px; }

  /* ---- page headings -------------------------------------------------- */
  .page-hero { position: relative; text-align: left; padding: 40px 0 24px; margin: 0; }
  .page-hero h1 { font-size: clamp(2rem, 4vw, 2.75rem); line-height: 1.1; max-width: 26ch; margin: 0 0 10px; }
  .page-hero p { font-family: var(--serif); font-style: italic; font-size: 1.15rem; line-height: 1.5; color: var(--ink-muted); max-width: 62ch; margin: 0; }

  .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }

  /* ---- post type labels: a small coloured square, then the type in small capitals ---- */
  .badge-model, .is-model, .post-card:has(.badge-model) { --type-c: var(--t-model); }
  .badge-paper, .is-paper, .post-card:has(.badge-paper) { --type-c: var(--t-paper); }
  .badge-file,  .is-file,  .post-card:has(.badge-file)  { --type-c: var(--t-file); }
  .badge-job,   .is-job,   .post-card:has(.badge-job)   { --type-c: var(--t-job); }
  .badge {
    display: inline-flex; align-items: center; gap: 7px; padding: 0; border-radius: 0; background: none;
    color: var(--type-c, var(--ink));
  }
  .badge::before { content: ""; width: 7px; height: 7px; flex: none; background: var(--type-c, var(--ink)); }
  .chip { border: 0; background: none; padding: 0; border-radius: 0; color: var(--ink-muted); font-size: .84rem; }
  .chip::before { content: "#"; opacity: .55; }
  .chip-sm { font-size: .8rem; padding: 0; }
  .tag-row { display: flex; flex-wrap: wrap; gap: 2px 14px; }

  /* ---- post lists: ruled rows (home, sections) -------------------------
   * type and date | title, who/where, excerpt, tags | key facts.  feed.js adds .fx-sub, .fx-abs, .fx-detail. */
  .post-list { display: block; margin: 0; border: 0; }
  .post-card {
    position: relative; display: grid; grid-template-columns: 104px minmax(0, 1fr) 176px; column-gap: 24px;
    align-items: start; padding: 20px 0 19px; margin: 0;
    background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none;
  }
  .post-card > * { grid-column: 2; min-width: 0; margin: 0; }
  .post-card > .post-head { display: contents; }
  .post-head .badge { grid-column: 1; grid-row: 1; margin-top: 5px; justify-self: start; }
  .post-head > .muted {
    grid-column: 1; grid-row: 1 / span 2; align-self: start; margin-top: 28px; font-size: .82rem; color: var(--ink-muted);
    white-space: nowrap; font-variant-numeric: tabular-nums;
  }
  .post-card > .post-title {
    grid-row: 1; font-size: 1.24rem; font-weight: 600; line-height: 1.3; letter-spacing: -.004em;
  }
  .post-title a { color: var(--ink); text-decoration: none; }
  .post-title a:hover { text-decoration: underline; text-decoration-color: var(--solar); text-decoration-thickness: 2px; text-underline-offset: 4px; }
  .post-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }   /* whole row clickable */
  .post-title a:focus-visible { outline: none; }
  .post-card:has(.post-title a:focus-visible) { box-shadow: inset 3px 0 0 var(--solar); }
  .post-card > .fx-sub { grid-row: 2; margin-top: 4px; font-size: .92rem; color: var(--body); }
  .post-card > .fx-sub:empty { display: none; }
  .post-card > .fx-abs, .post-card:not(.fx) > .post-body {
    grid-row: 3; margin-top: 6px; font-family: var(--serif); font-size: .98rem; line-height: 1.5; color: var(--ink-muted);
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  }
  .post-card > .tag-row { grid-row: 4; margin-top: 8px; position: relative; }
  .post-card > .fx-detail {
    grid-column: 3; grid-row: 1 / span 4; display: grid; gap: 3px; margin-top: 4px; min-width: 0; text-align: right;
  }
  .fx-k, .fx-v { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
  .fx-k { font-size: .92rem; font-weight: 600; color: var(--ink); }
  .fx-v { font-size: .86rem; color: var(--ink-muted); }
  .fx-k[hidden], .fx-v[hidden], .fx-k:empty, .fx-v:empty { display: none; }
  .fx-l { color: var(--ink-muted); margin-right: 7px; font-size: .64rem; }
  .post-card.fx > .post-body, .post-card.fx > .meta-row, .post-card > .post-foot { display: none; }
  .post-card:not(.fx) > .meta-row {
    grid-column: 3; grid-row: 1 / span 4; margin: 4px 0 0; display: grid; gap: 3px; justify-items: end;
    font-size: .86rem; color: var(--ink-muted); text-align: right;
  }
  .meta-row .meta-deadline { font-weight: 600; color: var(--ink); }
  .meta-row .meta-deadline.is-closed { color: #A3261B; }

  /* pager: text links on a rule */
  .pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .pager .btn { border: 0; background: none; padding: 4px 0; font-size: .92rem; color: var(--ink); }
  .pager .btn:hover:not(:disabled) { background: none; text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 4px; }
  .pager .btn:disabled { opacity: .35; }
  .pager .muted { font-size: .86rem; font-variant-numeric: tabular-nums; }
  /* the count, and "Page [n] of N" under it (feed.js, sections.js) */
  .pg-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .pg-jump { margin: 0; font-size: .86rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
  .pg-jump input {
    height: 26px; margin: 0 2px; padding: 0 4px; text-align: center; font: inherit; color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: 3px; background: var(--card); -moz-appearance: textfield; appearance: textfield;
  }
  .pg-jump input::-webkit-inner-spin-button, .pg-jump input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  .pg-jump input:hover { border-color: var(--ink-muted); }
  .pg-jump input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242, 160, 7, .3); }

  /* ---- post page ------------------------------------------------------
   * One reading column. The details box moves up under the title (flex order; the DOM stays as the app made it). */
  .detail-page { max-width: 720px; margin: 0 auto; padding-top: 36px; display: flex; flex-direction: column; }
  .detail-page > * { order: 30; min-width: 0; }
  .detail-page > .detail-head    { order: 1; }
  .detail-page > h1              { order: 2; }
  .detail-page > .detail-meta    { order: 3; }
  .detail-page > .detail-fields  { order: 4; }
  .detail-page > .buy-box        { order: 5; }
  .detail-page > .detail-body    { order: 6; }
  .detail-page > .source-note    { order: 7; }
  .detail-page > .cite-box       { order: 8; }
  .detail-page > .tag-row        { order: 9; }
  .detail-page > .share-row      { order: 10; }
  .detail-page > .sx-ask         { order: 11; }
  .detail-page > .related        { order: 13; }
  .detail-page > .comments       { order: 14; }

  .detail-head { display: flex; align-items: center; gap: 16px; font-size: .88rem; }
  .detail-head a.muted { color: var(--ink-muted); text-decoration: none; }
  .detail-head a.muted:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
  .detail-head .pp-btn {
    margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
    border: 0; padding: 0; background: none; color: var(--ink-muted); font-weight: 600; font-size: .86rem;
  }
  .detail-head .pp-btn:hover { color: var(--ink); background: none; text-decoration: underline; text-underline-offset: 3px; }
  .detail-head .pp-btn svg { width: 15px; height: 15px; }
  /* "Share" beside Print / PDF (share.js): it takes the push to the right, Print / PDF follows it */
  .detail-head .sh-top { position: relative; margin-left: auto; }
  .detail-head .sh-top + .pp-btn { margin-left: 0; }
  .sh-btn {
    display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 0; background: none; cursor: pointer;
    font: inherit; color: var(--ink-muted); font-weight: 600; font-size: .86rem;
  }
  .sh-btn:hover, .sh-btn[aria-expanded="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
  .sh-menu {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 20; min-width: 200px; padding: 4px 0;
    background: var(--card); border: 1px solid var(--line-strong); border-top: 2px solid var(--ink); border-radius: 0 0 3px 3px;
    box-shadow: 0 8px 22px rgba(19, 33, 58, .1);
  }
  .sh-menu ul { list-style: none; margin: 0; padding: 0; }
  .sh-menu a, .sh-copy {
    display: block; width: 100%; padding: 8px 16px; border: 0; background: none; text-align: left; cursor: pointer;
    font: inherit; font-size: .92rem; font-weight: 600; color: var(--ink); text-decoration: none;
  }
  .sh-menu li + li { border-top: 1px solid var(--line); }
  .sh-menu a:hover, .sh-copy:hover, .sh-menu a:focus-visible, .sh-copy:focus-visible { background: var(--wash); outline-offset: -2px; }
  .sh-said { margin: 0; padding: 6px 16px 8px; font-size: .84rem; color: var(--ink-muted); overflow-wrap: anywhere; }
  .sh-said:empty { display: none; }
  .detail-page h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.12; margin: 14px 0 12px; }
  .detail-meta { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 22px; font-size: .9rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

  /* the record: key facts between rules, like a catalogue entry */
  .detail-fields {
    display: grid; gap: 0; margin: 0 0 28px; padding: 0;
    background: none; border: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line-strong); border-radius: 0;
  }
  .kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 9px 0; border-top: 1px solid var(--line); }
  .kv:first-child { border-top: 0; }
  .kv-key { color: var(--ink-muted); padding-top: 3px; }
  .kv-val { color: var(--ink); overflow-wrap: anywhere; }
  .kv-val a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 3px; }
  .detail-fields > .btn { justify-self: start; margin: 4px 0 14px; padding: 9px 20px; }
  .detail-fields > .btn-primary::after { content: " \2197"; font-weight: 400; }   /* opens another site */

  /* reading text */
  .detail-body, .markdown { font-family: var(--serif); color: var(--body); font-size: 1.12rem; line-height: 1.7; }
  .markdown p { margin: 0 0 1em; }
  .markdown h1, .markdown h2, .markdown h3, .markdown h4 { font-family: var(--serif); color: var(--ink); line-height: 1.25; margin: 1.6em 0 .5em; }
  .markdown h2 { font-size: 1.45rem; }
  .markdown h3 { font-size: 1.2rem; }
  .markdown ul, .markdown ol { padding-left: 1.3em; margin: 0 0 1em; }
  .markdown li { margin: .3em 0; }
  .markdown li::marker { color: var(--ink-muted); }
  .markdown strong { color: var(--ink); font-weight: 600; }
  .markdown a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--solar); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
  .markdown a:hover { text-decoration-thickness: 2.5px; }
  .markdown code, code { font-family: var(--mono); background: var(--wash); color: var(--ink); font-size: .86em; padding: 1px 5px; border-radius: 3px; }
  .markdown blockquote { margin: 0 0 1em; padding: 2px 0 2px 18px; border-left: 2px solid var(--ink); background: none; border-radius: 0; color: var(--body); font-style: italic; }
  .markdown pre { background: var(--navy); color: #E8ECF4; border-radius: 4px; padding: 14px 16px; }
  .markdown pre code { background: none; color: inherit; padding: 0; }
  .markdown img { border-radius: 2px; }
  .markdown hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
  /* the facts table that opens most posts: plain rows, no grid */
  .markdown table { border-collapse: collapse; margin: 4px 0 1.4em; font-family: var(--sans); font-size: .95rem; min-width: min(100%, 420px); }
  .markdown th, .markdown td { border: 0; border-bottom: 1px solid var(--line); padding: 7px 28px 7px 0; text-align: left; vertical-align: top; }
  .markdown tr:first-child > * { border-top: 1px solid var(--line-strong); }
  .markdown th { font-weight: 600; color: var(--ink); white-space: nowrap; }
  .markdown thead th { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
  .markdown td { color: var(--body); }

  .detail-page .source-note { margin: -4px 0 28px; font-family: var(--serif); color: var(--ink-muted); font-size: .98rem; line-height: 1.6; }
  .detail-page > .tag-row { margin: 4px 0 0; }
  .detail-page .sx-ask { margin: 18px 0 0; font-size: .95rem; }
  .detail-page .sx-ask a { font-weight: 600; text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 4px; }

  /* "Cite this" (cite.js) */
  .cite-box { margin: 8px 0 28px; padding: 16px 0 0; background: none; border: 0; border-top: 1px solid var(--line-strong); border-radius: 0; }
  .cite-title { font-family: var(--serif); font-size: 1.15rem; }
  .cite-tabs { border-radius: 3px; background: var(--card); }
  .cite-tab { border-radius: 2px; }
  .cite-tab[aria-selected="true"] { background: var(--navy); color: #FFFFFF; }
  .cite-text { background: var(--card); border-color: var(--line); border-radius: 3px; font-family: var(--serif); font-size: .98rem; }
  .cite-text.cite-code { font-family: var(--mono); }

  /* related posts: ruled rows */
  .related { margin: 44px 0 0; padding-top: 0; border-top: 0; }
  .related h2, .comments > h2 {
    font-size: 1.25rem; margin: 0 0 4px; padding-bottom: 10px; border-bottom: 2px solid var(--ink);
  }
  .related-list { list-style: none; margin: 0; padding: 0; display: block; }
  .related-list li { border-bottom: 1px solid var(--line); }
  .related-list a {
    display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 24px; align-items: baseline;
    padding: 12px 0; color: var(--ink); text-decoration: none; border: 0; border-radius: 0; background: none; height: auto;
  }
  .related-list a:hover { background: none; }
  .related-list a:hover .related-title { text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 4px; }
  .related-title { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; line-height: 1.35; }

  /* sharing (share.js): one ruled line of plain links */
  .share-row {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px;
    margin: 22px 0 0; padding: 11px 0; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); font-size: .92rem;
  }
  .share-l { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
  .share-list { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; margin: 0; padding: 0; }
  .share-list a, .share-b {
    font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none;
  }
  .share-list a:hover, .share-b:hover { text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 3px; }
  .share-said { color: var(--ink-muted); font-size: .88rem; overflow-wrap: anywhere; }
  .share-said:empty { display: none; }

  /* newsletter sign-up (newsletter.js): in the footer's first column */
  .nl-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
  .nl-field { display: grid; gap: 6px; flex: 1 1 240px; max-width: 380px; }
  .nl-label { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
  .nl-form input[type="email"] {
    font-family: var(--sans); font-size: 1rem; color: var(--ink); height: 42px;
    border: 1px solid var(--line-strong); border-radius: 3px; background: var(--card); padding: 0 12px;
    transition: border-color .12s, box-shadow .12s;
  }
  .nl-form input[type="email"]:hover { border-color: var(--ink-muted); }
  .nl-form input[type="email"]:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242, 160, 7, .3); }
  .nl-form .btn-primary { height: 42px; padding: 0 22px; font-size: .95rem; }
  .nl-form .btn-primary:disabled { opacity: .6; cursor: progress; }
  .nl-trap { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
  .nl-msg { margin: 10px 0 0; font-size: .9rem; line-height: 1.5; color: var(--body); }
  .nl-msg:empty { display: none; }
  .nl-msg.err { color: #A3261B; font-weight: 600; }
  .nl-foot { margin-top: 16px; max-width: 42ch; }
  .nl-foot .nl-form { gap: 8px; }
  .nl-foot .nl-field { flex-basis: 190px; }
  .nl-foot .nl-label { color: var(--ink); }
  .nl-foot .nl-form input[type="email"] { height: 38px; padding: 0 10px; font-size: .92rem; }
  .nl-foot .nl-form .btn-primary { height: 38px; padding: 0 16px; font-size: .9rem; }
  .nl-note { margin: 8px 0 0; font-size: .8rem; color: var(--ink-muted); }
  .nl-note a { color: var(--ink-muted); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

  /* comments */
  .comments { margin-top: 44px; padding-top: 0; border-top: 0; }
  .comments > p.muted { margin: 14px 0; }
  .comment-list { gap: 0; margin: 0 0 24px; }
  .comment { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 14px 0; }
  .comment-head { font-size: .86rem; color: var(--ink-muted); }
  .comment-head strong, .comment-head b { color: var(--ink); font-size: .95rem; }
  .comment p { font-family: var(--serif); font-size: 1.02rem; line-height: 1.6; color: var(--body); }
  .comment-form { max-width: none; padding: 20px 0 0; background: none; border: 0; border-top: 1px solid var(--line-strong); border-radius: 0; gap: 12px; }
  .comment-form h3 { margin: 0; font-size: 1.1rem; }
  .comment-form > p.muted { margin: 0 0 4px; font-size: .88rem; }

  /* form fields everywhere on the public site */
  .comment-form input, .comment-form textarea,
  .contact-form input, .contact-form textarea, .contact-form select,
  .signin-form input, .stack-form input, .stack-form textarea {
    font-family: var(--sans); font-size: 1rem; color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: 3px; background: var(--card); padding: 10px 12px;
    transition: border-color .12s, box-shadow .12s;
  }
  .comment-form input:hover, .comment-form textarea:hover,
  .contact-form input:hover, .contact-form textarea:hover, .contact-form select:hover { border-color: var(--ink-muted); }
  .comment-form input:focus, .comment-form textarea:focus,
  .contact-form input:focus, .contact-form textarea:focus, .contact-form select:focus,
  .signin-form input:focus, .stack-form input:focus, .stack-form textarea:focus {
    outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242, 160, 7, .3);
  }
  .form-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
  .form-foot .btn-primary { height: 42px; padding: 0 22px; font-size: .95rem; }
  .form-foot .btn-primary:disabled { opacity: .6; cursor: progress; }
  .form-foot .err { padding: 6px 10px; border-radius: 3px; font-size: .88rem; font-weight: 600; background: #FBEDEA; color: #A3261B; }
  .legal-note { margin: 0; font-size: .84rem; line-height: 1.6; color: var(--ink-muted); }
  .legal-note a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

  /* sign-in inside the app (the main one is /login) */
  .signin-page { padding-top: 48px; }
  .signin-form { padding: 28px; border: 1px solid var(--line); border-top: 2px solid var(--ink); border-radius: 0; box-shadow: none; }
  .signin-form h1 { font-size: 1.7rem; margin: 0; }

  /* ---- footer ---------------------------------------------------------
   * legal-links.js (and shell.php) build .footer-cols and .footer-base; the app's own two spans are hidden. */
  .site-footer {
    display: block; margin-top: 40px; padding: 0 0 28px; background: none; border: 0; color: var(--ink-muted); font-size: .92rem;
  }
  .site-footer > span { display: none; }
  .site-footer:not(:has(.footer-cols)) > span { display: inline; margin: 0 6px; }   /* before the script runs */
  .site-footer:not(:has(.footer-cols)) { text-align: center; padding-top: 24px; border-top: 2px solid var(--ink); }
  .footer-cols, .footer-base { max-width: var(--maxw); margin: 0 auto; padding-left: 20px; padding-right: 20px; }
  .footer-cols {
    display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); gap: 32px;
    padding-top: 28px; padding-bottom: 28px;
    background: linear-gradient(var(--ink), var(--ink)) 20px 0 / calc(100% - 40px) 2px no-repeat;
  }
  .footer-cols h2 {
    margin: 0 0 12px; font-family: var(--sans); font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
  }
  .footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
  .footer-cols a { color: var(--body); text-decoration: none; }
  .footer-cols a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 3px; }
  .footer-about .footer-name { margin: 0 0 8px; font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--ink); }
  .footer-about p { margin: 0 0 8px; max-width: 42ch; line-height: 1.55; }
  .footer-base {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px;
    padding-top: 14px; font-size: .84rem;
    background: linear-gradient(var(--line), var(--line)) 20px 0 / calc(100% - 40px) 1px no-repeat;
  }
  .footer-base p { margin: 0; }
}

/* ---- home: lede, then the list with a sidebar ------------------------------------------- */
body:not(:has(.admin)) .feed-page {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 300px; column-gap: 0; align-items: start;

  > * { grid-column: 1 / 3; min-width: 0; }
  > .page-hero { grid-column: 1 / -1; grid-row: 1; padding: 44px 0 30px; }
  > .page-hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.1rem); max-width: 20ch; }
  > .page-hero > .fx-stats {
    margin: 14px 0 0; font-family: var(--sans); font-style: normal; font-size: .9rem; color: var(--ink-muted); font-variant-numeric: tabular-nums;
  }
  .fx-stats b { color: var(--ink); font-weight: 600; }
  > .page-hero .site-search--hero { max-width: 720px; margin: 22px 0 0; }

  /* toolbar: type tabs with counts | date, year, topic */
  > .type-tabs, > .filters { grid-row: 2; align-self: stretch; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line-strong); }
  > .type-tabs {
    grid-column: 1; display: flex; gap: 22px; margin: 0; padding: 0;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  }
  > .type-tabs::-webkit-scrollbar { display: none; }
  .tab {
    display: inline-flex; align-items: baseline; gap: 6px; padding: 11px 0 10px; margin: 0 0 -1px;
    border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none;
    font-family: var(--sans); font-size: .93rem; font-weight: 600; color: var(--ink-muted); white-space: nowrap;
  }
  .tab:hover { color: var(--ink); background: none; }
  .tab-active, .tab-active:hover { color: var(--ink); border-bottom-color: var(--ink); background: none; }
  .tab[data-n]::after { content: attr(data-n); font-size: .8rem; font-weight: 400; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

  > .filters {
    grid-column: 2; display: flex; align-items: center; gap: 2px; padding: 0 0 0 16px; margin: 0;
    background: none; border-left: 0; border-right: 0; border-radius: 0; box-shadow: none; flex-wrap: nowrap;
  }
  .filters label { gap: 0; }
  .filters label > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .filters select {
    -webkit-appearance: none; appearance: none; cursor: pointer; min-width: 0; max-width: 150px;
    font: inherit; font-size: .88rem; font-weight: 600; color: var(--ink-muted);
    padding: 6px 20px 6px 8px; border: 0; border-radius: 3px;
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7386' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 4px center / 10px no-repeat;
  }
  .filters select:hover { color: var(--ink); background-color: var(--wash); }
  .filters select:focus-visible { outline: 2px solid var(--solar); outline-offset: 0; color: var(--ink); }
  /* the date, year and topic menus are hidden: the type tabs, the search field and the sidebar's topics
     cover them, and the section pages have the full filters. Clear shows after a search, as a text link. */
  .filters > label { display: none; }
  .filters .btn-sm {
    margin: 0; padding: 4px 0; border: 0; background: none; font-size: .88rem; font-weight: 600; color: var(--ink);
    text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 4px;
  }
  .filters .btn-sm:hover { background: none; text-decoration-thickness: 2px; }

  /* home rows are an index: title, who/where, tags and key facts; the excerpt is kept for the section pages */
  .post-card > .fx-abs, .post-card:not(.fx) > .post-body { display: none; }
  .post-card { padding: 16px 0 15px; }

  > .post-list { grid-row: 3; }
  > .pager { grid-row: 4; }
  > p.muted, > p.err { grid-row: 3; margin: 0; padding: 48px 0; text-align: left; border-bottom: 1px solid var(--line); }
  .fx-cols { display: none; }

  /* sidebar (feed.js): recent papers, open roles, topics */
  > .fx-side { grid-column: 3; grid-row: 2 / span 3; padding-left: 40px; margin-left: 0; align-self: start; }
}
body:not(:has(.admin)) .fx-side {
  section { margin: 0 0 30px; }
  section:first-child h2 { border-top-width: 2px; }
  h2 { margin: 0; padding: 12px 0 10px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line-strong); color: var(--ink); }
  ol, ul { list-style: none; margin: 0; padding: 0; }
  li { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .fx-side-title { display: block; font-family: var(--serif); font-weight: 600; font-size: 1rem; line-height: 1.35; color: var(--ink); text-decoration: none; }
  .fx-side-title:hover { text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 3px; }
  .fx-side-meta { display: block; margin-top: 3px; font-size: .84rem; color: var(--ink-muted); }
  .fx-side-meta .is-soon { color: #A3261B; font-weight: 600; }
  .fx-topics { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 0 0; }
  .fx-topics li { padding: 0; border: 0; }
  .fx-topics a { font-size: .9rem; color: var(--body); text-decoration: none; }
  .fx-topics a::before { content: "#"; color: var(--ink-muted); opacity: .7; }
  .fx-topics a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
  .fx-topics span { color: var(--ink-muted); font-size: .8rem; margin-left: 3px; }
  .fx-all { display: inline-block; margin-top: 10px; font-size: .86rem; font-weight: 600; color: var(--ink); }
}

/* ---- contact ---------------------------------------------------------------------------- */
body:not(:has(.admin)) .contact-page {
  display: grid; grid-template-columns: minmax(0, 1fr) 280px; column-gap: 56px; align-items: start; max-width: none;

  > .page-hero { grid-column: 1 / -1; }
  .contact-form, .contact-sent {
    grid-column: 1; margin: 0 0 56px; padding: 24px 0 0; background: none;
    border: 0; border-top: 2px solid var(--ink); border-radius: 0; box-shadow: none;
  }
  .contact-form { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 18px; max-width: none; }
  .contact-form > * { grid-column: 1 / -1; min-width: 0; }
  .contact-form > label:nth-of-type(1) { grid-column: 1; }
  .contact-form > label:nth-of-type(2) { grid-column: 2; }
  .contact-form label { display: flex; flex-direction: column; gap: 7px; }
  .contact-form label > span:first-child { color: var(--ink); }
  .contact-form label:has(input:not([required])) > span:first-child::after { content: " (optional)"; color: var(--ink-muted); text-transform: none; letter-spacing: 0; font-weight: 400; }
  .contact-form input, .contact-form select { height: 44px; }
  .contact-form select { width: 100%; padding: 0 12px; cursor: pointer; }
  .contact-form textarea { min-height: 170px; line-height: 1.55; }
  .contact-count { align-self: flex-end; font-size: .8rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
  .contact-count.is-near { color: #A3261B; }
  .contact-about {
    display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: 0;
    background: var(--cream); border-left: 3px solid var(--solar); font-size: .92rem; color: var(--ink);
  }
  .contact-about strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .contact-about-x { flex: none; width: 28px; height: 28px; border: 0; border-radius: 3px; background: none; font-size: 1.2rem; line-height: 1; color: var(--ink-muted); cursor: pointer; }
  .contact-about-x:hover { background: rgba(19, 33, 58, .08); color: var(--ink); }
  .contact-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
  .legal-note { padding-top: 16px; border-top: 1px solid var(--line); }

  .contact-sent h2 { margin: 0 0 8px; font-size: 1.5rem; }
  .contact-sent p { margin: 0 0 20px; font-family: var(--serif); font-size: 1.08rem; color: var(--body); }

  .contact-side { grid-column: 2; grid-row: 2; padding: 0 0 24px; font-size: .95rem; color: var(--body); }
  .contact-side h2 { margin: 0; padding: 12px 0 10px; border-top: 2px solid var(--ink); color: var(--ink); }
  .contact-side h2:not(:first-child) { margin-top: 26px; }
  .contact-side p { margin: 0; }
  .contact-side a { color: var(--ink); font-weight: 600; text-decoration-color: var(--solar); text-underline-offset: 3px; }
  .contact-side ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--ink-muted); line-height: 1.5; }
}

/* ---- loading rows: "Loading…" becomes placeholder rows (feed.js adds .fx-loading) ---------- */
body:not(:has(.admin)) :is(.feed-page > p.fx-loading, .section-page p.fx-loading) {
  color: transparent; padding: 0; margin: 0; height: 400px; border-bottom: 0; user-select: none;
  background:
    linear-gradient(transparent 26px, #ECE9E2 26px 36px, transparent 36px) 0 0 / 64px 100px repeat-y,
    linear-gradient(transparent 22px, #E6E2DA 22px 40px, transparent 40px) 128px 0 / 52% 100px repeat-y,
    linear-gradient(transparent 50px, #EFECE6 50px 62px, transparent 62px) 128px 0 / 34% 100px repeat-y,
    linear-gradient(transparent 99px, var(--line) 99px) 0 0 / 100% 100px repeat-y;
  animation: fx-pulse 1.4s ease-in-out infinite;
}
@keyframes fx-pulse { 50% { opacity: .55; } }

/* ---- post page on wide screens: related posts in a column beside the post --------------------
 * Only when there is room for both (narrower screens keep them under the post). The column stays in view while
 * reading. ads.js sees this layout and puts the ad under the post instead of beside it. */
@media (min-width: 1100px) {
  body:not(:has(.admin)) .detail-page:has(> .related) {
    display: grid; grid-template-columns: minmax(0, 720px) 250px; column-gap: 56px; max-width: 1026px; align-content: start;
    > * { grid-column: 1; }
    > .related {
      grid-column: 2; grid-row: 1 / span 40; align-self: start; position: sticky; top: 24px; margin: 6px 0 0;
    }
    .related h2 {
      font-family: var(--sans); font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
      padding: 12px 0 10px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line-strong);
    }
    .related-list a { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 11px 0; }
    .related-title { font-size: 1rem; }
  }
}

/* ---- narrower screens -------------------------------------------------------------------- */
@media (max-width: 960px) {
  body:not(:has(.admin)) .feed-page {
    grid-template-columns: minmax(0, 1fr) auto;
    > .fx-side { display: none; }
  }
}
@media (max-width: 820px) {
  body:not(:has(.admin)) {
    .nav-inner { padding: 16px max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px)); row-gap: 14px; }
    .nav-inner:not(:has(.nav-actions > *)) .nav-link[href="/contact"] { right: max(20px, env(safe-area-inset-right, 0px)); top: 16px; }
    .brand-logo { height: 28px; }
    .nav-links { gap: 0 22px; overflow-x: auto; scrollbar-width: none; margin: 0; }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links .nav-link { flex: none; }
    .nav-date { display: none; }
    .page-hero { padding: 28px 0 20px; }
    .page-hero p { font-size: 1.05rem; }

    .footer-cols { grid-template-columns: 1fr 1fr; gap: 26px 20px; }
    .footer-about { grid-column: 1 / -1; }
  }
  body:not(:has(.admin)) .contact-page {
    display: block;
    .contact-side { padding: 0 0 32px; }
  }
}
@media (max-width: 720px) {
  body:not(:has(.admin)) {
    /* rows stack: type and date on one line, then the title, then everything else */
    .post-card { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 16px 0 15px; }
    .post-card > * { grid-column: 1 / -1; }
    .post-head .badge { grid-column: 1; grid-row: 1; margin: 0 0 6px; }
    .post-head > .muted { grid-column: 2; grid-row: 1; margin: 0; }
    .post-card > .post-title { grid-row: 2; font-size: 1.15rem; }
    .post-card > .fx-sub { grid-row: 3; }
    .post-card > .fx-abs, .post-card:not(.fx) > .post-body { grid-row: 4; }
    .post-card > .fx-detail { grid-column: 1 / -1; grid-row: 5; display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; text-align: left; }
    .post-card:not(.fx) > .meta-row { grid-column: 1 / -1; grid-row: 5; justify-items: start; text-align: left; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
    .post-card > .tag-row { grid-row: 6; }

    .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .related-list a { grid-template-columns: minmax(0, 1fr); gap: 4px; }
    .markdown table { display: block; overflow-x: auto; }
  }
  body:not(:has(.admin)) .feed-page {
    > .type-tabs { grid-column: 1 / -1; }
    > .filters { grid-column: 1 / -1; grid-row: 3; padding: 6px 0; border-top: 0; flex-wrap: wrap; }
    > .post-list, > p.muted, > p.err { grid-row: 4; }
    > .pager { grid-row: 5; }
  }
}
@media (max-width: 600px) {
  body:not(:has(.admin)) .contact-page {
    .contact-form { grid-template-columns: 1fr; }
    .contact-form > label:nth-of-type(2) { grid-column: 1; }
    .form-foot .btn-primary { width: 100%; }
  }
  body:not(:has(.admin)) .footer-cols { grid-template-columns: 1fr; }
  body:not(:has(.admin)) .footer-base { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  body:not(:has(.admin)) .fx-loading { animation: none; }
  body:not(:has(.admin)) * { transition: none !important; }
}
@media print {
  body:not(:has(.admin)) :is(.nav, .site-footer, .fx-side, .comments, .related, .pp-btn, .sh-top, .share-row) { display: none; }
}

/* ---- home: a short list, sortable, six posts at a time (feed.js) ----------------------------
 * The app's own list, tabs and pager are hidden until a search or topic is active (the Clear link appears),
 * when they come back as the results and the picks step aside. Without feed.js the app's list shows as before. */
body:not(:has(.admin)) .feed-page:has(> .fx-pick):not(:has(> .filters .btn-sm)) > :is(.type-tabs, .filters, .post-list, .pager, p.muted, p.err) { display: none; }
body:not(:has(.admin)) .feed-page:has(> .filters .btn-sm) > .fx-pick { display: none; }

body:not(:has(.admin)) .feed-page {
  > .fx-pick { grid-column: 1 / 3; grid-row: 2; }

  .fx-pick-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap;
    margin: 0; padding: 12px 0 11px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line-strong);
  }
  .fx-pick-head h2 { margin: 0; font-size: 1.3rem; }
  .fx-sort { display: flex; align-items: baseline; gap: 4px 16px; flex-wrap: wrap; }
  .fx-sort-l { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
  .fx-sort-b {
    font: inherit; font-size: .92rem; font-weight: 600; color: var(--ink-muted); background: none; border: 0; padding: 2px 0;
    border-bottom: 2px solid transparent; cursor: pointer;
  }
  .fx-sort-b:hover { color: var(--ink); }
  .fx-sort-b[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
  .fx-pick-note { margin: 0; padding: 10px 0 0; font-size: .88rem; color: var(--ink-muted); }
  .fx-reset {
    font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer;
    text-decoration: underline; text-decoration-color: var(--solar); text-underline-offset: 3px;
  }
  .post-card > .fx-why { grid-row: 3; margin-top: 4px; font-family: var(--serif); font-style: italic; font-size: .92rem; color: var(--ink-muted); }
  .fx-pick-list .post-card > .tag-row { grid-row: 4; }
  /* --fx-extra: the space feed.js shares out so the list ends level with the sidebar */
  .fx-pick-list > .post-card { padding-top: calc(16px + var(--fx-extra, 0px) / 2); padding-bottom: calc(15px + var(--fx-extra, 0px) / 2); }

  .fx-pager { margin-top: 0; }
}
@media (max-width: 720px) {
  body:not(:has(.admin)) .feed-page {
    .post-card > .fx-why { grid-row: 4; }
    .fx-pick-list .post-card > .fx-detail { grid-row: 5; }
    .fx-pick-list .post-card > .tag-row { grid-row: 6; }
  }
}
