/* ============================================================
   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; }

/* ---- 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); }
.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 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); }

/* ---- 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; }
.nav-links { display: flex; 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; } }

/* ---- 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; }

/* ---- 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); }
