:root {
    --bg: #f7f8fa;
    --white: #ffffff;

    --text: #20242a;
    --muted: #747b85;
    --border: #e5e7eb;

    --accent: #635bff;
    --accent-dark: #5148e5;
    --accent-light: #efeeff;

    --green: #16a36a;
    --green-light: #eaf8f1;

    --yellow: #d89200;
    --yellow-light: #fff7df;

    --red: #dc4c4c;
    --red-light: #fff0f0;

    --sidebar-width: 235px;
}


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


body {
    min-height: 100vh;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


/* SIDEBAR */

.sidebar {
    position: fixed;

    left: 0;
    top: 0;
    bottom: 0;

    width: var(--sidebar-width);

    background: white;

    border-right: 1px solid var(--border);

    padding: 24px 15px;

    display: flex;
    flex-direction: column;
}


.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 11px;
    filter: drop-shadow(0 4px 10px rgba(99, 91, 255, 0.18));
}


.brand-icon {
    width: 40px;
    height: 40px;

    border-radius: 11px;

    background: var(--accent-light);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 19px;
}


.brand h1 {
    font-size: 18px;
}


.brand span {
    color: var(--muted);

    font-size: 10px;
}


.nav {
    display: flex;
    flex-direction: column;

    gap: 5px;
}


.nav-item {
    width: 100%;

    border: none;

    background: transparent;

    color: #727983;

    padding: 11px 12px;

    border-radius: 8px;

    display: flex;
    align-items: center;

    gap: 12px;

    font-size: 13px;

    cursor: pointer;

    text-align: left;
}


.nav-item:hover {
    background: #f5f5f7;
}


.nav-item.active {
    background: var(--accent-light);

    color: var(--accent);

    font-weight: 600;
}


.sidebar-bottom {
    margin-top: auto;
}


.system-status {
    display: flex;
    align-items: center;

    gap: 10px;

    padding: 11px;

    background: #f8f9fa;

    border: 1px solid var(--border);

    border-radius: 9px;
}


.system-status strong {
    display: block;

    font-size: 11px;
}


.system-status small {
    display: block;

    margin-top: 2px;

    color: var(--muted);

    font-size: 9px;
}


.status-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: var(--green);

    box-shadow: 0 0 0 4px var(--green-light);
}


/* MAIN */

.main {
    margin-left: var(--sidebar-width);

    min-height: 100vh;

    padding: 0 42px 70px;
}


.topbar {
    height: 88px;

    max-width: 1080px;

    margin: auto;

    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: center;
    justify-content: space-between;
}


.eyebrow {
    color: #9298a0;

    font-size: 9px;

    font-weight: 700;

    letter-spacing: .13em;
}


.topbar h2 {
    margin-top: 4px;

    font-size: 20px;
}


.api-status {
    display: flex;
    align-items: center;

    gap: 7px;

    color: var(--muted);

    font-size: 10px;
}


/* PAGE */

.page {
    display: none;

    max-width: 1080px;

    margin: auto;

    padding-top: 38px;
}


.page.active {
    display: block;
}


/* HERO */

.hero {
    display: flex;

    justify-content: space-between;

    align-items: flex-start;

    margin-bottom: 25px;
}


.hero h3 {
    font-size: 25px;

    letter-spacing: -.025em;
}


.hero p {
    max-width: 650px;

    margin-top: 8px;

    color: var(--muted);

    font-size: 13px;

    line-height: 1.6;
}


.badge {
    padding: 8px 11px;

    background: white;

    border: 1px solid var(--border);

    border-radius: 20px;

    font-size: 10px;

    font-weight: 600;
}


/* CARD */

.card {
    background: white;

    border: 1px solid var(--border);

    border-radius: 11px;

    padding: 21px;
}


.card-header {
    margin-bottom: 16px;
}


.card-header h3 {
    font-size: 14px;
}


.card-header p {
    margin-top: 4px;

    color: var(--muted);

    font-size: 11px;
}


textarea {
    width: 100%;

    min-height: 145px;

    resize: vertical;

    padding: 14px;

    border: 1px solid var(--border);

    border-radius: 8px;

    background: #fcfcfd;

    color: var(--text);

    outline: none;

    font-family: inherit;

    font-size: 12px;

    line-height: 1.6;
}


textarea:focus {
    border-color: #aaa5ff;

    box-shadow: 0 0 0 3px rgba(99,91,255,.08);
}


textarea::placeholder {
    color: #a5aab1;
}


.input-footer {
    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-top: 11px;

    color: var(--muted);

    font-size: 10px;
}


/* BUTTONS */

.primary-button {
    border: none;

    background: var(--accent);

    color: white;

    border-radius: 7px;

    padding: 10px 15px;

    font-family: inherit;

    font-size: 11px;

    font-weight: 600;

    cursor: pointer;
}


.primary-button:hover {
    background: var(--accent-dark);
}


.primary-button:disabled {
    opacity: .6;

    cursor: wait;
}


.secondary-button {
    border: 1px solid var(--border);

    background: white;

    color: var(--muted);

    padding: 8px 12px;

    border-radius: 7px;

    cursor: pointer;
}


/* LOADING */

.loading {
    margin-top: 18px;

    background: white;

    border: 1px solid var(--border);

    border-radius: 10px;

    padding: 17px;

    display: flex;

    align-items: center;

    gap: 13px;
}


.spinner {
    width: 22px;
    height: 22px;

    border: 2px solid #e5e5f8;

    border-top-color: var(--accent);

    border-radius: 50%;

    animation: spin .8s linear infinite;
}


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


.loading strong {
    display: block;

    font-size: 12px;
}


.loading span {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 10px;
}


/* ERROR */

.error {
    margin-top: 14px;

    padding: 11px 13px;

    background: var(--red-light);

    border: 1px solid #f1caca;

    border-radius: 7px;

    color: #9b4141;

    font-size: 11px;
}


/* SECTION */

.section-header {
    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-top: 38px;

    margin-bottom: 15px;
}


.section-header h3 {
    margin-top: 4px;

    font-size: 17px;
}


/* SUMMARY */

.summary {
    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 11px;

    margin-bottom: 20px;
}


.summary-card {
    display: flex;

    align-items: center;

    gap: 12px;

    background: white;

    border: 1px solid var(--border);

    border-radius: 9px;

    padding: 14px;
}


.summary-icon {
    width: 31px;
    height: 31px;

    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: 700;
}


.verified .summary-icon {
    background: var(--green-light);

    color: var(--green);
}


.weak .summary-icon {
    background: var(--yellow-light);

    color: var(--yellow);
}


.not-found .summary-icon {
    background: var(--red-light);

    color: var(--red);
}


.summary-card span {
    display: block;

    color: var(--muted);

    font-size: 10px;
}


.summary-card strong {
    display: block;

    margin-top: 2px;

    font-size: 20px;
}


/* RESULTS */

.results-card {
    background: white;

    border: 1px solid var(--border);

    border-radius: 11px;

    overflow: hidden;
}


.results-header {
    padding: 17px 19px;

    border-bottom: 1px solid var(--border);

    display: flex;

    justify-content: space-between;

    align-items: center;
}


.results-header h3 {
    font-size: 14px;
}


.results-header p {
    margin-top: 4px;

    color: var(--muted);

    font-size: 10px;
}


.results-header > span {
    padding: 5px 8px;

    background: #f4f5f7;

    border-radius: 5px;

    color: var(--muted);

    font-size: 9px;
}


/* CITATION */

.citation {
    display: flex;

    gap: 14px;

    padding: 19px;

    border-bottom: 1px solid var(--border);
}


.citation:last-child {
    border-bottom: none;
}


.result-icon {
    width: 31px;
    height: 31px;

    flex-shrink: 0;

    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: 700;
}


.result-icon.verified {
    background: var(--green-light);

    color: var(--green);
}


.result-icon.weak {
    background: var(--yellow-light);

    color: var(--yellow);
}


.result-icon.not-found {
    background: var(--red-light);

    color: var(--red);
}


.citation-body {
    flex: 1;
}


.trust-label {
    display: inline-block;

    margin-bottom: 6px;

    padding: 4px 6px;

    border-radius: 4px;

    font-size: 8px;

    font-weight: 800;
}


.trust-label.verified {
    background: var(--green-light);

    color: var(--green);
}


.trust-label.weak {
    background: var(--yellow-light);

    color: var(--yellow);
}


.trust-label.not-found {
    background: var(--red-light);

    color: var(--red);
}


.citation-title {
    font-size: 13px;

    font-weight: 600;

    line-height: 1.45;
}


.citation-meta {
    margin-top: 5px;

    color: var(--muted);

    font-size: 10px;
}


.tags {
    display: flex;

    flex-wrap: wrap;

    gap: 6px;

    margin-top: 12px;
}


.tag {
    padding: 4px 7px;

    background: #f7f8fa;

    border: 1px solid #eceef1;

    border-radius: 4px;

    color: #6e747d;

    font-size: 9px;
}


.explanation {
    margin-top: 11px;

    padding: 10px 11px;

    background: var(--yellow-light);

    border: 1px solid #f0dfac;

    border-radius: 7px;

    color: #7c6119;

    font-size: 10px;

    line-height: 1.55;
}


.explanation.danger {
    background: var(--red-light);

    border-color: #f0caca;

    color: #934141;
}


/* SOURCE */

.source-card {
    background: white;

    border: 1px solid var(--border);

    border-radius: 10px;

    padding: 18px;

    margin-bottom: 10px;
}


.source-title {
    font-size: 14px;

    font-weight: 600;

    line-height: 1.45;
}


.source-meta {
    margin-top: 6px;

    color: var(--muted);

    font-size: 10px;

    line-height: 1.5;
}


.source-link {
    display: inline-block;

    margin-top: 12px;

    color: var(--accent);

    font-size: 10px;

    font-weight: 600;

    text-decoration: none;
}


/* UTILITY */

.hidden {
    display: none !important;
}


.empty {
    padding: 40px;

    text-align: center;

    color: var(--muted);

    font-size: 11px;
}


/* RESPONSIVE */

@media (max-width: 850px) {

    :root {
        --sidebar-width: 190px;
    }

    .main {
        padding: 0 24px 50px;
    }

    .summary {
        grid-template-columns: 1fr;
    }

}


@media (max-width: 650px) {

    .sidebar {
        position: static;

        width: 100%;

        border-right: none;

        border-bottom: 1px solid var(--border);
    }

    .sidebar-bottom {
        display: none;
    }

    .main {
        margin-left: 0;

        padding: 0 15px 40px;
    }

    .hero {
        flex-direction: column;

        gap: 15px;
    }

}

/* ================================
   POLISH / MICRO INTERACTIONS
   ================================ */

.sidebar {
    box-shadow: 4px 0 18px rgba(20, 24, 40, 0.025);
}

.brand-logo {
    transition: transform 0.2s ease, filter 0.2s ease;
}

.brand:hover .brand-logo {
    transform: translateY(-1px);
    filter: drop-shadow(0 6px 14px rgba(99, 91, 255, 0.24));
}


/* NAV */

.nav {
    margin-top: 32px;
}

.nav-item {
    transition:
        background 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.nav-item:hover {
    transform: translateX(2px);
}

.nav-item.active {
    box-shadow: inset 3px 0 0 var(--accent);
}


/* TOPBAR */

.topbar {
    position: relative;
}

.api-status {
    padding: 7px 10px;

    background: rgba(255, 255, 255, 0.8);

    border: 1px solid var(--border);

    border-radius: 999px;
}


/* HERO */

.hero h3 {
    letter-spacing: -0.035em;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    color: #5f5a9f;

    box-shadow: 0 2px 8px rgba(30, 35, 60, 0.035);

    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.badge:hover {
    transform: translateY(-1px);

    box-shadow: 0 5px 14px rgba(30, 35, 60, 0.07);
}


/* CARDS */

.card,
.results-card,
.source-card,
.summary-card {
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.card:hover,
.results-card:hover {
    border-color: #dcdde4;

    box-shadow: 0 8px 28px rgba(25, 30, 45, 0.035);
}


/* TEXTAREA */

textarea {
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

textarea:hover {
    border-color: #d5d7df;
}

textarea:focus {
    background: #ffffff;
}


/* BUTTONS */

.primary-button,
.secondary-button {
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.12s ease,
        box-shadow 0.18s ease;
}

.primary-button:hover {
    transform: translateY(-1px);

    box-shadow: 0 5px 14px rgba(99, 91, 255, 0.2);
}

.primary-button:active,
.secondary-button:active {
    transform: translateY(0);
}

.secondary-button:hover {
    border-color: #cfd2da;

    background: #fafafa;
}


/* SUMMARY CARDS */

.summary-card:hover {
    transform: translateY(-2px);

    box-shadow: 0 7px 18px rgba(25, 30, 45, 0.045);
}


/* RESULTS */

.citation {
    transition: background 0.18s ease;
}

.citation:hover {
    background: #fcfcfd;
}

.source-card:hover {
    transform: translateY(-1px);

    box-shadow: 0 6px 18px rgba(25, 30, 45, 0.045);
}

.source-link:hover {
    text-decoration: underline;
}


/* STATUS */

.status-dot {
    animation: statusPulse 2.2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%,
    100% {
        box-shadow: 0 0 0 4px var(--green-light);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(22, 163, 106, 0.08);
    }
}


/* BETTER MOBILE */

@media (max-width: 650px) {

    .topbar {
        height: auto;

        padding: 22px 0;

        gap: 12px;

        align-items: flex-start;
    }

    .topbar h2 {
        font-size: 18px;
    }

    .api-status {
        font-size: 9px;
    }

    .page {
        padding-top: 25px;
    }

    .hero h3 {
        font-size: 22px;
    }

    .card {
        padding: 16px;
    }

    .input-footer {
        align-items: flex-end;

        gap: 10px;
    }

    .primary-button {
        white-space: nowrap;
    }

}


/* REDUCED MOTION */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

}

.hero-flow {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.hero-flow span:not(:nth-child(even)) {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.hero-flow span:nth-child(even) {
    color: var(--text-muted);
}

/* ================================
   RECEIPTS BACKEND RESULTS
   (paste at the end of styles.css)
   ================================ */

/* "Can't check" had no colors */
.result-icon.cant-check,
.trust-label.cant-check {
    background: #f1f2f4;
    color: #6b7280;
}

/* Server offline dot */
.status-dot.offline {
    background: var(--red);
    box-shadow: 0 0 0 4px var(--red-light);
    animation: none;
}

/* Audit: list of problems */
.issues {
    list-style: disc;
    padding-left: 26px;
}

.issues li + li {
    margin-top: 3px;
}

/* Audit: the real paper it matched */
.match-line {
    margin-top: 10px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.6;
}

.match-line .source-link {
    margin-top: 0;
    margin-left: 6px;
}

/* Corrected / ready-made citation with a Copy button */
.cite-box {
    margin-top: 11px;
    padding: 10px 11px;
    background: #f7f8fa;
    border: 1px solid var(--border);
    border-radius: 7px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.cite-box > div {
    min-width: 0;
}

.cite-heading {
    color: #9298a0;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.cite-text {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.copy-button {
    flex-shrink: 0;
    font-family: inherit;
    font-size: 10px;
    padding: 5px 10px;
}

/* Find: the evidence quote from the abstract */
.evidence {
    margin-top: 11px;
    padding: 9px 12px;
    border-left: 3px solid var(--yellow);
    background: var(--yellow-light);
    border-radius: 0 7px 7px 0;
    font-size: 11.5px;
    font-style: italic;
    line-height: 1.55;
}

.evidence.verified {
    border-left-color: var(--green);
    background: var(--green-light);
}

.evidence.not-found {
    border-left-color: var(--red);
    background: var(--red-light);
}

.source-card .trust-label {
    margin-bottom: 8px;
}

/* Fix: these two variables didn't exist */
.hero-flow {
    color: var(--muted);
}

.hero-flow span:not(:nth-child(even)) {
    background: var(--white);
}

.hero-flow span:nth-child(even) {
    color: var(--muted);
}