*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #1a1a2e;
  background: #fff;
  padding: 0 1rem 4rem;
}

a { color: #C0392B; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 900px; margin: 0 auto; }

/* ── Header ── */
header { border-bottom: 2px solid #C0392B; padding: 2rem 0 1.2rem; }
header h1 { font-size: 1.55rem; font-weight: 700; line-height: 1.3; margin-bottom: .5rem; }
.authors { font-size: .9rem; color: #444; margin-bottom: .8rem; }
.subtitle { font-size: .85rem; color: #666; margin-bottom: 1rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn {
  display: inline-block;
  padding: .35rem .9rem;
  border: 1.5px solid #C0392B;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 600;
  color: #C0392B;
  background: #fff;
  cursor: pointer;
}
.btn:hover { background: #C0392B; color: #fff; text-decoration: none; }

/* ── Sections ── */
section { margin-top: 2.5rem; }
h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 1rem;
     padding-bottom: .3rem; border-bottom: 1px solid #ddd; }
h3 { font-size: 1rem; font-weight: 700; margin: 1.4rem 0 .6rem; }

/* ── Overview ── */
.overview { background: #fdf5f5; border-left: 4px solid #C0392B; padding: 1rem 1.2rem; border-radius: 0 4px 4px 0; }

/* ── Research questions ── */
.rq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .rq-grid { grid-template-columns: 1fr; } }
.rq-card { border: 1px solid #e8d0d0; border-radius: 6px; padding: 1rem; }
.rq-card strong { display: block; margin-bottom: .4rem; color: #C0392B; font-size: .9rem; }
.rq-card p { font-size: .88rem; color: #333; }
.rq-card .highlight { font-weight: 700; color: #C0392B; }

/* ── Taxonomy table ── */
.taxonomy-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.taxonomy-table th { background: #fdf0f0; text-align: left; padding: .45rem .7rem;
                      border: 1px solid #e0cccc; font-weight: 600; }
.taxonomy-table td { padding: .4rem .7rem; border: 1px solid #ddd; }
.taxonomy-table tr:nth-child(even) td { background: #fdf8f8; }
.ipa { font-family: "Noto Serif", Georgia, serif; font-size: .95em; }

/* ── Audio players ── */
.marker-section { margin-top: 1.8rem; }
.marker-section h3 { color: #1a1a2e; }
.listening-hint { font-size: .83rem; color: #555; margin-bottom: .9rem;
                  background: #f5f5f5; padding: .5rem .8rem; border-radius: 4px; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.class-col h4 { font-size: .9rem; font-weight: 700; margin-bottom: .6rem; color: #C0392B; }
.clip { border: 1px solid #ddd; border-radius: 6px; overflow: hidden; margin-bottom: .7rem; background: #fff; }
.clip img { width: 100%; display: block; }
.clip-meta { padding: .4rem .6rem; display: flex; flex-direction: column; gap: .3rem; }
.clip-meta audio { width: 100%; height: 32px; }
.clip-meta span { font-size: .78rem; color: #555; }

/* ── Ablation table ── */
.table-scroll { overflow-x: auto; margin-top: .8rem; }
.ablation { border-collapse: collapse; font-size: .8rem; min-width: 500px; width: 100%; }
.ablation th, .ablation td { padding: .28rem .55rem; border: 1px solid #ccc; white-space: nowrap; }
.ablation thead th { background: #fdf0f0; font-weight: 700; text-align: center; }
.ablation thead th:first-child { text-align: left; }
.ablation td:first-child { text-align: left; }
.ablation td { text-align: center; }
.ablation td.combo { padding-left: 1.4rem; color: #333; }
.ablation tr.group-hdr th {
  background: #1a1a2e; color: #fff; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em; text-align: left;
  padding: .3rem .55rem;
}
.std { font-size: .72em; opacity: .85; }
.legend { display: flex; align-items: center; gap: .7rem; margin-top: .6rem; font-size: .78rem; color: #555; }
.legend-bar {
  width: 140px; height: 12px; border-radius: 2px;
  background: linear-gradient(to right, #A50026, #F46D43, #FEFEBD, #A4D869, #006837);
  border: 1px solid #ccc;
}
.ablation-caption { font-size: .8rem; color: #555; margin-top: .5rem; }

/* ── Citation ── */
pre.bibtex {
  background: #f5f5f5; border: 1px solid #ddd; border-radius: 4px;
  padding: 1rem; font-size: .8rem; overflow-x: auto; white-space: pre;
}

/* ── Footer ── */
footer { margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid #ddd;
         font-size: .8rem; color: #666; line-height: 1.8; }

/* ══════════════ Paper B additions ══════════════ */

/* generic data tables (setup, effect sizes, per-group EER) */
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 460px; }
.data-table thead th { background: #fdf0f0; font-weight: 700; text-align: center;
                       padding: .32rem .55rem; border: 1px solid #e0cccc; white-space: nowrap; }
.data-table thead th:first-child { text-align: left; }
.data-table td { padding: .28rem .55rem; border: 1px solid #ddd; text-align: center; white-space: nowrap; }
.data-table td:first-child { text-align: left; white-space: normal; }
.data-table tr.group-hdr th { background: #1a1a2e; color: #fff; font-size: .78rem;
                              text-transform: uppercase; letter-spacing: .04em;
                              text-align: left; padding: .3rem .55rem; }
.data-table tr.sub td { background: #fafafa; }
.caption { font-size: .78rem; color: #555; margin-top: .5rem; line-height: 1.55; }

/* figure grids (feature distributions, vowel spaces, heatmaps) */
.fig-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
            gap: .9rem; margin-top: .9rem; }
.fig-grid figure { border: 1px solid #ddd; border-radius: 6px; overflow: hidden; background: #fff; }
.fig-grid img { width: 100%; display: block; }
.fig-grid figcaption { padding: .35rem .6rem; font-size: .76rem; color: #555; border-top: 1px solid #eee; }
.fig-wide { max-width: 560px; margin: .9rem auto 0; }
.fig-wide img { width: 100%; display: block; border: 1px solid #ddd; border-radius: 6px; }

/* collapsible blocks (sentence list 51-100, long tables) */
details { margin-top: .8rem; border: 1px solid #e8d0d0; border-radius: 6px; padding: .5rem .8rem; }
details summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: #C0392B; }
details[open] summary { margin-bottom: .6rem; }

/* inline notes / caveats */
.note { background: #f7f7f9; border-left: 3px solid #999; padding: .6rem .9rem;
        border-radius: 0 4px 4px 0; font-size: .83rem; color: #444; margin-top: .9rem; }
.note strong { color: #1a1a2e; }

/* sentence list */
.sentences { font-size: .82rem; line-height: 1.75; columns: 2; column-gap: 1.6rem; }
.sentences li { break-inside: avoid; margin-left: 1.1rem; }
@media (max-width: 640px) { .sentences { columns: 1; } }

/* file links (recipes, csv downloads) */
.filelist { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.filelist a { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
              font-size: .76rem; border: 1px solid #ddd; border-radius: 4px;
              padding: .22rem .5rem; background: #fafafa; color: #1a1a2e; }
.filelist a:hover { border-color: #C0392B; color: #C0392B; text-decoration: none; }

/* disabled placeholder button */
.btn.btn-off { border-color: #bbb; color: #999; cursor: default; }
.btn.btn-off:hover { background: #fff; color: #999; }
.data-table .dim { font-size: .72rem; color: #888; }
.data-table td.ids { font-size: .72rem; line-height: 1.45; max-width: 230px; }

/* v2 page: revision badge and wrapping tables */
.badge { display: inline-block; background: #C0392B; color: #fff; font-size: .7rem;
         font-weight: 700; letter-spacing: .06em; padding: .12rem .4rem; border-radius: 3px;
         vertical-align: .22em; margin-left: .45rem; }
.data-table.wrap td { white-space: normal; text-align: left; vertical-align: top; }
.data-table.wrap th { text-align: left; }
.data-table.wrap td:nth-child(1) { width: 26%; font-weight: 600; color: #1a1a2e; }
.status-ok::before { content: "\2713\00a0"; color: #1e7a45; font-weight: 700; }
.status-partial::before { content: "\25B2\00a0"; color: #b8860b; font-weight: 700; }

/* ═══════════════════════════════════════ v2 only: folding sections + sticky outline
   All of it is scoped to .layout / .outline / details.sec, which revision 1 never emits. */
.layout { display: grid; grid-template-columns: 210px 1fr; gap: 2.2rem; align-items: start; }
body:has(.layout) .container { max-width: 1160px; }

.outline { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto;
           font-size: .8rem; padding-top: 1.6rem; }
.outline-hd { font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
              color: #999; padding-bottom: .5rem; border-bottom: 1px solid #eee; margin-bottom: .5rem; }
.fold-all { display: block; margin-top: .45rem; letter-spacing: 0; text-transform: none; font-weight: 400; }
.fold-all button { background: none; border: none; padding: 0; margin-right: .6rem; cursor: pointer;
                   font: inherit; font-size: .72rem; color: #C0392B; border-bottom: 1px dotted #d9a7a2; }
.fold-all button:hover { color: #1a1a2e; }
html:not(.js) .fold-all { display: none; }

.outline-list, .outline-list ul { list-style: none; }
.outline-list > li > a { display: block; padding: .3rem 0 .3rem .6rem; color: #555; line-height: 1.35;
                         border-left: 2px solid transparent; }
.outline-list > li > a:hover { color: #C0392B; text-decoration: none; }
.outline-list > li.active > a, .outline-list > li.active-parent > a {
  color: #C0392B; font-weight: 700; border-left-color: #C0392B; }
.outline-list ul { margin: .1rem 0 .35rem .6rem; }
.outline-list ul a { display: block; padding: .18rem 0 .18rem .6rem; color: #777; font-size: .75rem;
                     border-left: 1px solid #eee; line-height: 1.3; }
.outline-list ul a:hover { color: #C0392B; text-decoration: none; }
.outline-list ul li.active > a { color: #C0392B; border-left-color: #C0392B; }
/* only the section you are in shows its sub-entries — and only once the script is running */
html.js .outline-list > li:not(.active):not(.active-parent) > ul { display: none; }

/* sections become foldable; the inner <details> (sentence list) keeps its own look */
details.sec { border: none; border-radius: 0; padding: 0; margin-top: 0; }
details.sec > summary { cursor: pointer; list-style: none; font-weight: inherit; color: inherit;
                        margin: 0; display: flex; align-items: baseline; gap: .5rem; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: "\25B8"; color: #C0392B; font-size: .8rem; line-height: 1;
                                transition: transform .15s ease; flex: 0 0 auto; }
details.sec[open] > summary::before { transform: rotate(90deg); }
details.sec > summary h2 { flex: 1; margin-bottom: 0; padding-bottom: .45rem; }
details.sec > summary:hover h2 { color: #C0392B; }
details.sec[open] > summary { margin-bottom: 1rem; }
.sec-body { animation: fold-in .16s ease; }
@keyframes fold-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .sec-body { animation: none; }
  details.sec > summary::before { transition: none; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 1rem; }
  .outline { position: static; max-height: none; padding-top: 1.2rem; }
  html.js .outline-list > li:not(.active):not(.active-parent) > ul { display: none; }
}

/* v2 only: the one-sentence TL;DR banner above the first section */
.tldr { font-size: 1.02rem; line-height: 1.5; color: #1a1a2e; margin: 1.6rem 0 .4rem;
        padding-left: .9rem; border-left: 3px solid #C0392B; }
.tldr strong { color: #C0392B; }

/* v2 only: the TL;DR reuses the Overview box */
.tldr { margin: 1.8rem 0 1.4rem; }
.tldr p { font-size: 1rem; line-height: 1.55; }
.tldr strong { color: #C0392B; }

/* v2 only: playable marker examples under the TL;DR */
.strip-hd { font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
            color: #999; margin-bottom: .6rem; }
.markers { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem;
           align-items: start; }
.marker-card { border: 1px solid #e8d0d0; border-radius: 6px; padding: .7rem .8rem; }
.marker-card h4 { font-size: .85rem; font-weight: 700; color: #C0392B; margin-bottom: .1rem; }
.marker-eg { font-size: .78rem; color: #777; margin-bottom: .55rem; font-style: italic; }
.marker-eg u { text-decoration: none; color: #C0392B; font-weight: 700;
               border-bottom: 2px solid #e8d0d0; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.ipa-chip { flex: 1 1 auto; min-width: 88px; cursor: pointer; font: inherit; text-align: left;
            background: #fafafa; border: 1px solid #ddd; border-radius: 5px; padding: .4rem .5rem;
            display: flex; flex-direction: column; gap: .1rem; transition: border-color .12s, background .12s; }
.ipa-chip:hover { border-color: #C0392B; background: #fdf5f5; }
.ipa-chip .ipa-sym { font-family: "Noto Serif", Georgia, serif; font-size: 1.15rem; color: #1a1a2e;
                     line-height: 1.1; }
.ipa-chip .ipa-name { font-size: .75rem; font-weight: 700; color: #444; }
.ipa-chip .ipa-reg { font-size: .68rem; color: #999; line-height: 1.3; }
.ipa-chip::after { content: "\25B6 play"; font-size: .63rem; color: #bbb; letter-spacing: .04em; }
.ipa-chip:hover::after { color: #C0392B; }
.ipa-chip.playing { border-color: #C0392B; background: #fdf0f0; }
.ipa-chip.playing::after { content: "\25B6 " attr(data-n) " of 3"; color: #C0392B; }
html.js .nojs-audio { display: none; }
.nojs-audio audio { width: 100%; height: 30px; margin-top: .4rem; }

/* v2 only: TL;DR heading sits outside any section, so it never folds */
.tldr-hd { margin-top: 1.8rem; }
.tldr-hd + .tldr { margin-top: 0; }

/* ── v2 only: marker map ──────────────────────────────────────────────────────
   Categorical slots 1-3 of the reference palette — the slots validated for
   all-pairs separation, which is what a choropleth needs. Aqua warns below 3:1
   against the surface, so the figure carries direct UF labels and a table view. */
.brmap-wrap { --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a;
              --geo-null: #ececec; --geo-line: #fff; margin: 1.4rem 0 .4rem; }
.map-tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; }
.map-tab { cursor: pointer; font: inherit; font-size: .78rem; padding: .3rem .7rem;
           border: 1px solid #ddd; border-radius: 999px; background: #fafafa; color: #555; }
.map-tab:hover { border-color: #C0392B; color: #C0392B; }
.map-tab.on { background: #1a1a2e; border-color: #1a1a2e; color: #fff; }
html:not(.js) .map-tabs { display: none; }

.brmap svg { display: block; width: 100%; height: auto; max-width: 560px; margin: 0 auto; }
.brmap .uf path { fill: var(--geo-null); stroke: var(--geo-line); stroke-width: .6;
                  stroke-linejoin: round; transition: fill .15s ease; }
.brmap .uf path:hover { stroke: #1a1a2e; stroke-width: 1; }
.brmap[data-marker="s"] .uf path[data-s="1"], .brmap[data-marker="r"] .uf path[data-r="1"],
.brmap[data-marker="dt"] .uf path[data-dt="1"] { fill: var(--cat-1); }
.brmap[data-marker="s"] .uf path[data-s="2"], .brmap[data-marker="r"] .uf path[data-r="2"],
.brmap[data-marker="dt"] .uf path[data-dt="2"] { fill: var(--cat-2); }
.brmap[data-marker="s"] .uf path[data-s="3"], .brmap[data-marker="r"] .uf path[data-r="3"],
.brmap[data-marker="dt"] .uf path[data-dt="3"] { fill: var(--cat-3); }
.brmap[data-marker="s"] .uf path[data-s="mixed"], .brmap[data-marker="r"] .uf path[data-r="mixed"],
.brmap[data-marker="dt"] .uf path[data-dt="mixed"] { fill: url(#mix); }

/* direct labels only on the units the active marker actually classifies */
.brmap .uf-lab text { font-size: 8px; font-weight: 700; fill: #fff; text-anchor: middle;
                      paint-order: stroke; stroke: rgba(26,26,46,.35); stroke-width: 2px;
                      pointer-events: none; display: none; }
.brmap[data-marker="s"] .uf-lab text:not([data-s="0"]),
.brmap[data-marker="r"] .uf-lab text:not([data-r="0"]),
.brmap[data-marker="dt"] .uf-lab text:not([data-dt="0"]) { display: block; }

.legend-row { display: none; flex-wrap: wrap; gap: .45rem .9rem; justify-content: center;
              margin-top: .5rem; font-size: .76rem; color: #444; }
.brmap[data-marker="s"] .legend-row[data-for="s"],
.brmap[data-marker="r"] .legend-row[data-for="r"],
.brmap[data-marker="dt"] .legend-row[data-for="dt"] { display: flex; }
html:not(.js) .brmap .legend-row { display: flex; }   /* no tabs, so show every key */
.lg { display: inline-flex; align-items: center; gap: .3rem; }
.lg-ipa { font-family: "Noto Serif", Georgia, serif; color: #777; }
.sw { width: .72rem; height: .72rem; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.sw1 { background: #2a78d6; } .sw2 { background: #eb6834; } .sw3 { background: #1baf7a; }
.sw0 { background: #ececec; border: 1px solid #ddd; }
.swm { background: linear-gradient(45deg, #1baf7a 50%, #eb6834 50%); }

/* v2 only: a shaded map unit is clickable — it plays the same clip as its chip */
.brmap[data-marker="s"] .uf path[data-s-clip],
.brmap[data-marker="r"] .uf path[data-r-clip],
.brmap[data-marker="dt"] .uf path[data-dt-clip] { cursor: pointer; }
.brmap .uf path.lit, .brmap .uf path:focus-visible {
  stroke: #1a1a2e; stroke-width: 1.6; outline: none; }

/* v2 only: the numbered "what the study builds" flow */
.steps { display: grid; gap: .5rem; margin: .9rem 0; }
.step { display: grid; grid-template-columns: 1.5rem 1fr; gap: .6rem; align-items: start;
        font-size: .84rem; color: #333; line-height: 1.55; }
.step-b { display: block; }
.step strong { color: #1a1a2e; }
.step-n { width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #1a1a2e; color: #fff;
          font-size: .72rem; font-weight: 700; display: flex; align-items: center;
          justify-content: center; }

/* v2 only: subsections fold under their own heading inside a section */
details.sub { border: none; border-left: 2px solid #f0dede; border-radius: 0;
              padding: 0 0 0 .8rem; margin-top: 1.1rem; }
details.sub > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline;
                        gap: .45rem; color: #1a1a2e; }
details.sub > summary::-webkit-details-marker { display: none; }
details.sub > summary::before { content: "\25B8"; color: #C0392B; font-size: .72rem; }
details.sub[open] > summary::before { content: "\25BE"; }
details.sub > summary h3 { margin: 0; font-size: .92rem; }
details.sub > summary:not(:has(h3)) { font-size: .85rem; font-weight: 600; color: #C0392B; }
details.sub > summary:hover h3 { color: #C0392B; }
details.sub[open] > summary { margin-bottom: .5rem; }

/* v2 only: a bulky reference table replaced by the CSV it would have printed */
.dl-card { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin-top: .8rem;
           border: 1px solid #e8d0d0; border-radius: 6px; padding: .7rem .85rem; background: #fdf8f8; }
.dl-btn { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem;
          border: 1px solid #C0392B; color: #C0392B; border-radius: 4px; padding: .3rem .6rem;
          background: #fff; white-space: nowrap; flex: 0 0 auto; }
.dl-btn:hover { background: #C0392B; color: #fff; text-decoration: none; }
.dl-meta { font-size: .78rem; color: #555; line-height: 1.5; flex: 1 1 260px; }
.dl-meta strong { color: #1a1a2e; }

/* the long texts are paragraphs, not one-liners — two columns would be unreadable */
.sentences.long { columns: 1; font-size: .8rem; line-height: 1.65; }
.sentences.long li { margin-bottom: .6rem; }
