/* lexodus — black on white, one dark blue for bars and links, system fonts, lots of white space. */
:root {
  --ink: #111111;
  --muted: #666666;
  --line: #e4e4e4;
  --blue: #1f3a68;
  --paper: #ffffff;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--blue); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2 { line-height: 1.2; margin: 0; font-weight: 600; }
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; }
p { margin: 0; }
.note { color: var(--muted); font-size: 0.9rem; }
.lead { max-width: 68ch; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top, main, footer {
  max-width: 1080px; margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 32px; padding-block: 24px 8px; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
nav { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 0.95rem; }
nav a { text-decoration: none; }
nav a[aria-current="page"] { color: var(--ink); }
nav .soon { color: var(--muted); }
main { padding-block: 32px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
#app { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
#app > .note, #app > .lead { margin-top: -12px; }
footer { padding-block: 24px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }

/* Home: plain list of the 33 languages */
.lang-list { list-style: none; margin: 0; padding: 0; columns: 2 300px; column-gap: 48px; }
.lang-list li { padding: 6px 0; break-inside: avoid; }
.lang-list a { font-weight: 600; }

/* Language page */
.head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; }
select { font: inherit; font-size: 0.9rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line); padding: 4px 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 40px; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.92rem; }
legend { float: left; margin-right: 12px; color: var(--muted); }
fieldset label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--blue); margin: 0; }

.columns { display: grid; grid-template-columns: 1fr; gap: 48px; }
@media (min-width: 820px) { .columns { grid-template-columns: 1fr 1fr; gap: 56px; } }
.columns section { min-width: 0; display: grid; gap: 6px; align-content: start; }

.rows, .sub ul { list-style: none; margin: 0; padding: 0; }
.row { padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 1px solid var(--line); }
.line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.line .name { font-weight: 600; }
.line .cat { color: var(--muted); font-size: 0.9rem; }
.line .num { margin-left: auto; font-variant-numeric: tabular-nums; }
.toggle {
  font: inherit; line-height: 1; width: 1.4em; padding: 0; border: 0; background: none; color: var(--blue); cursor: pointer; flex: none;
}
.bar { height: 3px; margin: 6px 0 0 calc(1.4em + 10px); }
.bar span { display: block; height: 100%; background: var(--blue); }
.ex { margin: 6px 0 0 calc(1.4em + 10px); font-style: italic; color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.sub { margin: 12px 0 4px calc(1.4em + 10px); padding-left: 16px; border-left: 1px solid var(--line); cursor: default; display: grid; gap: 8px; }
.sub-head { font-size: 0.9rem; color: var(--muted); }
.sub li { padding: 6px 0; }
.sub .bar, .sub .ex { margin-left: 0; }
.more { justify-self: start; margin-top: 8px; font: inherit; font-size: 0.9rem; color: var(--blue); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* About */
.prose { max-width: 68ch; display: grid; gap: 14px; }
.prose h2 { margin-top: 18px; }
.prose ul, .prose dl { margin: 0; padding-left: 20px; }
.prose dl { padding-left: 0; display: grid; gap: 8px; }
.prose dt { font-weight: 600; }
.prose dd { margin: 0 0 0 0; color: var(--muted); }
.prose li + li { margin-top: 6px; }

/* Home: the grid. Rows = the language that took, columns = the language it took from. */
.grid-block { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
.grid-block .switch { font-size: 0.95rem; }
.grid-status { min-height: 1.5em; font-size: 0.92rem; }
.grid-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.grid { border-collapse: separate; border-spacing: 2px; font-size: 0.8rem; }
.grid th { font-weight: 500; padding: 0; }
.grid th a { text-decoration: none; }
.grid th a:hover { text-decoration: underline; }
.grid .col { vertical-align: bottom; height: 9.5em; width: 22px; }
.grid .col > a, .grid .col > span { display: inline-block; }
.grid .col span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; line-height: 22px; }
.grid .corner { vertical-align: bottom; text-align: right; padding-right: 8px; color: var(--muted); font-weight: 400; white-space: nowrap; position: sticky; left: 0; background: var(--paper); z-index: 1; }
.grid .rowname { text-align: right; white-space: nowrap; padding-right: 8px; position: sticky; left: 0; background: var(--paper); z-index: 1; }
.grid td { width: 22px; height: 22px; min-width: 22px; padding: 0; }
.grid td.zero { background: #f4f4f4; }
.grid td.self { background: var(--paper); }
.grid .x, .grid th.extra { border-left: 6px solid var(--paper); }
.grid td a { display: block; height: 22px; line-height: 22px; text-align: center; font-size: 9.5px; color: #fff; text-decoration: none; font-variant-numeric: tabular-nums; }
.grid td a:hover, .grid td a:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.t1 { background: #dfe6f1; }
.t2 { background: #aebfdb; }
.t3 { background: #7590bd; }
.t4 { background: #44659c; }
.t5 { background: #1f3a68; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.legend .key { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 12px; height: 12px; }

/* Numbers that open a list of words */
.line .num a, .sub .num a { text-decoration: none; border-bottom: 1px solid currentColor; }
.line .num a:hover { border-bottom-width: 2px; }

/* Words page */
.search input { font: inherit; font-size: 0.95rem; width: min(100%, 22rem); padding: 5px 8px; border: 1px solid #bbb; background: var(--paper); color: var(--ink); }
.table-scroll { overflow-x: auto; }
.words { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.words th { text-align: left; font-weight: 600; font-size: 0.85rem; color: var(--muted); padding: 6px 12px 6px 0; border-bottom: 1px solid var(--ink); }
.words td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.words td.w { white-space: nowrap; }
.words td.w a { font-weight: 600; }
.unc { text-decoration: none; color: var(--muted); cursor: help; }
.pager { display: flex; align-items: baseline; gap: 18px; }
.pager .more { margin: 0; }
.pager .more:disabled { color: var(--muted); text-decoration: none; cursor: default; }
@media (max-width: 600px) {
  .words thead { display: none; }
  .words, .words tbody, .words tr, .words td { display: block; width: 100%; }
  .words tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .words td { border: 0; padding: 1px 0; }
  .words td.w { white-space: normal; }
}

/* Word page */
.word-page { display: grid; gap: 32px; }
.word-page section { display: grid; gap: 10px; }
.meaning { font-size: 1.15rem; margin-top: 8px; }
.path { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--blue); display: grid; gap: 0; max-width: 46rem; }
.path li { position: relative; padding: 10px 0; border-bottom: 1px solid var(--line); }
.path li::before { content: ""; position: absolute; left: -25px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--blue); }
.path li.here::before, .path li.origin::before { background: var(--blue); }
.step { display: grid; grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr) auto; gap: 4px 16px; align-items: baseline; }
.step .lang a, .step .lang { font-weight: 600; }
.step .term { font-style: italic; font-size: 1.05rem; overflow-wrap: anywhere; }
.path li.alts { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; }
.path li.alts .step { grid-template-columns: auto auto auto; border: 1px solid var(--line); padding: 6px 10px; }
.or { color: var(--muted); font-style: italic; }
.ety { margin: 0; padding: 0 0 0 16px; border-left: 1px solid var(--line); max-width: 68ch; color: var(--ink); }
@media (max-width: 600px) {
  .step { grid-template-columns: 1fr auto; }
  .step .term { grid-column: 1 / -1; grid-row: 2; }
}

/* Transliteration next to a word in another script: "قهوة (qahwa)" */
.tr { font-style: normal; font-weight: 400; color: var(--muted); }
h3 { font-size: 1rem; margin: 0 0 6px; font-weight: 600; }

/* Languages page */
.lang-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.lang-rows li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.lang-rows .line { flex-wrap: wrap; gap: 2px 12px; }
.took { margin-top: 4px; font-size: 0.92rem; overflow-wrap: anywhere; }

/* Search page */
.search-form { display: flex; gap: 8px; max-width: 30rem; }
.search-form input { flex: 1; min-width: 0; font: inherit; padding: 7px 10px; border: 1px solid #999; background: var(--paper); color: var(--ink); }
.search-form button { font: inherit; padding: 7px 14px; border: 1px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; }
.results { display: grid; gap: 28px; }
.result-lang { display: grid; gap: 4px; }
.result-lang h2 { font-size: 1.05rem; }
.result-lang ul, .ranked { list-style: none; margin: 0; padding: 0; }
.result-lang li, .ranked li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.result-lang .line, .ranked .line { flex-wrap: wrap; gap: 2px 10px; }
.result-lang a.w, .ranked a.w { font-weight: 600; overflow-wrap: anywhere; }
.mean { color: var(--muted); font-size: 0.88rem; margin-top: 2px; overflow-wrap: anywhere; }

/* Tree page: the trunk (furthest origin down to the word), then the branches (who took it) */
.tree { display: grid; gap: 10px; max-width: 52rem; }
.tree + .tree { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.trunk { list-style: none; margin: 0; padding: 0 0 0 4px; }
.trunk > li { position: relative; padding: 6px 0 10px 22px; border-left: 2px solid var(--blue); }
.trunk > li::before { content: ""; position: absolute; left: -7px; top: 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--blue); }
.trunk > li:first-child::before { background: var(--blue); }
.trunk > li.here-li { border-left-color: transparent; }
.trunk > li + li.here-li::after { content: ""; position: absolute; left: -2px; top: 0; height: 14px; border-left: 2px solid var(--blue); }
.trunk > li.here-li::before { background: var(--blue); top: 16px; }
.node { overflow-wrap: anywhere; }
.node .lang, .node .lang a { font-weight: 600; }
.node .tw { font-size: 1.05rem; }
.node .how, .node .page { font-size: 0.85rem; color: var(--muted); margin-left: 4px; }
.node .page { white-space: nowrap; }
.node a.page { color: var(--blue); }
.node .mean { display: block; }
.node.here { background: #eef2f8; padding: 6px 10px; }
.node.here .tw { font-weight: 700; font-size: 1.25rem; }
.branches { list-style: none; margin: 6px 0 0 4px; padding: 0; }
.branches li { position: relative; padding: 5px 0 5px 22px; }
.branches li::before { content: ""; position: absolute; left: 0; top: 0; width: 15px; height: calc(5px + 0.8em); border-left: 1px solid #888; border-bottom: 1px solid #888; }
.branches li::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 1px solid #888; }
.branches li:last-child::after { display: none; }
@media (max-width: 600px) {
  .branches li { padding-left: 16px; }
  .branches li::before { width: 11px; }
}

/* Statistics page */
.stats { gap: 48px; }
.stats section { display: grid; gap: 8px; min-width: 0; }
.rows.plain .row { cursor: default; }
.rows.plain .bar, .rows.plain .ex { margin-left: 0; font-style: normal; }
.warn { font-size: 0.92rem; padding-left: 12px; border-left: 3px solid var(--blue); max-width: 68ch; }
.numbers td:nth-child(n+2):nth-child(-n+4), .numbers th:nth-child(n+2):nth-child(-n+4) { text-align: right; font-variant-numeric: tabular-nums; }
.ranked .num { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
@media (max-width: 600px) {
  .numbers thead { display: table-header-group; }
  .numbers { display: table; width: 100%; }
  .numbers tbody { display: table-row-group; width: auto; }
  .numbers tr { display: table-row; }
  .numbers td { display: table-cell; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
}

/* Menu: Languages · Search · Explore ▾ · Statistics · About. "Explore" is a <details> drop-down, no library. */
.menu { align-items: baseline; }
.explore { position: relative; }
.explore summary { list-style: none; cursor: pointer; color: var(--blue); }
.explore summary::-webkit-details-marker { display: none; }
.explore summary::after { content: " \25BE"; font-size: 0.8em; }
.explore[open] summary::after { content: " \25B4"; }
.explore summary.current { color: var(--ink); }
.explore ul { list-style: none; margin: 0; padding: 6px 0; position: absolute; left: -12px; top: calc(100% + 6px); z-index: 10; min-width: 15rem; background: var(--paper); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); }
.explore li a { display: block; padding: 6px 14px; text-decoration: none; }
.explore li a:hover, .explore li a:focus-visible { background: #eef2f8; }
.explore li a[aria-current="page"] { color: var(--ink); font-weight: 600; }
@media (max-width: 600px) {
  .top { flex-direction: column; gap: 6px; }
  nav.menu { flex-direction: column; gap: 4px; }
  .explore ul { position: static; box-shadow: none; border: 0; border-left: 1px solid var(--line); padding: 2px 0 2px 4px; margin-top: 4px; min-width: 0; }
  .explore li a { padding: 4px 10px; }
}

/* Chains in one line: "Arabic qahwa → Ottoman Turkish kahve → Italian caffè" */
.chain { overflow-wrap: anywhere; }
.chain .sl { color: var(--muted); }
.chain .arr { color: var(--muted); }
.chain .hi { background: #eef2f8; padding: 0 3px; }
.chain .hi .sl { color: var(--blue); font-weight: 600; }
.way { margin-top: 4px; font-size: 0.92rem; }

/* Language page: the two blocks below the lists, closed by default */
.lang-extra { display: grid; gap: 14px; }
details.block { border-top: 1px solid var(--line); padding-top: 12px; }
details.block > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary h2 { display: inline; }
details.block > summary::before { content: "+"; color: var(--blue); width: 1.1em; flex: none; }
details.block[open] > summary::before { content: "\2212"; }
details.block > *:not(summary) { margin-top: 10px; }
details.inner > summary { cursor: pointer; color: var(--blue); font-size: 0.92rem; }
.rows.plain .note { margin-top: 2px; }
.ex a.w { font-style: normal; }

/* Hidden donors */
.words td.r, .words th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.share strong { font-size: 1.05rem; }
.minibar { display: block; height: 3px; background: var(--line); margin-top: 3px; width: 4.5rem; margin-left: auto; }
.minibar span { display: block; height: 100%; background: var(--blue); }
@media (max-width: 600px) {
  .hidden-table td.r { text-align: left; }
  .hidden-table td.r::before { color: var(--muted); font-size: 0.85rem; }
  .hidden-table td:nth-child(2)::before { content: "directly "; }
  .hidden-table td:nth-child(3)::before { content: "through another language "; }
  .hidden-table td:nth-child(4)::before { content: "share "; }
  .minibar { margin-left: 0; }
}

/* Doublets: the two words side by side */
.pairs { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.pair { padding: 16px 0; border-bottom: 1px solid var(--line); }
.pair:first-child { border-top: 1px solid var(--line); }
.halves { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 32px; }
.half { min-width: 0; display: grid; gap: 2px; align-content: start; }
.half .big { font-size: 1.1rem; }
.common { margin-top: 10px; font-size: 0.92rem; }
@media (max-width: 600px) { .halves { grid-template-columns: 1fr; } }
.search { display: block; }

/* Round trips */
.trips li { padding: 10px 0; }

/* Word families */
.families { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.families > li { border-bottom: 1px solid var(--line); }
.families summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 10px 0; }
.families summary::-webkit-details-marker { display: none; }
.families .rank { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2em; }
.families .fam-root { font-weight: 600; overflow-wrap: anywhere; }
.families .num { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.fam-body { padding: 0 0 14px 2.6em; display: grid; gap: 8px; }
.fam-words { margin: 0; display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); gap: 6px 16px; font-size: 0.92rem; }
.fam-words dt { font-weight: 600; }
.fam-words dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .fam-body { padding-left: 0; }
  .fam-words { grid-template-columns: 1fr; gap: 2px; }
  .fam-words dd { margin-bottom: 6px; }
}

/* Compare two languages */
.pickers { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; }
.pickers select { font-size: 1rem; }
.big-num { font-size: 1.6rem; font-weight: 600; }
.plain-ex { font-style: normal; margin-left: 0; color: var(--ink); }
.shared-table td { vertical-align: top; }

/* About */
.toc { border-left: 3px solid var(--blue); padding: 4px 0 4px 14px; }
.toc ol { margin: 0; padding-left: 20px; columns: 2 14rem; }
.toc li + li { margin-top: 2px; }
.about h2 { scroll-margin-top: 12px; }
code { font-size: 0.9em; background: #f4f4f4; padding: 0 3px; }
.node .amb { font-size: 0.78rem; color: #8a5a00; border: 1px solid #e3cf9f; background: #fdf8ec; padding: 0 5px; margin-left: 4px; white-space: nowrap; cursor: help; }

/* Mandate 14 — Explore menu in two columns on wide screens (seven entries) */
@media (min-width: 601px) {
  .explore ul { display: grid; grid-template-rows: repeat(4, auto); grid-auto-flow: column; min-width: 0; width: max-content; }
}

/* Compare: cousin words, the two words with the common origin in the middle */
.trio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(7rem, auto) minmax(0, 1fr); gap: 8px 24px; align-items: start; }
.trio .root { text-align: center; font-size: 0.92rem; padding-top: 14px; overflow-wrap: anywhere; }
.trio .root p::before { content: "\2190  "; color: var(--muted); }
.trio .root p::after { content: "  \2192"; color: var(--muted); }
.trio .half:last-child { text-align: right; }
@media (max-width: 600px) {
  .trio { grid-template-columns: 1fr; gap: 4px; }
  .trio .root { text-align: left; padding: 2px 0; }
  .trio .root p::before, .trio .root p::after { content: none; }
  .trio .half:last-child { text-align: left; }
}
.lang-extra h3 { margin-top: 14px; }

/* Surprise me (home, Search) and Another one (tree) */
.surprise-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.surprise { font: inherit; padding: 7px 14px; border: 1px solid var(--blue); background: var(--paper); color: var(--blue); cursor: pointer; }
.surprise:hover { background: #eef2f8; }
.surprise:disabled { color: var(--muted); border-color: var(--line); cursor: wait; }
.surprise.small { font-size: 0.88rem; padding: 3px 10px; }
.another-line { margin: 0 0 4px; display: flex; justify-content: flex-end; gap: 10px; align-items: baseline; }

/* What a language gave to the world */
.gave .num { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 0.92rem; white-space: nowrap; }
.gave .w.plain { font-weight: 600; }
.gave-body { padding: 0 0 14px 2.6em; display: grid; gap: 6px; font-size: 0.92rem; }
.gave-body .from { color: var(--ink); }
.gave-langs { margin: 0; overflow-wrap: anywhere; }
.gave-langs .ln { color: var(--muted); }
@media (max-width: 600px) { .gave-body { padding-left: 0; } }
.gave a.w { font-weight: 600; overflow-wrap: anywhere; }
.gave summary .num::after { content: "  +"; color: var(--blue); }
.gave details[open] summary .num::after { content: "  \2212"; }
