* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  background: #f7f8fa;
  color: #222;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #1e2a38;
}
header .brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  font-size: 18px;
}
header nav a {
  color: #cfd8e3;
  text-decoration: none;
  margin-left: 16px;
  font-size: 14px;
}
header nav a:hover { color: #fff; }

main {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

h1 { font-size: 22px; }
h2 { font-size: 18px; margin-top: 28px; }

.hint { color: #666; font-size: 14px; }

/* matrix */
.matrix {
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
}
.matrix th,
.matrix td {
  border: 1px solid #c9d2dc;
  padding: 4px;
  text-align: center;
  min-width: 32px;
}
.matrix thead th {
  background: #eef2f7;
  font-weight: 600;
  padding: 6px 8px;
  white-space: nowrap;
}
.matrix tbody th {
  background: #eef2f7;
  text-align: right;
  padding: 6px 10px;
  font-weight: 500;
}
.matrix td a {
  display: block;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}
.matrix td.diag { background: #e0e0e0; color: #888; }
.matrix td.empty { background: #f5f5f5; }

/* flash messages */
.flash {
  padding: 8px 12px;
  border-radius: 4px;
  margin: 8px 0;
  font-size: 14px;
}
.flash.ok    { background: #dff5e1; color: #206b2a; }
.flash.error { background: #fde2e2; color: #8a1f1f; }

/* forms */
form label {
  display: block;
  margin: 12px 0;
  font-size: 14px;
  font-weight: 500;
}
form input,
form textarea {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  font: inherit;
  border: 1px solid #b7c2ce;
  border-radius: 4px;
}
form button {
  padding: 9px 18px;
  background: #1e2a38;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
form button:hover { background: #2c3e56; }

/* evaluation list */
.pairs { padding-left: 18px; }
.pairs li {
  margin: 14px 0;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 6px;
  list-style: none;
}
.pairs .pair { margin-bottom: 6px; }

/* comments */
.comments { list-style: none; padding: 0; }
.comments li {
  background: #fff;
  padding: 10px 14px;
  border: 1px solid #dde3ea;
  border-radius: 6px;
  margin: 8px 0;
}
.comments h3 { margin: 0 0 4px; font-size: 15px; }
.comments .meta { color: #666; font-size: 12px; margin: 0 0 6px; }
.comments .desc { font-style: italic; color: #444; margin: 0 0 6px; }

/* topic titles are clickable links */
.matrix .topic-link {
  color: #1e2a38;
  text-decoration: none;
  border-bottom: 1px dotted #1e2a38;
}
.matrix .topic-link:hover {
  color: #2c3e56;
  border-bottom-style: solid;
}

/* per-pair vote count badge in the evaluate form */
.pairs .votes {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  color: #666;
  background: #eef2f7;
  padding: 2px 8px;
  border-radius: 10px;
}

/* cancel link next to submit button */
.cancel {
  margin-left: 12px;
  color: #666;
  font-size: 14px;
  text-decoration: none;
}
.cancel:hover { color: #222; text-decoration: underline; }

/* both header row and header column now show only IDs */
.matrix thead th.id-col,
.matrix tbody th.id-col {
  padding: 6px 6px;
  text-align: center;
  background: #eef2f7;
}
.matrix thead th.id-col a,
.matrix tbody th.id-col a {
  color: #1e2a38;
  text-decoration: none;
  font-weight: 700;
  display: inline-block;
  min-width: 20px;
}
.matrix thead th.id-col a:hover,
.matrix tbody th.id-col a:hover { text-decoration: underline; }

/* legend below the table */
.legend-title { font-size: 16px; margin-top: 26px; }
ul.legend {
  columns: 3;
  column-gap: 28px;
  list-style: none;
  padding: 0;
  font-size: 14px;
}
ul.legend li { padding: 2px 0; break-inside: avoid; }

@media (max-width: 700px) {
  ul.legend { columns: 1; }
  .matrix thead th,
  .matrix tbody th { font-size: 11px; }
}

/* topic detail page */
.topic-id { color: #888; font-weight: 400; font-size: 16px; }
.topic-desc { font-size: 15px; line-height: 1.5; color: #333; }
.button-like {
  display: inline-block;
  padding: 6px 14px;
  background: #1e2a38;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
}
.button-like:hover { background: #2c3e56; }

/* keep legend readable on narrow screens */
@media (max-width: 700px) {
  ul.legend { columns: 1; }
  .matrix thead th { font-size: 11px; }
}

/* trash icon on comments */
.comments .trash {
  background: transparent;
  border: none;
  color: #b23b3b;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  margin-left: 8px;
  border-radius: 4px;
  opacity: 0.45;
  transition: opacity 0.15s, background 0.15s;
  vertical-align: middle;
}
.comments .trash:hover {
  opacity: 1;
  background: #fbe9e9;
}
.comments h3 { display: flex; align-items: center; }

/* home page: list of texts */
.lead { font-size: 15px; line-height: 1.6; color: #333; max-width: 780px; }
.lead a { color: #1e2a38; }

ol.texts-list {
  list-style: none;
  padding: 0;
  margin: 24px 0;
}
li.text-card {
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 20px 24px;
  margin: 18px 0;
}
li.text-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
  color: #1e2a38;
}
li.text-card .meta {
  color: #666;
  font-size: 13px;
  margin: 0 0 12px;
}
li.text-card .desc {
  font-style: italic;
  color: #444;
  margin: 0 0 12px;
}
li.text-card .body {
  white-space: pre-wrap;   /* preserves paragraph breaks */
  line-height: 1.6;
  color: #222;
}

/* threshold graph page */
.slider-block { margin: 18px 0 10px; }
.slider-block label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1e2a38;
}
.slider-block input[type="range"] {
  width: 100%;
  max-width: 640px;
  accent-color: #1e2a38;
}
.counters { font-size: 14px; color: #333; margin: 6px 0 20px; }
.counters strong { color: #1e2a38; }

.adj-grid-wrap { overflow-x: auto; margin-bottom: 24px; }
table.adj-grid {
  border-collapse: collapse;
  font-size: 10px;
  background: #fff;
}
table.adj-grid th,
table.adj-grid td {
  border: 1px solid #c9d2dc;
  padding: 0;
  width: 18px;
  height: 18px;
  text-align: center;
}
table.adj-grid thead th,
table.adj-grid tbody th {
  background: #eef2f7;
  padding: 2px 4px;
  font-weight: 700;
  font-size: 11px;
  width: auto;
  height: auto;
}
table.adj-grid td.diag { background: #d0d0d0; }
table.adj-grid td.on   { background: #1e2a38; }
table.adj-grid td.off  { background: #ffffff; }

.cluster-list { display: flex; flex-direction: column; gap: 14px; }
.cluster {
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 6px;
  padding: 12px 18px;
}
.cluster h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #1e2a38;
}
.cluster ul {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 24px;
  font-size: 14px;
}
.cluster li { padding: 2px 0; break-inside: avoid; }
.cluster .topic-id { color: #888; font-size: 12px; }

@media (max-width: 700px) {
  .cluster ul { columns: 1; }
}

/* matrix + barcode side by side */
.barcode-wrap {
  margin: 12px 0 28px;
}
#barcode-svg {
  display: block;
  width: 100%;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 4px;
}
.barcode-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #666;
  padding: 4px 4px 0;
}
.barcode-hint {
  font-size: 11px;
  color: #777;
  line-height: 1.45;
  margin: 8px 0 0;
}

@media (max-width: 700px) {
  .matrix-barcode-wrap { flex-direction: column; }
}

/* participate CTA on the matrix page */
.participate-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: #eef2f7;
  border: 1px solid #d3dde8;
  border-radius: 8px;
  padding: 16px 22px;
  margin: 18px 0 22px;
}
.participate-cta .cta-text { flex: 1 1 auto; }
.participate-cta h2 {
  margin: 0 0 6px;
  font-size: 16px;
  color: #1e2a38;
}
.participate-cta p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #333;
}
.participate-cta strong { color: #1e2a38; }

.participate-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 10px 22px;
  font-size: 15px;
  background: #1e2a38;
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
}
.participate-btn:hover { background: #2c3e56; }

@media (max-width: 700px) {
  .participate-cta {
    flex-direction: column;
    align-items: flex-start;
  }
  .participate-btn { align-self: stretch; text-align: center; }
}

/* clickable legend entries */
ul.legend a {
  color: #1e2a38;
  text-decoration: none;
}
ul.legend a:hover { text-decoration: underline; }

/* detailed topic index */
.topic-index {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 18px 0 28px;
}
.topic-card {
  display: flex;
  gap: 24px;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 18px 22px;
}
.topic-left  { flex: 1 1 auto; min-width: 0; }
.topic-right {
  flex: 0 0 320px;
  border-left: 1px solid #e5e9ef;
  padding-left: 22px;
}
.topic-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #1e2a38;
}
.topic-card h3 a {
  color: inherit;
  text-decoration: none;
}
.topic-card h3 a:hover { text-decoration: underline; }
.topic-card .desc {
  color: #444;
  font-style: italic;
  margin: 0 0 12px;
  font-size: 14px;
}
.topic-card .button-like {
  margin-top: 12px;
  display: inline-block;
  font-size: 13px;
  padding: 5px 14px;
}

/* read-only comment list inside the topic card */
.topic-comments h4 {
  font-size: 13px;
  color: #1e2a38;
  margin: 16px 0 6px;
}
.topic-comments ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.topic-comments li {
  padding: 8px 0;
  border-top: 1px solid #eef1f5;
  font-size: 13px;
  line-height: 1.5;
}
.topic-comments li .meta {
  color: #888;
  font-size: 11px;
  margin-left: 6px;
}
.topic-comments li p { margin: 4px 0; }

/* top-5 connections list */
.connections-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
}
.connections-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #eef1f5;
}
.connections-list li:last-child { border-bottom: none; }
.conn-score {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  font-weight: 700;
  color: #1e2a38;
  background: #eef2f7;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 12px;
}
.connections-list a {
  color: #1e2a38;
  text-decoration: none;
}
.connections-list a:hover { text-decoration: underline; }
.conn-link {
  margin-left: auto;
  font-size: 11px;
  color: #888 !important;
}
.conn-link:hover { color: #1e2a38 !important; }

@media (max-width: 800px) {
  .topic-card { flex-direction: column; }
  .topic-right {
    flex-basis: auto;
    border-left: none;
    border-top: 1px solid #e5e9ef;
    padding-left: 0;
    padding-top: 14px;
  }
}

html { scroll-behavior: smooth; }

/* ensures the card isn't flush against the very top of the viewport */
.topic-card { scroll-margin-top: 16px; }

/* graph page: adjacency + topic legend side by side */
.graph-adj-and-legend {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.graph-adj { flex: 0 1 auto; }
.graph-legend-side {
  flex: 1 1 260px;
  min-width: 260px;
}
.graph-adj-and-legend h2 { margin-top: 28px; }

ul.topic-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  columns: 2;
  column-gap: 20px;
}
ul.topic-legend li {
  padding: 2px 0;
  break-inside: avoid;
}

ul.topic-legend a {
  color: #1e2a38;
  text-decoration: none;
}

ul.topic-legend a:hover { text-decoration: underline; }

/* dendrogram */
.dendro-wrap {
  margin: 12px 0;
  overflow-x: auto;
}
#dendro-svg {
  display: block;
  width: 100%;
  max-width: 900px;
  height: auto;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 4px;
}
.dendro-hint {
  font-size: 12px;
  color: #777;
  line-height: 1.5;
  margin: 8px 0 0;
  max-width: 900px;
}

@media (max-width: 800px) {
  .graph-adj-and-legend { flex-direction: column; }
}

form select {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  font: inherit;
  border: 1px solid #b7c2ce;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
form select:focus {
  outline: 2px solid #1e2a38;
  outline-offset: 1px;
}

/* hidden inputs must not be visible (fixes empty blocks under each pair) */
form input[type="hidden"] { display: none; }

/* clickable 0..10 score buttons — one row per pair */
.score-control {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.score-label {
  font-size: 13px;
  font-weight: 500;
  color: #444;
  flex: 0 0 auto;
}
.score-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
form .score-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  margin: 0;
  border: 1px solid #b7c2ce;
  border-radius: 4px;
  background: #fff;
  color: #1e2a38;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
form .score-btn:hover {
  background: #fff;
  border-color: #1e2a38;
}
form .score-btn.selected {
  background: #1e2a38;
  border-color: #1e2a38;
  color: #fff;
}
form .score-btn.selected:hover {
  background: #1e2a38;
}
form .score-btn:focus-visible {
  outline: 2px solid #1e2a38;
  outline-offset: 2px;
}
.score-control.error .score-btn {
  border-color: #c0392b;
}

button.button-like {
  font: inherit;
  font-size: 14px;
  border: none;
  cursor: pointer;
}

/* PDF attachment link on text cards */
.text-file {
  margin: 12px 0 0;
  font-size: 14px;
}
.text-file a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #eef2f7;
  border: 1px solid #d3dde8;
  border-radius: 4px;
  color: #1e2a38;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.text-file a:hover {
  background: #dfe7f1;
  border-color: #b9c8d8;
}

/* file upload: hidden native input + styled label as button */
.file-field {
  display: block;
  margin: 12px 0;
  font-size: 14px;
  font-weight: 500;
}

.file-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.file-button {
  display: inline-block;
  padding: 6px 14px;
  background: #1e2a38;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s;
}

.file-button:hover {
  background: #2c3e56;
}

.file-name {
  margin-left: 10px;
  color: #666;
  font-size: 13px;
  font-style: italic;
}