body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 24px;
  background: #f9fafb;
  color: #111827;
}

header { max-width: 1500px; }
h1 { font-size: 22px; margin: 0 0 6px; }
.description {
  font-size: 14px;
  color: #1f2937;
  max-width: 900px;
  margin: 6px 0 10px;
  line-height: 1.45;
}
.disclaimer {
  font-size: 13px;
  color: #4b5563;
  max-width: 900px;
  margin: 0 0 10px;
  line-height: 1.4;
  font-style: italic;
}
.disclaimer p { margin: 0; }
.disclaimer strong { font-style: normal; color: #1f2937; }
.subtitle { font-size: 12px; color: #4b5563; max-width: 900px; margin-bottom: 8px; line-height: 1.4; }
.subtitle p { margin: 0 0 4px; }
.subtitle p:last-child { margin-bottom: 0; }
.subtitle ul {
  margin: 2px 0 0;
  padding-left: 0;
  list-style: none;
}
.subtitle li { margin: 0; }
.subtitle strong { color: #1f2937; font-weight: 600; }

.legend {
  display: flex; gap: 14px; align-items: center; font-size: 12px; color: #374151;
  margin: 10px 0 18px; flex-wrap: wrap;
}
.legend-swatches { display: flex; align-items: center; gap: 2px; }
.swatch { width: 22px; height: 14px; border: 1px solid #9ca3af; }
.legend-gray { width: 22px; height: 14px; background: #e5e7eb; border: 1px solid #9ca3af; }

#summary {
  margin: 0 0 32px;
  width: fit-content;
}
.summary-heading {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 4px;
}
#summary-table {
  border-collapse: collapse;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-size: 13px;
  width: auto;
}
#summary-table th, #summary-table td {
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  text-align: center;
  line-height: 1.35;
  white-space: nowrap;
}
#summary-table th {
  background: #1f2937;
  color: white;
  font-weight: 600;
  font-size: 13px;
}
#summary-table th:first-child,
#summary-table td.summary-section-name {
  text-align: left;
}
#summary-table td.summary-section-name {
  background: #f3f4f6;
  font-weight: 600;
  color: #1f2937;
}
.summary-count {
  font-weight: 400;
  font-size: 12px;
  color: #6b7280;
  margin-left: 4px;
}
#summary-table td.summary-avg {
  font-weight: 700;
  font-size: 14px;
  color: #111827;
  min-width: 38px;
}
#summary-table td.summary-avg.gray {
  background: #e5e7eb;
  color: #9ca3af;
}
@media (max-width: 900px) {
  #summary-table th:not(:first-child):not(:last-child),
  #summary-table td:not(:first-child):not(:last-child) {
    display: none;
  }
}

table {
  border-collapse: collapse;
  width: 100%;
  max-width: 1500px;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
th, td {
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.35;
}
th {
  background: #1f2937;
  color: white;
  font-weight: 600;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
}
th:nth-child(1) { width: 170px; }
th:last-child { width: 80px; text-align: center; }

tr.section-header td {
  background: #374151;
  color: white;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  letter-spacing: 1px;
  padding: 6px 10px;
  text-transform: uppercase;
}

td.name {
  font-weight: 600;
  background: #f3f4f6;
  font-size: 13px;
  position: relative;
}
td.name:hover .name-propose,
.name-propose:focus { opacity: 1; }
td.name .title {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

td.score-cell { position: relative; transition: background-color 0.2s; padding-bottom: 22px; }
.score-input {
  display: inline-block;
  box-sizing: border-box;
  min-width: 28px;
  background: rgba(255,255,255,0.55);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 3px;
  color: #111827;
  margin-right: 6px;
  float: left;
}

.avg-pill {
  display: inline-block;
  background: rgba(255,255,255,0.55);
  border-radius: 3px;
  padding: 1px 8px;
  font-weight: 700;
  font-size: 14px;
  color: #111827;
}

.note {
  font-size: 12px;
  color: #1f2937;
  display: block;
  overflow: hidden;
}

td.gray {
  background: #e5e7eb !important;
  color: #6b7280;
}
td.gray .note { color: #6b7280; font-style: italic; }

td.avg {
  font-weight: 700;
  text-align: center;
  font-size: 15px;
  transition: background-color 0.2s;
}

tr.data-row:hover td.name { background: #e5e7eb; }

.cell-propose {
  position: absolute;
  bottom: 3px;
  right: 4px;
  background: rgba(255,255,255,0.85);
  border: 1px solid #d1d5db;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 2px 5px;
  opacity: 0;
  transition: opacity 0.15s;
  color: #374151;
}
.score-cell:hover .cell-propose,
.cell-propose:focus { opacity: 1; }
.cell-propose:hover { background: white; color: #111827; }

footer {
  margin-top: 16px;
  max-width: 900px;
  font-size: 11px;
  color: #6b7280;
}

.propose-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #2563eb;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.propose-btn:hover { background: #1d4ed8; }

dialog#propose-modal {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 24px;
  max-width: 520px;
  width: 90%;
  font-family: inherit;
  color: #111827;
}
dialog#propose-modal::backdrop { background: rgba(0,0,0,0.4); }

#propose-form h2 { margin: 0 0 6px; font-size: 18px; }
.modal-help { font-size: 12px; color: #6b7280; margin: 0 0 14px; }

#propose-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
}
#propose-form input,
#propose-form select,
#propose-form textarea {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-family: inherit;
  margin-top: 4px;
  box-sizing: border-box;
  background: white;
}
#propose-form textarea { resize: vertical; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.modal-actions button {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  border: 1px solid #d1d5db;
  background: white;
  color: #1f2937;
}
.modal-actions button[type="submit"] {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}
.modal-actions button[type="submit"]:disabled { opacity: 0.6; cursor: not-allowed; }

#propose-result {
  margin-top: 12px;
  font-size: 13px;
  color: #374151;
}
#propose-result a { color: #2563eb; }

@media (max-width: 900px) {
  body { margin: 10px; }
  h1 { font-size: 18px; }
  .subtitle { font-size: 12px; }

  /* Mobile widths: name column anchored, score columns split the remaining
     width equally. --score-col-width is set by matrix.js based on
     data.columns.length, so this works for Zohran (4 score cols) and Platner
     (2 score cols) alike. */
  #matrix { font-size: 12px; table-layout: fixed; width: 100%; }
  #matrix th, #matrix td { padding: 5px 6px; word-wrap: break-word; }
  #matrix th:first-child { width: 32%; }
  #matrix th:not(:first-child):not(:last-child) { width: var(--score-col-width); }
  /* Hide Avg column at narrow widths to keep table within viewport. */
  #matrix th:last-child, #matrix td.avg { display: none; }

  td.name {
    cursor: pointer;
    user-select: none;
    padding-right: 18px;
    position: relative;
  }
  td.name::after {
    content: '▸';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: 10px;
    transition: transform 0.15s;
  }
  tr.data-row.expanded td.name::after {
    transform: translateY(-50%) rotate(90deg);
  }

  td.score-cell {
    text-align: center;
    padding: 8px 4px;
    cursor: pointer;
  }
  td.score-cell .note { display: none; }
  td.score-cell .cell-propose { display: none; }

  td.score-cell.gray::after {
    content: '—';
    color: #9ca3af;
    font-weight: 700;
    font-size: 14px;
  }

  .score-input {
    float: none;
    margin: 0;
    min-width: 34px;
    font-size: 14px;
    background: rgba(255,255,255,0.4);
  }

  td.avg { font-size: 13px; padding: 6px 4px; }

  tr.data-row.expanded + tr.detail-row { display: table-row; }

  .propose-btn { padding: 8px 14px; font-size: 13px; }
}

/* Detail rows: hidden in wide view; revealed at narrow widths when expanded. */
tr.detail-row { display: none; }
tr.detail-row > td {
  padding: 8px 10px;
  background: #f9fafb;
  border-top: 0;
}
.detail-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-item {
  background: white;
  border-left: 3px solid #d1d5db;
  border-radius: 0 4px 4px 0;
  padding: 6px 10px;
}
.detail-item.gray { border-left-color: #9ca3af; }
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}
.detail-col-label {
  font-weight: 700;
  font-size: 11px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.detail-score {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 12px;
  margin-left: 4px;
  color: #111827;
  background: #e5e7eb;
}
.detail-note {
  font-size: 12px;
  color: #1f2937;
  line-height: 1.4;
}
.detail-item.gray .detail-note { color: #6b7280; font-style: italic; }
.detail-propose {
  position: static;
  opacity: 1;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  background: white;
  color: #2563eb;
  font-weight: 600;
  line-height: 1.2;
}
.detail-propose:hover { background: #eff6ff; }

.dossier-toggle {
  display: inline-block;
  margin-top: 4px;
  background: none;
  border: none;
  font-size: 11px;
  font-weight: 500;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  line-height: 1.3;
}
.dossier-toggle:hover { text-decoration: underline; }

tr.dossier-row { display: none; }
tr.dossier-row.expanded { display: table-row; }
tr.dossier-row > td {
  background: #f9fafb;
  padding: 14px 18px;
  border-top: 0;
}
dl.dossier {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 1100px;
}
dl.dossier dt {
  font-weight: 700;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
  padding-top: 3px;
  white-space: nowrap;
}
dl.dossier dd {
  margin: 0;
  color: #1f2937;
}
dl.dossier dd > p {
  margin: 0 0 6px;
}
dl.dossier dd > p:last-child { margin-bottom: 0; }
dl.dossier dd ul,
dl.dossier dd ol {
  margin: 4px 0 6px;
  padding-left: 20px;
}
dl.dossier dd em {
  font-style: italic;
}
dl.dossier dd strong {
  color: #4b5563;
  font-weight: 600;
}
dl.dossier dd a {
  color: #2563eb;
  text-decoration: none;
}
dl.dossier dd a:hover { text-decoration: underline; }
dl.dossier dd code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: #e5e7eb;
  padding: 1px 4px;
  border-radius: 3px;
}

@media (max-width: 900px) {
  tr.dossier-row > td { padding: 10px 12px; }
  dl.dossier {
    grid-template-columns: 1fr;
    gap: 2px 0;
    font-size: 12px;
  }
  dl.dossier dt {
    margin-top: 8px;
  }
  dl.dossier dt:first-child {
    margin-top: 0;
  }
}
