.page-shell,
.site-header__inner {
    width: min(var(--page-width), calc(100% - var(--space-4) * 2));
    margin-inline: auto;
}

.page-shell {
    padding-block: var(--space-6) var(--space-8);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.stack > * {
    margin-block: 0;
}

.cluster {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
}

.content-section {
    margin-block-start: var(--space-7);
}

.page-shell > article {
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.site-header {
    position: sticky;
    z-index: 10;
    top: 0;
    padding-block: 0; /* reset Pico's 1rem header padding */
    border-bottom: 1px solid var(--em-border);
    background: rgb(255 255 255 / 92%);
    backdrop-filter: blur(14px);
}

.site-header__inner {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-block: var(--space-3);
}

.site-header__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.75rem;
}

.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--em-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--em-text-muted);
    cursor: pointer;
    padding: 0;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    color: var(--em-primary);
    font-family: ui-serif, Georgia, "Times New Roman", serif;
    font-size: 2.35rem;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 0.95;
    text-decoration: none;
}

.site-brand__alpha {
    display: inline-block;
    font-style: italic;
    margin-inline-end: 0.04em;
}

.site-brand:hover {
    color: var(--em-primary-strong);
}

.site-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding-block: var(--space-2);
}

.site-nav a,
.site-nav__logout button {
    display: inline-flex;
    min-height: 2.25rem;
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    color: var(--em-text-muted);
    cursor: pointer;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 700;
    line-height: 1.1;
    text-decoration: none;
}

.site-nav__logout {
    margin: 0;
}

.site-nav a:hover,
.site-nav__logout button:hover {
    border-color: var(--em-border);
    background: var(--em-surface-subtle);
    color: var(--em-text);
}

.page-hero {
    display: grid;
    gap: var(--space-4);
    padding-block: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--em-border);
}

.page-hero h1 {
    font-size: var(--text-2xl);
    margin-block-end: var(--space-2);
}

.page-hero--compact h1 {
    max-width: 24ch;
}

.article-hero h1 {
    max-width: none;
}

.page-hero--search {
    grid-template-columns: minmax(0, 1fr);
}

.journal-hero h1 {
    max-width: none;
}

.info-panel,
.journal-card,
.link-panel {
    border: 1px solid var(--em-border);
    border-radius: var(--radius-md);
    background: var(--em-surface);
}

.info-panel {
    padding: var(--space-4);
    box-shadow: var(--em-shadow-panel);
}

.info-panel h2 {
    font-size: var(--text-xl);
}

.link-list p:last-child,
.info-panel p:last-child {
    margin-block-end: 0;
}

.journal-grid {
    align-items: stretch;
}

.journal-card,
.link-panel {
    position: relative;
    margin: 0;
    padding: var(--space-5);
    overflow: hidden;
    box-shadow: none;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        transform 160ms ease;
}

.journal-card::before,
.link-panel::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 0.25rem;
    background: var(--em-primary);
    opacity: 0.9;
}

.journal-card:hover,
.link-panel:hover {
    border-color: var(--em-border-strong);
    box-shadow: var(--em-shadow-card);
    transform: translateY(-1px);
}

.volume-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.journal-card h3,
.link-panel h3 {
    margin-block-end: var(--space-3);
}

.journal-card h3 a,
.link-panel h3 a {
    color: var(--em-text);
    text-decoration: none;
}

.journal-card h3 a:hover,
.link-panel h3 a:hover {
    color: var(--em-primary-strong);
    text-decoration: underline;
}

.tag {
    display: inline-flex;
    max-width: 100%;
    min-height: 1.8rem;
    align-items: center;
    overflow-wrap: anywhere;
    border: 1px solid var(--em-border);
    border-radius: var(--radius-pill);
    padding: var(--space-1) var(--space-3);
    background: var(--em-surface-subtle);
    color: var(--em-text-muted);
    font-size: var(--text-sm);
    font-weight: 700;
    line-height: 1.25;
    text-decoration: none;
}

.tag[href]:hover {
    border-color: var(--em-primary);
    background: var(--em-primary-soft);
    color: var(--em-primary-strong);
}

.tag--long {
    border-radius: var(--radius-sm);
}

.download-link,
.button {
    display: inline-flex;
    width: auto;
    min-height: 2.35rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--em-primary);
    border-radius: var(--radius-pill);
    padding: var(--space-2) var(--space-4);
    background: var(--em-surface);
    color: var(--em-primary-strong);
    font-size: var(--text-sm);
    font-weight: 800;
    line-height: 1.1;
    text-decoration: none;
}

button.button {
    cursor: pointer;
}

.download-link:hover,
.button:hover {
    border-color: var(--em-primary-strong);
    background: var(--em-primary-soft);
    color: var(--em-primary-strong);
}

.article-section {
    max-width: var(--measure);
}

.article-meta .tag:first-child,
.journal-meta .tag:first-child {
    border-color: var(--em-border-strong);
    background: var(--em-primary-soft);
    color: var(--em-primary-strong);
}

table.article-list {
    display: block;
    overflow: hidden;
    border: 1px solid var(--em-border);
    border-radius: var(--radius-md);
    background: var(--em-surface);
}

table.article-list thead {
    display: none;
}

table.article-list tbody,
table.article-list tr,
table.article-list td {
    display: block;
}

table.article-list tr {
    padding: var(--space-4);
    border-bottom: 1px solid var(--em-border);
}

table.article-list tr:last-child {
    border-bottom: 0;
}

table.article-list td {
    display: grid;
    grid-template-columns: minmax(5.5rem, 34%) minmax(0, 1fr);
    gap: var(--space-3);
    padding-block: var(--space-2);
    overflow-wrap: anywhere;
}

table.article-list td::before {
    content: attr(data-label);
    color: var(--em-text-muted);
    font-size: var(--text-sm);
    font-weight: 800;
}

table.article-list td[colspan] {
    display: block;
}

table.article-list td[colspan]::before {
    content: none;
}

.article-list--compact {
    display: grid;
    gap: var(--space-3);
}

.article-list__item {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    border: 1px solid var(--em-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--em-surface);
    box-shadow: none;
}

.article-list__main {
    display: grid;
    gap: var(--space-2);
    min-width: 0;
}

.article-list__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    color: var(--em-text-muted);
    font-size: var(--text-sm);
    font-weight: 700;
}

.article-list__actions {
    min-width: 0;
}

.article-list__empty {
    margin: 0;
    border: 1px solid var(--em-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--em-surface);
}

.article-list__authors,
.article-list__doi {
    color: var(--em-text-muted);
    font-size: var(--text-sm);
}

.article-list__doi {
    margin-block-start: var(--space-1);
    overflow-wrap: anywhere;
}

.article-title {
    display: inline-block;
    color: var(--em-text);
    font-weight: 800;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.article-title:hover {
    color: var(--em-primary-strong);
    text-decoration: underline;
}

.listing-summary {
    justify-content: space-between;
    margin-block-end: var(--space-4);
}

.listing-summary p {
    margin-block: 0;
}

.listing-summary__range {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
    margin-block-start: var(--space-5);
}

.pagination__status {
    margin: 0;
    color: var(--em-text-muted);
    font-size: var(--text-sm);
    font-weight: 800;
}

.pagination__link,
.pagination__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--em-border-strong);
    border-radius: var(--radius-pill);
    background: var(--em-surface);
    color: var(--em-primary-strong);
    font-size: var(--text-sm);
    font-weight: 800;
    text-decoration: none;
}

.pagination__link {
    min-height: 2.25rem;
    padding: var(--space-2) var(--space-4);
}

.pagination__arrow {
    width: 2rem;
    height: 2rem;
    line-height: 1;
}

.pagination__link:hover,
.pagination__arrow:hover {
    border-color: var(--em-primary);
    background: var(--em-primary-soft);
}

.pagination__link--disabled,
.pagination__arrow--disabled {
    color: var(--em-text-muted);
    opacity: 0.55;
}

.listing-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
    align-items: end;
    max-width: 46rem;
}

.article-search {
    display: grid;
    gap: var(--space-3);
    align-items: end;
    margin: 0;
    border: 1px solid var(--em-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--em-surface);
    box-shadow: var(--em-shadow-panel);
}

.article-search label {
    margin: 0;
}

.article-search label,
.listing-controls label,
.form-field label,
.form-check label,
.form-choice-list label {
    color: var(--em-text-muted);
    font-size: var(--text-sm);
    font-weight: 800;
}

.article-search input,
.article-search select,
.listing-controls input,
.listing-controls select,
.form-field input,
.form-field select {
    margin-block: 0;
}

.cms-body {
    max-width: var(--measure);
}

.cms-body > * + * {
    margin-block-start: var(--space-4);
}

.cms-body h1,
.cms-body h2,
.cms-body h3 {
    margin-block-start: var(--space-6);
}

.cms-body ul {
    padding-inline-start: 1.25rem;
}

.cms-body table {
    margin-block: var(--space-5);
    font-size: var(--text-sm);
}

.account-section {
    /* max-width: 38rem; */
}

.account-form {
    display: grid;
    gap: var(--space-4);
}

.form-field {
    display: grid;
    gap: var(--space-2);
}

.form-grid {
    display: grid;
    gap: var(--space-4);
}

.form-fieldset {
    display: grid;
    gap: var(--space-4);
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

.form-fieldset legend {
    margin-block-end: var(--space-3);
    color: var(--em-text);
    font-size: var(--text-lg);
    font-weight: 800;
}

.form-check {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-2);
    align-items: start;
}

.form-check input {
    margin-block-start: 0.35rem;
}

.form-choice-list {
    display: grid;
    gap: var(--space-2);
}

.form-choice-list input {
    margin-inline-end: var(--space-2);
}

.form-check ul,
.form-field ul:not(.file-list) {
    grid-column: 1 / -1;
    margin: 0;
    padding-inline-start: 1.15rem;
    color: var(--em-danger);
    font-size: var(--text-sm);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}

.account-message {
    max-width: 38rem;
}

.profile-section {
    max-width: 54rem;
}

@media (min-width: 44rem) {
    .page-shell,
    .site-header__inner {
        width: min(var(--page-width), calc(100% - var(--space-5) * 2));
    }

    .info-panel {
        padding: var(--space-5);
    }

    .site-header__inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-4);
        padding-block: 0;
        min-height: 4.5rem;
    }

    .site-brand {
        font-size: 2.65rem;
    }

    .nav-toggle {
        display: none;
    }

    .site-nav {
        display: flex !important;
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-2);
        padding-block: 0;
    }

    .content-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .listing-controls {
        grid-template-columns: minmax(0, 1fr) minmax(11rem, 0.35fr) auto;
    }

    .article-search {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .article-search .button {
        justify-self: start;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 62rem) {
    .page-shell {
        padding-block-start: var(--space-7);
    }

    .page-hero {
        gap: var(--space-5);
        padding-block: var(--space-4) var(--space-6);
        grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.38fr);
        align-items: end;
    }

    .page-hero h1 {
        font-size: var(--text-3xl);
    }

    .page-hero--compact {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-hero--search {
        grid-template-columns: minmax(0, 1fr);
    }

    .article-hero .stack,
    .article-hero .info-panel {
        grid-column: 1 / -1;
    }

    .page-hero--search .article-search {
        grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    }

    .content-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    table.article-list {
        display: table;
        table-layout: fixed;
        border-collapse: separate;
        border-spacing: 0;
        font-size: var(--text-sm);
    }

    table.article-list thead {
        display: table-header-group;
    }

    table.article-list tbody {
        display: table-row-group;
    }

    table.article-list tr {
        display: table-row;
        padding: 0;
        border-bottom: 0;
    }

    table.article-list th,
    table.article-list td {
        display: table-cell;
        border-bottom: 1px solid var(--em-border);
        padding: var(--space-3);
        vertical-align: top;
    }

    table.article-list th {
        background: var(--em-surface-subtle);
        color: var(--em-text-muted);
        font-size: 0.78rem;
        font-weight: 800;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    table.article-list td::before {
        content: none;
    }

    table.article-list th:first-child,
    table.article-list td:first-child {
        width: 10rem;
    }

    table.article-list th:last-child,
    table.article-list td:last-child {
        width: 13rem;
    }

    table.article-list--browse th:first-child,
    table.article-list--browse td:first-child {
        width: 9rem;
    }

    table.article-list--browse th:last-child,
    table.article-list--browse td:last-child {
        width: 13rem;
    }

    .article-list__item {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        padding: var(--space-5);
    }

    .article-list__meta {
        grid-column: 1;
    }

    .article-list__actions {
        grid-column: 2;
        grid-row: 1 / span 2;
        justify-self: end;
    }
}

[x-cloak] { display: none !important; }

.file-list {
    list-style: none;
    margin: var(--space-2) 0 0;
    padding: 0;
    border: 1px solid var(--em-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    grid-column: 1 / -1;
}

.file-list__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--em-border);
    font-size: var(--text-sm);
}

.file-list__item:last-child {
    border-bottom: none;
}

.file-list__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-list__size {
    flex-shrink: 0;
    color: var(--em-text-muted);
    font-size: var(--text-sm);
}

.file-list__remove {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    border-radius: 50%;
    padding: 0;
    background: transparent;
    color: var(--em-text-muted);
    cursor: pointer;
}

.file-list__remove:hover {
    background: #ffe4e6;
    color: var(--em-danger);
}
