:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #f0f2ee;
  --text: #171a17;
  --muted: #667066;
  --border: #dfe4dd;
  --accent: #214e3f;
  --accent-soft: #e7f0ec;
  --true: #176b45;
  --true-bg: #e6f4ed;
  --true-bg-hover: #dcefe5;
  --false: #9e3434;
  --false-bg: #faeceb;
  --false-bg-hover: #f6e1df;
  --conditional: #8a6200;
  --conditional-bg: #fff4d5;
  --conditional-bg-hover: #f9e9bb;
  --unknown: #63707a;
  --unknown-bg: #eef1f3;
  --unknown-bg-hover: #e3e8eb;
  --na: #757575;
  --na-bg: #f0f0f0;
  --na-bg-hover: #e5e5e5;
  --shadow: 0 18px 50px rgba(26, 36, 30, 0.11);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 40px clamp(20px, 5vw, 72px) 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.72);
}
.eyebrow { font-size: 11px; letter-spacing: .16em; font-weight: 800; color: var(--accent); }
h1 { margin: 5px 0 4px; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(34px, 5vw, 58px); line-height: 1; font-weight: 500; }
.subtitle { margin: 10px 0 0; max-width: 720px; color: var(--muted); font-size: 15px; }
.header-actions { min-width: min(440px, 100%); display: flex; gap: 8px; align-items: center; }
.search-wrap { flex: 1; min-width: 0; position: relative; }
.search-wrap svg { position: absolute; width: 18px; height: 18px; left: 13px; top: 50%; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-wrap input { width: 100%; min-height: 44px; padding: 10px 14px 10px 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); outline: none; }
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ghost-button, .icon-button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; min-height: 44px; padding: 0 14px; }
.ghost-button:hover, .icon-button:hover { background: var(--surface-soft); }

main { padding: 22px clamp(12px, 3vw, 44px) 56px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-soft); border-radius: 10px; }
.segmented button { border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 7px; font-size: 13px; }
.segmented button.active { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.toggle-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.toggle-label input { accent-color: var(--accent); width: 16px; height: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.true { background: var(--true); }.dot.false { background: var(--false); }.dot.conditional { background: var(--conditional); }.dot.na { background: var(--na); }

.matrix-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.matrix-meta { padding: 10px 14px; background: #fafbf9; border-bottom: 1px solid var(--border); display: flex; gap: 15px; justify-content: space-between; color: var(--muted); font-size: 12px; }
.table-scroll { overflow-x: auto; outline: none; }
table { border-collapse: separate; border-spacing: 0; min-width: max-content; width: 100%; }
th, td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
th:last-child, td:last-child { border-right: 0; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { position: relative; z-index: 1; background: #fafbf9; color: var(--muted); font-size: 11px; line-height: 1.2; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; padding: 10px 9px; width: 106px; max-width: 130px; vertical-align: bottom; }
thead th:first-child { left: 0; z-index: 7; min-width: 156px; width: 156px; text-align: left; }
.table-scroll thead th { box-shadow: 0 1px 0 var(--border); }
tbody th { position: sticky; left: 0; z-index: 4; background: var(--surface); min-width: 156px; width: 156px; padding: 13px 14px; text-align: left; }
.category-symbol { display: block; font-family: Georgia, serif; font-size: 22px; font-weight: 600; }
.category-name { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 500; }
td { padding: 0; min-width: 106px; height: 66px; text-align: center; }
.cell-button { width: 100%; height: 100%; min-height: 66px; padding: 8px; border: 0; background: transparent; color: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.cell-button:hover { background: #f8faf7; }
.cell-button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: -3px; }
.status-chip { min-width: 26px; height: 26px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 14px; font-weight: 900; }
.status-chip.true { color: var(--true); background: var(--true-bg); }
.status-chip.false { color: var(--false); background: var(--false-bg); }
.status-chip.conditional { color: var(--conditional); background: var(--conditional-bg); }
.status-chip.unknown { color: var(--unknown); background: var(--unknown-bg); }
.status-chip.not_applicable { color: var(--na); background: var(--na-bg); }
.cell-value { max-width: 105px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #3f493f; font-size: 11px; }
.empty-cell { color: #a9b0aa; font-size: 18px; }
.empty-state { padding: 50px; color: var(--muted); text-align: center; }

.detail-panel { position: fixed; inset: 0; z-index: 20; pointer-events: none; visibility: hidden; }
.detail-panel.open { pointer-events: auto; visibility: visible; }
.detail-backdrop { position: absolute; inset: 0; background: rgba(19, 24, 20, .26); opacity: 0; transition: opacity .18s ease; }
.detail-panel.open .detail-backdrop { opacity: 1; }
.detail-sheet { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 94vw); overflow-y: auto; background: var(--surface); box-shadow: var(--shadow); transform: translateX(100%); transition: transform .2s ease; }
.detail-panel.open .detail-sheet { transform: translateX(0); }
.detail-topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.96); }
.breadcrumb { color: var(--muted); font-size: 12px; }
.icon-button { width: 40px; min-height: 40px; padding: 0; font-size: 25px; line-height: 1; }
.detail-content { padding: 24px 24px 50px; }
.detail-kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 800; }
.detail-content h2 { margin: 4px 0 9px; font-family: Georgia, serif; font-size: 34px; line-height: 1.08; font-weight: 500; }
.statement { font-size: 17px; line-height: 1.55; margin: 15px 0 20px; }
.detail-status { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 6px 10px; background: var(--surface-soft); font-size: 12px; font-weight: 700; }
.detail-section { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 18px; }
.detail-section h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; }
.detail-section p { margin: 7px 0; color: #3f493f; line-height: 1.6; font-size: 14px; }
.formula { overflow-x: auto; padding: 12px; border-radius: 8px; background: #f4f5f2; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; }
.reference-list { margin: 8px 0 0; padding-left: 18px; color: #3f493f; font-size: 13px; }
.reference-list li { margin: 7px 0; }
.reference-list a { color: var(--accent); }
.verification { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; font-size: 12px; color: var(--muted); }
.verification dt { font-weight: 700; }
.verification dd { margin: 0; }
.load-error { position: fixed; left: 16px; right: 16px; bottom: 16px; padding: 14px 16px; border: 1px solid #e2b8b4; background: #fff0ee; border-radius: 10px; color: #7e2f29; display: flex; gap: 8px; flex-wrap: wrap; z-index: 30; }
mark { background: #fff0a8; color: inherit; }

@media (max-width: 850px) {
  .site-header { align-items: stretch; flex-direction: column; padding-top: 28px; }
  .header-actions { min-width: 0; width: 100%; }
  .toolbar { justify-content: flex-start; }
  .legend { width: 100%; }
}
@media (max-width: 520px) {
  main { padding-left: 8px; padding-right: 8px; }
  .site-header { padding-left: 16px; padding-right: 16px; }
  .header-actions { flex-direction: column; align-items: stretch; }
  .ghost-button { width: 100%; }
  thead th:first-child, tbody th { min-width: 124px; width: 124px; }
}
@media (prefers-reduced-motion: reduce) {
  .detail-backdrop, .detail-sheet { transition: none; }
}

/* Clickable row/column labels and optional column illustrations */
.category-column-label { display: inline-block; padding: 6px 3px; }
.column-header-button {
  width: 100%; min-height: 74px; padding: 5px 4px 7px; border: 0; background: transparent;
  color: inherit; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px;
  text-transform: inherit; letter-spacing: inherit; font-size: inherit; font-weight: inherit; line-height: inherit;
}
.column-header-button:hover { color: var(--accent); background: var(--accent-soft); }
.column-header-button:focus-visible, .category-button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: -3px; }
.column-image { display: block; width: 68px; height: 42px; object-fit: contain; }
.column-image-spacer { display: block; width: 68px; height: 42px; }
.category-button { width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; border-radius: 7px; }
.category-button:hover .category-symbol { color: var(--accent); }
.descriptive-cell { padding: 10px; }
.descriptive-value { max-width: 108px; color: #273129; font-size: 12px; line-height: 1.25; font-weight: 650; text-align: center; }
.descriptive-detail-value { display: inline-block; margin: 4px 0 8px; padding: 7px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 750; }
.detail-column-image { width: 150px; height: 94px; object-fit: contain; display: block; margin: 0 0 12px; padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: #fafbf9; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-list span { padding: 5px 8px; border-radius: 999px; background: var(--surface-soft); color: #3f493f; font-size: 12px; }
.mini-table { width: 100%; min-width: 0; border-collapse: collapse; }
.mini-table th, .mini-table td { position: static; min-width: 0; width: auto; height: auto; border: 0; border-bottom: 1px solid var(--border); padding: 9px 5px; text-align: left; background: transparent; font-size: 13px; }
.mini-table th { width: 74px; font-family: Georgia, serif; font-size: 16px; }
.detail-content code { padding: 2px 5px; border-radius: 5px; background: #f4f5f2; font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }

/* Advanced filtering */
.advanced-filter-wrap { position: relative; }
.filter-cog-button { position: relative; display: inline-grid; place-items: center; padding: 0; }
.filter-cog-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.filter-cog-button.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.filter-count { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; background: var(--accent); color: white; font-size: 10px; font-weight: 800; border: 2px solid var(--surface); }
.advanced-filter-panel { position: absolute; top: calc(100% + 9px); right: 0; z-index: 12; width: min(560px, calc(100vw - 28px)); padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.filter-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.filter-panel-heading strong { display: block; font-size: 14px; }
.filter-panel-heading span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--accent); padding: 4px; font-weight: 700; }
.filter-builder { display: grid; grid-template-columns: .8fr 1.35fr .9fr auto; gap: 8px; align-items: end; }
.filter-builder label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.filter-builder select { min-width: 0; min-height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; background: white; color: var(--text); font: inherit; text-transform: none; letter-spacing: normal; }
.add-filter-button { min-height: 40px; border: 0; border-radius: 8px; padding: 0 13px; background: var(--accent); color: white; font-weight: 750; }
.active-filter-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--border); }
.filter-rule-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 7px 6px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.filter-rule-chip button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 16px; line-height: 1; }
.filter-rule-chip button:hover { background: rgba(0,0,0,.06); }
.filter-empty { color: var(--muted); font-size: 12px; }
@media (max-width: 700px) {
  .filter-builder { grid-template-columns: 1fr 1fr; }
  .add-filter-button { grid-column: 1 / -1; }
}

/* Optional category illustrations */
.category-button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.category-image { display: block; width: 70px; height: 44px; object-fit: contain; margin: 0 0 5px; }
.detail-category-image { width: 150px; height: 94px; object-fit: contain; display: block; margin: 0 0 12px; padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: #fafbf9; }

/* Category entry editor */
.editor-launch-button { min-height: 38px; padding: 0 14px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.editor-launch-button:hover { background: #dfeae1; }
.editor-panel { position: fixed; inset: 0; z-index: 45; pointer-events: none; }
.editor-panel.open { pointer-events: auto; }
.editor-backdrop { position: absolute; inset: 0; background: rgba(24,31,26,.24); opacity: 0; transition: opacity .18s ease; }
.editor-panel.open .editor-backdrop { opacity: 1; }
.editor-sheet { position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 96vw); overflow-y: auto; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -14px 0 36px rgba(20,30,22,.12); transform: translateX(102%); transition: transform .22s ease; }
.editor-panel.open .editor-sheet { transform: translateX(0); }
.category-editor-form { padding: 8px 26px 36px; }
.editor-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; padding: 12px 0 20px; }
.editor-heading h2 { margin: 3px 0 6px; font-family: Georgia, serif; font-size: 30px; }
.editor-heading p, .editor-section-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.editor-actions, .editor-bottom-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.editor-section { padding: 20px 0; border-top: 1px solid var(--border); }
.editor-section h3 { margin: 0 0 12px; font-size: 15px; }
.editor-grid { display: grid; gap: 12px; }
.editor-grid.two { grid-template-columns: 1fr 1fr; }
.editor-grid .wide { grid-column: 1 / -1; }
.category-editor-form label { display: grid; gap: 6px; color: #485149; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .045em; }
.category-editor-form input, .category-editor-form textarea, .category-editor-form select { width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; background: white; color: var(--text); font: inherit; font-size: 14px; text-transform: none; letter-spacing: normal; }
.category-editor-form textarea { resize: vertical; }
.editor-feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 12px; }
.editor-feature-row { display: grid; grid-template-columns: minmax(0,1fr) 150px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #edf0ec; }
.editor-feature-row .feature-name { color: var(--text); font-size: 13px; font-weight: 700; }
.editor-construction-list { display: grid; gap: 9px; }
.editor-construction-row { display: grid; grid-template-columns: minmax(130px,.75fr) 145px minmax(180px,1.2fr); gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #edf0ec; }
.editor-construction-row .feature-name { font-size: 13px; font-weight: 700; }
.primary-editor-button, .secondary-editor-button { min-height: 40px; border-radius: 8px; padding: 0 13px; font-weight: 800; }
.primary-editor-button { border: 1px solid var(--accent); background: var(--accent); color: white; }
.secondary-editor-button { border: 1px solid var(--border); background: white; color: var(--text); }
.editor-message { min-height: 20px; margin: 12px 0; color: var(--accent); font-size: 13px; font-weight: 700; }
.editor-message.error { color: #8a342d; }
.editor-bottom-actions { padding-top: 12px; }
@media (max-width: 650px) {
  .editor-heading { flex-direction: column; }
  .editor-actions { justify-content: flex-start; }
  .editor-grid.two, .editor-feature-grid { grid-template-columns: 1fr; }
  .editor-construction-row { grid-template-columns: 1fr; }
  .category-editor-form { padding-left: 18px; padding-right: 18px; }
}

.editor-mode-section { padding-top: 14px; }
.editor-mode-help { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.category-editor-form input:disabled { background: #f3f5f2; color: #747d75; cursor: not-allowed; }
.detail-edit-button { margin-top: 12px; min-height: 38px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-soft); color: var(--accent); padding: 0 12px; font-weight: 800; }


/* Robust viewport-sticky matrix header. The real table is horizontally scrollable,
   so a synchronized floating copy is used once the original header leaves view. */
.floating-matrix-header {
  position: fixed;
  top: 0;
  z-index: 80;
  display: none;
  overflow: hidden;
  background: #fafbf9;
  border: 1px solid var(--border);
  border-top: 0;
  box-shadow: 0 8px 18px rgba(20,30,22,.10);
}
.floating-matrix-header.visible { display: block; }
.floating-matrix-header-scroll { overflow: hidden; width: 100%; }
.floating-matrix-header table { border-collapse: separate; border-spacing: 0; table-layout: fixed; margin: 0; }
.floating-matrix-header thead th { position: relative; top: auto; z-index: 1; background: #fafbf9; }
.floating-matrix-header thead th:first-child { position: sticky; left: 0; z-index: 3; background: #fafbf9; }

/* Atlas section navigation */
.atlas-nav { display: flex; gap: 5px; margin: 10px 0 13px; }
.atlas-nav a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 750; }
.atlas-nav a:hover { background: var(--surface-soft); color: var(--text); }
.atlas-nav a.active { background: var(--accent-soft); color: var(--accent); }

/* Functors page */
.functor-site-header { align-items: flex-start; }
.functor-main { max-width: 1320px; margin: 0 auto; padding-top: 28px; }
.functor-query-card { padding: clamp(18px,3vw,28px); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.functor-selector-grid { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 20px; align-items: end; }
.category-search-field { display: grid; gap: 8px; color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.functor-input-wrap { position: relative; }
.functor-input-wrap svg { position: absolute; left: 14px; top: 50%; width: 19px; height: 19px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; }
.functor-input-wrap input { width: 100%; min-height: 52px; padding: 11px 14px 11px 43px; border: 1px solid var(--border); border-radius: 10px; background: white; color: var(--text); outline: none; font-size: 16px; }
.functor-input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.functor-input-wrap input[aria-invalid="true"] { border-color: var(--false); box-shadow: 0 0 0 3px var(--false-bg); }
.functor-arrow { padding-bottom: 12px; color: var(--muted); font-family: Georgia,serif; font-size: 30px; }
.functor-query-footer { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--border); }
.query-summary { color: var(--muted); font-size: 13px; }
.query-summary strong { color: var(--text); }
.functor-results-section { margin-top: 28px; }
.functor-results-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 14px; }
.functor-results-heading h2 { margin: 3px 0 0; font-family: Georgia,serif; font-size: 30px; font-weight: 500; }
.functor-text-filter { width: min(390px,100%); }
.functor-text-filter input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); outline: none; }
.functor-text-filter input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.functor-card-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.functor-card { min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.functor-route { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--muted); font-family: Georgia,serif; font-size: 18px; }
.functor-route a { padding: 4px 7px; border-radius: 6px; background: var(--surface-soft); color: var(--accent); text-decoration: none; font-weight: 700; }
.functor-route a:hover { text-decoration: underline; }
.functor-card h3 { margin: 0; font-family: Georgia,serif; font-size: 21px; font-weight: 550; line-height: 1.15; }
.functor-card-title-row { display: flex; gap: 12px; justify-content: space-between; }
.functor-notation { margin-top: 4px; color: var(--accent); font-family: Georgia,serif; font-size: 18px; }
.functor-card p { margin: 12px 0 16px; color: #465047; font-size: 13px; line-height: 1.55; }
.functor-kind-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.functor-kind-tags span { padding: 4px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 750; }
.functor-empty { display: grid; gap: 5px; padding: 40px 20px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); text-align: center; }
.functor-empty strong { color: var(--text); }
@media (max-width: 900px) { .functor-card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 650px) {
  .functor-selector-grid { grid-template-columns: 1fr; gap: 12px; }
  .functor-arrow { display: none; }
  .functor-query-footer, .functor-results-heading { align-items: stretch; flex-direction: column; }
  .functor-card-grid { grid-template-columns: 1fr; }
  .functor-text-filter { width: 100%; }
}


/* Functor atlas table */
.functor-table-shell { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.functor-table-scroll { overflow-x: auto; }
.functor-table { width: 100%; min-width: 1120px; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.functor-table th, .functor-table td { padding: 12px 13px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); vertical-align: middle; background: var(--surface); }
.functor-table thead th { position: sticky; top: 0; z-index: 3; background: #f5f3ed; color: var(--text); font-size: 11px; line-height: 1.25; letter-spacing: .03em; text-transform: uppercase; text-align: center; white-space: nowrap; }
.functor-table thead th:first-child { left: 0; z-index: 5; text-align: left; }
.functor-table tbody tr:last-child th, .functor-table tbody tr:last-child td { border-bottom: 0; }
.functor-table tr > *:last-child { border-right: 0; }
.functor-name-cell { position: sticky; left: 0; z-index: 2; width: 310px; min-width: 310px; text-align: left; background: var(--surface) !important; box-shadow: 1px 0 0 var(--border); }
.functor-name-main { font-family: Georgia,serif; font-size: 17px; font-weight: 600; line-height: 1.15; }
.functor-name-notation { margin-top: 3px; color: var(--accent); font-family: Georgia,serif; font-size: 15px; }
.functor-name-desc { margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.35; font-weight: 400; }
.functor-route-cell { min-width: 155px; text-align: center; white-space: nowrap; font-family: Georgia,serif; font-size: 17px; }
.functor-route-cell a { color: var(--accent); font-weight: 700; text-decoration: none; }
.functor-route-cell a:hover { text-decoration: underline; }
.functor-route-cell span { display: inline-block; margin: 0 6px; color: var(--muted); }
.functor-prop-cell { min-width: 102px; text-align: center; }
.functor-status { display: inline-grid; width: 28px; height: 28px; place-items: center; border-radius: 999px; font-size: 16px; font-weight: 800; }
.functor-status.true { color: var(--true); background: var(--true-bg); }
.functor-status.false { color: var(--false); background: var(--false-bg); }
.functor-status.conditional { color: #8b6717; background: #fbf2d5; }
.functor-status.unknown { color: var(--muted); background: var(--surface-soft); }
@media (max-width: 700px) {
  .functor-name-cell { width: 230px; min-width: 230px; }
  .functor-name-desc { display: none; }
}

/* Functor v13: clickable headers/names and viewport-synced floating header. */
.functor-header-button { width: 100%; min-height: 34px; padding: 4px 5px; border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; border-radius: 6px; }
.functor-header-button:hover, .functor-header-button:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.functor-name-button { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.functor-name-button:hover .functor-name-main, .functor-name-button:focus-visible .functor-name-main { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.functor-name-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.floating-functor-header { display: none; position: fixed; top: 0; z-index: 18; overflow: hidden; border: 1px solid var(--border); border-top: 0; background: #f5f3ed; box-shadow: 0 6px 18px rgba(21,28,22,.12); }
.floating-functor-header.visible { display: block; }
.floating-functor-header-scroll { width: 100%; overflow: hidden; }
.floating-functor-header table { border-collapse: separate; border-spacing: 0; table-layout: fixed; margin: 0; }
.floating-functor-header thead th { position: relative; top: auto; z-index: 1; background: #f5f3ed; }
.floating-functor-header thead th:first-child { position: sticky; left: 0; z-index: 3; background: #f5f3ed; }
.functor-property-breakdown { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.functor-property-breakdown th, .functor-property-breakdown td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.functor-property-breakdown td:last-child { text-align: right; }

/* Functor v14: clickable fact cells and optional header/row images. */
.functor-cell-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 9px; background: transparent; cursor: pointer; }
.functor-cell-button:hover, .functor-cell-button:focus-visible { background: var(--accent-soft); outline: none; }
.functor-cell-button:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.functor-header-button { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.functor-header-image { display: block; width: 54px; height: 34px; object-fit: contain; margin: 0 auto 2px; }
.functor-row-image { display: block; width: 56px; height: 42px; object-fit: contain; margin: 0 0 7px; }
.functor-cell-verdict { display: flex; align-items: center; gap: 9px; margin: 10px 0 16px; }
.functor-cell-verdict strong { font-size: 15px; }
.functor-detail-image { display: block; width: 96px; max-height: 72px; object-fit: contain; margin: 2px 0 12px; }

/* Adjunction atlas */
.adjunction-table { min-width: 1900px; }
.adjunction-table .functor-name-cell { width: 300px; min-width: 300px; }
.adjunction-header-button { display: inline-flex; width: 100%; min-height: 34px; padding: 4px 5px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; align-items: center; justify-content: center; flex-direction: column; gap: 5px; font: inherit; letter-spacing: inherit; text-transform: inherit; }
.adjunction-header-button:hover,.adjunction-header-button:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.adjunction-diagram-cell { min-width: 215px; text-align: center; }
.adjunction-diagram-button { width: 100%; padding: 4px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.adjunction-diagram-button:hover,.adjunction-diagram-button:focus-visible { background: var(--accent-soft); outline: none; }
.adjunction-diagram { position: relative; display: inline-grid; gap: 3px; min-width: 170px; padding: 4px 8px; font-family: Georgia,serif; font-size: 16px; }
.adjunction-diagram > div:first-child { display: flex; align-items: center; justify-content: center; gap: 7px; }
.adjunction-arrow-label { color: var(--accent); font-size: 13px; font-weight: 700; }
.adjunction-arrow { color: var(--muted); }
.adjunction-return { display: flex; justify-content: center; gap: 8px; color: var(--accent); font-size: 13px; }
.adjunction-symbol { position: absolute; right: 4px; top: 24px; color: var(--muted); font-size: 18px; }
.adjunction-info-cell { min-width: 195px; max-width: 240px; }
.adjunction-info-button { display: grid; gap: 5px; width: 100%; padding: 7px; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.adjunction-info-button:hover,.adjunction-info-button:focus-visible { background: var(--accent-soft); outline: none; }
.adjunction-info-symbol { color: var(--accent); font-family: Georgia,serif; font-size: 15px; font-weight: 700; }
.adjunction-info-preview { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.35; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
@media (max-width: 700px) { .adjunction-table .functor-name-cell { width: 230px; min-width: 230px; } }

/* Optional LaTeX / MathJax notation */
.notation-help { display:block; margin-top:.38rem; color:var(--muted, #6c746f); font-size:.78rem; line-height:1.35; }
.notation-help code { font-size:.76rem; }
.notation-preview { display:block; min-height:1.5rem; margin-top:.45rem; padding:.4rem .55rem; border:1px dashed var(--line, #d8ddd9); border-radius:7px; background:#fafbf9; color:var(--ink, #172019); }
.notation-preview:empty { display:none; }
.category-symbol mjx-container, .functor-name-notation mjx-container, .adjunction-diagram-cell mjx-container, .detail-content mjx-container, th mjx-container, td mjx-container { margin:0 !important; }


/* v17: whole-cell truth colouring + optional per-cell images. */
.status-cell.true { background: var(--true-bg); }
.status-cell.false { background: var(--false-bg); }
.status-cell.conditional { background: var(--conditional-bg); }
.status-cell.unknown { background: var(--unknown-bg); }
.status-cell.not_applicable { background: var(--na-bg); }

.status-cell-button {
  background: transparent !important;
  border-radius: 0;
  transition: filter .12s ease, box-shadow .12s ease;
}
.status-cell-button:hover { filter: none; }
@media (hover: hover) and (pointer: fine) {
  .status-cell { transition: background-color .14s ease; }
  .status-cell.true:hover { background: var(--true-bg-hover); }
  .status-cell.false:hover { background: var(--false-bg-hover); }
  .status-cell.conditional:hover { background: var(--conditional-bg-hover); }
  .status-cell.unknown:hover { background: var(--unknown-bg-hover); }
  .status-cell.not_applicable:hover { background: var(--na-bg-hover); }
}
.status-cell-button:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 3px var(--accent);
}

.status-symbol {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 28px;
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
  background: transparent;
}
.status-symbol.true { color: var(--true); }
.status-symbol.false { color: var(--false); }
.status-symbol.conditional { color: var(--conditional); }
.status-symbol.unknown { color: var(--unknown); }
.status-symbol.not_applicable { color: var(--na); }

.cell-status-image {
  display: block;
  width: 42px;
  height: 32px;
  object-fit: contain;
  margin: 0 auto 3px;
}

/* Let truth-valued functor/adjunction buttons fill the coloured cell. */
.functor-prop-cell.status-cell { padding: 0; }
.functor-prop-cell.status-cell .functor-cell-button {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 66px;
  padding: 7px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* The old circular status badges remain useful in detail panels, but not in table cells. */
.status-cell .status-chip,
.status-cell .functor-status { border-radius: 0; background: transparent; }

.atlas-tabs { flex-wrap: wrap; max-width: 100%; }
.atlas-tabs button { white-space: nowrap; }


/* v24: in-browser editing for cells and row/column headings */
.empty-editable-cell { background: #fbfcfa; }
.empty-cell-button:hover { background: var(--surface-soft); }
.empty-cell-button:hover .empty-cell { color: var(--accent); }
.detail-cell-image { display:block; width:150px; height:94px; object-fit:contain; margin:0 0 12px; padding:9px; border:1px solid var(--border); border-radius:10px; background:#fafbf9; }
.detail-edit-button {
  margin-top: 22px; border: 0; border-radius: 9px; background: var(--accent); color: white;
  padding: 10px 14px; font-weight: 750;
}
.detail-edit-button:hover { filter: brightness(.94); }
.secondary-detail-edit { margin-left: 8px; background: var(--surface-soft); color: var(--accent); border: 1px solid var(--border); }
.inline-editor { display: grid; gap: 15px; margin-top: 20px; }
.inline-editor > label { display: grid; gap: 6px; font-size: 12px; font-weight: 750; color: #3f493f; }
.inline-editor input[type="text"], .inline-editor input:not([type]), .inline-editor input[type="file"],
.inline-editor textarea, .inline-editor select {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; background: white; color: var(--text);
  padding: 10px 11px; font: inherit; font-size: 13px;
}
.inline-editor textarea { resize: vertical; line-height: 1.45; }
.inline-editor input:focus, .inline-editor textarea:focus, .inline-editor select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.inline-editor-hint { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: #365146; font-size: 12px; line-height: 1.5; }
.image-editor-block { border-top: 1px solid var(--border); padding-top: 14px; display: grid; gap: 9px; }
.image-editor-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; }
.inline-image-preview { width: 150px; height: 95px; object-fit: contain; border: 1px solid var(--border); border-radius: 9px; padding: 7px; background: #fafbf9; }
.checkbox-editor { display:flex !important; grid-template-columns:none !important; align-items:center; gap:8px !important; font-weight:500 !important; }
.checkbox-editor input { width:auto !important; }
.inline-editor-actions { display:flex; justify-content:flex-end; gap:8px; padding-top: 5px; }
.inline-editor-message { min-height: 18px; color: var(--accent); font-size: 12px; }
.inline-editor-message.error { color: var(--false); }
.muted-editor-copy { margin:0; color:var(--muted); font-size:12px; line-height:1.5; }

/* v25: category-row images sit to the right of the category label */
.category-button-horizontal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.category-text-wrap {
  min-width: 0;
  flex: 1 1 auto;
}
.category-image-right {
  flex: 0 0 auto;
  width: 54px;
  height: 42px;
  object-fit: contain;
  margin: 0;
}

/* v26: force category label + image into one horizontal row. */
.category-button.category-button-horizontal {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.category-button.category-button-horizontal .category-text-wrap {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
}
.category-button.category-button-horizontal .category-image-right {
  display: block;
  flex: 0 0 54px;
  width: 54px;
  height: 42px;
  margin: 0 0 0 8px;
  object-fit: contain;
  align-self: center;
}


/* v27: persistent save button */
.save-button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 750;
}
.save-button:hover { background: #183f33; color: #fff; }
.save-button:disabled { opacity: .68; cursor: wait; }


/* v28: table control layout */
.table-action-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin: 0 0 10px;
}
.table-tab-row {
  margin: 0 0 8px;
}
.table-tab-row .atlas-tabs {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
}
.matrix-meta { display: none !important; }

/* Hover polish for group tabs */
.segmented button {
  transition: background-color .14s ease, color .14s ease, box-shadow .14s ease;
}
@media (hover: hover) and (pointer: fine) {
  .segmented button:hover {
    background: #e6ebe6;
    color: var(--accent);
  }
  .segmented button.active:hover {
    background: #f7faf7;
  }
}

/* Hover polish for every category-name cell */
tbody th[scope="row"] {
  transition: background-color .14s ease;
}
@media (hover: hover) and (pointer: fine) {
  tbody th[scope="row"]:hover {
    background: #f8faf7;
  }
  tbody th[scope="row"]:hover .category-button {
    background: transparent;
  }
}

/* Consistent notation underline for every category, including MathJax-rendered notation */
.category-symbol {
  width: fit-content;
  border-bottom: 1px solid transparent;
  transition: border-color .14s ease, color .14s ease;
}
@media (hover: hover) and (pointer: fine) {
  .category-button:hover .category-symbol {
    color: var(--accent);
    border-bottom-color: currentColor;
    text-decoration: none;
  }
}


/* v29: consolidated top navigation and category action bar */
.atlas-brand-header {
  align-items: center;
}
.atlas-brand-copy {
  min-width: 0;
}
.atlas-brand-header h1 {
  margin-top: 0;
}
.atlas-nav-right {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: center;
}
.atlas-nav-right a {
  white-space: nowrap;
}

.table-action-row-full {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.table-action-search-group,
.table-action-button-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.table-action-search-group {
  flex: 1 1 420px;
  min-width: 280px;
}
.table-action-button-group {
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.table-search-wrap {
  flex: 1 1 360px;
  min-width: 240px;
  max-width: 620px;
}
.action-toggle {
  min-height: 44px;
  padding: 0 5px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .atlas-brand-header {
    align-items: flex-start;
  }
  .atlas-nav-right {
    margin-left: 0;
    align-self: auto;
  }
  .table-action-search-group,
  .table-action-button-group {
    width: 100%;
  }
  .table-action-button-group {
    justify-content: flex-start;
  }
}


/* v30 — unified rich info-box editor */
.rich-edit-launch {
  margin-top: 24px;
  border: 1px solid var(--border);
  background: #f7f8f6;
  border-radius: 8px;
  padding: 9px 13px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.rich-edit-launch:hover { background: #ecefeb; }
.rich-editor-overlay[hidden] { display: none; }
.rich-editor-overlay { position: fixed; inset: 0; z-index: 1200; }
.rich-editor-backdrop { position: absolute; inset: 0; background: rgba(20,28,24,.42); }
.rich-editor-dialog {
  position: absolute; inset: 4vh 4vw; max-width: 1120px; margin: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 22px 70px rgba(0,0,0,.22); display: flex; flex-direction: column; overflow: hidden;
}
.rich-editor-head { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:16px 18px; border-bottom:1px solid var(--border); }
.rich-editor-head strong { display:block; font-size:18px; }
.rich-editor-head span { display:block; margin-top:3px; color:var(--muted); font-size:13px; }
.rich-toolbar { display:flex; flex-wrap:wrap; gap:6px; padding:10px 14px; border-bottom:1px solid var(--border); background:#fafbf9; }
.rich-toolbar button, .rich-toolbar select, .rich-image-button {
  border:1px solid var(--border); background:#fff; border-radius:6px; padding:7px 10px; font:inherit; cursor:pointer;
}
.rich-toolbar button:hover, .rich-image-button:hover { background:#eef2ee; }
.rich-latex-help { padding:8px 16px; font-size:12px; color:var(--muted); background:#fbfcfb; border-bottom:1px solid var(--border); }
.rich-editable {
  flex:1 1 auto; min-height:360px; overflow:auto; padding:28px 34px; outline:none;
  font-size:15px; line-height:1.65;
}
.rich-editable:focus { box-shadow: inset 0 0 0 2px rgba(38,92,72,.18); }
.rich-editable img, .detail-content img { max-width:100%; height:auto; }
.rich-editable h1 { font-size:30px; line-height:1.2; }
.rich-editable h2 { font-size:23px; line-height:1.25; }
.rich-editable h3 { font-size:18px; line-height:1.3; }
.rich-editor-actions { display:flex; justify-content:flex-end; gap:8px; padding:12px 16px; border-top:1px solid var(--border); background:#fafbf9; }
@media (max-width:700px) {
  .rich-editor-dialog { inset: 2vh 2vw; }
  .rich-editable { padding:20px 18px; }
}

/* v31: live-site save state */
.save-button { min-width: 108px; }


/* v32 — optional dark mode */
.theme-toggle { border:1px solid var(--border); background:var(--surface); color:var(--text); border-radius:8px; padding:7px 10px; font:inherit; font-size:12px; white-space:nowrap; }
.theme-toggle:hover { background:var(--surface-soft); }
html[data-theme="dark"] {
  --bg:#111512; --surface:#181d19; --surface-soft:#202620; --text:#edf1ed; --muted:#aab5ab; --border:#354038; --accent:#8fc7ad; --accent-soft:#243c31;
  --true:#83d4aa; --true-bg:#173526; --true-bg-hover:#1d4430;
  --false:#e59a96; --false-bg:#3b2221; --false-bg-hover:#4a2927;
  --conditional:#e7c66e; --conditional-bg:#3a3118; --conditional-bg-hover:#493d1d;
  --unknown:#b3c0c9; --unknown-bg:#293138; --unknown-bg-hover:#323c44;
  --na:#b7b7b7; --na-bg:#292b29; --na-bg-hover:#343634;
  --shadow:0 18px 50px rgba(0,0,0,.36);
}
html[data-theme="dark"] body, html[data-theme="dark"] .site-header { background-color:var(--bg); }
html[data-theme="dark"] .site-header { background:rgba(24,29,25,.92); }
html[data-theme="dark"] thead th, html[data-theme="dark"] .matrix-meta, html[data-theme="dark"] .rich-toolbar, html[data-theme="dark"] .rich-latex-help, html[data-theme="dark"] .rich-editor-actions { background:var(--surface-soft); }
html[data-theme="dark"] .rich-editor-dialog, html[data-theme="dark"] .detail-sheet, html[data-theme="dark"] .editor-sheet, html[data-theme="dark"] input, html[data-theme="dark"] textarea, html[data-theme="dark"] select { background:var(--surface); color:var(--text); }
html[data-theme="dark"] tbody th[scope="row"] { background:var(--surface); }
html[data-theme="dark"] tbody th[scope="row"]:hover { background:var(--surface-soft); }
html[data-theme="dark"] a { color:#a7d6c0; }
html[data-theme="dark"] code { color:#dce9df; }

/* v32 — table-cell/heading image manager inside the unified editor */
.rich-cell-image-manager { display:flex; justify-content:space-between; align-items:center; gap:18px; padding:12px 16px; border-bottom:1px solid var(--border); background:var(--surface-soft); }
.rich-cell-image-manager > div:first-child span { display:block; margin-top:3px; color:var(--muted); font-size:12px; }
.rich-cell-image-controls { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.rich-cell-image-controls img { width:64px; height:42px; object-fit:contain; border:1px solid var(--border); border-radius:6px; background:var(--surface); }
.rich-cell-image-controls button { border:1px solid var(--border); background:var(--surface); color:var(--text); border-radius:6px; padding:7px 10px; }
.rich-cell-image-controls button:disabled { opacity:.45; cursor:default; }
@media(max-width:700px){ .rich-cell-image-manager{align-items:flex-start;flex-direction:column}.rich-cell-image-controls{flex-wrap:wrap} }
.functor-route-button { width:100%; min-height:100%; border:0; background:transparent; color:var(--text); display:flex; align-items:center; justify-content:center; gap:8px; padding:10px; }
.functor-route-button:hover { background:var(--surface-soft); }

/* v33 — dark-mode contrast and floating-header polish */
html[data-theme="dark"] .floating-matrix-header,
html[data-theme="dark"] .floating-functor-header {
  background: var(--surface-soft);
  border-color: var(--border);
  box-shadow: 0 6px 18px rgba(0,0,0,.32);
}
html[data-theme="dark"] .floating-matrix-header thead th,
html[data-theme="dark"] .floating-matrix-header thead th:first-child,
html[data-theme="dark"] .floating-functor-header thead th,
html[data-theme="dark"] .floating-functor-header thead th:first-child,
html[data-theme="dark"] .functor-table thead th {
  background: var(--surface-soft) !important;
  color: var(--text);
}

/* Small secondary text inside table cells needs high contrast in dark mode. */
html[data-theme="dark"] .cell-value,
html[data-theme="dark"] .descriptive-value,
html[data-theme="dark"] .category-name,
html[data-theme="dark"] .functor-name-desc,
html[data-theme="dark"] .adjunction-info-preview,
html[data-theme="dark"] .functor-route-cell span,
html[data-theme="dark"] .empty-cell {
  color: #edf1ed !important;
}

/* Detail panels: remove remaining light-only surfaces. */
html[data-theme="dark"] .detail-topbar {
  background: rgba(24,29,25,.97);
  color: var(--text);
}
html[data-theme="dark"] .detail-section p,
html[data-theme="dark"] .reference-list,
html[data-theme="dark"] .tag-list span,
html[data-theme="dark"] .formula {
  color: var(--text);
}
html[data-theme="dark"] .formula,
html[data-theme="dark"] .tag-list span {
  background: var(--surface-soft);
}
html[data-theme="dark"] .rich-edit-launch {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .rich-edit-launch:hover { background: #2b342d; }

/* Unified info-box editor and every formatting/image/cancel control. */
html[data-theme="dark"] .rich-editor-dialog,
html[data-theme="dark"] .rich-editor-head,
html[data-theme="dark"] .rich-editable {
  background: var(--surface);
  color: var(--text);
}
html[data-theme="dark"] .rich-editor-head,
html[data-theme="dark"] .rich-toolbar,
html[data-theme="dark"] .rich-latex-help,
html[data-theme="dark"] .rich-editor-actions,
html[data-theme="dark"] .rich-cell-image-manager {
  border-color: var(--border);
}
html[data-theme="dark"] .rich-toolbar button,
html[data-theme="dark"] .rich-toolbar select,
html[data-theme="dark"] .rich-image-button,
html[data-theme="dark"] .secondary-editor-button,
html[data-theme="dark"] .rich-cell-image-controls button {
  background: #242b25;
  color: var(--text);
  border-color: #465249;
}
html[data-theme="dark"] .rich-toolbar button:hover,
html[data-theme="dark"] .rich-image-button:hover,
html[data-theme="dark"] .secondary-editor-button:hover,
html[data-theme="dark"] .rich-cell-image-controls button:hover:not(:disabled) {
  background: #303a32;
}
html[data-theme="dark"] .primary-editor-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #101713;
}
html[data-theme="dark"] .primary-editor-button:hover { filter: brightness(1.08); }
html[data-theme="dark"] .rich-editable:focus { box-shadow: inset 0 0 0 2px rgba(143,199,173,.25); }

/* Older category/inline editor controls, for visual consistency when opened in dark mode. */
html[data-theme="dark"] .filter-builder select,
html[data-theme="dark"] .category-editor-form input,
html[data-theme="dark"] .category-editor-form textarea,
html[data-theme="dark"] .category-editor-form select,
html[data-theme="dark"] .functor-input-wrap input,
html[data-theme="dark"] .inline-editor input,
html[data-theme="dark"] .inline-editor textarea,
html[data-theme="dark"] .inline-editor select {
  background: #202620;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .category-editor-form label,
html[data-theme="dark"] .inline-editor > label { color: var(--muted); }


/* v34: structured truth selector + dark-mode unentered cells + rotating quote. */
.rich-truth-manager { display:flex; align-items:center; justify-content:space-between; gap:18px; padding:12px 16px; border-bottom:1px solid var(--border); background:var(--surface-soft); }
.rich-truth-manager > div { display:grid; gap:3px; }
.rich-truth-manager span { color:var(--muted); font-size:12px; }
.rich-truth-manager select { min-width:150px; }
.atlas-quote { max-width:920px; }
.quote-text { font-family:Georgia,serif; font-style:italic; }
.quote-attribution { color:var(--muted); white-space:nowrap; }
html[data-theme="dark"] td.empty-editable-cell { background:#171d1a !important; }
html[data-theme="dark"] td.empty-editable-cell:hover { background:#1d2521 !important; }
html[data-theme="dark"] .empty-cell-button { color:#8f9b94 !important; background:transparent !important; }
html[data-theme="dark"] .rich-truth-manager { background:var(--surface-soft); color:var(--text); }
@media (max-width:650px){ .rich-truth-manager{align-items:stretch;flex-direction:column;gap:8px}.rich-truth-manager select{width:100%}.quote-attribution{white-space:normal;} }


/* v35: dark descriptive-cell hover consistency. */
html[data-theme="dark"] td.descriptive-cell:hover,
html[data-theme="dark"] td.descriptive-cell:has(.cell-button:hover) {
  background: #1d2521 !important;
}
html[data-theme="dark"] td.descriptive-cell .cell-button:hover,
html[data-theme="dark"] td.descriptive-cell .cell-button:focus-visible {
  background: transparent !important;
  color: var(--text) !important;
}

/* v36: descriptive Objects/Morphisms interaction states stay dark. */
html[data-theme="dark"] .matrix-table td:has(> .cell-button.descriptive-cell) {
  background: var(--surface) !important;
}
html[data-theme="dark"] .matrix-table td:has(> .cell-button.descriptive-cell):hover,
html[data-theme="dark"] .matrix-table td:has(> .cell-button.descriptive-cell:focus-visible),
html[data-theme="dark"] .matrix-table td:has(> .cell-button.descriptive-cell:active) {
  background: #1d2521 !important;
}
html[data-theme="dark"] .cell-button.descriptive-cell,
html[data-theme="dark"] .cell-button.descriptive-cell:hover,
html[data-theme="dark"] .cell-button.descriptive-cell:focus,
html[data-theme="dark"] .cell-button.descriptive-cell:focus-visible,
html[data-theme="dark"] .cell-button.descriptive-cell:active {
  background: transparent !important;
  color: var(--text) !important;
}

/* v36: the table-cell image is also the default hero image in its info box. */
.detail-cell-hero-image {
  display: block;
  width: min(260px, 42%);
  max-height: 210px;
  object-fit: contain;
  object-position: left top;
  margin: 0 18px 14px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}
@media (max-width: 650px) { .detail-cell-hero-image { width: min(220px, 65%); } }

/* v38 PWA install control */
.pwa-install-button[hidden]{display:none!important}.pwa-install-button:disabled{opacity:.72;cursor:pointer}

/* v39 accounts and permissions */
.auth-modal[hidden]{display:none}.auth-modal{position:fixed;inset:0;z-index:10000;display:grid;place-items:center}.auth-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.48)}.auth-card{position:relative;width:min(520px,calc(100vw - 28px));max-height:88vh;overflow:auto;background:var(--surface,#fff);color:var(--text,#17201d);border:1px solid var(--border,#d8dfdb);border-radius:16px;padding:24px;box-shadow:0 24px 70px rgba(0,0,0,.25)}.auth-card form{display:grid;gap:8px;margin:12px 0 20px}.auth-card input,.auth-card select{padding:10px;border:1px solid var(--border,#ccd5d0);border-radius:8px;background:var(--surface,#fff);color:inherit}.auth-close{position:absolute;right:12px;top:12px}.auth-card [data-user-list]{display:grid;gap:8px}.auth-card [data-user-list] label{display:flex;justify-content:space-between;gap:12px;align-items:center}.rich-display-text{display:grid;gap:6px;margin:12px 0}.rich-display-text input{padding:9px;border-radius:8px;border:1px solid var(--border,#ccd5d0);background:var(--surface,#fff);color:inherit}
html[data-can-edit="false"] .editor-launch-button,html[data-can-edit="false"] .save-button{display:none!important}

/* v40 global account control + signed-in profile */
[data-auth-button]{
  position:fixed!important;top:10px!important;right:12px!important;z-index:10020!important;
  display:flex;align-items:center;gap:7px;max-width:220px;
}
.auth-button-avatar{width:24px;height:24px;border-radius:50%;object-fit:cover}
.site-header,.topbar,.page-header{padding-right:125px}
.profile-head{display:flex;align-items:center;gap:16px;margin:6px 0 18px}
.profile-avatar-button{width:82px;height:82px;border-radius:50%;overflow:hidden;padding:0;display:grid;place-items:center;font-size:28px}
.profile-avatar-button img{width:100%;height:100%;object-fit:cover}
.profile-role{text-transform:capitalize;opacity:.7;margin-top:-6px}
.profile-photo-link{padding:0;border:0;background:transparent;text-decoration:underline;font-size:.88rem}
.profile-bio-label{display:grid;gap:6px;margin:12px 0}
.profile-bio-label textarea{width:100%;resize:vertical}
.profile-stats{margin:18px 0;padding:12px 0;border-top:1px solid var(--border,#d9ddda);border-bottom:1px solid var(--border,#d9ddda)}
.profile-stats>div{display:flex;justify-content:space-between;gap:20px;padding:5px 0}
@media(max-width:700px){[data-auth-button]{top:7px!important;right:7px!important}.site-header,.topbar,.page-header{padding-right:100px}}

/* v41 account appearance + advanced table option */
.account-setting-row{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:8px 0 14px;margin-bottom:10px;border-bottom:1px solid var(--border,#d9ddda)}
.account-setting-row .theme-toggle{position:static!important;inset:auto!important}
.advanced-filter-options{margin-top:12px;padding-top:12px;border-top:1px solid var(--border,#d9ddda)}

/* v42 admin-only info-box revision history */
.rich-history-launch{margin-left:8px}
.rich-history-dialog{max-width:820px}
.rich-history-list{max-height:68vh;overflow:auto;padding:4px 2px}
.history-entry{padding:14px 0;border-bottom:1px solid var(--border,#d9ddda)}
.history-meta{display:flex;justify-content:space-between;gap:16px;align-items:baseline}
.history-meta time{font-size:.86rem;opacity:.72}
.history-display-text{margin:7px 0;font-size:.9rem}
.history-revision{margin-top:10px;padding:14px;border:1px solid var(--border,#d9ddda);border-radius:8px}

/* v43 record/property creation */
.record-action-row{display:flex;justify-content:flex-end;gap:8px;margin:0 0 12px}
.record-editor-overlay{position:fixed;inset:0;z-index:11000;display:grid;place-items:center;padding:20px}
.record-editor-card{position:relative;z-index:1;width:min(560px,94vw);max-height:86vh;overflow:auto;background:var(--surface,#fff);border:1px solid var(--border,#d9ddda);border-radius:12px;padding:22px;box-shadow:0 18px 60px rgba(0,0,0,.22)}
.record-editor-card form{display:grid;gap:12px}.record-editor-card label{display:grid;gap:5px}.record-editor-card input,.record-editor-card select,.record-editor-card textarea{width:100%}.record-editor-x{position:absolute;right:12px;top:10px}

/* v44 simplified auth + admin activity page */
.auth-mode-switch{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:10px}.auth-mode-switch button.active{font-weight:700;border-color:currentColor}
.admin-page-link{display:block;text-align:center;margin:10px 0 16px;padding:10px;border:1px solid var(--border,#d9ddda);border-radius:8px;text-decoration:none;font-weight:700}
.admin-main{width:min(1050px,calc(100% - 32px));margin:70px auto 60px}.admin-intro{opacity:.75}.admin-audit-toolbar{display:flex;justify-content:space-between;align-items:center;gap:16px;margin:24px 0}.admin-audit-toolbar input{width:min(520px,100%)}
.admin-audit-feed{border-top:1px solid var(--border,#d9ddda)}.admin-audit-entry{display:grid;grid-template-columns:12px 1fr;gap:14px;padding:16px 4px;border-bottom:1px solid var(--border,#d9ddda)}.audit-dot{width:8px;height:8px;border-radius:50%;background:currentColor;margin-top:7px;opacity:.5}.audit-line{display:flex;flex-wrap:wrap;gap:5px}.audit-label{font-family:monospace}.admin-audit-entry time{display:block;font-size:.84rem;opacity:.65;margin-top:4px}.audit-detail{font-size:.88rem;margin-top:5px;opacity:.8}

/* v45 admin navigation and users */
.admin-page .atlas-nav>a{display:inline-flex;align-items:center;justify-content:center;padding:8px 13px;border:1px solid var(--border,#d9ddda);border-radius:8px;text-decoration:none;background:var(--surface,#fff)}
.admin-page .atlas-nav>a:hover{transform:translateY(-1px)}
.admin-section-nav{display:inline-flex;gap:5px;padding:4px;border:1px solid var(--border,#d9ddda);border-radius:10px;margin-bottom:28px}
.admin-section-nav a{padding:8px 18px;border-radius:7px;text-decoration:none}.admin-section-nav a.active{font-weight:700;background:rgba(127,127,127,.14)}
.admin-user-grid{display:grid;gap:12px}.admin-user-card{display:grid;grid-template-columns:74px 1fr;gap:18px;padding:18px;border:1px solid var(--border,#d9ddda);border-radius:12px}
.admin-user-avatar{width:74px;height:74px;border-radius:50%;object-fit:cover}.admin-user-avatar-empty{display:grid;place-items:center;border:1px solid var(--border,#d9ddda);font-size:1.5rem;font-weight:700}
.admin-user-title{display:flex;align-items:center;justify-content:space-between;gap:16px}.admin-user-title h2{margin:0;font-size:1.15rem}.admin-user-title select{width:auto}.admin-user-bio{margin:7px 0 14px;white-space:pre-wrap}
.admin-user-stats{display:flex;flex-wrap:wrap;gap:24px}.admin-user-stats span{display:grid;gap:2px;font-size:.9rem}.admin-user-stats b{font-size:.75rem;text-transform:uppercase;letter-spacing:.04em;opacity:.65}
@media(max-width:650px){.admin-user-card{grid-template-columns:52px 1fr}.admin-user-avatar{width:52px;height:52px}.admin-user-title{align-items:flex-start;flex-direction:column}.admin-user-stats{gap:14px}}

/* v46 readable, clickable audit revisions */
.audit-entry-button,.history-entry-button{display:block;width:100%;padding:0;border:0;background:transparent;color:inherit;text-align:left;cursor:pointer}
.audit-entry-button:hover .audit-line,.history-entry-button:hover strong{text-decoration:underline}
.audit-change-view,.history-change-view{margin-top:12px}.audit-compare{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.audit-compare>section{min-width:0;padding:12px;border:1px solid var(--border,#d9ddda);border-radius:8px;overflow:auto}.audit-compare h3{margin:0 0 9px;font-size:.82rem;text-transform:uppercase;letter-spacing:.05em}
.new-content,.audit-added{background:color-mix(in srgb,#72c98b 14%,transparent)}.new-content{box-shadow:inset 3px 0 #4a9d63}.audit-change-view pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:.82rem}
@media(max-width:700px){.audit-compare{grid-template-columns:1fr}}

/* v48 account and revision-history polish */
.auth-card{padding-top:30px}
.auth-card .account-setting-row{padding-right:44px}
.account-action-button{width:100%;box-sizing:border-box;cursor:pointer;font:inherit;color:inherit;background:var(--surface,#fff);margin:8px 0}
.account-action-button:hover,.account-mode-button:hover,.rich-history-launch:hover{transform:translateY(-1px)}
.auth-mode-switch{margin-top:8px}
.account-mode-button{padding:9px 12px;border:1px solid var(--border,#d9ddda);border-radius:8px;background:var(--surface,#fff);color:inherit;cursor:pointer;font:inherit}
.account-mode-button.active{font-weight:700;box-shadow:inset 0 -2px currentColor}
.profile-photo-link{display:none!important}
.rich-history-launch.admin-page-link{display:inline-flex;width:auto;margin:8px 0 8px 8px;padding:7px 11px;cursor:pointer;background:var(--surface,#fff);color:inherit}
.rich-history-list .admin-audit-entry{padding:14px 4px}
.rich-history-list .audit-entry-button{font:inherit}
.rich-history-list .history-revision{border:0;padding:0;margin:0}

/* v49 profile field, theme alignment and MathJax-ready admin revisions */
.auth-card{padding-top:22px}
.account-setting-row-top{display:grid!important;grid-template-columns:1fr auto 34px;align-items:center;gap:9px;padding-right:0!important;margin-bottom:16px;min-height:34px}
.account-setting-row-top>span{align-self:center}
.account-setting-row-top .theme-toggle{align-self:center;margin:0}
.auth-close-inline{position:static!important;align-self:center;justify-self:end;margin:0!important;width:34px;height:34px;display:grid;place-items:center}
.profile-bio-label{gap:7px!important}
.profile-bio-label textarea{box-sizing:border-box;width:100%;resize:vertical;min-height:104px;padding:11px 12px;border:1px solid var(--border,#d9ddda);border-radius:10px;background:var(--surface,#fff);color:inherit;font:inherit;line-height:1.45;outline:none;box-shadow:inset 0 1px 2px rgba(0,0,0,.025);transition:border-color .15s ease,box-shadow .15s ease}
.profile-bio-label textarea:hover{border-color:color-mix(in srgb,currentColor 35%,var(--border,#d9ddda))}
.profile-bio-label textarea:focus{border-color:currentColor;box-shadow:0 0 0 3px color-mix(in srgb,currentColor 10%,transparent)}

/* v50 simplified Categories controls */
.table-tab-row{margin-bottom:10px}
.table-action-row-full{justify-content:flex-start}
.table-action-search-group{width:100%;display:flex;align-items:center;gap:8px}
.table-search-wrap{flex:1;max-width:none}
.advanced-filter-actions{display:grid;gap:8px;margin-top:12px;padding-top:12px;border-top:1px solid var(--border,#d9ddda)}
.advanced-filter-actions button{width:100%;justify-content:center}

/* v51 */
.functor-search-cog-row{display:flex;align-items:center;gap:8px;min-width:min(100%,540px)}.functor-search-cog-row .functor-text-filter{flex:1;min-width:0}.atlas-secondary-cog{position:relative;flex:0 0 auto}.functor-results-heading{align-items:flex-end}@media(max-width:720px){.functor-search-cog-row{width:100%;min-width:0}.functor-results-heading{align-items:stretch}}

/* v54 compact navigation and polished admin controls */
.site-header.atlas-brand-header{padding-top:10px;padding-bottom:10px}
.admin-page .atlas-nav>a{
  border:0;
  border-radius:0;
  background:transparent;
  padding:6px 8px;
}
.admin-page .atlas-nav>a:hover{transform:none}

.admin-audit-toolbar input[type="search"],
.admin-user-title select{
  appearance:none;
  -webkit-appearance:none;
  box-sizing:border-box;
  border:1px solid var(--border,#d9ddda);
  border-radius:10px;
  background:var(--surface,#fff);
  color:inherit;
  font:inherit;
  outline:none;
  box-shadow:inset 0 1px 2px rgba(0,0,0,.025);
  transition:border-color .15s ease,box-shadow .15s ease,background .15s ease;
}
.admin-audit-toolbar input[type="search"]{
  min-height:42px;
  padding:9px 13px;
}
.admin-audit-toolbar input[type="search"]::placeholder{color:inherit;opacity:.48}
.admin-audit-toolbar input[type="search"]:hover,
.admin-user-title select:hover{border-color:color-mix(in srgb,currentColor 35%,var(--border,#d9ddda))}
.admin-audit-toolbar input[type="search"]:focus,
.admin-user-title select:focus{
  border-color:currentColor;
  box-shadow:0 0 0 3px color-mix(in srgb,currentColor 10%,transparent);
}
.admin-user-title select{
  min-height:38px;
  padding:7px 34px 7px 11px;
  background-image:
    linear-gradient(45deg,transparent 50%,currentColor 50%),
    linear-gradient(135deg,currentColor 50%,transparent 50%);
  background-position:calc(100% - 16px) 50%,calc(100% - 11px) 50%;
  background-size:5px 5px,5px 5px;
  background-repeat:no-repeat;
}

/* v55 */
.site-header.atlas-brand-header{padding-top:14px}
.audit-reverse-row{margin-top:12px;display:flex;justify-content:flex-end}
.audit-reverse-button{border:1px solid var(--border,#d9ddda);border-radius:8px;background:var(--surface,#fff);color:inherit;font:inherit;font-weight:700;padding:7px 11px;cursor:pointer}
.audit-reverse-button:hover{background:color-mix(in srgb,currentColor 6%,var(--surface,#fff))}
.audit-reverse-button:disabled{opacity:.5;cursor:default}

/* v56 spacing refinements */
.site-header.atlas-brand-header{padding-top:17px}
.admin-main{margin-top:34px}

/* v59 per-cell engagement statistics */
.rich-history-head{display:grid;grid-template-columns:minmax(180px,1fr) auto auto;align-items:start;gap:18px}
.rich-history-stats{display:flex;gap:22px;align-items:flex-start;justify-content:flex-end}
.rich-history-stats span{display:grid;gap:2px;text-align:right;min-width:68px}
.rich-history-stats b{font-size:1rem;font-variant-numeric:tabular-nums}
.rich-history-stats small{font-size:.72rem;opacity:.58;white-space:nowrap}
@media(max-width:700px){.rich-history-head{grid-template-columns:1fr auto}.rich-history-stats{grid-column:1/-1;justify-content:flex-start}.rich-history-stats span{text-align:left}}
/* v60 clickable read-only author profiles */
.audit-user-link{display:inline-flex;align-items:center;gap:7px;border:0;background:transparent;color:inherit;font:inherit;padding:0;cursor:pointer;vertical-align:middle}
.audit-user-link:hover strong{text-decoration:underline;text-underline-offset:2px}
.audit-user-avatar{width:24px;height:24px;border-radius:50%;display:inline-grid;place-items:center;overflow:hidden;background:var(--surface-2,#ecefed);font-size:.72rem;font-weight:700;flex:0 0 24px}
.audit-user-avatar img{width:100%;height:100%;object-fit:cover}
.public-profile-card{position:relative;max-width:430px}
.public-profile-close{position:absolute;right:14px;top:14px}
.public-profile-head{display:flex;align-items:center;gap:14px;padding-right:36px;margin-bottom:16px}
.public-profile-head h2{margin:0 0 3px}
.public-profile-avatar{width:62px;height:62px;border-radius:50%;object-fit:cover;display:grid;place-items:center;flex:0 0 62px}
.public-profile-fallback{background:var(--surface-2,#ecefed);font-size:1.35rem;font-weight:700}
.public-profile-bio{white-space:pre-wrap;line-height:1.55;margin:10px 0 18px}

/* v61 valid audit/profile interaction */
.audit-entry-button[role="button"]{cursor:pointer}
.audit-entry-button[role="button"]:focus-visible{outline:2px solid currentColor;outline-offset:3px}
.audit-user-link{position:relative;z-index:1}

/* v63: never paint the install control inside an installed PWA. */
@media (display-mode: standalone){.pwa-install-button{display:none!important}}

/* v64 admin Views ranking */
.admin-view-entry>div:last-child{width:100%}.admin-view-row{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:14px 4px}.admin-view-total{font-variant-numeric:tabular-nums;white-space:nowrap;color:var(--muted,#68736d)}

/* v65 Popular admin ranking */
.popular-tabs{width:max-content;max-width:100%;margin:18px 0 8px}.popular-tabs button{white-space:nowrap}

/* v68 cell discussions */
.comment-dialog{width:min(760px,calc(100vw - 28px))}.cell-comment-list{display:grid;gap:12px;max-height:58vh;overflow:auto;padding:4px 2px 14px}.cell-comment{border:1px solid var(--border);border-radius:12px;padding:12px;background:var(--surface)}.cell-comment-reply{margin:12px 0 0 28px;background:var(--surface-soft)}.cell-comment header{display:flex;justify-content:space-between;align-items:center;gap:12px}.comment-user{border:0;background:none;color:inherit;padding:0;display:inline-flex;align-items:center;gap:8px;cursor:pointer}.comment-user .audit-user-avatar{width:28px;height:28px}.cell-comment time{font-size:.8rem;color:var(--muted)}.comment-body{margin:10px 0;line-height:1.55}.comment-reply-button{border:0;background:none;padding:0;color:var(--accent);cursor:pointer;font:inherit;font-size:.86rem}.comment-composer{border-top:1px solid var(--border);padding-top:14px}.comment-composer textarea{width:100%;min-height:92px;resize:vertical;padding:10px;border:1px solid var(--border);border-radius:9px;background:var(--surface);color:var(--text);font:inherit}.comment-compose-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:8px}.comment-composer [data-replying]{font-size:.86rem;color:var(--muted);margin-bottom:7px}.comment-login-note,.comment-empty{color:var(--muted)}

.comment-actions{display:flex;gap:12px;align-items:center}.comment-delete-button{color:var(--danger,#a33)}

/* v71 Popular range controls */
.popular-controls{display:flex;align-items:flex-end;justify-content:space-between;gap:18px;flex-wrap:wrap}.popular-range-label{display:grid;gap:6px;font-size:.82rem;color:var(--muted)}.popular-range-label select{min-width:130px;padding:8px 30px 8px 10px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text);font:inherit}

.cell-comment-deleted{opacity:.72}.cell-comment-deleted>.comment-body{color:var(--muted);margin:2px 0}.user-sort-tabs{margin-bottom:14px}

/* v73 notifications and deep links */
.notification-bell{position:relative;border:0;background:transparent;color:inherit;font-size:1rem;cursor:pointer;padding:7px}.notification-count,.comment-unread-badge{position:absolute;right:-5px;top:-6px;min-width:17px;height:17px;padding:0 4px;border-radius:10px;background:#c62828;color:white;font-size:10px;font-weight:700;line-height:17px;text-align:center}.comment-launch{position:relative}.comment-unread-badge{right:-7px;top:-8px}.notification-popup{position:fixed;z-index:1300;width:min(390px,calc(100vw - 24px));max-height:70vh;overflow:auto;background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:0 16px 50px rgba(0,0,0,.18);padding:10px}.notification-popup-head{display:flex;justify-content:space-between;align-items:center;padding:4px 5px 9px}.notification-entry{display:block;width:100%;text-align:left;border:0;border-top:1px solid var(--border);background:transparent;color:inherit;padding:11px 7px;cursor:pointer;font:inherit}.notification-entry time{display:block;color:var(--muted);font-size:.76rem;margin-top:4px}.notification-delete-all{width:100%;margin-top:8px;padding:9px;border:1px solid var(--border);border-radius:8px;background:var(--surface-soft);color:inherit;cursor:pointer}.notification-empty{color:var(--muted);padding:12px 7px}.comment-follow-row{display:flex;gap:8px;align-items:center;margin-top:13px;color:var(--muted);font-size:.86rem}.audit-view-button{text-decoration:none;display:inline-flex;align-items:center;justify-content:center}

/* v74 account/notification alignment */
.account-nav-cluster{display:inline-flex;align-items:center;gap:2px;white-space:nowrap}.account-nav-cluster .notification-bell{position:relative;flex:0 0 auto;margin:0;padding:6px 5px}.account-nav-cluster [data-auth-button]{margin-left:0}
.auth-card [data-profile]>.account-setting-row{display:grid;grid-template-columns:1fr 118px 28px;align-items:center;gap:8px;padding:4px 0;margin:0;border-bottom:0;min-height:34px}.auth-card [data-profile]>.account-setting-row:not(.account-setting-row-top){grid-template-columns:1fr 118px;padding-top:2px;padding-bottom:4px}.auth-card [data-profile]>.account-setting-row .theme-toggle,.auth-card [data-profile]>.account-setting-row select{width:118px;min-width:118px;height:30px;margin:0;box-sizing:border-box}.auth-card [data-profile]>.account-setting-row .theme-toggle{justify-self:stretch}.auth-card [data-profile]>.account-setting-row select{padding:3px 7px}.auth-card [data-profile]>.account-setting-row .auth-close-inline{grid-column:3;grid-row:1}.auth-card [data-profile]>.profile-head{margin-top:8px}

/* v75 exact account-control placement */
.atlas-nav .account-nav-cluster{position:fixed;top:14px;right:18px;z-index:950;display:inline-flex;align-items:center;gap:1px;white-space:nowrap}
.atlas-nav .account-nav-cluster .notification-bell{position:relative!important;inset:auto!important;margin:0 1px 0 0!important;padding:6px 5px!important}
.atlas-nav .account-nav-cluster [data-auth-button]{position:static!important;inset:auto!important;margin:0!important}
.auth-card{position:relative}
.auth-card [data-profile]>.account-setting-row{grid-template-columns:1fr 118px!important}
.auth-card [data-profile]>.account-setting-row.account-setting-row-top{grid-template-columns:1fr 118px!important;padding-right:0}
.auth-card [data-profile]>.account-setting-row .auth-close-inline{position:absolute!important;top:8px!important;right:8px!important;grid-column:auto!important;grid-row:auto!important;margin:0!important}
@media(max-width:700px){.atlas-nav .account-nav-cluster{top:7px;right:7px}}

/* v76 profile popup autosave cleanup */
#authModal .auth-card{position:relative!important}
#authModal .auth-card>.auth-close-inline{position:absolute!important;top:10px!important;right:10px!important;bottom:auto!important;left:auto!important;margin:0!important;z-index:5}
#authModal .profile-bio-label{display:block;margin-top:10px}
#authModal .profile-bio-label textarea{width:100%;box-sizing:border-box}

/* v77 profile close alignment and ranked initial paint */
#authModal .auth-card>.auth-close-inline{top:2px!important;right:10px!important}
html:not(.ranking-ready) body:not(.admin-page) .table-scroll{visibility:hidden}

/* v78 profile layout and instant close */
#authModal [data-profile]{position:relative}
#authModal [data-profile]>.auth-close-inline{position:absolute!important;top:0!important;right:0!important;bottom:auto!important;left:auto!important;margin:0!important;z-index:5}
#authModal [data-profile]>.profile-head{margin-top:0;padding-right:38px}
#authModal .profile-settings-block{margin:2px 0 12px}
#authModal .profile-settings-block .account-setting-row{display:grid!important;grid-template-columns:1fr 118px!important;align-items:center!important;gap:8px!important;padding:4px 0!important;margin:0!important;border-bottom:0!important;min-height:34px}
#authModal .profile-settings-block .theme-toggle,#authModal .profile-settings-block select{width:118px!important;min-width:118px!important;height:30px!important;margin:0!important;box-sizing:border-box}

/* v79 About page and account polish */
.atlas-brand-link{color:inherit;text-decoration:none}
.atlas-brand-link:hover,.atlas-brand-link:focus-visible{text-decoration:none;opacity:.78}
.atlas-nav .account-nav-cluster .notification-bell{transform:translateX(-5px)}
.about-main{width:min(980px,calc(100% - 40px));margin:42px auto 72px}
.about-sheet{background:var(--surface,#fff);border:1px solid var(--border,#d9ddda);border-radius:14px;padding:clamp(28px,5vw,58px);box-shadow:0 12px 34px rgba(0,0,0,.045)}
.about-kicker{text-transform:uppercase;letter-spacing:.13em;font-size:.72rem;font-weight:700;color:var(--muted,#66706a);margin-bottom:14px}
.about-sheet h2{font-size:clamp(2rem,4.6vw,3.6rem);line-height:1.04;letter-spacing:-.035em;max-width:720px;margin:0 0 20px}
.about-lede{font-size:1.12rem;line-height:1.75;max-width:760px;color:var(--muted,#59635e);margin:0}
.about-rule{height:1px;background:var(--border,#d9ddda);margin:38px 0}
.about-section{display:grid;grid-template-columns:minmax(150px,220px) 1fr;gap:34px;padding:24px 0;border-bottom:1px solid var(--border,#d9ddda)}
.about-section h3{margin:0;font-size:1rem}.about-section p{margin:0;line-height:1.75}
.about-note{margin-top:34px;padding:20px 22px;border:1px solid var(--border,#d9ddda);border-radius:10px;background:var(--surface-soft,#f7f8f7)}
.about-note-label{display:block;font-size:.75rem;text-transform:uppercase;letter-spacing:.1em;font-weight:700;margin-bottom:7px}.about-note p{margin:0;line-height:1.65}
@media(max-width:700px){.about-main{width:min(100% - 24px,980px);margin-top:24px}.about-sheet{padding:24px 20px}.about-section{grid-template-columns:1fr;gap:8px}}

/* v80 Grothendieck header portrait */
.atlas-brand-header{display:flex;align-items:center}
.atlas-portrait-wrap{flex:0 0 142px;width:142px;height:128px;margin:-10px 8px -10px -4px;overflow:visible;pointer-events:none}
.atlas-portrait{display:block;width:142px;height:128px;object-fit:cover;object-position:50% 38%;
  -webkit-mask-image:radial-gradient(ellipse 69% 76% at 52% 47%,#000 36%,rgba(0,0,0,.94) 49%,rgba(0,0,0,.68) 63%,rgba(0,0,0,.28) 78%,transparent 100%);
  mask-image:radial-gradient(ellipse 69% 76% at 52% 47%,#000 36%,rgba(0,0,0,.94) 49%,rgba(0,0,0,.68) 63%,rgba(0,0,0,.28) 78%,transparent 100%);
}
.atlas-brand-copy{min-width:0}
/* v80 ensure notification option text is never vertically clipped */
#authModal .profile-settings-block select[data-notification-mode]{
  height:34px!important;min-height:34px!important;line-height:normal!important;
  padding:5px 28px 5px 8px!important;overflow:visible!important;
}
@media(max-width:700px){
  .atlas-portrait-wrap{flex-basis:92px;width:92px;height:88px;margin:-4px 4px -4px -4px}
  .atlas-portrait{width:92px;height:88px}
}

/* v81 robust portrait placement: portrait | title/quote | navigation */
.site-header.atlas-brand-header{
  display:grid!important;
  grid-template-columns:150px minmax(280px,1fr) auto!important;
  grid-template-areas:"portrait brand nav"!important;
  align-items:center!important;
  column-gap:8px!important;
}
.site-header.atlas-brand-header>.atlas-portrait-wrap{
  grid-area:portrait!important;position:relative!important;inset:auto!important;
  width:150px!important;height:132px!important;margin:-12px 0 -12px -6px!important;
  align-self:center!important;justify-self:start!important;overflow:visible!important;
}
.site-header.atlas-brand-header>.atlas-portrait-wrap>.atlas-portrait{
  width:150px!important;height:132px!important;display:block!important;object-fit:cover!important;object-position:50% 38%!important;
  -webkit-mask-image:none!important;mask-image:none!important;
}
.site-header.atlas-brand-header>.atlas-brand-copy{grid-area:brand!important;margin:0!important;align-self:center!important}
.site-header.atlas-brand-header>.atlas-nav{grid-area:nav!important;align-self:center!important}
@media(max-width:820px){
 .site-header.atlas-brand-header{grid-template-columns:104px minmax(0,1fr)!important;grid-template-areas:"portrait brand" "nav nav"!important;row-gap:6px!important}
 .site-header.atlas-brand-header>.atlas-portrait-wrap{width:104px!important;height:96px!important;margin:-5px 0 -5px -4px!important}
 .site-header.atlas-brand-header>.atlas-portrait-wrap>.atlas-portrait{width:104px!important;height:96px!important}
}

/* v82 admin-aware Grothendieck portrait */
.atlas-portrait-wrap.admin-portrait-link{cursor:pointer}
.atlas-portrait-wrap.admin-portrait-link:hover .atlas-portrait,.atlas-portrait-wrap.admin-portrait-link:focus-visible .atlas-portrait{opacity:.82}
.atlas-portrait-wrap.admin-portrait-link:focus-visible{outline:2px solid currentColor;outline-offset:3px;border-radius:8px}

/* v83 reliable native admin portrait link */
a.atlas-portrait-wrap{color:inherit;text-decoration:none}
a.atlas-portrait-wrap.admin-portrait-link{pointer-events:auto!important;cursor:pointer!important}
a.atlas-portrait-wrap:not(.admin-portrait-link){cursor:default}

/* v90 — polished account, editor, history and discussion surfaces */
:root{
  --atlas-modal-bg:color-mix(in srgb,var(--surface) 96%,transparent);
  --atlas-modal-border:color-mix(in srgb,currentColor 12%,transparent);
  --atlas-modal-soft:color-mix(in srgb,currentColor 4%,transparent);
  --atlas-modal-shadow:0 28px 80px rgba(20,24,32,.20),0 8px 24px rgba(20,24,32,.10);
}
.auth-backdrop,.rich-editor-backdrop{background:rgba(16,20,27,.42)!important;backdrop-filter:blur(8px) saturate(.9);-webkit-backdrop-filter:blur(8px) saturate(.9)}
.auth-card,.rich-editor-dialog{
  background:var(--atlas-modal-bg)!important;border:1px solid var(--atlas-modal-border)!important;
  border-radius:18px!important;box-shadow:var(--atlas-modal-shadow)!important;
}
.auth-card{padding:24px!important;max-width:520px}
.rich-editor-dialog{overflow:hidden;max-height:min(88vh,900px)}
.rich-editor-head,.notification-popup-head{
  padding:17px 20px!important;border-bottom:1px solid var(--atlas-modal-border)!important;
  background:linear-gradient(180deg,color-mix(in srgb,var(--surface) 98%,transparent),color-mix(in srgb,var(--surface) 92%,transparent))!important;
}
.rich-editor-head strong,.profile-head strong,.notification-popup-head strong{font-family:Georgia,"Times New Roman",serif;font-size:1.08rem;letter-spacing:-.01em}
.icon-button{border:1px solid transparent!important;border-radius:10px!important;transition:background .16s,border-color .16s,transform .16s!important}
.icon-button:hover{background:var(--atlas-modal-soft)!important;border-color:var(--atlas-modal-border)!important;transform:translateY(-1px)}
.rich-editable,.rich-display-text,.auth-card input,.auth-card textarea,.auth-card select,.rich-editor-dialog input,.rich-editor-dialog textarea,.rich-editor-dialog select{
  border:1px solid color-mix(in srgb,currentColor 15%,transparent)!important;border-radius:10px!important;
  background:color-mix(in srgb,var(--surface) 98%,transparent)!important;
  box-shadow:inset 0 1px 2px rgba(20,24,32,.035)!important;transition:border-color .15s,box-shadow .15s!important
}
.rich-editable:focus,.rich-display-text:focus,.auth-card input:focus,.auth-card textarea:focus,.auth-card select:focus,.rich-editor-dialog input:focus,.rich-editor-dialog textarea:focus,.rich-editor-dialog select:focus{
  outline:none!important;border-color:color-mix(in srgb,currentColor 34%,transparent)!important;box-shadow:0 0 0 3px color-mix(in srgb,currentColor 7%,transparent)!important
}
.primary-editor-button,.account-action-button{
  border-radius:10px!important;box-shadow:0 1px 2px rgba(20,24,32,.08)!important;transition:transform .15s,box-shadow .15s,opacity .15s!important
}
.primary-editor-button:hover,.account-action-button:hover{transform:translateY(-1px);box-shadow:0 5px 14px rgba(20,24,32,.12)!important}
.auth-mode-switch{padding:4px!important;border-radius:12px!important;background:var(--atlas-modal-soft)!important;border:1px solid var(--atlas-modal-border)!important}
.account-mode-button{border-radius:8px!important;padding:8px 14px!important}
.account-mode-button.active{background:var(--surface)!important;box-shadow:0 1px 5px rgba(20,24,32,.10)!important}
.profile-head{padding-bottom:18px!important;margin-bottom:16px!important;border-bottom:1px solid var(--atlas-modal-border)!important}
.profile-stats{gap:8px!important}
.profile-stats>*{background:var(--atlas-modal-soft)!important;border:1px solid var(--atlas-modal-border)!important;border-radius:12px!important;padding:11px!important}
.profile-settings-block{margin-top:16px!important;padding-top:16px!important;border-top:1px solid var(--atlas-modal-border)!important}
.account-setting-row{padding:10px 0!important}
.rich-cell-image-manager,.rich-truth-manager{margin:14px 18px!important;padding:14px!important;border:1px solid var(--atlas-modal-border)!important;border-radius:12px!important;background:var(--atlas-modal-soft)!important}
.rich-editor-actions{padding:14px 18px!important;border-top:1px solid var(--atlas-modal-border)!important;background:color-mix(in srgb,var(--surface) 97%,transparent)!important}
.rich-history-list,.cell-comment-list{padding:14px 18px 20px!important}
.history-revision,.admin-audit-entry,.cell-comment{
  border:1px solid var(--atlas-modal-border)!important;border-radius:13px!important;background:color-mix(in srgb,var(--surface) 98%,transparent)!important;
  box-shadow:0 2px 8px rgba(20,24,32,.045)!important;margin-bottom:10px!important
}
.history-revision,.admin-audit-entry{padding:14px!important}
.cell-comment{padding:13px 14px!important}
.cell-comment-reply{margin-left:26px!important;border-left:2px solid color-mix(in srgb,currentColor 18%,transparent)!important}
.comment-user,.audit-user-link{font-weight:650!important}
.comment-actions{opacity:.72;transition:opacity .15s}.cell-comment:hover .comment-actions{opacity:1}
.comment-composer{margin:12px 18px 18px!important;padding:14px!important;border-radius:13px!important;background:var(--atlas-modal-soft)!important;border:1px solid var(--atlas-modal-border)!important}
.comment-compose-actions,.comment-follow-row{gap:10px!important}
.rich-history-stats{display:flex!important;gap:6px!important;flex-wrap:wrap!important}
.rich-history-stats>*{border-radius:999px!important;background:var(--atlas-modal-soft)!important;border:1px solid var(--atlas-modal-border)!important;padding:4px 8px!important}
.notification-entry{padding:12px!important;border-radius:11px!important;transition:background .15s!important}.notification-entry:hover{background:var(--atlas-modal-soft)!important}
@media(max-width:640px){.auth-card{border-radius:16px!important;padding:19px!important}.rich-editor-dialog{border-radius:15px!important;max-height:92vh}.cell-comment-reply{margin-left:12px!important}}

/* v91 — dark-compatible polished surfaces and save feedback */
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .rich-editor-dialog,
html[data-theme="dark"] .history-revision,
html[data-theme="dark"] .admin-audit-entry,
html[data-theme="dark"] .cell-comment,
html[data-theme="dark"] .comment-composer{
  background:var(--surface)!important;color:var(--text)!important;border-color:var(--border)!important;
  box-shadow:0 28px 80px rgba(0,0,0,.42),0 8px 24px rgba(0,0,0,.24)!important
}
html[data-theme="dark"] .rich-editor-head,
html[data-theme="dark"] .notification-popup-head,
html[data-theme="dark"] .rich-editor-actions,
html[data-theme="dark"] .profile-stats>*,
html[data-theme="dark"] .rich-cell-image-manager,
html[data-theme="dark"] .rich-truth-manager,
html[data-theme="dark"] .comment-composer,
html[data-theme="dark"] .auth-mode-switch{
  background:var(--surface-soft)!important;color:var(--text)!important;border-color:var(--border)!important
}
html[data-theme="dark"] .account-mode-button.active{background:#2a312b!important;color:var(--text)!important}
html[data-theme="dark"] .auth-card input,
html[data-theme="dark"] .auth-card textarea,
html[data-theme="dark"] .auth-card select,
html[data-theme="dark"] .rich-editor-dialog input,
html[data-theme="dark"] .rich-editor-dialog textarea,
html[data-theme="dark"] .rich-editor-dialog select,
html[data-theme="dark"] .rich-editable,
html[data-theme="dark"] .rich-display-text{
  background:#141915!important;color:var(--text)!important;border-color:var(--border)!important
}
html[data-theme="dark"] .history-revision,
html[data-theme="dark"] .admin-audit-entry,
html[data-theme="dark"] .cell-comment{background:#1b211c!important}
html[data-theme="dark"] .comment-actions,
html[data-theme="dark"] .profile-role,
html[data-theme="dark"] .account-setting-row,
html[data-theme="dark"] .rich-editor-head span{color:var(--muted)!important}

.atlas-saving-toast{
 position:fixed;left:50%;top:50%;z-index:10050;display:flex;align-items:center;gap:10px;
 padding:11px 16px;border-radius:999px;background:color-mix(in srgb,var(--surface) 96%,transparent);
 color:var(--text);border:1px solid var(--border);box-shadow:0 14px 40px rgba(20,24,32,.18);
 backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
 opacity:0;transform:translate(-50%,-44%) scale(.96);pointer-events:none;
 transition:opacity .16s ease,transform .2s cubic-bezier(.2,.8,.2,1)
}
.atlas-saving-toast.show{opacity:1;transform:translate(-50%,-50%) scale(1)}
.atlas-saving-spinner{width:14px;height:14px;border-radius:50%;border:2px solid color-mix(in srgb,var(--text) 20%,transparent);border-top-color:var(--accent);animation:atlasSavingSpin .7s linear infinite}
@keyframes atlasSavingSpin{to{transform:rotate(360deg)}}
html[data-theme="dark"] .atlas-saving-toast{box-shadow:0 16px 44px rgba(0,0,0,.42)}

/* v94 — phone-first matrix density and single-line section navigation */
.table-tab-row{overflow:hidden}
.table-tab-row .atlas-tabs{
  display:flex!important;flex-wrap:nowrap!important;overflow-x:auto;overflow-y:hidden;
  max-width:100%;width:100%;justify-content:flex-start;align-items:center;
  scrollbar-width:thin;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;
}
.table-tab-row .atlas-tabs button{flex:0 0 auto;white-space:nowrap}
.atlas-nav .account-nav-cluster{
  position:absolute!important;top:14px;right:18px;z-index:950;
}
/* The header itself is the positioning context: account controls stay at the page top,
   rather than following the viewport during vertical scrolling. */
.site-header{position:relative}

@media(max-width:600px){
  /* Roughly category name + four ordinary property columns on a typical phone viewport. */
  main{padding-left:5px!important;padding-right:5px!important}
  .matrix-card{border-radius:10px}
  thead th:not(:first-child){width:64px!important;min-width:64px!important;max-width:64px!important;padding:7px 3px!important;font-size:8.5px!important;letter-spacing:.025em!important}
  thead th:first-child,tbody th{width:100px!important;min-width:100px!important;max-width:100px!important;padding:9px 7px!important}
  td{min-width:64px!important;width:64px!important;height:55px!important}
  .cell-button{min-height:55px!important;padding:5px 3px!important;gap:2px!important}
  .category-symbol{font-size:17px!important}
  .category-name{font-size:9px!important;line-height:1.15!important}
  .cell-value,.descriptive-value{font-size:8.5px!important;line-height:1.15!important}
  .status-chip{min-width:21px!important;height:21px!important;font-size:12px!important}
  .column-header-button{min-height:58px!important;padding:3px 2px 5px!important;font-size:8.5px!important}
  .column-header-image{max-width:38px!important;max-height:28px!important}
  .table-tab-row{margin-left:-5px;margin-right:-5px}
  .table-tab-row .atlas-tabs{padding:0 5px}
  .table-tab-row .atlas-tabs button{font-size:11px!important;padding-left:9px!important;padding-right:9px!important}
  .atlas-nav .account-nav-cluster{top:7px!important;right:7px!important}
}

/* v95 — phone matrix fit and full-width mobile masthead */
@media(max-width:600px){
  /* Keep category content comfortably contained, then gain the extra visible
     property column by making the property columns denser instead. */
  thead th:first-child,tbody th{
    width:132px!important;min-width:132px!important;max-width:132px!important;
    padding:8px 7px!important;overflow:hidden!important
  }
  .category-button.category-button-horizontal{gap:4px!important;max-width:100%!important;overflow:hidden!important}
  .category-button.category-button-horizontal .category-text-wrap{min-width:0!important;overflow:hidden!important}
  .category-button.category-button-horizontal .category-image-right{
    flex:0 0 34px!important;width:34px!important;height:31px!important;margin-left:3px!important;max-width:34px!important
  }
  .category-symbol{font-size:15px!important;max-width:100%!important;overflow:hidden!important}
  .category-symbol mjx-container{max-width:100%!important;font-size:.88em!important}
  .category-name{font-size:8.5px!important;overflow-wrap:anywhere!important}
  thead th:not(:first-child){width:46px!important;min-width:46px!important;max-width:46px!important;padding:6px 1px!important;font-size:7.4px!important}
  td{width:46px!important;min-width:46px!important;max-width:46px!important;height:52px!important}
  .cell-button{min-height:52px!important;padding:3px 1px!important}
  .cell-value,.descriptive-value{font-size:7.2px!important;max-width:44px!important}
  .status-chip{min-width:19px!important;height:19px!important;font-size:11px!important}
  .column-header-button{min-height:54px!important;padding:2px 1px 4px!important;font-size:7.4px!important}
  .column-header-image{max-width:30px!important;max-height:23px!important}

  /* Mobile masthead: portrait occupies a compact left slot while the brand
     copy receives the full remaining width. Navigation then spans both columns. */
  .site-header.atlas-brand-header{
    grid-template-columns:66px minmax(0,1fr)!important;
    grid-template-areas:"portrait brand" "nav nav"!important;
    column-gap:4px!important;row-gap:5px!important;
    padding-left:8px!important;padding-right:8px!important
  }
  .site-header.atlas-brand-header>.atlas-portrait-wrap{
    width:66px!important;height:66px!important;margin:-2px 0!important;overflow:hidden!important
  }
  .site-header.atlas-brand-header>.atlas-portrait-wrap>.atlas-portrait{width:66px!important;height:66px!important}
  .site-header.atlas-brand-header>.atlas-brand-copy{width:100%!important;min-width:0!important}
  .site-header.atlas-brand-header h1{
    font-size:clamp(25px,7.4vw,32px)!important;line-height:1!important;
    white-space:nowrap!important;letter-spacing:-.035em!important;margin:0 0 5px!important
  }
  .site-header.atlas-brand-header .subtitle{
    max-width:none!important;width:100%!important;font-size:10.5px!important;line-height:1.32!important;margin-top:4px!important
  }
  .site-header.atlas-brand-header>.atlas-nav{width:100%!important;min-width:0!important}
}

/* v96 — community rankings */
.rankings-main{width:min(980px,calc(100% - 32px));margin:34px auto 72px}.rankings-heading{display:flex;justify-content:space-between;align-items:end;margin-bottom:18px}.rankings-heading h2,.ranking-detail-head h2{font-family:Georgia,"Times New Roman",serif;font-size:clamp(30px,4vw,44px);margin:4px 0 5px}.ranking-directory-list{border:1px solid var(--border);border-radius:14px;overflow:hidden;background:var(--surface)}.ranking-directory-row{width:100%;display:flex;align-items:center;justify-content:space-between;gap:20px;padding:17px 18px;border:0;border-bottom:1px solid var(--border);background:var(--surface);color:var(--text);text-align:left}.ranking-directory-row:last-child{border-bottom:0}.ranking-directory-row:hover{background:var(--surface-soft)}.ranking-directory-row strong{display:block;font-size:15px}.ranking-directory-row small{display:block;color:var(--muted);margin-top:4px}.ranking-count{color:var(--muted);font-size:12px;white-space:nowrap}.ranking-create{margin-top:14px}.ranking-detail-head{margin:22px 0 18px}.ranking-vote-list{list-style:none;margin:0;padding:0;border:1px solid var(--border);border-radius:14px;overflow:hidden;background:var(--surface)}.ranking-vote-row{display:grid;grid-template-columns:48px 1fr 64px 86px;align-items:center;min-height:62px;border-bottom:1px solid var(--border);padding:0 12px}.ranking-vote-row:last-child{border-bottom:0}.ranking-position{font-family:Georgia,serif;font-size:20px;color:var(--muted)}.ranking-option{font-weight:700}.ranking-score{text-align:center;font-variant-numeric:tabular-nums}.ranking-votes{display:flex;gap:6px;justify-content:flex-end}.ranking-votes button{width:34px;height:34px;border:1px solid var(--border);border-radius:8px;background:var(--surface-soft);color:var(--text);font-size:18px}.ranking-votes button:hover{border-color:var(--accent);color:var(--accent)}.ranking-comments{margin-top:34px;padding-top:24px;border-top:1px solid var(--border)}.ranking-comments h3{font-family:Georgia,serif;font-size:24px}.ranking-comment{padding:13px 0;border-bottom:1px solid var(--border)}.ranking-comment p{margin:5px 0;white-space:pre-wrap}.ranking-comments textarea{width:100%;min-height:90px;margin:16px 0 8px;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--text);padding:12px}.ranking-create-card label{display:block;margin:13px 0;color:var(--muted);font-size:12px;font-weight:700}.ranking-create-card input,.ranking-create-card textarea{display:block;width:100%;margin-top:5px;padding:10px;border:1px solid var(--border);border-radius:9px;background:var(--surface);color:var(--text)}.ranking-create-card{position:relative}.ranking-create-close{position:absolute;right:12px;top:12px}.muted{color:var(--muted)}@media(max-width:600px){.rankings-main{width:calc(100% - 16px);margin-top:20px}.ranking-vote-row{grid-template-columns:32px 1fr 42px 74px;padding:0 7px;min-height:56px}.ranking-option{font-size:13px}.ranking-votes{gap:4px}.ranking-votes button{width:32px;height:32px}.ranking-directory-row{padding:14px 12px}}

/* v97 rankings integration */
html[data-theme="dark"] .ranking-directory-list,html[data-theme="dark"] .ranking-directory-row,html[data-theme="dark"] .ranking-vote-list,html[data-theme="dark"] .ranking-votes button,html[data-theme="dark"] .ranking-create-card{background:var(--surface)!important;color:var(--text)!important;border-color:var(--border)!important}
html[data-theme="dark"] .ranking-directory-row:hover,html[data-theme="dark"] .ranking-votes button:hover{background:var(--surface-soft)!important}
.ranking-vote-row{grid-template-columns:48px 1fr 86px auto!important}.ranking-option-open{display:flex;align-items:center;gap:10px;width:100%;min-height:58px;border:0;background:transparent;color:inherit;text-align:left;font-weight:700}.ranking-option-open img{width:42px;height:42px;object-fit:contain;border-radius:7px}.ranking-option-open:hover span{text-decoration:underline}.ranking-votes button.selected{border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}.ranking-admin-row{display:flex;gap:5px;margin-left:8px}.ranking-admin-row button{border:0;background:transparent;color:var(--muted);font-size:11px}.ranking-admin-tools{display:flex;justify-content:flex-end;margin:-8px 0 10px}.ranking-comments{display:flex;align-items:center;justify-content:space-between}.ranking-comments h3{margin:0}.ranking-comments textarea,.ranking-comment{display:none!important}
@media(max-width:600px){.ranking-vote-row{grid-template-columns:30px 1fr 72px!important}.ranking-admin-row{grid-column:2/4;justify-content:flex-end;padding-bottom:6px}.ranking-option-open img{width:34px;height:34px}}

/* v98 — rankings theme, larger entries, descriptions and image editor */
html[data-theme="dark"] .rankings-main{color:var(--text)!important}
html[data-theme="dark"] .ranking-directory-list,
html[data-theme="dark"] .ranking-directory-row,
html[data-theme="dark"] .ranking-vote-list,
html[data-theme="dark"] .ranking-vote-row,
html[data-theme="dark"] .ranking-option-open,
html[data-theme="dark"] .ranking-create-card,
html[data-theme="dark"] .ranking-item-image-preview{background-color:var(--surface)!important;color:var(--text)!important;border-color:var(--border)!important}
.ranking-vote-row{min-height:112px!important;grid-template-columns:54px 1fr 92px auto!important;padding:10px 16px!important}
.ranking-option-open{min-height:90px!important;gap:16px!important}
.ranking-option-open img{width:78px!important;height:78px!important;flex:0 0 78px!important;object-fit:contain!important;border-radius:10px!important}
.ranking-option-copy{display:flex;flex-direction:column;align-items:flex-start;gap:7px;min-width:0}
.ranking-option-copy strong{font-size:17px;line-height:1.15}
.ranking-option-copy small{font-size:12px;line-height:1.4;color:var(--muted);font-weight:400;text-align:left;max-width:680px}
.ranking-item-image-preview{min-height:92px;margin:8px 0 14px;padding:10px;border:1px solid var(--border);border-radius:10px;display:flex;align-items:center;gap:12px;background:var(--surface-soft)}
.ranking-item-image-preview img{width:76px;height:76px;object-fit:contain;border-radius:8px}
.ranking-item-image-preview button{border:1px solid var(--border);border-radius:7px;background:var(--surface);color:var(--text);padding:7px 9px}
@media(max-width:600px){.ranking-vote-row{min-height:100px!important;grid-template-columns:34px 1fr 74px!important;padding:7px!important}.ranking-option-open{min-height:82px!important;gap:9px!important}.ranking-option-open img{width:58px!important;height:58px!important;flex-basis:58px!important}.ranking-option-copy strong{font-size:14px}.ranking-option-copy small{font-size:10px}}

/* v99 — special century filter for Greatest mathematicians */
.ranking-century-filter{display:flex;align-items:center;justify-content:flex-end;gap:8px;margin:-6px 0 12px;color:var(--muted);font-size:12px;font-weight:700}
.ranking-century-filter select,#rankingItemCentury{border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text);padding:8px 10px}
html[data-theme="dark"] .ranking-century-filter select,html[data-theme="dark"] #rankingItemCentury{background:var(--surface)!important;color:var(--text)!important;border-color:var(--border)!important}

/* v101 — restrained notification bell */
.atlas-nav .account-nav-cluster .notification-bell{
  width:38px!important;height:34px!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;
  box-sizing:border-box!important;padding:0!important;margin:0 5px 0 0!important;
  border:1px solid #111!important;border-radius:9px!important;background:transparent!important;color:#111!important;
  box-shadow:none!important;line-height:1!important;
}
.notification-bell-icon{width:19px;height:19px;display:block;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.atlas-nav .account-nav-cluster .notification-bell:hover{background:rgba(0,0,0,.035)!important}
html[data-theme="dark"] .atlas-nav .account-nav-cluster .notification-bell{
  border-color:#6fae8d!important;color:#6fae8d!important;background:transparent!important;
}
html[data-theme="dark"] .atlas-nav .account-nav-cluster .notification-bell:hover{background:rgba(111,174,141,.08)!important}

/* v102 — category AI fill, About-only install control, collision-proof site navigation */
.category-row-tools{display:flex;align-items:center;gap:5px;min-width:0;width:100%}
.category-row-tools .category-button{flex:1 1 auto;min-width:0}
.category-ai-fill-button{
  flex:0 0 auto;border:1px solid var(--border);border-radius:7px;background:transparent;color:var(--muted);
  padding:5px 6px;font:inherit;font-size:9px;font-weight:700;line-height:1.05;cursor:pointer;white-space:nowrap
}
.category-ai-fill-button:hover{color:var(--accent);border-color:var(--accent);background:var(--accent-soft)}
.category-ai-fill-button:disabled{opacity:.55;cursor:wait}
html[data-theme="dark"] .category-ai-fill-button{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 55%,var(--border))}
.about-install-app{margin:56px 0 8px;padding-top:24px;border-top:1px solid var(--border)}
.about-install-app h2{margin-bottom:6px}.about-install-app p{color:var(--muted);margin:0 0 14px}
.about-install-button{position:static!important;display:inline-flex!important}

/* The section navigation is always a separate grid row, so Categories/Functors/
   Adjunctions/Rankings can never collide with the title or quotation. */
.site-header.atlas-brand-header{
  grid-template-columns:150px minmax(0,1fr)!important;
  grid-template-areas:"portrait brand" "nav nav"!important;
  row-gap:8px!important;
}
.site-header.atlas-brand-header>.atlas-nav{
  grid-area:nav!important;width:100%!important;min-width:0!important;
  display:flex!important;align-items:center!important;gap:8px!important;
  overflow-x:auto!important;overflow-y:visible!important;white-space:nowrap!important;
  scrollbar-width:thin;
}
.site-header.atlas-brand-header>.atlas-brand-copy{min-width:0!important}
@media(max-width:820px){
  .site-header.atlas-brand-header{
    grid-template-columns:104px minmax(0,1fr)!important;
    grid-template-areas:"portrait brand" "nav nav"!important
  }
}
@media(max-width:600px){
  .site-header.atlas-brand-header{
    grid-template-columns:72px minmax(0,1fr)!important;
    grid-template-areas:"portrait brand" "nav nav"!important
  }
  .category-row-tools{gap:2px}
  .category-ai-fill-button{padding:4px 3px;font-size:7px}
}

/* v105 — activity pagination and persistent ranking vote indication */
.admin-audit-pagination{display:flex;align-items:center;justify-content:flex-end;gap:10px;margin:10px 0 18px;color:var(--muted);font-size:12px}
.admin-audit-pagination button{min-width:112px}
.admin-audit-pagination button:disabled{opacity:.42;cursor:default}
.ranking-votes button.selected{font-weight:800;box-shadow:inset 0 0 0 1px currentColor}
.ranking-votes button.vote-up-selected{color:#176b45!important;border-color:#176b45!important;background:#e6f4ed!important}
.ranking-votes button.vote-down-selected{color:#9e3434!important;border-color:#9e3434!important;background:#faeceb!important}
html[data-theme="dark"] .ranking-votes button.vote-up-selected{color:#83d4aa!important;border-color:#83d4aa!important;background:#173526!important}
html[data-theme="dark"] .ranking-votes button.vote-down-selected{color:#e59a96!important;border-color:#e59a96!important;background:#3b2221!important}

/* v107 — fast first paint and graceful loading state */
html:not(.ranking-ready) body:not(.admin-page) .table-scroll{visibility:visible!important}

.site-loading-pill{
  position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);
  z-index:1800;display:inline-flex;align-items:center;gap:10px;
  padding:10px 16px;border:1px solid var(--border);border-radius:999px;
  background:color-mix(in srgb,var(--surface) 94%,transparent);
  color:var(--text);box-shadow:0 10px 35px rgba(0,0,0,.10);
  font-size:13px;font-weight:700;letter-spacing:.01em;
  backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);
  pointer-events:none
}
.site-loading-pill[hidden]{display:none!important}
.site-loading-dot{
  width:8px;height:8px;border-radius:50%;background:var(--accent);
  box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 45%,transparent);
  animation:atlasLoadingPulse 1.25s ease-in-out infinite
}
@keyframes atlasLoadingPulse{
  0%,100%{opacity:.55;box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 35%,transparent)}
  50%{opacity:1;box-shadow:0 0 0 6px transparent}
}
@media(prefers-reduced-motion:reduce){.site-loading-dot{animation:none}}

/* v109 — admin-only Rankings and viewport-safe rich info editor */
body.rankings-admin-gated > *{visibility:hidden}

/* Keep the complete Edit entire info box dialog inside the viewport.
   The editable document is the flexible scrolling region; table text and
   Cancel/Save remain visible at the bottom at normal browser zoom. */
#richInfoEditor .rich-editor-dialog{
  inset:12px!important;
  width:min(1120px,calc(100vw - 24px))!important;
  height:calc(100dvh - 24px)!important;
  max-height:calc(100dvh - 24px)!important;
  min-height:0!important;
  margin:auto!important;
  overflow:hidden!important;
  display:flex!important;
  flex-direction:column!important;
}
#richInfoEditor .rich-editor-head,
#richInfoEditor .rich-toolbar,
#richInfoEditor .rich-latex-help,
#richInfoEditor .rich-truth-manager,
#richInfoEditor .rich-cell-image-manager,
#richInfoEditor .rich-display-text,
#richInfoEditor .rich-editor-actions{
  flex:0 0 auto!important;
}
#richInfoEditor .rich-toolbar{
  flex-wrap:nowrap!important;
  overflow-x:auto!important;
  overflow-y:hidden!important;
  padding:7px 12px!important;
  scrollbar-width:thin;
}
#richInfoEditor .rich-latex-help{padding:6px 14px!important}
#richInfoEditor .rich-truth-manager,
#richInfoEditor .rich-cell-image-manager{padding:8px 14px!important}
#richInfoEditor .rich-editable{
  flex:1 1 0!important;
  min-height:60px!important;
  overflow:auto!important;
  padding:18px 24px!important;
}
#richInfoEditor .rich-display-text{
  margin:7px 14px!important;
  padding:0!important;
  border:0!important;
  background:transparent!important;
}
#richInfoEditor .rich-editor-actions{
  padding:9px 14px!important;
  position:relative!important;
  z-index:2;
}
@media(max-width:700px){
  #richInfoEditor .rich-editor-dialog{
    inset:7px!important;
    width:calc(100vw - 14px)!important;
    height:calc(100dvh - 14px)!important;
    max-height:calc(100dvh - 14px)!important;
  }
  #richInfoEditor .rich-editor-head{padding:10px 12px!important}
  #richInfoEditor .rich-toolbar{padding:5px 8px!important}
  #richInfoEditor .rich-latex-help{padding:5px 10px!important}
  #richInfoEditor .rich-truth-manager,
  #richInfoEditor .rich-cell-image-manager{padding:6px 10px!important;gap:8px!important}
  #richInfoEditor .rich-editable{padding:12px!important;min-height:40px!important}
  #richInfoEditor .rich-display-text{margin:5px 10px!important}
  #richInfoEditor .rich-editor-actions{padding:7px 10px!important}
}
@media(max-height:620px){
  #richInfoEditor .rich-editor-head{padding-top:7px!important;padding-bottom:7px!important}
  #richInfoEditor .rich-editor-head span,
  #richInfoEditor .rich-cell-image-manager > div:first-child span{display:none!important}
  #richInfoEditor .rich-toolbar{padding-top:4px!important;padding-bottom:4px!important}
  #richInfoEditor .rich-latex-help{font-size:10px!important;padding-top:3px!important;padding-bottom:3px!important}
  #richInfoEditor .rich-truth-manager,
  #richInfoEditor .rich-cell-image-manager{padding-top:4px!important;padding-bottom:4px!important}
  #richInfoEditor .rich-display-text{margin-top:3px!important;margin-bottom:3px!important}
  #richInfoEditor .rich-editor-actions{padding-top:5px!important;padding-bottom:5px!important}
}

/* v111 — strict temporary admin visibility and no quote fallback flash */
[data-admin-only][hidden],
.admin-only-hidden{
  display:none!important;
}
[data-admin-about].admin-about-disabled{
  color:inherit!important;
  text-decoration:none!important;
  cursor:default!important;
  pointer-events:none!important;
}
#atlasQuote.quote-pending{
  visibility:hidden!important;
}

/* v112 — do not silently show image-free seed data during a backend outage */
.live-data-unavailable{
  position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);
  width:min(480px,calc(100vw - 32px));max-height:calc(100dvh - 32px);
  overflow:auto;z-index:1805;padding:24px;
  border:1px solid var(--border);border-radius:16px;
  background:var(--surface);color:var(--text);
  box-shadow:0 20px 60px rgba(0,0,0,.24);
  line-height:1.5;
}
.live-data-unavailable strong{display:block;font-size:18px;margin-bottom:8px}
.live-data-unavailable p{margin:0 0 16px;color:var(--muted)}
.live-data-unavailable button{
  font:inherit;font-weight:700;padding:10px 14px;cursor:pointer;
  border:1px solid var(--border);border-radius:9px;
  background:var(--surface-soft);color:var(--text);
}
.live-data-unavailable[hidden]{display:none!important}
