:root {
    --bg: #f4f1ea;
    --surface: #fffdfa;
    --surface-alt: #efe6d7;
    --text: #1e1a16;
    --muted: #665f57;
    --accent: #006a6a;
    --accent-soft: #cfe8e8;
    --border: #d9cfbf;
    --danger: #a53a2b;
    --success: #2f6b38;
    --shadow: 0 14px 40px rgba(30, 26, 22, 0.08);
    --highlight-green: #dff2d8;
    --highlight-yellow: #fff29a;
    --highlight-red: #ffd3cf;
    --highlight-neutral: #ece5d8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    background:
        radial-gradient(circle at top left, rgba(0, 106, 106, 0.08), transparent 28%),
        linear-gradient(180deg, #f8f4ed 0%, var(--bg) 100%);
    color: var(--text);
}

a {
    color: inherit;
}

.inline-link {
    color: var(--accent);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.16em;
}

.shell {
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(217, 207, 191, 0.8);
    background: rgba(255, 253, 250, 0.88);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.brand__title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand__meta,
.eyebrow,
.muted {
    color: var(--muted);
}

.nav {
    display: flex;
    gap: 0.75rem;
}

.nav a {
    text-decoration: none;
    padding: 0.6rem 0.95rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.nav a.is-active,
.nav a:hover {
    border-color: var(--border);
    background: var(--surface-alt);
}

.page {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.hero,
.panel,
.card,
.upload-form {
    background: rgba(255, 253, 250, 0.96);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.hero {
    padding: 2rem;
    display: grid;
    gap: 1rem;
}

.hero h1,
.panel h2,
.card h3,
.upload-form h2 {
    margin: 0;
}

.hero p {
    max-width: 56rem;
    line-height: 1.6;
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.8rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

.button--ghost {
    background: transparent;
    color: var(--accent);
}

.button--small {
    padding: 0.45rem 0.75rem;
    font-size: 0.95rem;
}

.button--inline {
    padding: 0.45rem 0.8rem;
    font-size: 0.92rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.review-meta-stack {
    grid-template-columns: 1fr;
}

.card {
    padding: 1.25rem;
}

.card dl {
    margin: 1rem 0 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 0.75rem;
}

.card dt {
    color: var(--muted);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
}

.status::before {
    content: "";
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: currentColor;
}

.status--ok {
    color: var(--success);
}

.status--warn,
.status--warning,
.status--reject {
    color: var(--danger);
}

.status--pass {
    color: var(--success);
}

.decision-banner {
    margin-top: 1rem;
    padding: 1.1rem 1.25rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    background: rgba(255, 253, 250, 0.98);
}

.decision-banner--pass {
    border-color: rgba(47, 107, 56, 0.35);
    background: rgba(47, 107, 56, 0.08);
}

.decision-banner--warning {
    border-color: rgba(139, 94, 26, 0.35);
    background: rgba(139, 94, 26, 0.08);
}

.decision-banner--reject {
    border-color: rgba(165, 58, 43, 0.35);
    background: rgba(165, 58, 43, 0.08);
}

.decision-banner__eyebrow {
    color: var(--muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.decision-banner__body {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.decision-banner__body h2,
.decision-banner__body p {
    margin: 0;
}

.panel {
    padding: 1.5rem;
    margin-top: 1rem;
}

.panel--preflight {
    scroll-margin-top: 5.5rem;
}

.two-up {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 1rem;
    margin-top: 1rem;
}

.checklist,
.upload-notes,
.upload-form ul {
    padding-left: 1.2rem;
    line-height: 1.65;
}

.upload-form {
    padding: 1.5rem;
}

.field {
    display: grid;
    gap: 0.45rem;
    margin-top: 1rem;
}

.field input[type="text"],
.field input[type="file"],
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.checkbox-field {
    align-items: start;
}

.checkbox-field label {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.flash {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
}

.flash--error {
    color: var(--danger);
    border-color: rgba(165, 58, 43, 0.35);
    background: rgba(165, 58, 43, 0.08);
}

.flash--success {
    color: var(--success);
    border-color: rgba(47, 107, 56, 0.35);
    background: rgba(47, 107, 56, 0.08);
}

.footer {
    padding: 0 0 2rem;
    text-align: center;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
    margin-top: 1rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 0.8rem 0.65rem;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--muted);
    font-weight: 700;
}

.parsed-table .table-cell-paragraph {
    margin: 0 0 0.45rem;
}

.parsed-table .table-cell-paragraph:last-child {
    margin-bottom: 0;
}

.table-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
    margin-top: 1rem;
}

.inline-form label {
    display: block;
    width: 100%;
    color: var(--muted);
}

.inline-form input[type="text"] {
    width: min(220px, 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.inline-form select {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.review-list {
    display: grid;
    gap: 0.9rem;
    margin-top: 1rem;
}

.profile-catalog {
    display: grid;
    gap: 0;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
}

.profile-row {
    display: grid;
    gap: 0.65rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.profile-row__summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
}

.profile-row__name,
.profile-row__key,
.profile-row__notes p {
    margin: 0;
}

.profile-row__name {
    font-weight: 700;
}

.profile-row__key {
    margin-top: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92rem;
}

.profile-row__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    align-items: center;
}

.review-block {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fffdfa;
    padding: 1rem 1.1rem;
}

.review-block--heading {
    border-left: 5px solid var(--accent);
}

.review-block--reference {
    border-left: 5px solid #9c7a2b;
}

.review-block--figure,
.review-block--table {
    border-left: 5px solid #8b5e1a;
}

.review-block--issue {
    border-left: 5px solid var(--danger);
}

.review-block:target {
    outline: 3px solid rgba(0, 106, 106, 0.28);
    outline-offset: 4px;
}

.review-block__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 0.7rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 700;
    text-transform: capitalize;
}

.review-block__content p {
    margin: 0;
    line-height: 1.6;
}

.figure-assets {
    display: grid;
    gap: 0.85rem;
    margin-top: 0.9rem;
}

.table-media-assets {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-alt);
}

.figure-asset {
    margin: 0;
}

.figure-asset img {
    display: block;
    max-width: min(100%, 760px);
    height: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.figure-asset figcaption {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.review-block--list .review-block__content ul {
    margin: 0;
    padding-left: 1.2rem;
}

.review-block--list-level-1 {
    margin-left: 1.25rem;
}

.review-block--list-level-2 {
    margin-left: 2.5rem;
}

.review-block--list-level-3,
.review-block--list-level-4,
.review-block--list-level-5 {
    margin-left: 3.75rem;
}

.metadata-table td {
    vertical-align: top;
}

.toc-list {
    display: grid;
    gap: 0.32rem;
    margin: 0.5rem 0 0;
    padding-left: 1.3rem;
    list-style: disc;
}

.toc-list__item {
    line-height: 1.4;
}

.toc-list__item--level-1 {
    margin-left: 1.25rem;
}

.toc-list__item--level-2 {
    margin-left: 2.5rem;
}

.toc-list__item--level-3,
.toc-list__item--level-4,
.toc-list__item--level-5 {
    margin-left: 3.75rem;
}

.review-block__content p + p {
    margin-top: 0.45rem;
}

.review-jump {
    margin-top: 0.75rem !important;
}

.review-block__content table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
    font-size: 0.95rem;
}

.review-block__content td,
.review-block__content th {
    border: 1px solid var(--border);
    padding: 0.55rem 0.65rem;
    vertical-align: top;
    text-align: left;
}

.review-block__content tr:first-child td,
.review-block__content tr:first-child th {
    background: var(--surface-alt);
    font-weight: 700;
}

.table-inline-media {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.55rem;
}

.table-inline-media__figure {
    margin: 0;
    display: grid;
    gap: 0.35rem;
}

.table-inline-media__image {
    max-width: min(100%, 320px);
    height: auto;
    display: block;
    border: 1px solid var(--border);
    background: #fff;
}

.review-columns {
    align-items: start;
}

.status-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-weight: 700;
    text-transform: capitalize;
    background: var(--surface-alt);
}

.status-tag--matched {
    color: var(--success);
    border-color: rgba(47, 107, 56, 0.35);
    background: rgba(47, 107, 56, 0.08);
}

.status-tag--candidate,
.status-tag--unmatched {
    color: var(--danger);
    border-color: rgba(165, 58, 43, 0.35);
    background: rgba(165, 58, 43, 0.08);
}

.status-tag--parsed {
    color: var(--success);
    border-color: rgba(47, 107, 56, 0.35);
    background: rgba(47, 107, 56, 0.08);
}

.status-tag--uploaded,
.status-tag--processing {
    color: #8b5e1a;
    border-color: rgba(139, 94, 26, 0.35);
    background: rgba(139, 94, 26, 0.08);
}

.status-tag--failed {
    color: var(--danger);
    border-color: rgba(165, 58, 43, 0.35);
    background: rgba(165, 58, 43, 0.08);
}

.status-tag--warning {
    color: #8b5e1a;
    border-color: rgba(139, 94, 26, 0.35);
    background: rgba(139, 94, 26, 0.08);
}

.status-tag--pass {
    color: var(--success);
    border-color: rgba(47, 107, 56, 0.35);
    background: rgba(47, 107, 56, 0.08);
}

.status-tag--validated {
    color: #6f5200;
    border-color: rgba(111, 82, 0, 0.28);
    background: var(--highlight-yellow);
}

.status-tag--probable {
    color: #8b5e1a;
    border-color: rgba(139, 94, 26, 0.35);
    background: rgba(139, 94, 26, 0.12);
}

.status-tag--reject,
.status-tag--blocking {
    color: var(--danger);
    border-color: rgba(165, 58, 43, 0.35);
    background: rgba(165, 58, 43, 0.08);
}

.status-tag--needs_review,
.status-tag--ambiguous,
.status-tag--not_found {
    color: var(--danger);
    border-color: rgba(165, 58, 43, 0.35);
    background: var(--highlight-red);
}

.status-tag--not_applicable {
    color: var(--muted);
    border-color: rgba(102, 95, 87, 0.24);
    background: var(--highlight-neutral);
}

.status-tag--pending {
    color: var(--muted);
    border-color: rgba(102, 95, 87, 0.24);
    background: rgba(102, 95, 87, 0.08);
}

.table-note-row td {
    padding-top: 0;
    font-size: 0.95rem;
}

.table-subnote {
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.citation-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.85rem;
}

.citation-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.citation-status-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fffdfa;
    padding: 1rem 1.1rem;
}

.citation-status-card h3,
.citation-status-card p {
    margin: 0;
}

.citation-status-card .summary-pills {
    margin-top: 0.75rem;
    justify-content: flex-start;
}

.citation-highlight {
    display: inline;
    padding: 0.05rem 0.18rem;
    border-radius: 0.22rem;
    text-decoration: none;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.citation-highlight--validated {
    background: var(--highlight-green);
}

.citation-highlight--needs-review {
    background: var(--highlight-yellow);
}

.citation-highlight--not-found {
    background: var(--highlight-red);
}

.citation-highlight--not-applicable {
    background: var(--highlight-green);
}

.collapsible-panel {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fffdfa;
    padding: 0.9rem 1rem 1rem;
}

.collapsible-panel summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    font-weight: 700;
    list-style: none;
}

.collapsible-panel summary::-webkit-details-marker {
    display: none;
}

.section-panel {
    padding: 0;
}

.section-panel > :not(summary) {
    margin-left: 1.25rem;
    margin-right: 1.25rem;
}

.section-panel > :last-child {
    margin-bottom: 1.25rem;
}

.section-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    cursor: pointer;
    list-style: none;
}

.section-summary::-webkit-details-marker {
    display: none;
}

.section-summary::after {
    content: "▾";
    color: var(--accent);
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

.section-panel:not([open]) .section-summary::after {
    transform: rotate(-90deg);
}

.section-summary__title {
    display: block;
    margin-top: 0.15rem;
    font-size: 1.45rem;
    font-weight: 700;
}

.summary-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.citation-compare-table td {
    vertical-align: top;
}

.citation-row--validated {
    background: rgba(255, 242, 154, 0.22);
}

.citation-row--needs_review,
.citation-row--not_found {
    background: rgba(255, 211, 207, 0.26);
}

.citation-row--not_applicable {
    background: rgba(236, 229, 216, 0.32);
}

.citation-row:target {
    outline: 3px solid rgba(0, 106, 106, 0.35);
    outline-offset: -3px;
}

.citation-compare-cell {
    display: grid;
    gap: 0.35rem;
}

.citation-compare-cell p {
    margin: 0;
}

.citation-inline-chip {
    display: inline-flex;
    width: fit-content;
    padding: 0.2rem 0.45rem;
    border-radius: 0.35rem;
    font-weight: 700;
}

.citation-inline-chip--validated {
    background: var(--highlight-yellow);
}

.citation-inline-chip--needs_review,
.citation-inline-chip--not_found {
    background: var(--highlight-red);
}

.citation-inline-chip--not_applicable {
    background: var(--highlight-neutral);
}

@media (max-width: 760px) {
    .topbar,
    .two-up {
        grid-template-columns: 1fr;
        display: grid;
    }

    .nav {
        flex-wrap: wrap;
    }

    .profile-row__summary {
        grid-template-columns: 1fr;
    }

    .profile-row__actions {
        justify-content: flex-start;
    }

    .collapsible-panel summary {
        align-items: start;
        flex-direction: column;
    }

    .summary-pills {
        justify-content: start;
    }
}
