@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://use.typekit.net/hsb4lyn.css');

/* Datasette Lite inserts a complete document into #output: body classes do not
   survive. Scope the human view by its unique who/source column signature. */
:root { --ink: #2c2c2c; --muted: #686560; --gold: #b7861f; --line: #e7e5e4; --warm: #faf7f0; }
html { background: #fff; }
body { margin: 0; background: #fff; color: var(--ink); font-family: Inter, Arial, sans-serif; line-height: 1.5; }
*, *::before, *::after { box-sizing: border-box; }
a:link, a:visited, #output a:link, #output a:visited { color: inherit; text-decoration-color: #dfae47; text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover, #output a:hover { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.jdo-header { position: relative; max-width: 1000px; margin: 0 auto; padding: 56px 32px 64px; background: #fff; color: var(--ink); overflow: visible; border-bottom: 1px solid var(--line); }
.jdo-by:link, .jdo-by:visited { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); font-size: 13px; font-weight: 500; text-decoration: none; }
.jdo-by img { width: 28px; height: 28px; border-radius: 50%; }
.jdo-title { max-width: 800px; margin: 24px 0 16px; font: 500 clamp(32px, 4vw, 56px)/1.12 'new-kansas', Georgia, serif; letter-spacing: -.035em; color: #1c1917; }
.jdo-sub { max-width: 690px; margin: 0; font-size: 15px; line-height: 1.7; color: #65615d; }
.jdo-peek { position: absolute; right: 24px; bottom: -1px; width: 116px; height: auto; pointer-events: none; }
#output { max-width: 1000px; margin: 0 auto; padding: 28px 32px 48px; min-width: 0; }
#output header { display: none; }
#output section.content { margin: 0; }
#output .page-header { border: 0 !important; margin: 0 0 12px; padding: 0; }
#output h1 { display: none; }
#output h2, #output h3 { color: #1c1917; font-size: 15px; font-weight: 600; margin: 24px 0 16px; }
#output .metadata-description { color: var(--muted); font-size: 13px; }
#output .metadata-description p { margin: 0 0 12px; }
#output .page-action-menu, #output .actions-menu-links { font-size: 13px; }
#output .icon-text { background: var(--warm); color: var(--ink); border: 1px solid var(--line); }
#output form { font-family: inherit; }
#output form.filters { font-size: 13px; margin: 16px 0 24px; }
#output .search-row { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
#output .search-row label { width: auto; font-size: 14px; font-weight: 600; padding: 0; }
#output input[type=text], #output input[type=search], #output select, #output button, #output input[type=submit] { font-family: inherit; }
#output input[type=text], #output input[type=search] { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); background: #fff; max-width: 100%; }
#output #_search { flex: 1; width: auto; padding: 14px 20px; border-radius: 999px; font-size: 17px; }
#output input:focus, #output .select-wrapper:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px #dfae4726; }
#output input[type=submit], #output button[type=button] { background: var(--warm); border: 1px solid var(--line); border-radius: 999px; color: var(--ink); padding: 10px 16px; }
#output input[type=submit]:hover { border-color: var(--gold); }
#output .select-wrapper { border: 1px solid var(--line); background: #fff; border-radius: 8px; }
#output .filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); }
#output .filter-row .filter-value { width: 180px; }
#output .filter-row .select-wrapper { margin: 0; }
#output .filter-row .small-screen-only { display: inline-block; }
#output .facet-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 24px; margin: 24px 0 32px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
#output .facet-info { width: auto; min-width: 0; margin: 0; }
#output .facet-info-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; margin-bottom: 8px; }
#output .facet-info-name strong { font-weight: 600; }
#output .facet-info-total { color: var(--muted); }
#output .facet-info ul { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; padding: 0 4px 4px 0; margin: 0; max-height: 104px; overflow-y: auto; scrollbar-width: thin; }
#output .facet-info li { display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%; margin: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; line-height: 1.5; color: var(--muted); list-style: none; overflow-wrap: anywhere; }
#output .facet-info li a { color: var(--ink); text-decoration: none; }
#output .facet-info li:hover { background: var(--warm); border-color: #dfae47; }
#output .facet-info li:has(a.cross) { background: #fbf4e5; border-color: #dfae47; }
#output .facet-truncated { top: auto; text-indent: 0; }
#output .table-wrapper { max-width: 100%; overflow-x: auto; }
#output table.rows-and-columns { width: 100%; table-layout: fixed; }
#output th { position: sticky; top: 0; background: #fff; padding: 12px 8px; font-size: 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: normal; }
#output td { padding: 12px 8px; border: 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; overflow-wrap: anywhere; white-space: normal; }
#output td.col-quote { font-size: 16px; line-height: 1.6; color: var(--ink); }
#output th.col-quote { width: 360px; }
#output tr:hover { background: var(--warm); }
#output td a { text-decoration: underline; }
#output td.type-none { color: transparent; }
#output td.col-url a, #output td.col-company_url a { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Quote cards retain the original links and data; no duplicated complaint copy. */
#output table:has(th.col-who):has(th.col-source) { display: block; width: 100%; }
#output table:has(th.col-who):has(th.col-source) thead { display: none; }
#output table:has(th.col-who):has(th.col-source) tbody { display: grid; gap: 16px; max-width: 824px; margin: 0 auto; }
#output table:has(th.col-who):has(th.col-source) tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; padding: 24px 28px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
#output table:has(th.col-who):has(th.col-source) tr:hover { background: var(--warm); }
#output table:has(th.col-who):has(th.col-source) td { display: block; border: 0; padding: 0; margin: 0; font-size: 12px; }
#output table:has(th.col-who):has(th.col-source) td::before { content: none; }
#output table:has(th.col-who):has(th.col-source) td.col-quote { position: relative; flex-basis: 100%; order: 2; padding: 8px 0 16px; font-size: 19px; line-height: 1.55; }
#output table:has(th.col-who):has(th.col-source) td.col-quote::before { content: '“'; display: block; margin: 0 0 -28px -8px; font: 64px/1 Georgia, serif; color: #dfae4770; pointer-events: none; }
#output table:has(th.col-who):has(th.col-source) td:is(.col-who,.col-store,.col-platform,.col-date,.col-source) { order: 3; }
#output table:has(th.col-who):has(th.col-source) td.col-who { font-size: 13px; font-weight: 600; color: var(--ink); }
#output table:has(th.col-who):has(th.col-source) td:is(.col-store,.col-about,.col-category,.col-leak_source) { border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; font-size: 11px; }
#output table:has(th.col-who):has(th.col-source) td:is(.col-about,.col-category,.col-leak_source) { order: 1; }
#output table:has(th.col-who):has(th.col-source) td.col-about { color: #896316; background: #fcf8ee; }
#output table:has(th.col-who):has(th.col-source) td.col-source { margin-left: auto; }
#output table:has(th.col-who):has(th.col-source) td.col-source a { font-size: 0; }
#output table:has(th.col-who):has(th.col-source) td.col-source a::after { content: 'Open original →'; font-size: 12px; text-decoration: underline; text-decoration-color: #dfae47; text-decoration-thickness: 2px; text-underline-offset: 4px; }
#output table:has(th.col-who):has(th.col-source) td:is(.col-id,.col-role,.col-loss_stated,.col-size_signal,.col-speaker_type,.col-last_9_months),
#output table:has(th.col-who):has(th.col-source) td.type-none,
#output table:has(th.col-who):has(th.col-source) td:empty { display: none; }
/* Raw table row detail: a large quote followed by a two-column field list. */
#output:not(:has(form.filters)) table:has(td.col-quote):not(:has(th.col-who)) { display: block; }
#output:not(:has(form.filters)) table:has(td.col-quote):not(:has(th.col-who)) thead { display: none; }
#output:not(:has(form.filters)) table:has(td.col-quote):not(:has(th.col-who)) :is(tbody,tr) { display: block; }
#output:not(:has(form.filters)) table:has(td.col-quote):not(:has(th.col-who)) tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-quote { grid-column: 1 / -1; order: -1; font-size: 22px; padding: 0 0 24px; }
#output:not(:has(form.filters)) table:has(td.col-quote) td:not(.col-quote)::before { content: ''; display: block; margin: 0 0 4px; font-size: 11px; color: var(--muted); }
#output:not(:has(form.filters)) table:has(td.col-quote) td.type-none { display: none; }
#output .advanced-export { box-shadow: none; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
#output section.content > p, #output .suggested-facets { font-size: 12px; color: var(--muted); }
#output footer { background: none; color: var(--muted); border-top: 1px solid var(--line); margin-top: 32px; padding: 16px 0; min-height: 0; font-size: 12px; }
#output footer > * { display: none; }
#output footer::after { content: 'Built on Datasette'; }
#load-custom { display: none; }
@media (max-width: 600px) {
  .jdo-header { margin: 0 20px; padding: 28px 0 64px; }
  .jdo-title { margin-top: 24px; font-size: 32px; letter-spacing: -.025em; }
  .jdo-sub { font-size: 13px; line-height: 1.65; }
  .jdo-peek { width: 96px; right: 4px; }
  #output { padding: 20px 16px 32px; }
  #output .search-row { gap: 8px; }
  #output #_search { min-width: 0; }
  #output .facet-results { display: flex; overflow-x: auto; gap: 16px; padding-bottom: 16px; }
  #output .facet-info { flex: 0 0 240px; }
  #output .facet-info ul { max-height: 84px; }
  #output table.rows-and-columns { display: table; min-width: 1100px; }
  #output .rows-and-columns thead { display: table-header-group; }
  #output .rows-and-columns thead tr { position: static; }
  #output .rows-and-columns :is(tbody) { display: table-row-group; }
  #output .rows-and-columns tr { display: table-row; }
  #output .rows-and-columns :is(td,th) { display: table-cell; }
  #output .rows-and-columns td::before { content: none; }
  #output table:has(th.col-who):has(th.col-source) { min-width: 0; }
  #output table:has(th.col-who):has(th.col-source) tr { padding: 20px; gap: 8px; }
  #output table:has(th.col-who):has(th.col-source) td.col-quote { font-size: 18px; }
  #output table:has(th.col-who):has(th.col-source) td.col-source { flex-basis: 100%; margin: 8px 0 0; }
  #output:not(:has(form.filters)) table:has(td.col-quote) { min-width: 0; }
  #output:not(:has(form.filters)) table:has(td.col-quote):not(:has(th.col-who)) tr { grid-template-columns: 1fr; padding: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

#output:not(:has(form.filters)) table:has(td.col-quote) td.col-id::before { content: "id"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-about::before { content: "about"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-date::before { content: "date"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-platform::before { content: "platform"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-url::before { content: "url"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-person_name::before { content: "person name"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-handle::before { content: "handle"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-follower_count::before { content: "follower count"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-role::before { content: "role"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-company::before { content: "company"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-company_url::before { content: "company url"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-size_signal::before { content: "size signal"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-gloss::before { content: "gloss"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-engagement::before { content: "engagement"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-rating::before { content: "rating"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-speaker_type::before { content: "speaker type"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-category::before { content: "category"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-leak_source::before { content: "leak source"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-code_type::before { content: "code type"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-loss_stated::before { content: "loss stated"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-tool_named::before { content: "tool named"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-notes::before { content: "notes"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-last_9_months::before { content: "last 9 months"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-big_store::before { content: "big store"; }
#output:not(:has(form.filters)) table:has(td.col-quote) td.col-verified::before { content: "verified"; }
/* Wide raw records scroll within their container instead of compressing fields. */
#output:has(form.filters) table.rows-and-columns:not(:has(th.col-who)) { min-width: 1800px; }
#output:has(form.filters) table.rows-and-columns:not(:has(th.col-who)) th.col-quote { width: 520px; }

/* ---- Orchestrator pass: get the first complaint on the first screen ---- */
@media (min-width: 601px) {
  .jdo-header { padding-top: 32px; padding-bottom: 20px; }
  .jdo-title { margin-top: 16px; margin-bottom: 12px; }
}

/* The quotes view: search + compact filters, then the cards. Power tools live under "All columns". */
#output section.content:has(th.col-who) form.filters .filter-row,
#output section.content:has(th.col-who) > p:has(> a.not-underlined),
#output section.content:has(th.col-who) .suggested-facets,
#output section.content:has(th.col-who) #export,
#output section.content:has(th.col-who) pre.wrapped-sql { display: none; }
#output section.content:has(th.col-who) > h3 { margin: 8px 0 12px; font-size: 14px; font-weight: 500; color: #2c2c2cb3; }
#output section.content:has(th.col-who) .metadata-description { margin: 0; }
#output section.content:has(th.col-who) form.filters { margin: 0 0 16px; }
#output section.content:has(th.col-who) .export-links { margin: 0 0 12px; font-size: 12px; }
#output section.content:has(th.col-who) .facet-results {
  display: grid; grid-template-columns: 1.15fr 1.15fr 1.45fr 1fr .85fr; gap: 12px 20px;
  margin: 0 0 24px; padding: 0 0 20px; border-bottom: 1px solid var(--line);
}
#output section.content:has(th.col-who) .facet-info { margin: 0; min-width: 0; }
#output section.content:has(th.col-who) .facet-info ul {
  max-height: 104px; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 0 0; margin: 6px 0 0;
}
#output section.content:has(th.col-who) .facet-info li { margin: 0; }
#output section.content:has(th.col-who) .facet-info li a { font-size: 12px; }

@media (max-width: 900px) {
  #output section.content:has(th.col-who) .facet-results {
    display: flex !important; flex-wrap: nowrap; overflow-x: auto; gap: 16px; scroll-snap-type: x proximity; padding-bottom: 12px;
  }
  #output section.content:has(th.col-who) .facet-info { flex: 0 0 240px !important; width: 240px; scroll-snap-align: start; }
}

#output section.content:has(th.col-who) .facet-info li a { white-space: nowrap; }

/* Tone chip: the first thing on each card, so a reader knows what kind of quote it is. */
#output table:has(th.col-who):has(th.col-source) td.col-tone {
  order: 0; border: 1px solid #2c2c2c; border-radius: 999px; padding: 3px 10px;
  font-size: 11px; font-weight: 600; color: #2c2c2c; background: #fff;
}
#output table:has(th.col-who):has(th.col-source) td.col-tone:empty,
#output table:has(th.col-who):has(th.col-source) td.col-tone.type-none { display: none; }
