/* =========================================================
   STATSSY CITATION VERIFIER — DESIGN SYSTEM
   Modelled on scholarly textual criticism: a reference list
   annotated the way a critical edition marks its apparatus —
   an obelus for doubtful text, a query for questioned text,
   a collation table for comparing witness against source.
   Deliberately not a SaaS status-dashboard.
   ========================================================= */

.st-cv {
    --st-green: #15A270;
    --st-green-dark: #087F5B;
    --st-ink: #102A2B;
    --st-muted: #5B6E70;
    --st-faint: #8A9B9C;
    --st-border: #DDE9E5;
    --st-surface: #FFFFFF;
    --st-bg: #F7FAF9;
    --st-warning: #9C6013;
    --st-danger: #A5372F;

    --st-sans: Barlow, Inter, Arial, sans-serif;
    --st-serif: "Source Serif Pro", Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
    --st-mono: "IBM Plex Mono", "SFMono-Regular", "Liberation Mono", Menlo, Consolas, monospace;

    max-width: 820px;
    margin: 40px auto;
    padding: 0 18px;
    font-family: var(--st-sans);
    color: var(--st-ink);
}

.st-cv * { box-sizing: border-box; }
.st-cv :focus-visible {
    outline: 2px solid var(--st-green);
    outline-offset: 2px;
}

/* ---------------------------------------------------------
   HEADER
   --------------------------------------------------------- */

.st-cv-header { margin-bottom: 22px; }

.st-cv-kicker {
    display: block;
    margin-bottom: 10px;
    color: var(--st-green-dark);
    font-family: var(--st-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
}

.st-cv-header h1,
.st-cv-header h2,
.st-cv-header h3,
.st-cv-header h4 {
    margin: 0 0 10px;
    font-family: var(--st-serif);
    font-size: clamp(24px, 3.6vw, 32px);
    line-height: 1.15;
    letter-spacing: -0.01em;
    font-weight: 600;
    color: var(--st-ink);
}

.st-cv-header p {
    margin: 0;
    max-width: 640px;
    color: var(--st-muted);
    font-size: 15px;
    line-height: 1.6;
}

/* ---------------------------------------------------------
   HOW IT WORKS
   --------------------------------------------------------- */

.st-cv-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin: 22px 0 28px;
    padding-top: 16px;
    border-top: 1px solid var(--st-border);
}

.st-cv-step { display: flex; flex-direction: column; gap: 4px; }

.st-cv-step-num {
    font-family: var(--st-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--st-green-dark);
    letter-spacing: .04em;
}

.st-cv-step strong {
    font-size: 13.5px;
    font-weight: 650;
    color: var(--st-ink);
}

.st-cv-step p {
    margin: 0;
    color: var(--st-muted);
    font-size: 12.5px;
    line-height: 1.55;
}

/* ---------------------------------------------------------
   INPUT SHELL — flat, hairline only, no drop shadow
   --------------------------------------------------------- */

.st-cv-input-shell {
    background: var(--st-surface);
    border: 1px solid var(--st-border);
    border-radius: 10px;
    padding: 18px;
}

.st-cv-input-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.st-cv-input-toolbar label {
    font-size: 12.5px;
    font-weight: 650;
    color: var(--st-ink);
}

.st-cv-input-actions { display: flex; gap: 16px; }

.st-cv-ghost-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--st-muted);
    font: 600 12px var(--st-sans);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color .15s ease, text-decoration-color .15s ease;
}

.st-cv-ghost-btn:hover {
    color: var(--st-green-dark);
    text-decoration-color: currentColor;
}

.st-cv textarea {
    display: block;
    width: 100%;
    min-height: 190px;
    resize: vertical;
    padding: 14px 15px;
    border: 1px solid #C9DAD5;
    border-radius: 8px;
    outline: none;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent, transparent 25px,
            rgba(16, 42, 43, .045) 26px
        ),
        #FBFDFC;
    background-attachment: local;
    color: var(--st-ink);
    font: 14px/26px var(--st-sans);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.st-cv textarea:focus {
    border-color: var(--st-green);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(21, 162, 112, .10);
}

.st-cv textarea::placeholder { color: #91A2A0; }

.st-cv-input-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 9px;
    padding: 0 2px;
}

#st-cv-count {
    color: var(--st-ink);
    font-family: var(--st-mono);
    font-size: 11.5px;
    font-weight: 600;
}

#st-cv-count.is-over { color: var(--st-danger); }

.st-cv-hint {
    color: var(--st-muted);
    font-size: 11.5px;
}

/* Collapsible line preview */

.st-cv-preview {
    margin-top: 10px;
    border: 1px solid var(--st-border);
    border-radius: 8px;
    background: #FBFDFC;
    overflow: hidden;
}

.st-cv-preview summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
    color: var(--st-muted);
    font-size: 11.5px;
    font-weight: 650;
    list-style: none;
}

.st-cv-preview summary::-webkit-details-marker { display: none; }
.st-cv-preview summary::after { content: "Show \25BE"; color: var(--st-green-dark); font-size: 11px; }
.st-cv-preview[open] summary::after { content: "Hide \25B4"; }

.st-cv-preview-list {
    display: grid;
    gap: 5px;
    max-height: 200px;
    overflow: auto;
    padding: 0 10px 10px;
}

.st-cv-preview-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 9px;
    border: 1px solid #E7EFEC;
    border-radius: 6px;
    background: #fff;
}

.st-cv-preview-number {
    flex: 0 0 auto;
    color: var(--st-faint);
    font-family: var(--st-mono);
    font-size: 11px;
    font-weight: 700;
    padding-top: 1px;
}

.st-cv-preview-text {
    min-width: 0;
    color: #425557;
    font-size: 12.5px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------
   VERIFY BUTTON + STATUS MESSAGE
   --------------------------------------------------------- */

.st-cv button#st-cv-btn {
    width: 100%;
    min-height: 46px;
    margin-top: 14px;
    padding: 12px 18px;
    border: 0;
    border-radius: 8px;
    background: var(--st-green);
    color: #fff;
    font: 650 14.5px var(--st-sans);
    letter-spacing: .01em;
    cursor: pointer;
    transition: background .2s ease;
}

.st-cv button#st-cv-btn:hover:not(:disabled) { background: var(--st-green-dark); }
.st-cv button#st-cv-btn:disabled { opacity: .75; cursor: wait; }

.st-cv-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid rgba(255,255,255,.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: st-cv-spin .7s linear infinite;
}

@keyframes st-cv-spin { to { transform: rotate(360deg); } }

#st-cv-msg {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 20px;
    margin: 12px 2px 0;
    color: var(--st-muted);
    font-size: 13px;
}

#st-cv-msg:empty { margin: 0; }

#st-cv-msg::before {
    content: "";
    display: none;
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

#st-cv-msg.is-loading::before { display: inline-block; background: var(--st-green); animation: st-cv-pulse 1s ease-in-out infinite; }
#st-cv-msg.is-error { color: var(--st-danger); }
#st-cv-msg.is-error::before { display: inline-block; background: var(--st-danger); }
#st-cv-msg.is-success { color: var(--st-green-dark); }
#st-cv-msg.is-success::before { display: inline-block; background: var(--st-green); }

@keyframes st-cv-pulse { 50% { opacity: .3; } }

/* ---------------------------------------------------------
   RESULTS HEADER — a sentence, not stat tiles
   --------------------------------------------------------- */

#st-cv-results { margin-top: 34px; }

.st-cv-eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--st-green-dark);
    font-family: var(--st-mono);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
}

.st-cv-results-head h4 {
    margin: 0 0 6px;
    font-family: var(--st-serif);
    font-size: 21px;
    line-height: 1.2;
    font-weight: 600;
    color: var(--st-ink);
}

.st-cv-results-summary {
    margin: 0;
    font-family: var(--st-serif);
    font-style: italic;
    color: var(--st-muted);
    font-size: 14px;
    line-height: 1.6;
}

/* Filters — plain text tabs, like a journal index, not pill buttons */

.st-cv-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 16px;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--st-border);
}

.st-cv-filter {
    padding: 0 0 3px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--st-faint);
    font: 600 12.5px var(--st-sans);
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease;
}

.st-cv-filter:hover { color: var(--st-ink); }

.st-cv-filter.is-active {
    color: var(--st-ink);
    border-bottom-color: var(--st-ink);
}

.st-cv-filter span {
    color: var(--st-faint);
    font-family: var(--st-mono);
    font-size: 11px;
    margin-left: 2px;
}

.st-cv-empty-filter {
    margin-top: 16px;
    padding: 22px;
    border: 1px dashed var(--st-border);
    border-radius: 8px;
    color: var(--st-muted);
    font-size: 13px;
    text-align: center;
}

/* ---------------------------------------------------------
   REFERENCE LIST — the ledger, reimagined as an annotated
   bibliography rather than a card stack
   --------------------------------------------------------- */

.st-cv-result-list {
    margin-top: 6px;
}

.st-cv-ref {
    border-bottom: 1px solid var(--st-border);
}

.st-cv-ref.st-cv-hidden { display: none; }

.st-cv-ref-summary {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 13px 4px;
    cursor: pointer;
    list-style: none;
}

.st-cv-ref-summary::-webkit-details-marker { display: none; }

.st-cv-ref-num {
    flex: 0 0 auto;
    color: var(--st-faint);
    font-family: var(--st-serif);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.st-cv-ref-text {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--st-ink);
    font-family: var(--st-serif);
    font-size: 13.5px;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.st-cv-ref-mark {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.st-cv-ref-mark .glyph {
    font-family: var(--st-serif);
    font-size: 14px;
}

.st-cv-ref-mark.verified { color: var(--st-green-dark); }
.st-cv-ref-mark.review { color: var(--st-warning); }
.st-cv-ref-mark.not-verified { color: var(--st-danger); }

.st-cv-ref-caret {
    flex: 0 0 auto;
    color: var(--st-faint);
    font-size: 10px;
    transition: transform .15s ease;
}

.st-cv-ref[open] .st-cv-ref-caret { transform: rotate(90deg); }

/* Expanded body */

.st-cv-ref-body {
    padding: 0 4px 18px 27px;
}

.st-cv-ref-note {
    margin: 0 0 12px;
    color: var(--st-muted);
    font-family: var(--st-serif);
    font-style: italic;
    font-size: 12.5px;
    line-height: 1.6;
}

.st-cv-ref-confidence {
    color: var(--st-faint);
    font-family: var(--st-mono);
    font-size: 10.5px;
}

/* Collation table — submitted vs. verified record, the classic
   textual-criticism device for comparing witness to source */

table.st-cv-collation {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 12px;
}

table.st-cv-collation caption {
    text-align: left;
    color: var(--st-faint);
    font-family: var(--st-mono);
    font-size: 9.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 6px;
}

table.st-cv-collation th {
    text-align: left;
    padding: 5px 10px 5px 0;
    color: var(--st-faint);
    font-size: 9.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--st-border);
}

table.st-cv-collation td {
    padding: 7px 10px 7px 0;
    border-bottom: 1px solid #ECF2F0;
    color: #425557;
    line-height: 1.45;
    vertical-align: top;
}

table.st-cv-collation td:first-child {
    width: 78px;
    color: var(--st-muted);
    font-weight: 650;
    white-space: nowrap;
}

table.st-cv-collation td.st-cv-state {
    width: 90px;
    white-space: nowrap;
    font-weight: 650;
}

table.st-cv-collation tr.is-match td.st-cv-state,
table.st-cv-collation tr.is-close td.st-cv-state { color: var(--st-green-dark); }
table.st-cv-collation tr.is-partial td.st-cv-state { color: var(--st-warning); }
table.st-cv-collation tr.is-mismatch td.st-cv-state { color: var(--st-danger); }

table.st-cv-collation tr:last-child td { border-bottom: none; }

/* Plain submitted-only list, used when no scholarly record was found */

.st-cv-submitted-list {
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
    font-size: 12px;
}

.st-cv-submitted-list li {
    display: flex;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px solid #ECF2F0;
}

.st-cv-submitted-list li:last-child { border-bottom: none; }

.st-cv-submitted-list span:first-child {
    flex: 0 0 78px;
    color: var(--st-faint);
    font-size: 9.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding-top: 2px;
}

.st-cv-submitted-list span:last-child {
    color: #425557;
    line-height: 1.5;
}

/* Source line */

.st-cv-source-line {
    color: var(--st-faint);
    font-size: 11.5px;
}

.st-cv-source-line a {
    color: var(--st-green-dark);
    font-weight: 650;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 2px;
    transition: text-decoration-color .15s ease;
}

.st-cv-source-line a:hover { text-decoration-color: currentColor; }

/* ---------------------------------------------------------
   DISCLAIMER
   --------------------------------------------------------- */

.st-cv-disclaimer {
    margin: 22px 2px 0;
    color: #7E8E8F;
    font-size: 11.5px;
    line-height: 1.6;
    font-style: italic;
}

/* ---------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------- */

@media (max-width: 760px) {
    .st-cv { margin: 25px auto; padding: 0 12px; }
    .st-cv-steps { grid-template-columns: 1fr; gap: 12px; }
    .st-cv-input-shell { padding: 14px; }
    .st-cv-ref-summary { flex-wrap: wrap; }
    .st-cv-ref-text { white-space: normal; flex-basis: 100%; order: 3; }
    .st-cv-ref-mark { order: 2; margin-left: auto; }
    table.st-cv-collation td:first-child { width: 60px; }
}

@media (max-width: 480px) {
    .st-cv-filters { gap: 12px; }
    table.st-cv-collation { font-size: 11px; }
}