:root {
    --brand: #02094b;
    --brand-soft: #eef0ff;
    --accent: #990000;
    --text: #1f2933;
    --muted: #5f6b7a;
    --border: #d8dee8;
    --bg: #f7f7fb;
    --panel: #ffffff;
    --max-width: 1440px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a {
    color: var(--brand);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

.site-header {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.site-header__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem clamp(1rem, 3vw, 2rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.site-brand__image {
    width: 88px;
    height: auto;
}

.site-brand__title {
    display: block;
    color: var(--brand);
    font-size: clamp(1.45rem, 2.5vw, 2.25rem);
    font-weight: 700;
    line-height: 1.1;
}

.site-brand__subtitle {
    display: block;
    color: var(--muted);
    margin-top: 0.25rem;
}

.partner-logos {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.dasg-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
}

.dasg-logo img {
    max-height: 144px;
    width: auto;
    flex-shrink: 0;
}

.dasg-text {
    width: 180px;
    color: var(--brand);
    font-weight: 400;
    line-height: 1.25;
    font-size: 0.95rem;
}

.dasg-text-left {
    text-align: right;
}

.dasg-text-right {
    text-align: left;
}

.partner-logos > a:last-child img {
    max-height: 144px;
    max-width: 400px;
    object-fit: contain;
}

@media (max-width: 900px) {

    .partner-logos {
        flex-direction: column;
        align-items: flex-start;
    }

    .dasg-logo {
        flex-direction: column;
        text-align: center;
    }

    .dasg-text,
    .dasg-text-left,
    .dasg-text-right {
        width: auto;
        text-align: center;
    }
}

.search-wrapper {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem clamp(1rem, 3vw, 2rem) 0;
}

.page-shell {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem clamp(1rem, 3vw, 2rem) 3rem;
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 1.5rem;
}

.site-nav {
    align-self: start;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: auto;
    background: var(--panel);
    background-color: #fff1ca;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    font-size: clamp(0.8rem, 0.8vw, 0.8rem);
}

.site-nav h2,
.site-nav h3,
.site-nav h4,
.site-nav .sites-embed-title {
    margin: 1rem 0 0.4rem;
    color: var(--brand);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.site-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav li {
    margin: 0.2rem 0;
}

.site-nav a,
.site-nav .current-bg {
    display: block;
    padding: 0.35rem 0.45rem;
    border-radius: 8px;
    text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus,
.site-nav .current-bg {
    background: var(--brand-soft);
}

.content-wrapper {
    min-width: 0;
}

.breadcrumbs {
    margin-bottom: 0.75rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.page-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: clamp(1rem, 3vw, 2rem);
    box-shadow: 0 10px 30px rgba(2, 9, 75, 0.06);
    min-width: 0;
}

.page-content h1 {
    margin-top: 0;
    color: var(--brand);
    line-height: 1.15;
}

.home-page-title,
.home-page-subtitle,
.home-page-content .home-centred {
    text-align: center;
}

.home-page-subtitle {
    margin-top: -0.4rem;
    margin-bottom: 2rem;
    color: var(--brand);
    font-weight: 500;
}

.view-toggle {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--brand-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--brand);
    font-weight: 600;
}

.column {
    margin-bottom: 2rem;
    min-width: 0;
}

.column > :first-child,
.column b:first-child {
    color: var(--accent);
}

#ms,
#restored-text,
#translation {
    font-family: "Times New Roman", Times, serif;
    font-size: 1.08rem;
    line-height: 1.65;
}

/* Side-by-side edition view */
body.side-by-side-active .site-nav {
    display: none;
}

body.side-by-side-active .page-shell {
    max-width: none;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    padding-left: 1rem;
    padding-right: 1rem;
}

body.side-by-side-active .search-wrapper,
body.side-by-side-active .site-header__inner {
    max-width: none;
}

body.side-by-side-active .content-wrapper,
body.side-by-side-active .page-content {
    max-width: none;
    width: 100%;
}

.poem-columns {
    display: block;
    width: 100%;
}

body.side-by-side-active .poem-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
    width: 100%;
    align-items: start;
}

body.side-by-side-active .poem-columns .column {
    min-width: 0;
    margin-bottom: 0;
    overflow-wrap: break-word;
}


/* Aligned stanza view generated by main.js.
   It is only shown in side-by-side mode; the standard reading view keeps the
   original three full columns exactly as before. */
.poem-aligned {
    display: none;
    width: 100%;
}

body.side-by-side-active .poem-columns.has-aligned-stanzas {
    display: block;
}

body.side-by-side-active .poem-columns.has-aligned-stanzas > .column {
    display: none;
}

body.side-by-side-active .poem-columns.has-aligned-stanzas .poem-aligned {
    display: block;
}

body.side-by-side-active .stanza-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: stretch;
    width: 100%;
    margin: 0 0 1.4rem;
}

body.side-by-side-active .stanza-cell {
    min-width: 0;
    overflow-wrap: break-word;
    font-family: "Times New Roman", Times, serif;
    font-size: 1.08rem;
    line-height: 1.65;
}

body.side-by-side-active .stanza-cell > :first-child {
    margin-top: 0;
}

body.side-by-side-active .stanza-cell > :last-child {
    margin-bottom: 0;
}

.pagefind-highlight {
    background: #fff2a8;
    padding: 0.05em 0.1em;
    border-radius: 0.2em;
}

@media (max-width: 1100px) {
    body.side-by-side-active .poem-columns {
        grid-template-columns: 1fr;
    }

    body.side-by-side-active .stanza-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    body.side-by-side-active .stanza-cell:not(:empty)::before {
        content: attr(data-column-label);
        display: block;
        margin: 0 0 0.25rem;
        color: var(--accent);
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        font-size: 0.78rem;
        font-weight: 700;
    }
}

@media (max-width: 900px) {
    .site-header__inner,
    .partner-logos {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-shell {
        grid-template-columns: 1fr;
    }

    .site-nav {
        position: static;
        max-height: none;
    }
}

.view-toggle {
    margin: 0 0 1.25rem;
    padding: 0;
    background: transparent;
    border: 0;
}

.view-toggle-button {
    display: inline-block;
    width: 100%;
    max-width: 200px;
    padding: .75rem 1rem;
    border: 1px solid var(--brand);
    border-radius: 14px;
    background: var(--brand);
    color: #ffffff;
    font: inherit;
    font-weight: 500;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
}

.view-toggle-button:hover,
.view-toggle-button:focus {
    background: #ffffff;
    color: var(--brand);
}

/* Variant quatrain bracket layout used in Poem XXIII.
   This preserves the original grouped-brace display after conversion. */
.variant {
    display: grid;
    grid-template-columns: 1.5em max-content 1em minmax(0, 1fr);
    align-items: center;
    column-gap: 0;
    margin: 1.5em 0;
    font-family: "Times New Roman", Times, serif;
    font-size: 1.1rem;
    line-height: 1.45;
}

.variant .num {
    align-self: start;
    margin-right: 0;
}

.variant .letter {
    align-self: center;
    text-align: right;
    white-space: nowrap;
    min-width: 2.5em;
}

.variant .brace {
    font-size: 2.6em;
    line-height: 0.55;
    transform: scaleX(0.7);
    white-space: nowrap;
}

.variant .lines {
    padding-left: 0.4em;
    line-height: 1.45;
    min-width: 0;
}

.variant .lines div {
    margin: 0;
}

