:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --border: #dcdce0;
  --text: #1f2328;
  --muted: #555d66;
  --accent: #1d3557;
  --selected: #e8eef7;
  --error: #c0392b;
  --ok: #1f6b43;
  --warn: #a8440b;
  --control-border: #858b94;  /* 3:1 against white and --bg, for inputs and buttons */
  --focus: #1d4f91;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
header :focus-visible { outline-color: white; }
[tabindex="-1"]:focus { outline: none; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-links a {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 10;
  padding: 8px 12px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  border-radius: 0 0 6px 6px;
}
.skip-links a:focus { top: 0; outline-color: white; outline-offset: -4px; }
kbd {
  font: 11px ui-monospace, Menlo, Consolas, monospace;
  padding: 0 4px;
  border: 1px solid var(--control-border);
  border-radius: 3px;
  background: var(--panel);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 4px 16px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
header h2 { margin: 0; font-size: 16px; font-weight: 600; min-width: 0; }
@media (max-width: 700px) {
  header { flex-wrap: wrap; padding: 6px 16px; }
}

#paper {
  padding: 12px 16px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
#paper .paper-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 24px;
  align-items: start;
}
#paper h1 { margin: 0; font-size: 20px; line-height: 1.3; color: var(--accent); }
#paper .authors { margin: 4px 0 0; color: var(--muted); }
.accessibility-statement h2 { margin: 0 0 4px; font-size: 14px; color: var(--accent); }
.accessibility-statement p { margin: 0; color: var(--muted); line-height: 1.5; }
.accessibility-statement a { color: var(--accent); }
#abstract summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
#abstract p {
  margin: 6px 0 0;
  max-width: 1100px;
  line-height: 1.5;
}
.taxonomy-link {
  display: inline-block;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  text-decoration: none;
}
.taxonomy-link:hover { filter: brightness(1.15); }
.taxonomy-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
@media (max-width: 800px) {
  #paper .paper-heading { grid-template-columns: 1fr; gap: 8px; }
  #abstract p { max-height: 9em; overflow-y: auto; }
}

#test-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
  flex-shrink: 0;
}
#test-toggle button {
  font: inherit;
  border: none;
  border-radius: 6px;
  padding: 3px 12px;
  background: transparent;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.25;
}
#test-toggle button span { font-size: 11px; opacity: 0.8; }
#test-toggle button:hover { background: rgba(255, 255, 255, 0.15); }
#test-toggle button[aria-pressed="true"] { background: white; color: var(--accent); }

#filters {
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
#facet-filters {
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
#facet-filters select { max-width: 200px; }
#filters label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
#filters label.grow { flex: 1 1 220px; }
#filters select, #filters input, #filters button {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  max-width: 260px;
}
#filters input { max-width: none; }
#filters button { cursor: pointer; }
#filters button:hover { background: var(--bg); }

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#list-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
#list-count {
  padding: 8px 12px 2px;
  font-size: 12px;
  color: var(--muted);
}
.list-help {
  margin: 0;
  padding: 0 12px 8px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
#prompt-list {
  position: relative;  /* offset parent for scrolling the selected prompt into view */
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
#prompt-list li { border-bottom: 1px solid var(--border); }
#prompt-list button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
#prompt-list button:focus-visible { outline-offset: -3px; }
#prompt-list li:hover { background: var(--bg); }
#prompt-list li.selected { background: var(--selected); border-left: 3px solid var(--accent); }
#prompt-list li.selected button { padding-left: 9px; }
#prompt-list .li-head { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }
#prompt-list .li-dataset, #prompt-list .li-prompt { display: block; }
#prompt-list .li-prompt {
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#prompt-list .li-id { font-weight: 600; color: var(--text); }
#prompt-list .li-dataset { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#prompt-list .err-count { color: var(--error); font-weight: 600; white-space: nowrap; }
#prompt-list .ok-count { color: var(--ok); white-space: nowrap; }

#detail {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-width: 0;
}
.empty { color: var(--muted); }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.detail-head h2 { margin: 0 0 6px; font-size: 17px; line-height: 1.4; }
#detail:focus { outline: none; }
.detail-id { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.nav-buttons { display: flex; gap: 6px; flex-shrink: 0; }
.nav-buttons button, .tabs button {
  font: inherit;
  padding: 5px 10px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  cursor: pointer;
}
.nav-buttons button:disabled { opacity: 0.4; cursor: default; }

.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; align-items: center; }
.meta-label { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 2px 0 0; }
h3.meta-label { margin: 6px 0 2px; }
.meta-row > h3.meta-label { margin: 0 2px 0 0; }
.meta-sublabel { font-size: 12px; color: var(--muted); }
.meta-sublabel::after { content: ":"; }
.error-group { margin: 3px 0 3px 10px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  background: #eef0f3;
  color: var(--text);
  border: 1px solid transparent;
}
.badge.error { background: #fdecea; color: var(--error); border-color: #f5c6c0; }
.badge.ok { background: #e7f5ec; color: var(--ok); }
.badge.warn { background: #ffeddc; color: var(--warn); border-color: #f9c79a; }
.badge.inferred { font-style: italic; }
.badge.op { background: #e8f1f8; color: #245a82; }
.badge.design { background: #fff4e0; color: #8a5300; border-color: #f3d9a8; }

.tabs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.tabs button.active { background: var(--accent); color: white; border-color: var(--accent); }
.tabs button.dim:not(.active) { color: var(--muted); border-style: dashed; background: var(--bg); }
.tab-err { font-size: 12px; opacity: 0.85; }

.coding {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 10px 0 14px;
}
.design-list { margin: 6px 0; }
.design-items { margin: 0; padding: 0; list-style: none; }
.design-item { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
.design-item .badge { flex-shrink: 0; }
.design-text {
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  max-height: 7.5em;
  overflow-y: auto;
}
.facets-box { margin: 6px 0; }
.facets-box summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.facet-grid {
  margin: 6px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 4px 14px;
}
.facet { display: flex; align-items: center; gap: 6px; }
.facet dd { margin: 0; }
.facet .meta-label::after { content: ":"; }

.columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.column {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}
.column h3 { margin: 0 0 8px; font-size: 14px; }
.text-block { padding: 8px 0; border-bottom: 1px dashed var(--border); line-height: 1.5; overflow-wrap: anywhere; }
.text-block:last-child { border-bottom: none; }
.text-block p { margin: 0 0 6px; }
.text-block pre, .code-block {
  overflow-x: auto;
  font-size: 12px;
  border-radius: 6px;
}
.code-block { margin: 0 0 10px; border: 1px solid var(--border); }
.code-block code { padding: 10px !important; overflow-x: visible !important; }  /* the focusable <pre> scrolls, not <code> */
.chart-img { width: 100%; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 10px; background: white; }
.chart-data { margin: 0 0 14px; }
.chart-data summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.chart-data table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12px; }
.chart-data caption { text-align: left; font-weight: 600; margin-bottom: 4px; }
.chart-data th, .chart-data td { padding: 5px 7px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.chart-data thead th { background: #f4f6f8; }
.missing { color: var(--error); font-size: 12px; }

@media (max-width: 1100px) {
  .columns { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  main { flex-direction: column; }
  #list-panel { width: 100%; max-height: 35vh; border-right: none; border-bottom: 1px solid var(--border); }
}

/* Windows High Contrast and other forced-colour modes drop backgrounds, so give pills and the
   selected prompt visible outlines there. */
@media (forced-colors: active) {
  .badge { border-color: CanvasText; }
  #prompt-list li.selected { border-left-color: Highlight; }
}
