* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent-dark);
  text-underline-offset: 0.16em;
}
a:hover {
  text-decoration-thickness: 2px;
}
h1,
h2,
h3 {
  line-height: 1.25;
  font-weight: 600;
}
h1 {
  font: 700 2.125rem var(--serif);
  margin: 0 0 14px;
}
h2 {
  font: 700 13px var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 18px 0 12px;
}
h3 {
  font-size: 1rem;
}
p {
  max-width: 78ch;
}
.site-footer,
main {
  max-width: 680px;
  margin: auto;
  padding: 16px;
}
.site-header,
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}
.site-header { padding: 12px 18px; }
.brand {
  font: 700 1.2rem var(--serif);
  letter-spacing: 0.2px;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--accent); }
.site-header label { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); }
.site-header select { border-radius: 999px; }
.site-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  margin-top: 2rem;
  font-size: 0.9rem;
}
main {
  padding-bottom: 24px;
}
.skip-link {
  position: fixed;
  top: -100px;
  left: 1rem;
  background: var(--card);
  padding: 1rem;
  z-index: 10;
}
.skip-link:focus {
  top: 1rem;
}
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
nav a {
  padding: 10px 9px;
  color: var(--ink);
  border-radius: 12px;
  text-decoration: none;
  min-height: 44px;
  font-size: 13px;
}
nav [aria-current] {
  font-weight: 700;
  background: var(--accent);
  color: var(--button-ink);
}
nav a:hover { background: var(--card); color: var(--ink); }
nav [aria-current]:hover { background: var(--accent-dark); color: var(--button-ink); }
form,
.actions,
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin: 1rem 0;
}
label {
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 0;
}
form label {
  flex: 1 1 12rem;
  max-width: 100%;
  grid-template-columns: minmax(0, 1fr);
}
form {
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.workspace-card,
.research-card,
#results > section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 0 14px;
  min-width: 0;
}
.workspace-card > :last-child,
.research-card > :last-child { margin-bottom: 0; }
.workspace-card form { box-shadow: none; padding: 0; border: 0; background: transparent; border-radius: 0; }
.workspace-card form:last-child { margin-bottom: 0; }
.workspace-card h2:first-child,
.research-card h2:first-child,
#results > section > h2:first-child { margin-top: 0; }
.workspace-card:has(> h1:only-child) { margin-bottom: 14px; }
.language-workspace > form + form { border-top: 1px solid var(--line); padding-top: 16px; }
.language-selection { padding: 12px 0; font-size: 13px; }
.language-selection .actions { margin-bottom: 0; }
.language-catalog table { font-size: 13px; }
.language-catalog .table-wrap { border-radius: 10px; box-shadow: none; }
.language-catalog input[type="checkbox"] { width: 20px; height: 20px; min-height: 20px; accent-color: var(--accent); }
.language-catalog td:has(input[type="checkbox"]) label { min-width: 44px; min-height: 44px; display: grid; place-items: center; }
.catalog-selection span { display: none; }
.language-catalog caption { color: var(--muted); font-size: 12px; }
form > button:not([type="button"]) {
  background: var(--accent);
  color: var(--button-ink);
  border-color: var(--accent);
}
.language-pickers { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.language-picker { min-width: 0; align-content: start; margin: 0; }
.language-picker h2, .language-picker p, .language-picker [role="status"] { flex-basis: 100%; margin: 0; }
.language-picker label { flex-basis: 100%; }
.identifier-help { flex-basis: 100%; margin: 0.35rem 0; font-size: 0.875rem; font-weight: 400; color: var(--muted); }
.identifier-help a { white-space: normal; }
form select {
  min-width: 0;
  width: 100%;
}
input,
select,
button {
  font: inherit;
  min-height: 44px;
  max-width: 100%;
  border: 1px solid var(--control-line);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  color: var(--ink);
  background: var(--card);
}
input {
  width: 100%;
}
button {
  cursor: pointer;
  font-weight: 600;
}
button:hover {
  border-color: var(--accent);
}
button:disabled {
  cursor: wait;
  opacity: 0.65;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.metadata,
.empty,
figcaption {
  color: var(--muted);
  font-size: 0.9rem;
}
.error {
  border-left: 3px solid var(--accent);
  padding: 0.6rem 1rem;
  background: var(--card);
}
.table-wrap {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.94rem;
}
caption {
  text-align: left;
  padding: 0.65rem;
  font-weight: 600;
}
th,
td {
  padding: 0.65rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
th {
  background: var(--surface-2);
}
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, var(--card)); }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap a { display: inline-block; }
th button {
  padding: 0.25rem 0.4rem;
  text-align: left;
}
details {
  margin: 0.6rem 0;
}
summary {
  cursor: pointer;
  min-height: 44px;
  padding: 0.5rem 0;
  font-weight: 600;
}
.tree {
  padding-left: 1.25rem;
  border-left: 1px solid var(--line);
  list-style: none;
}
.tree li {
  margin: 0.3rem 0;
}
.node-type {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 0.5rem;
}
.lineage {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
  padding-left: 1.2rem;
}
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.6rem;
}
.facts dt {
  font-weight: 600;
}
.facts dd {
  margin: 0;
}
.inventory {
  border-top: 1px solid var(--line);
}
.segments {
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
}
.kwic {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
mark {
  background: var(--card);
  color: var(--accent-dark);
  font-weight: 700;
}
.kwic small {
  display: block;
}
.map-canvas svg {
  display: block;
  width: 100%;
  height: auto;
}
.country-shape {
  stroke: var(--paper);
  stroke-width: 0.5;
}
.map-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.swatch {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 1px solid var(--ink);
  vertical-align: middle;
  margin-right: 0.3rem;
}
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.comparison td,
.comparison th {
  width: 33.3%;
}
code {
  overflow-wrap: anywhere;
}
#status {
  min-height: 1.4rem;
  margin: 6px 0;
  font-size: 12px;
  color: var(--muted);
}
.references {
  font-size: 0.9rem;
}
.notice {
  border-left: 3px solid var(--line);
  padding-left: 0.8rem;
}
@media (max-width: 480px) {
  main,
  .site-header,
  .site-footer {
    padding: 0.75rem;
  }
  nav {
    gap: 0;
  }
  nav a {
    padding: 0.5rem;
  }
  .compare-grid {
    grid-template-columns: 1fr;
  }
  .language-pickers { grid-template-columns: minmax(0,1fr); }
  form { padding: 0.75rem; }
  form > button { flex-grow: 1; }
  .comparison th,
  .comparison td {
    padding: 0.45rem 0.3rem;
    font-size: 0.82rem;
  }
  .table-wrap table {
    min-width: 0;
  }
  h1 {
    font-size: 1.875rem;
  }
  .workspace-card, .research-card, #results > section { padding: 16px; }
  .language-catalog thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .language-catalog tr { display: grid; grid-template-columns: minmax(0,1fr) 62px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
  .language-catalog tr:last-child { border-bottom: 0; }
  .language-catalog td { display: block; padding: 3px; border: 0; }
  .language-catalog td:first-child { grid-column: 1; font-size: 15px; }
  .language-catalog td:nth-child(2), .language-catalog td:nth-child(3) { grid-column: 1; font-size: 12px; color: var(--muted); }
  .language-catalog td:last-child { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .catalog-selection span { display: inline; font-size: 11px; }
  .tree {
    padding-left: 0.7rem;
  }
  .actions button {
    flex: 1 1 auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
@media (forced-colors: active) {
  button,
  .table-wrap,
  .swatch {
    border: 1px solid CanvasText;
  }
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
dd {
  margin-left: 0;
  overflow-wrap: anywhere;
}
section {
  min-width: 0;
}

.source-comment {
  white-space: pre-line;
}
