/* ============================================================
   Signs of AI Writing — application styles
   Theme-aware (light default + dark via prefers-color-scheme).
   ============================================================ */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #1a1d21;
    --text-muted: #5b6470;
    --border: #e2e6ea;
    --brand: #2563eb;      /* PeopleWorks blue (blue-600) */
    --brand-2: #3b82f6;    /* lighter blue for gradients (blue-500) */
    --brand-ink: #ffffff;
    --lex: #db2777;   /* lexical  — pink   */
    --rhet: #d97706;  /* rhetoric — amber  */
    --syn: #0891b2;   /* syntax   — cyan   */
    --stat: #dc2626;  /* stats    — red    */
    --good: #16a34a;
    --notice: #ca8a04;
    --warn: #ea580c;
    --danger: #dc2626;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
    --radius: 14px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #171b21;
        --surface-2: #1e242c;
        --text: #e8ebee;
        --text-muted: #9aa4b0;
        --border: #2a313a;
        --brand: #3b82f6;      /* brighter blue for dark mode */
        --brand-2: #60a5fa;
        --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

h1, h2, h3 { line-height: 1.2; }
a { color: var(--brand); }

.app-shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.app-shell > main { flex: 1; }

/* ---- hero ---- */
.hero { text-align: center; margin-bottom: 1.75rem; }
.hero h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    margin: 0 0 .5rem;
    letter-spacing: -.02em;
}
.logo-mark { color: var(--brand); }
.tagline { color: var(--text-muted); max-width: 640px; margin: 0 auto .6rem; font-size: 1.05rem; }
.tagline strong { color: var(--text); }
.privacy { font-size: .85rem; color: var(--text-muted); margin: 0; }

/* ---- task entry ----
   Four routes by what the reader came to do. Quiet on purpose: it sits above the editor, so it must
   read as signposting and never compete with the result panels below it. auto-fit rather than a
   fixed count, so it becomes two rows on a laptop and one column on a phone without a breakpoint. */
.task-entry { max-width: 900px; margin: 0 auto 1.75rem; }
.task-q {
    text-align: center;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 .7rem;
}
.task-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: .7rem;
}
.task-card {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    height: 100%;
    padding: .85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, transform .15s;
}
a.task-card:hover, a.task-card:focus-visible {
    border-color: var(--brand);
    transform: translateY(-1px);
}
.task-name { font-weight: 650; font-size: .96rem; color: var(--text); line-height: 1.3; }
.task-what { font-size: .82rem; color: var(--text-muted); line-height: 1.45; }
/* Where the thing actually lives, when it is not here. Same slot as "you are here", muted. */
.task-where {
    margin-top: auto;
    padding-top: .3rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}
/* Where you already are: still readable, visibly not a destination. */
.task-card.here { background: var(--surface-2); border-style: dashed; }
.task-here {
    margin-top: auto;
    padding-top: .3rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--brand);
}

/* ---- cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

/* ---- editor ---- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}
.field { display: flex; flex-direction: column; font-size: .78rem; color: var(--text-muted); gap: .25rem; }
.field select {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .4rem .6rem;
    font-size: .9rem;
}
.samples { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--text-muted); }
.counter { margin-left: auto; font-size: .82rem; color: var(--text-muted); }

.link {
    background: none; border: none; color: var(--brand);
    cursor: pointer; font-size: .82rem; padding: .1rem .2rem; text-decoration: underline;
}

textarea {
    width: 100%;
    min-height: 200px;
    resize: vertical;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .9rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.6;
}
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.actions { display: flex; gap: .6rem; margin-top: .9rem; }
button.primary, button.ghost {
    border-radius: 9px; padding: .55rem 1.2rem; font-size: .95rem; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; transition: transform .05s ease, opacity .15s;
}
button.primary { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: var(--brand-ink); }
button.ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
button.primary:not(:disabled):active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ---- summary / score ---- */
.summary { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
/* Register --pct as a number so the conic-gradient fill can animate smoothly as the live score changes. */
@property --pct { syntax: "<number>"; inherits: false; initial-value: 0; }
.score-ring {
    --pct: 0;
    --ring: var(--warn);
    flex: 0 0 auto;
    width: 116px; height: 116px; border-radius: 50%;
    background: conic-gradient(var(--ring) calc(var(--pct) * 1%), var(--surface-2) 0);
    display: grid; place-items: center;
    transition: --pct .55s cubic-bezier(.22,.61,.36,1), background .55s ease;
}
.score-ring.good { --ring: var(--good); }
.score-ring.notice { --ring: var(--notice); }
.score-ring.warn { --ring: var(--warn); }
.score-ring.danger { --ring: var(--danger); }
/* Outside what was measured. Grey rather than green: the page is refusing to answer, and green is
   an answer. See VerdictEmphasis.Unmeasured. */
.score-ring.unmeasured { --ring: var(--text-muted); }
.score-inner {
    width: 88px; height: 88px; border-radius: 50%; background: var(--surface);
    display: grid; place-items: center; text-align: center;
}
.score-num { font-size: 1.9rem; font-weight: 700; }
.score-of { font-size: .7rem; color: var(--text-muted); display: block; margin-top: -.3rem; }

.verdict h2 { margin: 0 0 .25rem; font-size: 1.35rem; }
.verdict h2.good { color: var(--good); }
.verdict h2.notice { color: var(--notice); }
.verdict h2.warn { color: var(--warn); }
.verdict h2.danger { color: var(--danger); }
.verdict h2.unmeasured { color: var(--text-muted); }
.hint.unmeasured { margin-top: .4rem; max-width: 46rem; }
.verdict p { margin: 0 0 .6rem; color: var(--text-muted); font-size: .9rem; }

.cat-chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
    font-size: .78rem; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--border);
    display: inline-flex; gap: .35rem; align-items: center; background: var(--surface-2);
}
.chip b { font-weight: 700; }
.chip-lex { color: var(--lex); } .chip-rhet { color: var(--rhet); }
.chip-syn { color: var(--syn); } .chip-stat { color: var(--stat); }

/* ---- stats ---- */
.stats { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }
.stat { display: flex; flex-direction: column; gap: .1rem; min-width: 90px; }
.stat-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-val { font-size: 1.3rem; font-weight: 700; }
.stat-val.warn { color: var(--warn); }

/* ---- character artifacts ----
   Styled unlike the score card on purpose. The score is a judgement and reads as a coloured gauge;
   this is a list of facts and reads as a table. A reader should be able to tell the two apart
   without having read a word. */
.artifacts { border-left: 3px solid var(--text-muted); }
.artifacts.artifacts-strong { border-left-color: var(--warn); }

.artifacts-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.artifacts-head h3 { margin: 0; font-size: 1.05rem; display: inline-flex; align-items: center; gap: .4rem; }
.artifacts-head .chip-strong { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.artifacts-head button { margin-left: auto; }

.artifacts-summary { margin: 0 0 .8rem; font-size: .92rem; }

.artifacts-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-bottom: .7rem; }
.artifacts-table th {
    text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); font-weight: 600; padding: .25rem .5rem .25rem 0;
    border-bottom: 1px solid var(--border);
}
.artifacts-table td { padding: .3rem .5rem .3rem 0; border-bottom: 1px solid var(--border); }
.artifacts-table th.num, .artifacts-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.artifacts-table code { font-size: .82rem; background: var(--surface-2); padding: .1rem .35rem; border-radius: 5px; }
.artifacts-table tr.weak td { color: var(--text-muted); }
.lookslike { color: var(--text-muted); font-size: .8rem; margin-left: .4rem; }

.artifacts-positions {
    list-style: none; margin: .6rem 0 .3rem; padding: 0;
    display: flex; flex-direction: column; gap: .3rem;
    max-height: 18rem; overflow-y: auto; font-size: .84rem;
}
.artifacts-positions li { display: flex; gap: .5rem; align-items: baseline; }
.artifacts-positions code.at {
    background: var(--surface-2); padding: .05rem .35rem; border-radius: 5px;
    font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-muted);
}

.artifacts-advice {
    display: flex; gap: .5rem; align-items: flex-start;
    margin: .8rem 0 0; padding-top: .7rem; border-top: 1px solid var(--border);
    font-size: .85rem; color: var(--text-muted);
}


/* ---- sources (citation cross-check) ----
   Reads as a table of statements about the file, like the artifact panel and unlike the score. */
.citations { border-left: 3px solid var(--text-muted); }
.citations.citations-strong { border-left-color: var(--warn); }

.citations-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.citations-head h3 { margin: 0; font-size: 1.05rem; display: inline-flex; align-items: center; gap: .4rem; }
.citations-head button { margin-left: auto; }

.citations-summary { margin: 0 0 .6rem; font-size: .92rem; }
.citations-counts { display: flex; gap: 1.2rem; font-size: .8rem; color: var(--text-muted); margin-bottom: .7rem; }
.citations-counts b { color: var(--text); font-size: 1rem; }

.citations-issues { list-style: none; margin: 0 0 .7rem; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.citations-issues li {
    display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap;
    font-size: .86rem; padding-left: .6rem; border-left: 2px solid var(--border);
}
.citations-issues li.contradiction { border-left-color: var(--warn); }
.citations-issues li.untidy { color: var(--text-muted); }
.issue-kind {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
    padding: .1rem .4rem; border-radius: 999px; background: var(--surface-2); white-space: nowrap;
}
.citations-issues li.contradiction .issue-kind { color: var(--warn); }
.issue-message { flex: 1 1 16rem; min-width: 0; }

.citations-list {
    margin: .6rem 0 .3rem; padding-left: 1.4rem; font-size: .82rem;
    display: flex; flex-direction: column; gap: .35rem;
    max-height: 20rem; overflow-y: auto;
}
.citations-list li { display: flex; gap: .5rem; align-items: baseline; }
.citations .at {
    background: var(--surface-2); padding: .05rem .35rem; border-radius: 5px;
    font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-muted); font-size: .78rem;
}

.citations-advice {
    display: flex; gap: .5rem; align-items: flex-start;
    margin: .8rem 0 0; padding-top: .7rem; border-top: 1px solid var(--border);
    font-size: .85rem; color: var(--text-muted);
}


/* ---- baseline (comparison with the writer's own earlier work) ----
   Built so a distance never appears without the writer's own spread beside it: the bar shows both,
   on one axis, at the same scale. */
.base-inputs { display: flex; flex-direction: column; gap: .9rem; margin-bottom: 1.25rem; }
.base-questioned { border-left: 3px solid var(--brand); }
.base-questioned h3, .base-earlier-head h3 {
    margin: 0; font-size: 1rem; display: inline-flex; align-items: center; gap: .4rem;
}
.base-earlier-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.base-earlier-head .hint { margin: 0; }
.base-earlier-head .orig-wc { margin-left: auto; }
.orig-wc.short { color: var(--warn); }

.base-actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.base-lang { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-muted); }
.base-actions .primary { margin-left: auto; }

.base-result { border-left: 3px solid var(--text-muted); }
.base-result.within { border-left-color: var(--good); }
.base-result.edge { border-left-color: var(--notice); }
.base-result.beyond { border-left-color: var(--warn); }
.base-verdict { margin: 0 0 .35rem; font-size: 1.25rem; display: flex; align-items: center; gap: .45rem; }
.base-result.within .base-verdict { color: var(--good); }
.base-result.edge .base-verdict { color: var(--notice); }
.base-result.beyond .base-verdict { color: var(--warn); }
.base-summary { margin: 0 0 1.1rem; font-size: .92rem; }

.base-scale {
    position: relative; height: 2.6rem; margin: 0 0 1rem;
    border-bottom: 2px solid var(--border);
}
.base-tick { position: absolute; bottom: 0; width: 2px; transform: translateX(-1px); border-radius: 1px; }
.base-tick.own { height: 12px; background: var(--text-muted); opacity: .55; }
.base-tick.questioned { height: 26px; width: 3px; background: var(--brand); }
.base-scale-label {
    position: absolute; top: 0; font-size: .7rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .04em;
}
.base-scale-label.left { left: 0; }
.base-scale-label.right { right: 0; }

.citations-counts .notable b { color: var(--warn); }

.base-drivers { width: 100%; border-collapse: collapse; font-size: .85rem; margin: .4rem 0 .5rem; }
.base-drivers th {
    text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); font-weight: 600; padding: .25rem .5rem .25rem 0;
    border-bottom: 1px solid var(--border);
}
.base-drivers td { padding: .3rem .5rem .3rem 0; border-bottom: 1px solid var(--border); }
.base-drivers th.num, .base-drivers td.num { text-align: right; font-variant-numeric: tabular-nums; }
.base-drivers code { font-size: .84rem; background: var(--surface-2); padding: .1rem .35rem; border-radius: 5px; }
.base-drivers tr.outside td { background: color-mix(in srgb, var(--warn) 9%, transparent); }

/* ---- highlighted text ---- */
.highlighted h3, .findings h3 { margin: 0 0 .3rem; font-size: 1.1rem; }
.hint { margin: 0 0 .8rem; font-size: .82rem; color: var(--text-muted); }
.text-view {
    white-space: pre-wrap; word-wrap: break-word;
    background: var(--surface-2); border-radius: 10px; padding: 1rem 1.15rem;
    font-size: 1.02rem; line-height: 1.7;
}
.hl { border-radius: 4px; padding: .05em .15em; cursor: help; color: inherit; }
.hl-lex  { background: color-mix(in srgb, var(--lex) 22%, transparent);  box-shadow: inset 0 -2px 0 var(--lex); }
.hl-rhet { background: color-mix(in srgb, var(--rhet) 22%, transparent); box-shadow: inset 0 -2px 0 var(--rhet); }
.hl-syn  { background: color-mix(in srgb, var(--syn) 22%, transparent);  box-shadow: inset 0 -2px 0 var(--syn); }
.hl-stat { background: color-mix(in srgb, var(--stat) 22%, transparent); box-shadow: inset 0 -2px 0 var(--stat); }

/* ---- findings ---- */
.finding-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.finding {
    border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; padding: .7rem .9rem;
    background: var(--surface-2);
}
.finding.sev-high { border-left-color: var(--danger); }
.finding.sev-medium { border-left-color: var(--warn); }
.finding.sev-low { border-left-color: var(--notice); }
.finding.sev-info { border-left-color: var(--border); }
.finding-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; }
.badge {
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: .12rem .45rem; border-radius: 5px; color: #fff;
}
.badge-lex { background: var(--lex); } .badge-rhet { background: var(--rhet); }
.badge-syn { background: var(--syn); } .badge-stat { background: var(--stat); }
.finding-head code {
    background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
    padding: .05rem .35rem; font-size: .85rem; color: var(--text);
}
.sev-tag { margin-left: auto; font-size: .7rem; color: var(--text-muted); }
.finding-msg { margin: 0 0 .3rem; font-size: .92rem; }
.finding-fix { margin: 0; font-size: .9rem; color: var(--text); }
.finding-evidence { margin: .35rem 0 0; font-size: .78rem; color: var(--text-muted); font-style: italic; }
.findings.empty p { margin: 0; color: var(--good); font-size: 1rem; }

/* ---- nav ---- */
.app-nav {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
    padding-bottom: .9rem; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); letter-spacing: -.01em; }
/* Wraps: the nav gained a sixth link and a narrow window must not push the language switch off. */
.nav-links { display: flex; flex-wrap: wrap; gap: .35rem; }
.nav-link {
    text-decoration: none; color: var(--text-muted); font-size: .92rem; font-weight: 600;
    padding: .35rem .75rem; border-radius: 8px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--brand); color: var(--brand-ink); }

.dotnet-badge {
    display: inline-flex; align-items: center; gap: .4rem; font-size: .74rem; font-weight: 600;
    color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
    padding: .25rem .6rem; border-radius: 999px; margin-right: auto; margin-left: .5rem;
}
.dotnet-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
@media (max-width: 640px) { .dotnet-badge { display: none; } }

/* ---- interface-language switch ---- */
.lang-switch { display: inline-flex; align-items: center; gap: .4rem; margin-left: .35rem; }
.lang-globe { color: var(--text-muted); font-size: 1rem; }
/* --n = how many languages the manifest offers, --i = index of the active one. Both are set
   inline by LanguageSwitch, so adding a locale needs no CSS change. */
.lang-track {
    position: relative; display: grid; grid-template-columns: repeat(var(--n, 2), 1fr);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; padding: 3px;
}
/* Sized to one segment of the track's inner width, so translateX(i * 100%) lands the thumb exactly
   on the active segment — no magic pixel offsets to re-tune when the labels change. */
.lang-thumb {
    position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 3px;
    width: calc((100% - 6px) / var(--n, 2));
    transform: translateX(calc(var(--i, 0) * 100%));
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    border-radius: 999px; box-shadow: 0 1px 3px rgb(0 0 0 / .18);
    transition: transform .24s cubic-bezier(.4, .01, .2, 1);
}
.lang-opt {
    position: relative; z-index: 1; appearance: none; background: none; border: 0;
    cursor: pointer; font: inherit; font-size: .74rem; font-weight: 700; letter-spacing: .03em;
    color: var(--text-muted); padding: .26rem .6rem; border-radius: 999px; line-height: 1.45;
    transition: color .18s ease;
}
.lang-opt.on { color: var(--brand-ink); }
.lang-opt:hover:not(.on) { color: var(--text); }
.lang-opt:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .lang-thumb { transition: none; } }

/* ---- file upload ---- */
.upload-btn {
    display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    padding: .4rem .7rem; font-size: .85rem; color: var(--text); font-weight: 600;
}
.upload-btn:hover { border-color: var(--brand); }
.upload-btn input[type=file] { display: none; }
.file-note { margin: 0 0 .5rem; font-size: .82rem; color: var(--good); }
.doc-hint { margin: .45rem 0 0; }

/* ---- azure fields ---- */
.azure-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.azure-grid input {
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; padding: .45rem .7rem; font-size: .88rem;
}
.azure-grid input:focus { outline: 2px solid var(--brand); }
@media (max-width: 560px) { .azure-grid { grid-template-columns: 1fr; } }
.hint.sub { margin-top: .4rem; }
.settings .field { margin-bottom: .6rem; }

/* ---- settings / api key ---- */
.settings { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.key-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.key-row input {
    flex: 1; min-width: 220px; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px; padding: .45rem .7rem; font-size: .9rem; font-family: ui-monospace, monospace;
}
.key-row input:focus { outline: 2px solid var(--brand); }
.settings-toggle { margin-left: auto; }
.saved-note { display: inline-block; margin-top: .5rem; font-size: .8rem; color: var(--good); }

/* ---- humanize ---- */
.humanize-btn { margin-top: .3rem; }
.humanize-error { color: var(--warn); font-size: .92rem; }
.humanized { border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--border)); }
.humanized-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.humanized-head h3 { margin: 0; font-size: 1.1rem; }
.humanized-head > div { display: flex; gap: .4rem; }

/* ---- workspace: text left, recommendations right ---- */
.workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.workspace .findings { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
@media (max-width: 900px) {
    .workspace { grid-template-columns: 1fr; }
    .workspace .findings { position: static; max-height: none; }
}
.empty { color: var(--good); font-size: 1rem; margin: 0; }

/* ---- catalog ---- */
.catalog-controls { display: flex; flex-direction: column; gap: .8rem; }
.search-box {
    width: 100%; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem; font-size: 1rem;
}
.search-box:focus { outline: 2px solid var(--brand); }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.filter {
    background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
    border-radius: 999px; padding: .3rem .8rem; font-size: .82rem; cursor: pointer; font-weight: 600;
}
.filter.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.filter-lex.on { background: var(--lex); } .filter-rhet.on { background: var(--rhet); }
.filter-syn.on { background: var(--syn); } .filter-stat.on { background: var(--stat); }
.result-count { font-size: .82rem; color: var(--text-muted); margin: 0 0 .8rem; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.sign { border-left: 4px solid var(--border); display: flex; flex-direction: column; gap: .35rem; margin: 0; }
.sign.sev-high { border-left-color: var(--danger); }
.sign.sev-medium { border-left-color: var(--warn); }
.sign.sev-low { border-left-color: var(--notice); }
.sign-head { display: flex; align-items: center; gap: .5rem; }
.lang-tag { font-size: .68rem; font-weight: 700; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: .05rem .35rem; }
.sign-title { margin: .1rem 0 0; font-size: 1.05rem; }
.examples { display: flex; gap: .3rem; flex-wrap: wrap; }
.examples code {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
    padding: .05rem .35rem; font-size: .8rem; color: var(--text);
}
.sign-msg { margin: .2rem 0 0; font-size: .9rem; }
.sign-fix { margin: 0; font-size: .88rem; }
.sign-evidence { margin: .2rem 0 0; font-size: .76rem; color: var(--text-muted); font-style: italic; }

/* ---- live analysis ---- */
.live-pill {
    display: inline-flex; align-items: center; gap: .35rem; font-size: .74rem; font-weight: 700;
    color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--good) 30%, transparent);
    padding: .2rem .6rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: livepulse 1.6s ease-in-out infinite; }
@keyframes livepulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.6); } }

.idle-hint { text-align: center; color: var(--text-muted); font-size: .95rem; margin: 2rem 0 3rem; }

.results { animation: fadeup .4s ease both; }
@keyframes fadeup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stat-val { transition: color .3s ease; }
.score-num { transition: color .3s ease; }

/* ---- sentence-rhythm chart ---- */
.rhythm h3 { margin: 0 0 .3rem; font-size: 1.1rem; }
.rhythm-svg { width: 100%; height: 84px; display: block; margin-top: .5rem; overflow: visible; }
.rhythm-mean { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: .5; vector-effect: non-scaling-stroke; }
.rhythm-caption { margin: .55rem 0 0; font-size: .85rem; color: var(--text-muted); }
.rhythm-empty { color: var(--text-muted); font-size: .9rem; margin: .3rem 0 0; }

/* ---- custom catalogs ---- */
.catalog-list { display: flex; flex-direction: column; gap: .35rem; margin: .6rem 0; }
.catalog-row { display: flex; align-items: center; gap: .6rem; font-size: .9rem; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.catalog-row.builtin { color: var(--good); background: transparent; border-style: dashed; }
.cat-toggle { display: flex; align-items: center; gap: .45rem; cursor: pointer; }
.cat-meta { margin-left: auto; font-size: .78rem; color: var(--text-muted); }
.catalog-add { margin-top: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.add-tabs { display: flex; gap: .4rem; }
.catalog-add input, .cat-words { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; font-size: .9rem; width: 100%; }
.cat-words { min-height: 90px; resize: vertical; font-family: inherit; }
.cat-words.mono { font-family: ui-monospace, monospace; font-size: .82rem; }
.link.danger { color: var(--danger); }
.danger-text { color: var(--danger); }

/* ---- humanize diff ---- */
.summary-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.score-compare { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; margin-right: .5rem; }
.sc-num { font-size: 1.25rem; }
.sc-num.good { color: var(--good); } .sc-num.notice { color: var(--notice); }
.sc-num.warn { color: var(--warn); } .sc-num.danger { color: var(--danger); }
.sc-arrow { color: var(--text-muted); }
.sc-delta { font-size: .8rem; font-weight: 700; color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); padding: .1rem .45rem; border-radius: 999px; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .diff-grid { grid-template-columns: 1fr; } }
.diff-col h4 { margin: 0 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.diff-view { line-height: 1.7; }
.d-del { background: color-mix(in srgb, var(--danger) 16%, transparent); text-decoration: line-through; color: var(--text-muted); border-radius: 3px; }
.d-add { background: color-mix(in srgb, var(--good) 20%, transparent); box-shadow: inset 0 -2px 0 var(--good); border-radius: 3px; }

/* ---- live rewrite ---- */
.rewrite-btn.on { box-shadow: inset 0 0 0 2px var(--brand-ink); }
.rewrite-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .7rem; }
.rewrite-head h3 { margin: 0; font-size: 1.1rem; display: inline-flex; align-items: center; gap: .4rem; }
.rw-badge {
    display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 700;
    color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--good) 30%, transparent);
    padding: .15rem .5rem; border-radius: 999px;
}
.rw-strength { display: flex; gap: .3rem; margin-left: auto; }

.rw-summary { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: .8rem; }
.rw-count { font-size: .84rem; font-weight: 600; color: var(--text-muted); }
.rw-pending {
    font-size: .76rem; font-weight: 700; color: var(--notice); cursor: help;
    background: color-mix(in srgb, var(--notice) 14%, transparent);
    padding: .12rem .5rem; border-radius: 999px;
}
.rw-actions { margin-left: auto; display: flex; gap: .4rem; }

.rw-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .rw-panes { grid-template-columns: 1fr; } }
.rw-pane h4 {
    margin: 0 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); display: inline-flex; align-items: center; gap: .35rem;
}
.rw-body { max-height: 22rem; overflow-y: auto; font-size: .97rem; }
.rw-out { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 35%, transparent); }

/* Applied edits read as resolved (green); skipped ones stay flagged as the tell they are. */
.rw-hl { border-radius: 4px; padding: .05em .15em; cursor: help; }
.rw-hl.on { background: color-mix(in srgb, var(--good) 20%, transparent); box-shadow: inset 0 -2px 0 var(--good); }
.rw-hl.off { background: color-mix(in srgb, var(--lex) 20%, transparent); box-shadow: inset 0 -2px 0 var(--lex); }

.rw-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.rw-item {
    display: flex; gap: .6rem; align-items: flex-start;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 8px; padding: .5rem .6rem;
}
.rw-item.skipped { opacity: .62; }
.rw-toggle {
    flex: 0 0 auto; width: 1.65rem; height: 1.65rem; padding: 0; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.rw-toggle.on { background: var(--good); border-color: transparent; color: #fff; }
.rw-item-body { min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.rw-change { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .92rem; }
.rw-change del { color: var(--text-muted); }
.rw-change ins { text-decoration: none; font-weight: 700; color: var(--good); }
.rw-arrow { color: var(--text-muted); }
.rw-deleted { color: var(--text-muted); font-size: .84rem; }
.rw-needspick {
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--notice); background: color-mix(in srgb, var(--notice) 14%, transparent);
    padding: .1rem .4rem; border-radius: 4px; cursor: help;
}
.rw-alts { display: flex; gap: .3rem; flex-wrap: wrap; }
.rw-alt {
    font-size: .78rem; padding: .18rem .5rem; border-radius: 999px; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.rw-alt:hover { color: var(--text); }
.rw-alt.on { background: var(--brand); border-color: transparent; color: var(--brand-ink); font-weight: 700; }
.rw-structural { margin: .9rem 0 0; }

/* ---- share card ---- */
.share-canvas { width: 100%; max-width: 640px; height: auto; display: block; margin: .3rem auto 0; border: 1px solid var(--border); border-radius: 10px; }

/* ---- footer ---- */
.app-footer { text-align: center; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .78rem; color: var(--text-muted); }
.app-footer p { margin: .2rem 0; }
.app-footer strong { color: var(--text); }

/* ============================================================
   Blazor framework bits (loading indicator + error UI)
   ============================================================ */
.loading-progress {
    position: absolute; display: block; width: 8rem; height: 8rem;
    inset: 20vh 0 auto 0; margin: 0 auto;
}
.loading-progress circle {
    fill: none; stroke: var(--border); stroke-width: 0.6rem;
    transform-origin: 50% 50%; transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--brand);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    position: absolute; text-align: center; font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem; color: var(--text);
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

#blazor-error-ui {
    background: lightyellow; color: #111; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    box-sizing: border-box; display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem; position: fixed;
    width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; border-radius: 8px; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ── Perplexity panel (optional server signal) ─────────────────────────────── */
.ppl-head { display: flex; align-items: center; justify-content: space-between; }
.ppl-head h3 { margin: 0; }
.badge-beta {
    font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    background: var(--brand); color: var(--brand-ink); padding: .12rem .4rem; border-radius: 6px;
    vertical-align: middle; margin-left: .35rem;
}
.ppl-gear {
    background: none; border: none; color: var(--text-muted); font-size: 1.05rem; cursor: pointer;
    padding: .1rem .3rem; border-radius: 6px;
}
.ppl-gear:hover { background: var(--surface-2); color: var(--text); }
.ppl-settings { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; margin-bottom: .7rem; }
.ppl-field { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--text-muted); }
.ppl-field input {
    padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font-size: .85rem;
}
.ppl-settings-actions { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }
.ppl-ok { font-size: .76rem; color: var(--good); }
.ppl-privacy { font-size: .74rem; color: var(--text-muted); margin: .55rem 0 0; line-height: 1.4; }
.ppl-models { display: flex; gap: .4rem; margin-bottom: .5rem; }
.ppl-model-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem;
    padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface); color: var(--text); cursor: pointer; font-size: .82rem; font-weight: 600;
}
.ppl-model-btn span { font-size: .64rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.ppl-model-btn:hover { border-color: var(--brand); }
.ppl-model-btn.sel { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--brand); }
.ppl-run { width: 100%; margin-bottom: .3rem; }
.ppl-error { color: var(--danger); font-size: .82rem; margin-top: .5rem; }

.ppl-result { margin-top: .8rem; }
.ppl-verdict { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .45rem; }
.ppl-verdict-label { font-weight: 700; font-size: 1.02rem; }
.ppl-verdict-pct { font-size: 1.5rem; font-weight: 800; }
.ppl-verdict-pct small { font-size: .7rem; font-weight: 600; color: var(--text-muted); margin-left: .15rem; }
.ppl-verdict.b-pred .ppl-verdict-label, .ppl-verdict.b-pred .ppl-verdict-pct { color: var(--notice); }
.ppl-verdict.b-var .ppl-verdict-label, .ppl-verdict.b-var .ppl-verdict-pct { color: var(--good); }
.ppl-verdict.b-typ .ppl-verdict-label, .ppl-verdict.b-typ .ppl-verdict-pct { color: var(--brand); }

.ppl-meter { position: relative; height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.ppl-meter-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }
.ppl-meter-fill.b-pred { background: var(--notice); }
.ppl-meter-fill.b-var { background: var(--good); }
.ppl-meter-fill.b-typ { background: var(--brand); }
.ppl-note { font-size: .78rem; color: var(--text-muted); margin: .5rem 0 0; line-height: 1.4; }

.ppl-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .7rem; }
.ppl-num { display: flex; flex-direction: column; }
.ppl-num span { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ppl-num strong { font-size: .98rem; }
.ppl-num .ppl-model { font-size: .72rem; font-weight: 600; color: var(--brand); }

/* ---- inline line-icons (our own SVG set, no emoji) ---- */
.icon { display: inline-block; vertical-align: -0.15em; flex: none; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.9rem; height: 1.9rem; padding: 0; border-radius: 7px; font-size: .95rem;
    background: none; border: 1px solid transparent; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 40%, transparent);
    background: color-mix(in srgb, var(--danger) 8%, transparent);
}

/* ============================ Originality checker ============================ */
/* Overlap bands: b-pred = high (danger) · b-typ = notable (warn) · b-some = some (notice) · b-var = little (good) */
.orig-inputs { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.orig-doc { padding: 1rem 1.15rem; }
.orig-doc-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.orig-title {
    flex: 1 1 12rem; min-width: 8rem; font-weight: 600; font-size: .95rem;
    padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.orig-title:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.upload-btn.sm { padding: .35rem .6rem; font-size: .82rem; }
.orig-wc { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.orig-text {
    width: 100%; min-height: 8rem; resize: vertical; font-size: .96rem; line-height: 1.6;
    padding: .7rem .85rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.orig-text:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.orig-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.orig-actions .hint { margin: 0; }

.orig-results { display: flex; flex-direction: column; gap: 1.15rem; margin-top: 1rem; }
.orig-summary { display: flex; align-items: center; gap: 1.2rem; }
.orig-summary h2 { margin: 0 0 .25rem; font-size: 1.15rem; }
.orig-summary p { margin: 0; color: var(--text-muted); font-size: .92rem; line-height: 1.5; }
.orig-big {
    font-size: 2.4rem; font-weight: 800; line-height: 1; min-width: 4.2rem; text-align: center;
}
.orig-summary.b-pred .orig-big { color: var(--danger); }
.orig-summary.b-typ  .orig-big { color: var(--warn); }
.orig-summary.b-some .orig-big { color: var(--notice); }
.orig-summary.b-var  .orig-big { color: var(--good); }

.orig-pairs h3, .orig-detail h3 { margin: 0 0 .3rem; }
.orig-pair-list { display: flex; flex-direction: column; gap: .35rem; margin-top: .6rem; }
.orig-pair {
    display: grid; grid-template-columns: minmax(9rem, 1.4fr) 3fr auto; align-items: center; gap: .8rem;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
    padding: .5rem .75rem; cursor: pointer; text-align: left; width: 100%; font: inherit;
}
.orig-pair:hover { border-color: var(--brand); }
.orig-pair.sel { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.orig-pair-names { font-size: .88rem; font-weight: 600; }
.orig-pair-names .vs { color: var(--text-muted); font-weight: 400; margin: 0 .2rem; }
.orig-bar { height: 8px; border-radius: 5px; background: color-mix(in srgb, var(--text-muted) 20%, transparent); overflow: hidden; }
.orig-bar-fill { display: block; height: 100%; border-radius: 5px; }
.orig-bar-fill.b-pred { background: var(--danger); }
.orig-bar-fill.b-typ  { background: var(--warn); }
.orig-bar-fill.b-some { background: var(--notice); }
.orig-bar-fill.b-var  { background: var(--good); }
.orig-pair-pct { font-size: .9rem; font-weight: 700; min-width: 3rem; text-align: right; }
.orig-pair-pct.b-pred { color: var(--danger); }
.orig-pair-pct.b-typ  { color: var(--warn); }
.orig-pair-pct.b-some { color: var(--notice); }
.orig-pair-pct.b-var  { color: var(--good); }

.orig-detail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.orig-detail-head h3 .b-pred { color: var(--danger); }
.orig-detail-head h3 .b-typ  { color: var(--warn); }
.orig-detail-head h3 .b-some { color: var(--notice); }
.orig-detail-head h3 .b-var  { color: var(--good); }
.orig-stats { display: flex; gap: .9rem; font-size: .76rem; color: var(--text-muted); flex-wrap: wrap; }
.orig-side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; margin-top: .7rem; }
.orig-col h4 { margin: 0 0 .35rem; font-size: .88rem; color: var(--text-muted); }
.orig-body { max-height: 22rem; overflow-y: auto; font-size: .95rem; }
.orig-hl {
    background: color-mix(in srgb, var(--danger) 22%, transparent);
    box-shadow: inset 0 -2px 0 var(--danger); border-radius: 3px; padding: .02em .1em; color: inherit;
}
.orig-passages-h { margin: 1rem 0 .4rem; }
.orig-passages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.orig-passages li { display: flex; gap: .6rem; align-items: baseline; font-size: .9rem; }
.orig-pass-len {
    flex: 0 0 auto; font-size: .72rem; font-weight: 700; color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent); border-radius: 6px; padding: .1rem .4rem;
}
.orig-passages q { color: var(--text); line-height: 1.5; }
.orig-disclaimer {
    font-size: .82rem; color: var(--text-muted); line-height: 1.55; margin: 0;
    border-left: 3px solid color-mix(in srgb, var(--notice) 60%, transparent); padding: .3rem 0 .3rem .8rem;
}

/* ---- Phase B: paraphrase check ---- */
.orig-para { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.orig-para-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.orig-para-head h4 { margin: 0; display: flex; align-items: center; gap: .4rem; }
.orig-beta {
    font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent);
    border-radius: 6px; padding: .1rem .4rem;
}
button.ghost.sm { padding: .35rem .7rem; font-size: .82rem; }
.orig-para-status { font-size: .9rem; color: var(--text-muted); margin: .5rem 0 0; }
.orig-para-status.err { color: var(--warn); }
.orig-para-list { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.orig-para-list li { display: flex; gap: .7rem; align-items: flex-start; }
.orig-sim {
    flex: 0 0 auto; font-size: .78rem; font-weight: 700; color: var(--brand);
    background: color-mix(in srgb, var(--brand) 12%, transparent); border-radius: 6px; padding: .15rem .45rem; margin-top: .1rem;
}
.orig-para-texts { display: flex; flex-direction: column; gap: .15rem; font-size: .9rem; line-height: 1.45; }
.orig-para-texts .pa { color: var(--text); }
.orig-para-texts .pb { color: var(--text-muted); }
.orig-para-texts q::before, .orig-para-texts q::after { opacity: .5; }

/* ---- Phase C: cohort overlap matrix (heatmap) ---- */
.orig-matrix-scroll { overflow-x: auto; padding-bottom: .3rem; }
.orig-matrix { display: grid; gap: 3px; min-width: max-content; margin-top: .6rem; }
.orig-mx-corner { }
.orig-mx-head, .orig-mx-rowhead {
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 700; color: var(--text-muted); min-height: 1.7rem;
}
.orig-mx-cell {
    aspect-ratio: 1 / 1; min-width: 1.7rem; border: 1px solid var(--border); border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: .66rem; font-weight: 700; color: var(--text); padding: 0;
}
.orig-mx-cell.self { background: var(--surface-2); border-style: dashed; opacity: .5; }
.orig-mx-cell.hot { cursor: pointer; }
.orig-mx-cell.hot:hover { outline: 2px solid var(--brand); outline-offset: -1px; }
.orig-legend {
    list-style: none; margin: .8rem 0 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .2rem .8rem;
    font-size: .82rem; color: var(--text-muted);
}
.orig-legend-n {
    display: inline-flex; align-items: center; justify-content: center; width: 1.3rem; height: 1.3rem;
    border-radius: 4px; background: var(--surface-2); font-weight: 700; font-size: .7rem; margin-right: .4rem; color: var(--text);
}
.orig-hidden-note { margin: .6rem 0 0; }

/* ---- Phase D: web spot-check ---- */
.orig-webbtn { display: inline-flex; align-items: center; gap: .25rem; font-size: .82rem; white-space: nowrap; }
.orig-webbtn:disabled { opacity: .45; cursor: default; }
.orig-web {
    margin-top: .7rem; padding: .8rem .9rem; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border);
}
.orig-web .hint { margin: 0 0 .6rem; }
.orig-web-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.orig-web-list li {
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem;
    padding-bottom: .5rem; border-bottom: 1px solid var(--border);
}
.orig-web-list li:last-child { border-bottom: none; padding-bottom: 0; }
.orig-web-list q { flex: 1 1 16rem; font-size: .9rem; color: var(--text); line-height: 1.4; }
.orig-web-links { display: inline-flex; gap: .5rem; flex: 0 0 auto; }
.orig-web-links a {
    font-size: .78rem; font-weight: 600; text-decoration: none;
    color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent); border-radius: 6px; padding: .12rem .5rem;
}
.orig-web-links a:hover { background: color-mix(in srgb, var(--brand) 18%, transparent); }

/* ---- Phase D+: optional automatic web search ---- */
.orig-web-auto { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: .6rem; }
.orig-auto-badge {
    display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700;
    color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--good) 30%, transparent); border-radius: 6px; padding: .12rem .5rem;
}
.orig-web-hits { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.orig-web-hits:last-of-type { border-bottom: none; }
.orig-web-q { display: block; font-size: .88rem; color: var(--text); margin-bottom: .35rem; }
.orig-hitlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.orig-hitlist li { display: flex; flex-direction: column; gap: .1rem; }
.orig-hitlist a { font-size: .88rem; font-weight: 600; }
.orig-verbatim {
    align-self: flex-start; font-size: .68rem; font-weight: 700; color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent); border-radius: 5px; padding: .05rem .35rem;
}
.orig-hit-snip { font-size: .8rem; color: var(--text-muted); line-height: 1.4; }
.empty.sm { font-size: .82rem; }
.orig-manual-h { margin: .7rem 0 .3rem; font-weight: 600; }

@media (max-width: 640px) {
    .orig-pair { grid-template-columns: 1fr auto; }
    .orig-pair .orig-bar { grid-column: 1 / -1; order: 3; }
    .orig-side-by-side { grid-template-columns: 1fr; }
}

/* ── InfoDrawer (reusable slide-in explanation panel) ──────────────────────── */
.explain-trigger {
    display: inline-flex; align-items: center; gap: .3rem;
    margin-left: .5rem; padding: .1rem .25rem;
    background: none; border: none; cursor: pointer;
    color: var(--brand); font: inherit; font-size: .82rem; font-weight: 600;
    border-bottom: 1px solid transparent;
}
.explain-trigger:hover { border-bottom-color: currentColor; }
.explain-trigger svg { width: .9em; height: .9em; }

.drawer-backdrop {
    position: fixed; inset: 0; z-index: 1200;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(2px);
    animation: drawer-fade .18s ease-out;
}
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 1201;
    width: min(440px, 92vw);
    background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, .18);
    display: flex; flex-direction: column;
    animation: drawer-in .22s cubic-bezier(.2, .8, .2, 1);
    overflow: hidden;
}
@keyframes drawer-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) {
    .drawer, .drawer-backdrop { animation: none; }
}

.drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.drawer-title {
    display: flex; align-items: center; gap: .5rem;
    margin: 0; font-size: 1.05rem; line-height: 1.2;
}
.drawer-title svg { width: 1.1em; height: 1.1em; color: var(--brand); }
.drawer-body { padding: 1.1rem; overflow-y: auto; }

.explain-lead { margin: 0 0 1.1rem; color: var(--text); font-size: .92rem; line-height: 1.55; }

.explain-case {
    border: 1px solid var(--border); border-radius: 12px;
    padding: .85rem .95rem; margin-bottom: .9rem; background: var(--surface-2);
}
.explain-h { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .5rem; }
.explain-h h3 { margin: 0; font-size: 1rem; }
.explain-badge {
    align-self: flex-start;
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .15rem .5rem; border-radius: 999px;
    font-size: .72rem; font-weight: 700; letter-spacing: .01em;
    border: 1px solid transparent;
}
.explain-badge svg { width: .9em; height: .9em; }
.explain-badge.good   { color: var(--good);   background: color-mix(in srgb, var(--good) 14%, transparent);   border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.explain-badge.notice { color: var(--notice); background: color-mix(in srgb, var(--notice) 16%, transparent); border-color: color-mix(in srgb, var(--notice) 38%, transparent); }
.explain-badge.muted  { color: var(--text-muted); background: var(--surface); border-color: var(--border); }

.explain-case p { margin: .4rem 0; font-size: .88rem; line-height: 1.5; color: var(--text); }
.explain-list { margin: .5rem 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .35rem; }
.explain-list li { font-size: .86rem; line-height: 1.45; color: var(--text); }
.explain-fit { color: var(--text-muted); }
.explain-note {
    display: flex; align-items: flex-start; gap: .4rem;
    margin-top: .6rem; padding: .5rem .6rem; border-radius: 9px;
    background: color-mix(in srgb, var(--notice) 12%, transparent);
    color: var(--text); font-size: .84rem;
}
.explain-note svg { width: 1em; height: 1em; flex: 0 0 auto; margin-top: .15rem; color: var(--notice); }

.explain-bottom {
    display: flex; align-items: flex-start; gap: .45rem;
    margin: 1rem 0 0; padding-top: .9rem; border-top: 1px solid var(--border);
    font-size: .9rem; line-height: 1.5; color: var(--text);
}
.explain-bottom svg { width: 1.1em; height: 1.1em; flex: 0 0 auto; margin-top: .15rem; color: var(--good); }

/* ── Folder scan (desktop only) ─────────────────────────────────────────────
   A results table rather than the single-document layout: the question here is
   "which of these two hundred do I need to look at", so the answer has to be
   scannable at a glance and sorted worst-first. */
.batch-controls .row { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; }
.batch-controls label.inline { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; }

.batch-summary { display: flex; gap: 1.2rem; margin-bottom: .8rem; font-size: .88rem; }
.batch-summary .warn { color: var(--warn); }

.batch-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.batch-table th, .batch-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; }
.batch-table th { font-weight: 600; color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; }
.batch-table th.num, .batch-table td.num { text-align: right; white-space: nowrap; }
/* Long file names must not push the numbers off screen; the full path is in the title. */
.batch-table td.file { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-table td.note { color: var(--text-muted); font-size: .82rem; }
.batch-table tr.row-error td.file { color: var(--text-muted); }
.batch-table td .muted { color: var(--text-muted); }

.score-pill { display: inline-block; min-width: 2.4rem; padding: .1rem .45rem; border-radius: 999px;
              font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
.score-pill.high   { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.score-pill.medium { background: color-mix(in srgb, var(--warn) 18%, transparent);   color: var(--warn); }
.score-pill.low    { background: color-mix(in srgb, var(--ok) 16%, transparent);     color: var(--ok); }
.score-pill.unmeasured { background: var(--surface-2); color: var(--text-muted); }

/* One-time model download (desktop). The bar only appears once a total is known; when the server
   sends no Content-Length the megabytes counter carries the message on its own. */
.ppl-progress { margin-top: .6rem; }
.ppl-bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.ppl-bar > span { display: block; height: 100%; background: var(--accent, #2563eb); transition: width .25s ease; }

/* ---- Windows app download (/download) ----
   Deliberately shares the visual language of the front-door task cards: somebody who learned to
   read those four cards reads these four the same way. */
.dl-h2 { font-size: 1.02rem; margin: 0 0 .35rem; }
.dl-h2 svg { vertical-align: -2px; }

/* The call to action. A link, not a button, because it is a download and the browser should be
   allowed to say so — right-click, copy address, resume, all of it. */
.dl-cta {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "icon main" "icon sub";
    column-gap: .8rem;
    align-items: center;
    padding: .9rem 1.2rem;
    background: var(--brand);
    color: var(--brand-ink);
    border-radius: var(--radius);
    text-decoration: none;
    transition: filter .15s, transform .15s;
}
.dl-cta:hover, .dl-cta:focus-visible { filter: brightness(1.08); transform: translateY(-1px); }
.dl-cta svg { grid-area: icon; width: 26px; height: 26px; }
.dl-cta-main { grid-area: main; font-weight: 700; font-size: 1.02rem; }
.dl-cta-sub { grid-area: sub; font-size: .78rem; opacity: .85; }
.dl-get .hint.sub { margin: .6rem 0 0; }

.dl-running-line { margin: 0 0 .3rem; font-size: 1rem; }
.dl-running-line svg { vertical-align: -3px; color: var(--good); margin-right: .3rem; }

.dl-grid {
    list-style: none;
    margin: .9rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: .7rem;
}
.dl-item {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .85rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.dl-item h3 { margin: 0; font-size: .96rem; font-weight: 650; line-height: 1.3; }
.dl-item p { margin: 0; font-size: .84rem; color: var(--text-muted); line-height: 1.45; }
/* What the browser does instead. Pushed to the bottom so the four line up however long the
   description above happens to be. */
.dl-item .dl-vs {
    margin-top: auto;
    padding-top: .45rem;
    border-top: 1px dashed var(--border);
    font-size: .78rem;
}

/* Said before the download, not after it. Bordered like a notice rather than an error: the
   warning is correct, and the page is explaining it rather than apologising for it. */
.dl-warn { border-color: color-mix(in srgb, var(--notice) 45%, var(--border)); }
.dl-warn .dl-h2 svg { color: var(--notice); }
.dl-steps { margin: .6rem 0 .8rem; padding-left: 1.2rem; font-size: .88rem; line-height: 1.6; }
.dl-steps li { margin-bottom: .2rem; }
.dl-steps code { font-size: .84em; }

/* The before/after pair of the rewriter, and the folder-scan pill, share the refusal colour. */
.sc-num.unmeasured { color: var(--text-muted); }

/* ---- new-version strip (desktop host only) ----
   Quiet on purpose. It is about the app, not about the document on the page, and a downloaded tool
   that shouts about itself over somebody's essay has misjudged whose afternoon it is. */
.update-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .6rem 1rem;
    margin: 0 0 1rem;
    padding: .6rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: .88rem;
}
.update-strip.found { border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
.update-strip strong { display: block; color: var(--text); }
.update-detail { color: var(--text-muted); font-size: .82rem; }
.update-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.update-actions .small { font-size: .82rem; padding: .3rem .7rem; }
.update-actions a.small { text-decoration: none; display: inline-flex; align-items: center; }
