:root {
  color-scheme: light;
  --text: #202122;
  --page: #f8f9fa;
  --surface: #fff;
  --muted: #54595d;
  --control-border: #a2a9b1;
  --teal: #36c;
  --orange: #a55858;
  --link: #36c;
  --border: #c8ccd1;
  --accent-surface: #eaf3ff;
  --subtle: #eaecf0;
  --warning-surface: #fef6e7;
  --warning-text: #705000;
  --shadow: #20212208;
  font: 16px/1.6 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Lato,Helvetica,Arial,sans-serif;
  color: var(--text);
  background: var(--page);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
}

header,main,footer {
  width: min(100%,1480px);
  margin: 0 auto;
  padding: 24px 40px;
}

header {
  padding-top: 28px;
  padding-bottom: 12px;
}

h1 {
  font-family: 'Linux Libertine',Georgia,'Times New Roman',serif;
  font-weight: 400;
  font-size: clamp(1.75rem,3vw,2.25rem);
  line-height: 1.3;
  margin: 14px 0;
}

h2 {
  font-family: 'Linux Libertine',Georgia,'Times New Roman',serif;
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.35;
  margin: 0;
}

p {
  margin: 8px 0 18px;
}

.muted,.panel p,footer {
  color: var(--muted);
  font-size: .9rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  border-top: 1px solid var(--border);
  padding-block: 16px;
}

.footer-nav a {
  padding-block: 4px;
  overflow-wrap: anywhere;
}

.toolbar,.panel-head {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.toolbar {
  justify-content: flex-start;
  align-items: flex-end;
}

body[data-page="articles"] .toolbar,
body[data-page="creators"] .toolbar {
  padding-bottom: 24px;
}

.panel-head {
  justify-content: space-between;
}

label {
  display: flex;
  gap: 8px;
  flex-direction: column;
  font-size: .85rem;
}

select,input,button {
  font: inherit;
  border: 1px solid var(--control-border);
  background: var(--surface);
  border-radius: 2px;
  padding: 9px;
  max-width: 100%;
}

button {
  cursor: pointer;
  color: var(--teal);
}

.list-pagination,.pagination-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.list-pagination {
  margin-block-start: 16px;
  justify-content: center;
}

.pagination-pages {
  justify-content: center;
}

.pagination-pages button {
  min-inline-size: 44px;
}

.pagination-pages button[aria-current="page"] {
  color: var(--text);
  background: var(--accent-surface);
  border-color: var(--teal);
  font-weight: 700;
}

a {
  color: var(--link);
}

.panel {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  margin: 22px 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 16px;
}

.metric {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--teal);
  border-radius: 2px;
}

.metric strong {
  display: block;
  font-size: 2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 20px;
}

.grid .panel {
  margin-bottom: 0;
}

.legend {
  text-align: center;
  font-size: 1rem;
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.orphan {
  color: var(--orange);
}

.other {
  color: var(--teal);
}

svg {
  display: block;
  width: 100%;
  height: auto;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px,1fr) 2fr 180px;
  align-items: center;
  gap: 18px;
  font-size: 1rem;
  margin: 18px 0;
}

.bar-bg {
  background: var(--subtle);
  height: 18px;
  border-radius: 0;
}

.bar {
  background: var(--orange);
  height: 18px;
  border-radius: 0;
}

.bar-label {
  overflow-wrap: anywhere;
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#status {
  padding: 12px;
  background: var(--accent-surface);
  border-radius: 2px;
}

#status.demo {
  background: var(--warning-surface);
  color: var(--warning-text);
}

@media(max-width:700px) {
  header,main,footer {
    padding: 18px;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .bar-row {
    grid-template-columns: minmax(0,1fr) 120px;
    gap: 8px;
  }
  .bar-label {
    grid-column: 1/-1;
  }
  .panel {
    padding: 16px;
  }
}

[hidden] {
  display: none!important;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(min(100%,300px),1fr));
  gap: 20px;
  align-items: stretch;
}

.candidate-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: none;
}

.candidate-card:hover {
  border-color: var(--teal);
}

.candidate-body {
  flex: 1;
  padding: 24px;
  overflow-wrap: anywhere;
}

.candidate-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.candidate-title {
  font-size: 1.15rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.candidate-title a {
  color: inherit;
  text-decoration: none;
}

.candidate-title a:hover {
  text-decoration: underline;
}

.candidate-badge {
  flex-shrink: 0;
  background: var(--accent-surface);
  color: var(--link);
  border-radius: 2px;
  padding: 4px 12px;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.candidate-category,.candidate-hint {
  font-size: .85rem;
  font-weight: 400;
  margin: 14px 0 0;
  color: var(--muted);
}

.candidate-hint {
  color: var(--teal);
}

.candidate-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.fix-link {
  font-size: .85rem;
  text-decoration: none;
}

.fix-link:hover {
  text-decoration: underline;
}

.fix-link[aria-disabled="true"] {
  color: var(--muted);
}

dialog {
  width: min(900px,calc(100% - 32px));
  max-height: 90vh;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: #0008;
}

dialog textarea {
  display: block;
  width: 100%;
  height: 45vh;
  margin: 16px 0;
  padding: 12px;
  font: 14px/1.5 ui-monospace,monospace;
  color: var(--text);
  background: var(--page);
  border: 1px solid var(--control-border);
  border-radius: 2px;
  resize: vertical;
}

.prompt-debug {
  flex-direction: row;
  align-items: center;
  margin-top: 12px;
}

.prompt-debug input {
  margin: 0;
  padding: 0;
}

.prompt-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.review-row {
  border-top: 1px solid var(--border);
  padding: 16px 0;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-actions button[aria-pressed="true"] {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.review-badge {
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 4px 8px;
}

.prompt-actions button:last-child {
  margin-left: auto;
}

.connect-button {
  display: inline-block;
  border-radius: 2px;
  background: var(--teal);
  color: var(--surface);
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 600;
  font-size: .85rem;
}

.connect-button:hover {
  background: var(--link);
}

.candidate-footer a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
}

.candidate-grid+button,.connection-list+button {
  margin-top: 20px;
}

.connection-list {
  display: grid;
  gap: 20px;
}

.connection-card .candidate-title {
  font-size: 1.3rem;
}

.connection-proposed,.connection-evidence {
  margin-top: 20px;
  padding: 18px;
  border-radius: 2px;
  background: var(--accent-surface);
}

.connection-evidence {
  background: var(--page);
}

.connection-proposed h3,.connection-evidence h3 {
  font-size: .9rem;
  margin: 0 0 8px;
}

.connection-proposed p,.connection-evidence p {
  margin: 0;
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  width: min(100%,1400px);
  margin: 0 auto;
  padding: 0;
  border-bottom: 1px solid var(--control-border);
}

.page-nav a {
  padding: 12px 0;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}

.page-nav a[aria-current="page"] {
  border-bottom-color: var(--text);
  color: var(--text);
  font-weight: 600;
}

.page-nav a:hover {
  text-decoration: underline;
}

.page-nav a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

@media(max-width:700px) {
  .page-nav {
    padding: 0 18px;
  }
}

.dead-end-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 2px;
  background: var(--warning-surface);
  color: var(--warning-text);
  font-size: .75rem;
  font-weight: 600;
  vertical-align: middle;
}

.toolbar #download {
  margin-left: auto;
}

body[data-page="connections"] .toolbar select,body[data-page="connections"] #connection-copy-prompt {
  height: 42px;
  font-size: .85rem;
}

body[data-page="connections"] #connection-copy-prompt {
  align-self: flex-end;
}

.compact-panel {
  padding: 16px;
}

.list-controls {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-top: 12px;
}

.toolbar #profile-username {
  min-width: 220px;
  height: 42px;
  box-sizing: border-box;
}

.toolbar #profile-apply {
  height: 42px;
  box-sizing: border-box;
}

.list-controls input,.list-controls select {
  padding: 6px 8px;
}

#candidate-hidden {
  padding: 6px 8px;
  font-size: .85rem;
}

#candidate-hidden-control {
  position: relative;
}

#candidate-hidden[aria-expanded="true"] {
  background: var(--teal);
  color: var(--surface);
}

#candidate-hidden-options {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  width: 360px;
  max-width: calc(100vw - 84px);
  max-height: min(70vh, 620px);
  overflow-y: auto;
  padding: 12px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--control-border);
  border-radius: 2px;
  background: var(--surface);
  box-shadow: 0 4px 12px var(--shadow);
}

#candidate-hidden-options fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 10px;
}

#candidate-hidden-options fieldset + fieldset {
  border-block-start: 1px solid var(--control-border);
  padding-block-start: 12px;
}

#candidate-hidden-options legend {
  padding: 0;
  margin-block-end: 8px;
  font-weight: 700;
}

#candidate-hidden-options p { margin: 0; font-size: .85rem; }
body[data-page="connections"] #candidate-hidden-options { inset-inline-start: 0; }

#candidate-hidden-options label {
  flex-direction: row;
  align-items: flex-start;
  flex: initial;
  cursor: pointer;
}

#candidate-hidden-options input {
  flex: none;
  width: auto;
  margin: 4px 0 0;
  padding: 0;
}

@media(max-width:1000px) {
  #candidate-hidden-control {
    position: static;
  }
}

.table-scroll {
  overflow-x: auto;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  line-height: 1.25;
}

.compact-table th,.compact-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.compact-table th {
  white-space: nowrap;
  background: var(--page);
}

.compact-table td:first-child {
  min-width: 180px;
  overflow-wrap: anywhere;
}

.compact-table tbody tr:hover {
  background: var(--page);
}

.compact-panel button {
  margin-top: 12px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #eaecf0;
  --page: #101418;
  --surface: #202122;
  --muted: #a2a9b1;
  --control-border: #72777d;
  --teal: #88a3e8;
  --orange: #e6a0a0;
  --link: #88a3e8;
  --border: #54595d;
  --accent-surface: #233449;
  --subtle: #27292d;
  --warning-surface: #3d3219;
  --warning-text: #f8d080;
  --shadow: #00000033;
}

input,select {
  color: var(--text);
}

a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-row h1 {
  flex: 1;
  min-width: 0;
}

.preferences {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.preference-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  color: var(--text);
  font-weight: 700;
  background: var(--accent-surface);
  border-color: var(--control-border);
}

.preference-button:hover {
  color: var(--text);
  border-color: var(--teal);
}

.account-menu {
  position: relative;
}

.account-menu summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--control-border);
  border-radius: 2px;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px,calc(100vw - 56px));
  padding: 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: 0 8px 24px var(--shadow);
  overflow-wrap: anywhere;
}

#auth-status {
  margin: 0;
  padding: 10px;
  background: var(--warning-surface);
  color: var(--warning-text);
  border-radius: 2px;
  font-size: .9rem;
}

.theme-button span {
  display: flex;
}

.theme-button svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

@media(max-width:600px) {
  .header-row {
    gap: 12px;
  }
  .preferences {
    gap: 6px;
  }
  .preference-button {
    min-width: 38px;
    min-height: 44px;
    padding: 6px;
  }
  .header-row h1 {
    font-size: clamp(1.3rem,5vw,2rem);
  }
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.feature-chart .bar-row {
  grid-template-columns: minmax(240px,1fr) minmax(0,2fr) 180px;
}

.feature-chart .bar-label {
  min-width: 0;
}

.feature-chart .bar-value {
  overflow-wrap: anywhere;
}

@media(max-width:700px) {
  .feature-chart .bar-row {
    grid-template-columns: minmax(0,1fr) 140px;
  }
}

/* Keep prior observations hidden until the selected census has loaded. */
body[data-loading="true"] main > :not(.toolbar):not(#status) {
  visibility: hidden;
}

button:disabled {
  cursor: default;
  opacity: .55;
}

/* Shared Wikimedia-style workspace: neutral surfaces and progressive actions. */
main {
  background: var(--surface);
  min-height: 60vh;
}

.about-copy {
  max-width: 75ch;
  overflow-wrap: anywhere;
}

.about-copy h2,.about-copy h3 {
  margin-block: 24px 12px;
}

footer {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  padding-bottom: 32px;
}

button {
  min-height: 36px;
  padding: 6px 12px;
  background: var(--page);
  color: var(--text);
  font-weight: 600;
  line-height: 1.5;
}

button:hover:enabled {
  background: var(--subtle);
  border-color: var(--muted);
}

button:active:enabled {
  background: var(--accent-surface);
  border-color: var(--teal);
}

input,select {
  min-height: 36px;
  padding: 6px 10px;
}

input[type="checkbox"] {
  min-height: auto;
  accent-color: var(--teal);
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.toolbar {
  padding: 16px;
  gap: 16px 24px;
  background: var(--page);
  border: 1px solid var(--border);
}

body[data-page="articles"] .toolbar,
body[data-page="creators"] .toolbar {
  padding-bottom: 16px;
}

.panel-head {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-head p:last-child {
  margin-bottom: 0;
}

.panel > h2 {
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.legend {
  padding: 12px 16px;
  font-size: .875rem;
  background: var(--page);
  border: 1px solid var(--border);
}

.orphan::before,.other::before {
  content: '';
  display: inline-block;
  width: .75em;
  height: .75em;
  margin-right: .5em;
  background: currentColor;
}

.bar-row {
  padding: 8px 0;
  margin: 0;
  border-bottom: 1px solid var(--subtle);
  font-size: .875rem;
}

.bar-bg,.bar {
  height: 14px;
}

svg text {
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

#status {
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  background: var(--page);
  font-size: .875rem;
}

#status.demo {
  border-left-color: var(--warning-text);
}

.candidate-title a {
  color: var(--link);
}

.candidate-footer {
  background: var(--page);
}

.candidate-badge {
  border: 1px solid var(--border);
  font-weight: 600;
}

.connect-button,#llm-prompt-copy {
  color: #fff;
  background: #36c;
  border: 1px solid #36c;
}

.connect-button:hover,#llm-prompt-copy:hover:enabled {
  color: #fff;
  background: #3056a9;
  border-color: #3056a9;
  text-decoration: none;
}

.connection-proposed {
  border-left: 3px solid var(--teal);
}

.connection-evidence {
  border: 1px solid var(--border);
}

.table-scroll {
  border: 1px solid var(--border);
  margin-top: 16px;
}

.compact-table {
  line-height: 1.5;
}

.compact-table th,.compact-table td {
  padding: 10px 12px;
}

.compact-table th {
  background: var(--subtle);
}

.compact-table tbody tr:nth-child(even) {
  background: var(--page);
}

.compact-table tbody tr:hover {
  background: var(--accent-surface);
}

.preference-button {
  background: transparent;
  border-color: transparent;
}

dialog {
  box-shadow: 0 8px 32px #0003;
}

dialog textarea:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

@media(min-width:1480px) {
  main {
    border-inline: 1px solid var(--border);
  }
}

@media(max-width:1480px) {
  .page-nav {
    width: calc(100% - 80px);
  }
}

@media(max-width:700px) {
  .page-nav {
    width: calc(100% - 36px);
    padding: 0;
    gap: 0 20px;
  }
  .page-nav a {
    font-size: .875rem;
  }
  .toolbar {
    padding: 12px;
  }
  .toolbar label,.list-controls label {
    flex: 1 1 180px;
    min-width: 0;
  }
  .toolbar select,.toolbar input,.list-controls input,.list-controls select {
    width: 100%;
  }
  .toolbar #download {
    margin-left: 0;
  }
  .candidate-body {
    padding: 16px;
  }
  .candidate-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .metric {
    padding: 14px;
    overflow-wrap: anywhere;
  }
  .metric strong {
    font-size: 1.6rem;
  }
}
