:root {
  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --text: #1c1e21;
  --muted: #6b7280;
  --border: #e2e5e9;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --danger: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --bg-alt: #1e2128;
    --text: #e8eaed;
    --muted: #9aa2ad;
    --border: #2e333b;
    --accent: #7aa2f7;
    --accent-soft: #1f2a44;
    --danger: #f87171;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

nav.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
nav.topbar .brand { font-weight: 650; font-size: 1.05rem; color: var(--text); }
nav.topbar a.navlink { color: var(--muted); font-size: 0.95rem; padding: 0.2rem 0.1rem; }
nav.topbar a.navlink:hover { color: var(--text); text-decoration: none; }
nav.topbar a.navlink.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
h1 { font-size: 1.7rem; font-weight: 650; margin: 0 0 0.4rem; }
h2 { font-size: 1.25rem; font-weight: 640; margin: 2.2rem 0 0.8rem; }
p.lead { color: var(--muted); margin-top: 0; }

.feature-list { display: grid; gap: 0.75rem; margin-top: 1rem; }
.feature-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  background: var(--bg-alt);
}
.feature-card h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.feature-card p { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.92rem; }
.choice-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  white-space: nowrap;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.matrix { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
table.matrix th, table.matrix td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
  min-width: 130px;
}
table.matrix th:last-child, table.matrix td:last-child { border-right: none; }
table.matrix tr:last-child td { border-bottom: none; }
table.matrix thead th { background: var(--bg-alt); }
table.matrix td.paper-cell, table.matrix th.paper-col {
  position: sticky; left: 0;
  background: var(--bg);
  min-width: 180px;
  font-weight: 600;
  z-index: 1;
}
table.matrix thead th.paper-col { background: var(--bg-alt); z-index: 2; }
table.matrix tr.group-row th {
  text-align: center;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}
table.matrix select {
  width: 100%;
  padding: 0.25rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.87rem;
}
table.matrix select.unset { color: var(--muted); }

.del-btn {
  border: none; background: none; color: var(--muted);
  cursor: pointer; font-size: 0.85rem; padding: 0 0.2rem;
  visibility: hidden;
}
th:hover .del-btn, td:hover .del-btn { visibility: visible; }
.del-btn:hover { color: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
button.action {
  padding: 0.42rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
button.action.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.action:hover { filter: brightness(1.05); }

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  padding: 1.2rem 1.4rem;
  max-width: 480px;
  width: 90vw;
}
dialog::backdrop { background: rgba(0,0,0,0.45); }
dialog h3 { margin-top: 0; }
dialog label { display: block; font-size: 0.9rem; margin: 0.7rem 0 0.2rem; color: var(--muted); }
dialog input, dialog textarea {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.92rem;
}
dialog .dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.1rem; }

.note { color: var(--muted); font-size: 0.85rem; }

.reading-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.6rem;
  background: var(--bg-alt);
}
.reading-group summary {
  cursor: pointer;
  padding: 0.6rem 1rem;
  user-select: none;
}
ul.reading-items { list-style: none; margin: 0; padding: 0 1rem 0.8rem; }
ul.reading-items li {
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}
.inline-chips { display: inline-flex; margin-left: 0.5rem; vertical-align: middle; }
.inline-chips .chip { font-size: 0.72rem; padding: 0.05rem 0.45rem; }

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-notimpl { background: var(--bg-alt); color: var(--muted); border: 1px solid var(--border); }
.status-waiting { background: #fef9c3; color: #854d0e; }
.status-progress { background: #dbeafe; color: #1e40af; }
.status-done { background: #dcfce7; color: #166534; }
@media (prefers-color-scheme: dark) {
  .status-waiting { background: #423a12; color: #fef08a; }
  .status-progress { background: #1f2a44; color: #93c5fd; }
  .status-done { background: #14321f; color: #86efac; }
}
table.matrix.exp td { font-size: 0.88rem; }
td.exp-name { font-weight: 600; min-width: 160px; }
td.exp-desc { min-width: 220px; color: var(--muted); }
td.exp-features { max-width: 380px; }
.feat-chip { margin: 0.12rem 0.15rem; display: inline-block; font-size: 0.78rem; }
.feat-chip .feat-name { color: var(--muted); }
.artifact-entry { font-size: 0.82rem; margin-bottom: 0.2rem; }
.artifact-entry code { font-size: 0.78rem; word-break: break-all; }
details.diagram-toggle {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-alt);
  margin: 0.8rem 0 1rem;
}
details.diagram-toggle summary { cursor: pointer; padding: 0.6rem 1rem; user-select: none; font-weight: 600; }
details.diagram-toggle .diagram-wrap { padding: 0 1rem; }

table.matrix.setups td.paper-cell { min-width: 240px; }
.setup-id { margin-top: 0.15rem; }
tr:target td { background: var(--accent-soft); }
tr:target td.paper-cell { background: var(--accent-soft); }

td.exp-details { min-width: 200px; font-size: 0.85rem; color: var(--muted); }
