/* ProtoLingua ---------------------------------------------------------------
   Colour is doing real work here: each of the nine parts of speech has its own
   hue, and the gloss line beneath a word reuses that hue at lower weight so the
   two lines read as one object. Everything is defined once as a token and
   redefined for dark mode. */

:root {
    color-scheme: light dark;

    --bg: #fbfbfa;
    --panel: #ffffff;
    --ink: #16181d;
    --ink-soft: #5b6472;
    --ink-faint: #8a93a3;
    --line: #e3e6ea;
    --line-soft: #eef0f3;
    --accent: #3b5bdb;
    --accent-soft: #edf1ff;
    --warn: #b45309;
    --error: #b91c1c;

    --pos-noun: #1d4ed8;
    --pos-pronoun: #7c3aed;
    --pos-verb: #b91c1c;
    --pos-adjective: #15803d;
    --pos-adverb: #c2410c;
    --pos-adposition: #0e7490;
    --pos-conjunction: #a16207;
    --pos-determiner: #475569;
    --pos-interjection: #be185d;
    --pos-marker: #8a93a3;

    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161a;
        --panel: #1c1f25;
        --ink: #e8eaee;
        --ink-soft: #a3acbb;
        --ink-faint: #79828f;
        --line: #2c313a;
        --line-soft: #23272e;
        --accent: #8ba4ff;
        --accent-soft: #232a3d;
        --warn: #e0a14a;
        --error: #f08a84;

        --pos-noun: #7fa5ff;
        --pos-pronoun: #c4a2ff;
        --pos-verb: #ff9189;
        --pos-adjective: #6fce8f;
        --pos-adverb: #ffab6b;
        --pos-adposition: #5fc7d8;
        --pos-conjunction: #e0bc5c;
        --pos-determiner: #a5b0c0;
        --pos-interjection: #ff8fc0;
        --pos-marker: #79828f;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
}

/* -- shell ---------------------------------------------------------------- */

.page {
    display: grid;
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; gap: .65rem; align-items: center; }

.brand-mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}

.brand-name { font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: .78rem; color: var(--ink-faint); }

.nav-menu { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .45rem .6rem;
    border-radius: 7px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: .92rem;
}

.nav-item:hover { background: var(--line-soft); color: var(--ink); }

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav-num {
    width: 1.35rem; height: 1.35rem;
    border-radius: 5px;
    background: var(--line-soft);
    display: grid; place-items: center;
    font-size: .72rem; font-variant-numeric: tabular-nums;
    color: var(--ink-faint);
}

.nav-item.active .nav-num { background: var(--accent); color: #fff; }

.current-language {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.cl-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); }
.cl-name { font-weight: 600; margin-top: .15rem; }
.cl-stats { font-size: .78rem; color: var(--ink-faint); }

main {
    padding: 2rem 2.5rem 5rem;
    max-width: 1100px;
}

/* -- typography ----------------------------------------------------------- */

h1 { font-size: 1.65rem; letter-spacing: -.02em; margin: 0 0 .35rem; font-weight: 650; }
h2 { font-size: 1.05rem; letter-spacing: -.01em; margin: 2rem 0 .6rem; font-weight: 650; }

.lede { color: var(--ink-soft); max-width: 62ch; margin: 0 0 1.5rem; }
.hint { color: var(--ink-faint); font-size: .9rem; max-width: 68ch; }
.muted { color: var(--ink-soft); }
.small { font-size: .82rem; }
code { font-family: var(--mono); font-size: .88em; background: var(--line-soft); padding: .08em .35em; border-radius: 4px; }

/* -- interlinear: the centrepiece ---------------------------------------- */

.interlinear {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .1rem 1.05rem;
    padding: .35rem 0 .2rem;
}

.interlinear.rtl { justify-content: flex-end; }

.il-word { min-width: 0; padding-bottom: .3rem; }

.il-role {
    font-size: .62rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-faint);
    line-height: 1.4;
}

.il-empty { color: var(--ink-faint); font-style: italic; }

/* A word standing in for one that has not been coined yet: same hue, dotted
   underline, so it is visible without shouting. */
.il-word.fallback .il-warnings {
    margin: .5rem 0 0;
    padding-left: 1.1rem;
    font-size: .8rem;
    color: var(--warn);
}

/* -- part-of-speech colours ---------------------------------------------- */

.pos-noun { color: var(--pos-noun); }
.pos-pronoun { color: var(--pos-pronoun); }
.pos-verb { color: var(--pos-verb); }
.pos-adjective { color: var(--pos-adjective); }
.pos-adverb { color: var(--pos-adverb); }
.pos-adposition { color: var(--pos-adposition); }
.pos-conjunction { color: var(--pos-conjunction); }
.pos-determiner { color: var(--pos-determiner); }
.pos-interjection { color: var(--pos-interjection); }
.pos-marker { color: var(--pos-marker); font-style: italic; }

.il-word.pos-marker .legend { display: flex; flex-wrap: wrap; gap: .3rem .5rem; margin: .6rem 0 1.2rem; }

.legend-chip {
    font-size: .72rem;
    padding: .1rem .45rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    opacity: .85;
}

/* -- cards, fields, buttons ---------------------------------------------- */

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.row-fields { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }

.field { display: flex; flex-direction: column; gap: .25rem; }
.field.grow { flex: 1 1 20rem; }

.field label {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-faint);
}

.text, .select {
    font: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: .38rem .55rem;
    min-width: 0;
    width: 100%;
}

.text:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.text.short { width: 17rem; }
.text.tiny { width: 7rem; }
.text.tiny.wide { width: 100%; }
.select.small { padding: .2rem .3rem; font-size: .85rem; }

.form-cell { font-family: var(--serif); font-size: 1.02rem; }

.btn {
    font: inherit;
    font-size: .88rem;
    padding: .38rem .8rem;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { opacity: .9; color: #fff; }
.btn.ghost { background: transparent; color: var(--ink-soft); }
.btn.small { font-size: .82rem; padding: .25rem .6rem; }
.btn.tiny { font-size: .75rem; padding: .12rem .45rem; }

.toolbar {
    display: flex; flex-wrap: wrap; gap: .5rem .8rem;
    align-items: center;
    margin: .8rem 0 1rem;
}

.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; color: var(--ink-soft); }
.check input { margin: 0; }

.msg { font-size: .85rem; color: var(--accent); }
.msg.block { display: block; margin: .5rem 0; }
.msg.error { color: var(--error); }

/* -- questionnaire -------------------------------------------------------- */

.sticky-preview {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .7rem 1rem .5rem;
    margin-bottom: 1rem;
    box-shadow: 0 6px 18px -14px rgba(0,0,0,.5);
}

.preview-picker { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.preview-picker .select { margin-top: .2rem; text-transform: none; letter-spacing: normal; font-size: .85rem; }

.qsection { margin-bottom: 2rem; }

.question {
    border-top: 1px solid var(--line-soft);
    padding: .9rem 0 .3rem;
}

.question.form-question { padding-left: 1.2rem; border-left: 2px solid var(--line); border-top: none; padding-top: .5rem; }

.q-text { font-weight: 550; margin-bottom: .1rem; }
.q-note { font-size: .82rem; color: var(--ink-faint); max-width: 66ch; margin-bottom: .4rem; }

.q-options { display: flex; flex-direction: column; gap: .1rem; margin-top: .35rem; }

.option {
    display: flex; align-items: baseline; gap: .5rem;
    padding: .2rem .45rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: .92rem;
    color: var(--ink-soft);
}

.option:hover { background: var(--line-soft); }
.option.chosen { background: var(--accent-soft); color: var(--ink); font-weight: 550; }

/* -- tiles ---------------------------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }

.tile {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .85rem 1rem;
    text-decoration: none;
    color: inherit;
}

.tile:hover { border-color: var(--accent); }
.tile-num { font-size: .7rem; color: var(--ink-faint); }
.tile-title { font-weight: 600; margin-bottom: .2rem; }
.tile-body { font-size: .84rem; color: var(--ink-soft); }

.preview .source { font-size: .84rem; color: var(--ink-faint); margin-bottom: .3rem; }

/* -- sentences ------------------------------------------------------------ */

.sentence-card { padding: .9rem 1.1rem 1rem; }

.sentence-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 1rem; margin-bottom: .2rem;
}

.sentence-head .source { font-size: .85rem; color: var(--ink-faint); }

.tagger { margin-top: .8rem; padding-top: .7rem; border-top: 1px dashed var(--line); }

.tagger-title {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-faint);
    display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem;
}

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }

.chip {
    display: inline-flex; align-items: center; gap: .25rem;
    border: 1px solid currentColor;
    border-radius: 6px;
    padding: .1rem .3rem .1rem .45rem;
    font-size: .85rem;
}

.chip.locked { border-width: 2px; }
.chip-word { font-family: var(--serif); }

.chip-select {
    font: inherit; font-size: .68rem;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
}

.parse-summary {
    margin-top: .5rem;
    font-family: var(--mono);
    font-size: .74rem;
    color: var(--ink-faint);
    word-break: break-word;
}

/* -- tables and charts ---------------------------------------------------- */

.grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    font-size: .9rem;
}

.grid th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-faint);
    font-weight: 600;
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--line);
}

.grid td { padding: .3rem .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.grid tr:last-child td { border-bottom: none; }
.grid .blank-row { background: color-mix(in srgb, var(--warn) 7%, transparent); }

.ipa { font-family: var(--mono); font-size: 1rem; }

.chart-scroll { overflow-x: auto; margin-bottom: 1rem; }

.ipa-chart {
    border-collapse: collapse;
    font-size: .82rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.ipa-chart th {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-faint);
    font-weight: 600;
    padding: .4rem .35rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.ipa-chart .rowhead { text-align: left; border-right: 1px solid var(--line); white-space: nowrap; }
.ipa-chart td { padding: .15rem .2rem; border-bottom: 1px solid var(--line-soft); text-align: center; }

.cell {
    display: inline-grid;
    place-items: center;
    width: 1.75rem; height: 1.6rem;
    font-family: var(--mono);
    font-size: .95rem;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
}

.cell:hover { border-color: var(--accent); color: var(--accent); }
.cell.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.cell.blank { cursor: default; opacity: .18; }
.cell.blank::after { content: "·"; }

.sample { font-family: var(--serif); font-size: 1.05rem; color: var(--ink-soft); }
.sample strong { color: var(--ink); }

.file { font-size: .9rem; }

@media (max-width: 820px) {
    .page { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    main { padding: 1.25rem; }
}

/* -- nav groups ----------------------------------------------------------- */

.nav-group {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--ink-faint);
    margin: .7rem 0 .15rem .6rem;
}

/* -- the five views ------------------------------------------------------- */

.view-picker { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 .9rem; }

.view-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .82rem;
    padding: .18rem .55rem .18rem .35rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
}

.view-chip input { margin: 0; }
.view-chip:hover { border-color: var(--accent); }
.view-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }

.view-chip.unavailable { opacity: .45; }
.view-chip.unavailable.on { border-style: dashed; }

.view-num {
    width: 1.1rem; height: 1.1rem;
    border-radius: 50%;
    background: var(--line-soft);
    display: grid; place-items: center;
    font-size: .64rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink-faint);
}

.view-chip.on .view-num { background: var(--accent); color: #fff; }

/* -- interlinear lines ---------------------------------------------------- */

.il-line { white-space: nowrap; line-height: 1.35; }

/* Whichever view is topmost leads, whatever it is. */
.il-lead {
    font-family: var(--serif);
    font-size: 1.32rem;
    line-height: 1.3;
}

.il-english,
.il-pointtranslation {
    font-family: var(--mono);
    font-size: .72rem;
    letter-spacing: .01em;
    opacity: .72;
}

.il-lead.il-english,
.il-lead.il-pointtranslation {
    font-family: var(--serif);
    font-size: 1.2rem;
    opacity: 1;
    letter-spacing: normal;
}

.il-transliteration { font-family: var(--serif); font-size: 1.05rem; }
.il-lead.il-transliteration { font-size: 1.32rem; }

.il-ipa { font-family: var(--mono); font-size: .8rem; opacity: .8; }
.il-lead.il-ipa { font-size: 1.1rem; opacity: 1; }
.ipa-slashes::before { content: "/"; opacity: .45; }
.ipa-slashes::after { content: "/"; opacity: .45; }

.il-gap { opacity: .3; }

.il-word.fallback .il-lead {
    text-decoration: underline dotted;
    text-underline-offset: .28em;
    text-decoration-thickness: 1px;
    opacity: .82;
}

.il-warnings.quiet { color: var(--ink-faint); }

/* -- glyphs --------------------------------------------------------------- */

.glyph-run { display: inline-flex; align-items: flex-end; gap: .12rem; }

.glyph-piece {
    display: inline-grid;
    place-items: center;
    font-size: 1.5rem;
    line-height: 1;
}

.glyph-piece img { height: 1.75rem; width: auto; display: block; }

.glyph-piece.vowel-mark { font-size: .85rem; align-self: flex-start; margin-left: -.25rem; }
.glyph-piece.vowel-mark img { height: .95rem; }

.glyph-piece.missing {
    font-family: var(--mono);
    font-size: .95rem;
    opacity: .45;
    border-bottom: 1px dotted currentColor;
}

.il-lead .glyph-piece img { height: 2.1rem; }
.il-lead .glyph-piece { font-size: 1.8rem; }

.glyph-grid .glyph-cell { text-align: center; }
.glyph-preview { max-height: 2rem; max-width: 3rem; }
.glyph-char { font-size: 1.5rem; line-height: 1; }
.glyph-input { font-size: 1.1rem; }

.hidden-file {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    overflow: hidden;
}

label.btn { position: relative; overflow: hidden; cursor: pointer; }

.coverage { font-size: .9rem; color: var(--ink-soft); display: flex; align-items: center; gap: .6rem; }

.bar {
    display: inline-block;
    width: 12rem; height: .45rem;
    background: var(--line-soft);
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill { display: block; height: 100%; background: var(--accent); }

/* -- romanisation grid ---------------------------------------------------- */

.roman-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    gap: .35rem;
    margin-bottom: 1rem;
}

.roman-cell {
    display: flex; align-items: center; gap: .35rem;
    padding: .25rem .35rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    position: relative;
}

.roman-cell.vowel { border-color: color-mix(in srgb, var(--pos-adjective) 45%, var(--line)); }
.roman-cell .ipa { min-width: 1.6rem; text-align: center; color: var(--ink-soft); }
.roman-cell .text.tiny { width: 100%; min-width: 0; }

.roman-remove {
    position: absolute;
    top: -.4rem; right: -.4rem;
    width: 1.1rem; height: 1.1rem;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink-faint);
    font-size: .7rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
}

.roman-cell:hover .roman-remove { opacity: 1; }
.roman-remove:hover { color: var(--error); border-color: var(--error); }

/* -- sticky preview head -------------------------------------------------- */

.preview-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .6rem;
}

.preview-head .view-picker { margin: 0 0 .2rem; }

/* -- the generated guide -------------------------------------------------- */

.guide {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.75rem 2.25rem 2.25rem;
    max-width: 46rem;
}

.guide h1 { font-size: 1.7rem; margin: 0 0 .2rem; }
.guide h2 { font-size: 1.15rem; margin: 1.9rem 0 .5rem; padding-top: .9rem; border-top: 1px solid var(--line-soft); }
.guide h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; color: var(--ink-soft); }
.guide p { margin: .5rem 0; }
.guide ul { margin: .5rem 0; padding-left: 1.2rem; }
.guide li { margin: .15rem 0; }

.guide-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
    margin: .7rem 0 1rem;
}

.guide-table th {
    text-align: left;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-faint);
    padding: .3rem .5rem;
    border-bottom: 1px solid var(--line);
}

.guide-table td { padding: .28rem .5rem; border-bottom: 1px solid var(--line-soft); }

.guide-block {
    background: var(--bg);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: .7rem .9rem;
    font-family: var(--mono);
    font-size: .8rem;
    line-height: 1.6;
    overflow-x: auto;
    margin: .8rem 0;
}

/* -- accounts ------------------------------------------------------------- */

.account-page { max-width: 34rem; }

.account-page .card { display: flex; flex-direction: column; gap: .8rem; }

.account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-top: .4rem;
}

.account-facts {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: .2rem .8rem;
    margin: 0 0 1.5rem;
    font-size: .92rem;
}

.account-facts dt { color: var(--ink-faint); }
.account-facts dd { margin: 0; }

/* Blazor's validation output */
.validation-message {
    display: block;
    font-size: .82rem;
    color: var(--error);
    margin-top: .15rem;
}

.invalid { border-color: var(--error); }

/* -- who is signed in ----------------------------------------------------- */

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .75rem; }

.current-language { margin: 0; padding-top: 1rem; border-top: 1px solid var(--line); }

.who {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding-top: .75rem;
    border-top: 1px solid var(--line);
    font-size: .82rem;
}

.who-name { color: var(--ink-soft); text-decoration: none; }
.who-name:hover { color: var(--accent); }

.who-out {
    font: inherit;
    font-size: .78rem;
    background: none;
    border: none;
    padding: 0;
    color: var(--ink-faint);
    cursor: pointer;
    text-decoration: underline;
}

.who-out:hover { color: var(--error); }

.cl-name .dot { color: var(--warn); font-size: 1.1em; line-height: 0; }

/* -- your languages ------------------------------------------------------- */

.badge {
    display: inline-block;
    margin-left: .4rem;
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: .05rem .35rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    vertical-align: .1em;
}

.grid .open-row { background: var(--accent-soft); }

/* -- gallery -------------------------------------------------------------- */

.gallery-tile .tile-num { margin-top: .1rem; color: var(--ink-faint); }
.gallery-tile .tile-title { font-size: 1.05rem; }
.gallery-tile .tile-body + .tile-body { margin-top: .3rem; }

/* ---------------------------------------------------------------------------
   Tiers, progress and the maturity ladder
   --------------------------------------------------------------------------- */

.domain-distinction { margin-top: -.4rem; font-style: italic; }

.tier-picker {
    display: flex; align-items: center; flex-wrap: wrap; gap: .4rem;
    margin: 1rem 0 1.4rem; padding: .6rem .7rem;
    border: 1px solid var(--line); border-radius: 6px;
}
.tier-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-right: .3rem; }
.tier {
    display: inline-flex; align-items: baseline; gap: .35rem;
    padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px;
    background: none; color: inherit; font: inherit; font-size: .88rem; cursor: pointer;
}
.tier:hover:not(:disabled) { border-color: currentColor; }
.tier.chosen { background: var(--accent, #2b6cb0); color: #fff; border-color: transparent; }
.tier:disabled { opacity: .35; cursor: default; }
.tier-count { font-size: .74rem; opacity: .75; }
.tier-note { flex: 1 1 16rem; font-size: .82rem; opacity: .75; }

.tier-tag {
    margin-left: .5rem; padding: .05rem .4rem; border-radius: 3px;
    font-size: .66rem; text-transform: uppercase; letter-spacing: .05em;
    border: 1px solid var(--line); opacity: .65; vertical-align: middle;
}
.question.answered > .q-text { font-weight: 600; }

/* The ladder. Deliberately not a percentage: expressive range arrives in
   steps, and a bar would imply it accumulates smoothly. */
.stage-card { border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.1rem; margin-bottom: 2rem; }
.stage-head { display: flex; align-items: baseline; gap: .8rem; margin-bottom: .8rem; }
.stage-name { font-size: 1.35rem; font-weight: 600; }
.stage-of { font-size: .8rem; opacity: .6; }
.stage-ladder { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .9rem; }
.rung {
    padding: .25rem .6rem; border-radius: 999px; font-size: .76rem;
    border: 1px solid var(--line); opacity: .45;
}
.rung.reached { opacity: 1; }
.rung.current { background: var(--accent, #2b6cb0); color: #fff; border-color: transparent; font-weight: 600; }
.stage-desc { margin: 0 0 .5rem; }
.stage-advice { margin: 0; font-size: .92rem; }

.progress-table { width: 100%; border-collapse: collapse; margin: .6rem 0 1rem; }
.progress-table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; opacity: .6; padding: .3rem .5rem; }
.progress-table td { padding: .35rem .5rem; border-top: 1px solid var(--line); }
.progress-table td.ok { color: #2f855a; font-weight: 600; }
.progress-table td.todo { opacity: .7; }
.progress-table .dash { opacity: .4; }
.progress-table .wide { width: 40%; }

.bar { height: .5rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent, #2b6cb0); }

/* --- design features: a wide comparison table that has to survive a phone --- */

/* The table scrolls inside its own box rather than pushing the page sideways. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.feature-table { min-width: 40rem; }
.feature-table th:not(:first-child),
.feature-table td:not(:first-child) { text-align: center; width: 5.5rem; }

.feature-table td.yes { color: #2f855a; font-weight: 600; }
.feature-table td.no { opacity: .35; }

/* The builder's own row sits at the top and is marked, so the eye finds it
   before reading any of the reference systems below it. */
.feature-table tr.mine td { background: color-mix(in srgb, var(--accent, #2b6cb0) 7%, transparent); }
.feature-table tr.mine td:first-child { border-left: 3px solid var(--accent, #2b6cb0); }

.feature-table .q-note { display: block; font-size: .8rem; opacity: .7; margin-top: .1rem; }

/* --- a word's history: the chain of forms, then the working --- */

.lineage-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin-top: .35rem; }
.lineage-form { font-size: 1.35rem; letter-spacing: .01em; opacity: .75; }
.lineage-form.now { opacity: 1; font-weight: 600; }
.lineage-arrow { opacity: .4; font-size: 1.1rem; }

/* Each generation is a block with a rule left-edge, so the eye can count the
   steps without reading them. */
.stage { border-left: 3px solid var(--line); padding: .1rem 0 .6rem .8rem; margin: 0 0 .9rem; }
.stage:last-child { border-left-color: var(--accent, #2b6cb0); }
.stage-head { display: flex; align-items: baseline; gap: .6rem; }
.stage-lang { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; opacity: .6; }
.stage-form { font-size: 1.1rem; font-weight: 600; }

.gap-list { list-style: none; padding: 0; margin: .6rem 0 0; }
.gap-list li { padding: .55rem 0; border-top: 1px solid var(--line); }
.gap-what { font-weight: 600; }
.gap-where { margin-left: .5rem; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; opacity: .55; }
.gap-why { font-size: .88rem; opacity: .8; margin-top: .15rem; }

/* --- typology presets --- */
.callout {
    border-left: 3px solid var(--accent, #2b6cb0); padding: .6rem .9rem;
    margin: 1rem 0 1.6rem; font-size: .92rem;
}
.preset { border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; margin-bottom: .9rem; }
.preset.open { border-color: var(--accent, #2b6cb0); }
.preset-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.preset-name { font-size: 1.1rem; font-weight: 600; }
.preset-exemplars { font-size: .82rem; opacity: .65; margin-top: .1rem; }
.preset-summary { margin: .55rem 0 .3rem; }
.preset-freq { font-size: .78rem; opacity: .6; }
.preset-rationale { margin: .8rem 0; font-size: .92rem; padding-left: .8rem; border-left: 2px solid var(--line); }
.change-table td { font-size: .88rem; vertical-align: top; }
.change-domain {
    display: inline-block; margin-right: .45rem; padding: .03rem .35rem;
    border: 1px solid var(--line); border-radius: 3px;
    font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; opacity: .6;
}
.change-table .was { opacity: .55; text-decoration: line-through; }
.change-table .now { font-weight: 600; }

/* --- typology report --- */
.tab-row { display: flex; gap: .4rem; margin: .8rem 0 1.2rem; }
.callout.warn { border-left-color: #b7791f; }
.rarity { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; margin-right: .5rem; }
.rarity-very-common, .rarity-common { opacity: .55; }
.rarity-uncommon { color: #b7791f; }
.rarity-rare, .rarity-very-rare { color: #c05621; font-weight: 600; }
.pct { font-size: .82rem; opacity: .7; }
.harmony { border-top: 1px solid var(--line); padding: .6rem 0; }
.harmony.unusual { border-left: 3px solid #b7791f; padding-left: .7rem; }
.harmony-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.harmony-count { font-size: .8rem; opacity: .65; white-space: nowrap; }
.harmony-eg { font-size: .82rem; opacity: .7; margin-top: .25rem; }
.attribution { margin-top: 2rem; padding-top: .8rem; border-top: 1px solid var(--line); font-size: .76rem; }

/* --- sound change --- */
.rule-help { font-size: .82rem; opacity: .8; margin: .5rem 0 .6rem; line-height: 1.7; }
.rule-help code { padding: .05rem .3rem; border: 1px solid var(--line); border-radius: 3px; }
.rules-box { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92rem; }
.rule-table code { font-size: .9rem; }
.rule-table tr.off { opacity: .4; }
.rule-actions { white-space: nowrap; }
.linkish {
    background: none; border: none; color: inherit; font: inherit;
    cursor: pointer; padding: .1rem .3rem; opacity: .7;
}
.linkish:hover:not(:disabled) { opacity: 1; text-decoration: underline; }
.linkish:disabled { opacity: .25; cursor: default; }
.select.tiny { font-size: .82rem; padding: .1rem .25rem; margin-right: .3rem; }
.sound-delta { margin: .6rem 0 1rem; font-size: .92rem; line-height: 1.8; }
.trace-table td { vertical-align: top; }
.trace-table .was { opacity: .6; font-family: ui-monospace, monospace; }
.trace-table .now { font-weight: 600; font-family: ui-monospace, monospace; }
.steps { display: flex; flex-direction: column; gap: .15rem; }
.step { font-size: .82rem; display: flex; gap: .6rem; align-items: baseline; }
.step-rule { opacity: .65; min-width: 9rem; }
.src { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; padding: .05rem .35rem;
       border: 1px solid var(--line); border-radius: 3px; opacity: .7; }
.src-grambank { border-color: #2b6cb0; }

/* --- icons ---------------------------------------------------------------
   Sized in em so an icon tracks whatever text it sits beside, and nudged down
   a fraction because a line drawing's optical centre sits above a capital's. */
.icon {
    display: inline-block; vertical-align: -0.18em;
    width: 1.15em; height: 1.15em; flex: 0 0 auto;
    opacity: .78;
}
h1 > .icon, h2 > .icon { opacity: .55; margin-right: .15em; }
.nav-item .icon { margin-right: .15rem; opacity: .6; }
.nav-item.active .icon, .nav-item:hover .icon { opacity: 1; }
.nav-item { display: flex; align-items: center; gap: .35rem; }
.nav-item .nav-num { min-width: 1.1rem; text-align: right; }

/* --- contact languages --- */
.purpose-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .6rem; }
.purpose {
    text-align: left; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 8px;
    background: none; color: inherit; font: inherit; cursor: pointer; display: flex;
    flex-direction: column; gap: .2rem;
}
.purpose:hover { border-color: currentColor; }
.purpose.chosen { border-color: var(--accent, #2b6cb0); box-shadow: inset 0 0 0 1px var(--accent, #2b6cb0); }
.purpose-name { font-weight: 600; }
.purpose-count { font-size: .74rem; opacity: .6; }
.purpose-desc { font-size: .82rem; opacity: .8; }
.in-mix { background: color-mix(in srgb, currentColor 4%, transparent); }
.stat-row { display: flex; flex-wrap: wrap; gap: 1.4rem; margin: .8rem 0 1rem; }
.stat { display: flex; flex-direction: column; }
.stat-n { font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
.stat-l { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; opacity: .6; }
.not-yet { opacity: .45; }

/* --- ten questions -------------------------------------------------------
   Wider than the question pages and centred: this is a focused flow, and the
   sidebar is a distraction while somebody is halfway through it. */
.start { max-width: 46rem; margin: 0 auto; }
.start-head { display: flex; justify-content: space-between; align-items: baseline; }
.start-count { font-size: .82rem; opacity: .6; }
.start-rail { display: flex; gap: .3rem; margin: .6rem 0 1.4rem; }
.pip {
    flex: 1; height: .3rem; border: none; border-radius: 999px; padding: 0;
    background: var(--line); cursor: pointer;
}
.pip.done { background: color-mix(in srgb, var(--accent, #2b6cb0) 55%, transparent); }
.pip.here { background: var(--accent, #2b6cb0); }
.start-preview {
    border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem;
    margin-bottom: 1.6rem; overflow-x: auto;
}
.start-q h2 { margin-bottom: .2rem; }
.pick {
    display: flex; flex-direction: column; gap: .15rem; width: 100%;
    text-align: left; padding: .7rem .9rem; margin-bottom: .5rem;
    border: 1px solid var(--line); border-radius: 8px;
    background: none; color: inherit; font: inherit; cursor: pointer;
}
.pick:hover { border-color: currentColor; }
.pick.chosen { border-color: var(--accent, #2b6cb0); box-shadow: inset 0 0 0 1px var(--accent, #2b6cb0); }
.pick strong { font-size: 1rem; }
.pick span { font-size: .87rem; opacity: .8; }
.text.big { font-size: 1.3rem; padding: .6rem .8rem; width: 100%; }
.start-nav { display: flex; align-items: center; gap: .6rem; margin-top: 1.6rem;
             padding-top: 1rem; border-top: 1px solid var(--line); }
.start-nav .linkish { margin-left: auto; font-size: .82rem; }
.start-callout { display: flex; gap: .7rem; align-items: flex-start; }
.nav-item.start-link { font-weight: 600; }

/* --- family tree and reconstruction --- */
.family { margin-bottom: 1.4rem; }
.tree-row {
    display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
    padding: .4rem 0; border-top: 1px solid var(--line);
}
.tree-row.depth-1 { padding-left: 1.6rem; }
.tree-row.depth-2 { padding-left: 3.2rem; }
.tree-row.depth-3 { padding-left: 4.8rem; }
.tree-row.depth-4 { padding-left: 6.4rem; }
.tree-row.depth-5 { padding-left: 8rem; }
.tree-row.depth-6 { padding-left: 9.6rem; }
.tree-row.depth-1, .tree-row.depth-2, .tree-row.depth-3,
.tree-row.depth-4, .tree-row.depth-5, .tree-row.depth-6 {
    background: linear-gradient(to right, var(--line) 0 1px, transparent 1px) no-repeat;
    background-size: 1px 100%;
}
.tree-name { font-weight: 600; }
.tree-meta { font-size: .78rem; opacity: .6; }
.tree-how {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
    padding: .04rem .35rem; border: 1px solid var(--line); border-radius: 3px; opacity: .7;
}
.tree-row.orphan { opacity: .75; }
.pick-list { display: flex; flex-direction: column; margin: .5rem 0 1rem; }
.check-row {
    display: flex; align-items: center; gap: .6rem;
    padding: .45rem .6rem; border-bottom: 1px solid var(--line); cursor: pointer;
}
.check-row .grow { flex: 1; }
.corr { font-size: .95rem; letter-spacing: .03em; }
.rule-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .3rem 0 .9rem; }
.chip { padding: .1rem .45rem; border: 1px solid var(--line); border-radius: 999px; font-size: .84rem; }
.lang-changes { margin-bottom: .4rem; }
.bar.tiny { width: 5rem; height: .35rem; }

/* --- glossary terms ------------------------------------------------------
   A dotted underline and nothing else: the mark has to be findable without
   competing with the sentence it sits in. No colour, no icon, no weight
   change -- those all pull the eye harder than the word deserves. */
.term-wrap { position: relative; display: inline; }
.term {
    background: none; border: none; padding: 0; font: inherit; color: inherit;
    cursor: help; border-bottom: 1px dotted currentColor;
    opacity: .95;
}
.term:hover, .term:focus-visible, .term.open { border-bottom-style: solid; outline: none; }
.term:focus-visible { outline: 2px solid var(--accent, #2b6cb0); outline-offset: 2px; border-radius: 2px; }

.term-pop {
    position: absolute; left: 0; top: 1.6em; z-index: 40;
    display: none; width: max-content; max-width: min(24rem, 80vw);
    padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 6px;
    background: var(--bg, #fff); color: inherit;
    box-shadow: 0 6px 22px rgba(0,0,0,.16);
    font-size: .85rem; line-height: 1.45; font-weight: 400; text-align: left;
    white-space: normal;
}
.term-wrap:hover .term-pop, .term-pop.open { display: block; }
.term-pop strong { display: block; margin-bottom: .15rem; }
.term-pop em { display: block; margin-top: .35rem; opacity: .8; font-style: italic; }

/* Near the right edge a fixed-left popover runs off screen; on narrow
   viewports pin it to the left margin instead of the word. */
@media (max-width: 40rem) {
    .term-pop { left: 0; right: 0; width: auto; max-width: none; }
}
.glossary-list { margin-top: 1rem; }
.glossary-entry { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem;
                  padding: .7rem 0; border-top: 1px solid var(--line); }
.glossary-term { font-weight: 600; }
.glossary-def em { display: block; margin-top: .25rem; opacity: .78; font-style: italic; }
@media (max-width: 34rem) { .glossary-entry { grid-template-columns: 1fr; gap: .2rem; } }

/* --- grammaticalisation --- */
.path-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .6rem; }
.path {
    display: flex; flex-direction: column; gap: .25rem; text-align: left;
    padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 8px;
    background: none; color: inherit; font: inherit; cursor: pointer;
}
.path:hover { border-color: currentColor; }
.path.chosen { border-color: var(--accent, #2b6cb0); box-shadow: inset 0 0 0 1px var(--accent, #2b6cb0); }
.path-arrow { font-weight: 600; }
.path-note { font-size: .84rem; opacity: .82; }
.path-attested { font-size: .74rem; opacity: .55; font-style: italic; }

/* The cline, drawn as a track so the direction is obvious. It only runs one
   way -- affixes do not climb back into content words -- and the layout says
   so without a sentence about it. */
.cline { display: flex; align-items: stretch; gap: .25rem; margin: .8rem 0 1rem; flex-wrap: wrap; }
.cline-step {
    flex: 1 1 7rem; display: flex; flex-direction: column; gap: .2rem;
    padding: .55rem .5rem; border: 1px solid var(--line); border-radius: 6px;
    background: none; color: inherit; font: inherit; cursor: pointer; opacity: .55;
}
.cline-step.past { opacity: .8; }
.cline-step.here { opacity: 1; border-color: var(--accent, #2b6cb0);
                   box-shadow: inset 0 0 0 1px var(--accent, #2b6cb0); }
.cline-name { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; opacity: .7; }
.cline-form { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; }
.roman-table .ipa { font-size: 1.05rem; margin-right: .4rem; }
.roman-table tr.manual { background: color-mix(in srgb, currentColor 5%, transparent); }
.roman-table tr.manual .text { font-weight: 600; }
