:root {
    --primary-color: #3366cc;
    --text-color: #222;
    --bg-color: #f8f9fa;
    --sidebar-bg: #f3f3f3;
    --border-color: #a2a9b1;
    --link-color: #0645ad;
    --header-font: 'Merriweather', serif;
    --body-font: 'Open Sans', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--body-font);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

header {
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Search sits in the header on every page: with ~23,000 entities the listings
   alone are not a realistic way to reach a specific one. */
.site-search {
    display: flex;
    flex: 1 1 20rem;
    max-width: 30rem;
    gap: 0.4rem;
}

.site-search input {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    font-family: var(--body-font);
    font-size: 0.95rem;
}

.site-search button {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background: var(--sidebar-bg);
    font-family: var(--body-font);
    font-size: 0.95rem;
    cursor: pointer;
}

.site-search button:hover {
    background: #e8e8e8;
}

/* Available to screen readers, absent from the visual layout. The search input
   needs a label; the placeholder is not one. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Search mixes four entity types in one list, so each hit says which it is. */
.kind-badge {
    margin-left: 0.5rem;
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background: var(--sidebar-bg);
    color: #555;
    font-family: var(--body-font);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

header h1 {
    margin: 0;
    font-family: var(--header-font);
    font-size: 1.8rem;
}

header h1 a {
    color: black;
    text-decoration: none;
}

header p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.top-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1rem;
}

.main-container {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    min-height: 80vh;
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
}

.sidebar {
    width: 200px;
    background-color: var(--sidebar-bg);
    padding: 1rem;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar h3 {
    margin-top: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #555;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.5rem;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    margin-bottom: 0.5rem;
}

.content {
    flex-grow: 1;
    padding: 2rem;
}

h1, h2, h3, h4 {
    font-family: var(--header-font);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.5rem; margin-top: 1.5rem; }

.infobox {
    float: right;
    width: 300px;
    border: 1px solid var(--border-color);
    background-color: #f9f9f9;
    padding: 1rem;
    margin-left: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.infobox h3 {
    margin-top: 0;
    text-align: center;
    background-color: #e0e0e0;
    padding: 0.5rem;
    border: none;
}

.infobox-row {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.2rem;
}

.infobox-label {
    font-weight: bold;
    display: block;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

table.data-table th, table.data-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

table.data-table th {
    background-color: #f2f2f2;
}

table.data-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.list-item {
    border: 1px solid #ddd;
    padding: 1rem;
    border-radius: 4px;
}

.list-item h3 {
    margin-top: 0;
    border: none;
    font-size: 1.2rem;
}

footer {
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: #666;
}

/* A definition quoted from an openly licensed reference, with its attribution.
   The credit line is a licence obligation (MONDO, Uberon and NCIT are CC BY),
   not styling — it must stay legible. */
.sourced-definition {
    margin: 1.2rem 0;
    padding: 1rem 1.2rem;
    border-left: 3px solid #7a9cc6;
    background: #f7f9fc;
}
.sourced-definition p {
    margin: 0 0 0.6rem 0;
}
.attribution {
    font-size: 0.82rem;
    color: #5a5a5a;
}
.attribution a {
    color: #35618f;
}
.match-flag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border: 1px solid #c9a227;
    border-radius: 3px;
    background: #fdf6e3;
    color: #7a6216;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: help;
}

/* Outbound identifiers. medwiki stores the code and links to its authority;
   it does not reproduce the classification. */
.xref-list {
    list-style: none;
    padding: 0;
    margin: 0.8rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
}
.xref-list li {
    font-size: 0.88rem;
}
.xref-system {
    display: inline-block;
    min-width: 5.5rem;
    color: #666;
    font-variant: small-caps;
    letter-spacing: 0.04em;
}
.xref-code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.xref-source {
    color: #8a8a8a;
    font-size: 0.78rem;
}

/* Shown when an entry has no sourced descriptive content yet. Reads as a
   deliberate statement about provenance, not as a page that failed to load. */
.sourcing-note {
    margin: 1.5rem 0;
    padding: 0.9rem 1.1rem;
    border-left: 3px solid var(--border-color);
    background: #fafafa;
    color: #555;
    font-size: 0.92rem;
    font-style: italic;
}

/* Alternative names. Sits directly under the definition, where a reader who
   arrived knowing a different name for the condition will see it first. */
.synonyms {
    margin: 0.9rem 0 1.2rem;
    padding: 0.7rem 0.9rem;
    background: #fafafa;
    border-left: 3px solid var(--border-color);
    font-size: 0.93rem;
    line-height: 1.7;
}

.synonyms-label {
    font-weight: 600;
    margin-right: 0.3rem;
}

.synonyms-label::after {
    content: ":";
}

.synonym {
    font-style: italic;
}

.synonyms-source {
    color: #666;
    font-size: 0.86rem;
    white-space: nowrap;
}

/* Pointer to another organ record sharing a code. Styled as a navigation aid,
   not a warning: both records are legitimate and separately sourced. */
.siblings {
    margin: 0.9rem 0 1.2rem;
    padding: 0.7rem 0.9rem;
    background: #fafafa;
    border-left: 3px solid var(--border-color);
    font-size: 0.93rem;
    line-height: 1.6;
}

/* When this page has nothing but a definition, the pointer IS the useful
   content, so it gets the accent border rather than the muted one. */
.siblings-empty {
    border-left-color: var(--primary-color);
}

.siblings-label {
    font-weight: 600;
    margin-right: 0.3rem;
}

.siblings-label::after {
    content: ":";
}

.siblings-note {
    display: block;
    margin-top: 0.35rem;
    color: #666;
    font-size: 0.86rem;
}

/* Pagination. Rendered above and below the list so a reader who has scrolled
   a full page does not have to scroll back up to continue. */
.pager-summary {
    margin: 0.6rem 0;
    color: #555;
    font-size: 0.92rem;
}

.pager {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 1rem 0;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.pager a,
.pager span {
    padding: 0.3rem 0.6rem;
    border-radius: 2px;
}

.pager a {
    border: 1px solid var(--border-color);
    background: #fff;
    text-decoration: none;
}

.pager a:hover {
    background: var(--sidebar-bg);
    text-decoration: none;
}

.pager-numbers {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0;
}

.pager-current {
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
}

.pager-gap,
.pager-disabled {
    color: #999;
}

.pager-step {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    /* On a narrow screen the numbered jumps cost more width than they earn;
       Previous/Next and the summary line still carry the reader through. */
    .pager-numbers {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .infobox {
        float: none;
        width: 100%;
        margin-left: 0;
    }
}
