:root {
    --base-font-size: 16px;
    --title-font-size: 24px;
    --tag-font-size: 12px;
    --bg: #f5f7fa;
    --card: #ffffff;
    --primary: #a02337;
    --primary-hover: #1d4ed8;
    --primary-dark: #1e3a8a;
    --primary-dark-hover: #172554;
    --text: #111827;
    --muted: #6b7280;
    --border: #d1d5db;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
}

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 24px 20px;
}

.sidebar h2 {
    font-size: var(--base-font-size);
    margin: 0 0 6px;
    color: var(--text);
}

.refine-panel > h3 {
    color: #2373ad;
}

.sidebar-note {
    font-size: var(--base-font-size);
    color: var(--muted);
    margin: 0 0 24px;
    line-height: 1.4;
}

.filter-group {
    margin-bottom: 22px;
}

.filter-group label {
    font-size: var(--base-font-size);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.filter-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: var(--base-font-size);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.filter-group .select-wrap {
    position: relative;
}

.filter-group .select-wrap::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--muted);
    pointer-events: none;
}

.filter-group .checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px 0;
}

.filter-group .checkbox-list.collapse-panel {
    display: none;
    padding-top: 10px;
}

.filter-group .checkbox-list.collapse-panel.open {
    display: flex;
}

.filter-group .collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    font-size: var(--base-font-size);
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}

.filter-group .collapse-toggle:hover {
    color: var(--primary);
}

.filter-group .collapse-toggle .toggle-icon {
    font-size: var(--base-font-size);
    font-weight: 700;
    line-height: 1;
    color: var(--primary);
}

.filter-group .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--base-font-size);
    color: var(--text);
    cursor: pointer;
    padding: 4px 0;
}

.filter-group .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.subject-filter {
    position: relative;
}

.subject-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: var(--base-font-size);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.subject-toggle[aria-expanded="true"] {
    border-color: black;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.15);
}

.subject-toggle>span:first-child {
    flex: 1;
    text-align: left;
}

.subject-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-size: var(--base-font-size);
    font-weight: 700;
}

.subject-badge.hidden {
    display: none;
}

.subject-chevron {
    font-size: var(--base-font-size);
    color: var(--muted);
    transition: transform 0.2s;
    margin-left: 2px;
}

.subject-toggle[aria-expanded="true"] .subject-chevron {
    transform: rotate(180deg);
}

.subject-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 12px;
    max-height: 360px;
}

.subject-dropdown.open {
    display: block;
}

.filter-group-header {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.subject-search {
    position: relative;
    margin-bottom: 10px;
}

.subject-search input {
    width: 100%;
    padding: 8px 32px 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: var(--base-font-size);
    outline: none;
    padding-right: 8px;
}

.subject-search input:focus {
    border-color: var(--primary);
}

.subject-search .search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--base-font-size);
    color: var(--muted);
    pointer-events: none;
}

.subject-list {
    display: flex;
    flex-direction: column;
    max-height: 240px;
    overflow-y: auto;
    gap: 4px;
}

.subject-option {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 6px;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--base-font-size);
    color: var(--text);
    transition: background 0.15s;
    margin-bottom: 0;
}

.subject-option:hover {
    background: #f3f4f6;
}

.subject-option.hidden {
    display: none !important;
}

.subject-option input[type="checkbox"] {
    display: none;
}

.subject-label {
    flex: 1;
    line-height: 1.35;
}

.subject-count {
    color: var(--muted);
    font-weight: 500;
}

.subject-check {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.subject-option:has(input[type="checkbox"]:checked) .subject-check {
    background: #16a34a;
    border-color: #16a34a;
}

.subject-option:has(input[type="checkbox"]:checked) .subject-check::after {
    content: "✓";
    color: #fff;
    font-size: var(--base-font-size);
    font-weight: 700;
}

.filter-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    background: #f3f4f6;
    border-radius: 8px;
    margin-top: 10px;
    gap: 10px;
}

@media (min-width: 801px) {

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        overflow-y: auto;
        scrollbar-gutter: stable;
        display: flex;
        flex-direction: column;
        border-bottom: 1px solid var(--border);
        border-radius: 0 0 8px 8px;
    }

    .main {
        margin-left: 260px;
    }

    .sidebar .refine-panel {
        flex: 1 0 auto;
        display: flex;
        flex-direction: column;
    }

    .sidebar .filter-actions {
        position: fixed;
        left: 20px;
        bottom: 24px;
        width: 220px;
        margin-top: 0;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.08);
        z-index: 50;
    }

    .sidebar .refine-panel {
        padding-bottom: 90px;
    }
}

.filter-clear-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: var(--base-font-size);
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    text-transform: uppercase;
}

.filter-clear-btn:hover {
    background: #454545;
    color: #fff;
}

.filter-apply-btn {
    background: none;
    border: none;
    color: #16a34a;
    font-size: var(--base-font-size);
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    text-transform: uppercase;
    transition: background 0.2s;
}

.filter-apply-btn:hover {
    background: #15803d;
    color: #fff;
}

.active-filters-section {
    margin-top: 18px;
}

.active-filters-divider {
    height: 4px;
    background: #111827;
    margin-bottom: 14px;
    border-radius: 2px;
}

h3.active-filters-heading {
    margin: 2px 0 16px;
    color: #2373ad;
}

a.reset-filters-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin-bottom: 12px;
    background: #f3f4f6;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #5F6F7F !important;
    font-size: var(--base-font-size);
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
}

a.reset-filters-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff !important;
}

a.reset-filters-btn .btn-icon {
    width: 16px;
    height: 16px;
}

.active-filters-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.active-filter-group {
    margin-bottom: 22px;
}

.active-filter-group-label {
    display: block;
    font-size: var(--base-font-size);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.filter-group-header,
.active-filter-group-label {
    white-space: nowrap;
}

.active-filters-groups .active-filters-chips {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
}

.active-filters-groups .filter-chip {
    width: 100%;
    justify-content: space-between;
    box-sizing: border-box;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #5f6f7f;
    color: #fff;
    font-size: var(--base-font-size);
    font-weight: 500;
    border-radius: 6px;
}

.chip-remove {
    background: none;
    border: none;
    color: #fff;
    font-size: var(--base-font-size);
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.chip-remove:hover {
    opacity: 1;
}

.clear-filters {
    display: inline-block;
    margin-top: 6px;
    font-size: var(--base-font-size);
    color: var(--primary);
    text-decoration: none;
}

.clear-filters:hover {
    text-decoration: underline;
}

.clear-filters.hidden {
    display: none;
}

.main {
    flex: 1;
    padding: 24px 32px 60px;
    min-width: 0;
}

.main h1 {
    font-size: var(--title-font-size);
    margin: 0 0 18px;
    color: #2373ad;
}

.search-bar-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 20px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: visible;
    background: #fff;
    position: relative;
}

.search-bar .field-select-wrap {
    position: relative;
    flex-shrink: 0;
}

.search-bar .field-select-wrap select {
    height: 44px;
    padding: 0 34px 0 14px;
    font-size: var(--base-font-size);
    font-weight: 500;
    color: #fff;
    background: var(--primary);
    border: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.search-bar .field-select-wrap::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #fff;
    pointer-events: none;
}

.search-bar .field-select-wrap select:focus {
    outline: none;
}

.search-bar .field-select-wrap select option {
    background: #fff;
    color: var(--text);
}

.search-bar .input-wrap {
    flex: 1;
    position: relative;
    min-width: 180px;
}

.search-bar input {
    width: 100%;
    height: 44px;
    border: none;
    border-left: 1px solid var(--border);
    padding: 0 12px;
    font-size: var(--base-font-size);
    outline: none;
    color: var(--text);
    background: transparent;
}

.search-bar input::placeholder {
    color: #9ca3af;
}

.search-bar .clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 44px;
    border: none;
    border-left: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    text-decoration: none;
    font-size: var(--base-font-size);
    cursor: pointer;
}

.search-bar .clear-btn:hover {
    color: #dc2626;
    background: #f9fafb;
}

.search-bar .clear-btn.hidden {
    display: none;
}

.search-bar button[type="submit"] {
    height: 44px;
    padding: 0 20px;
    border: none;
    border-left: 1px solid var(--border);
    background: var(--primary);
    color: #fff;
    font-size: var(--base-font-size);
    cursor: pointer;
    transition: background 0.2s;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.result-count {
    font-size: var(--base-font-size);
    color: var(--muted);
    margin: 0;
}

.result-count strong {
    color: var(--text);
    font-weight: 600;
}

.back-link {
    text-decoration: none;
    font-weight: 600;
}
.back-link:hover { text-decoration: underline; }
.top-back-link {
    display: inline-block;
    font-size: var(--base-font-size);
    margin-bottom: 10px;
}

.sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-wrap label {
    font-size: var(--base-font-size);
    color: var(--muted);
}

.sort-wrap select {
    padding: 8px 28px 8px 10px;
    font-size: var(--base-font-size);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
}

.sort-wrap .select-wrap {
    position: relative;
}

.sort-wrap .select-wrap::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--muted);
    pointer-events: none;

}


/* Mobile: keep the Sort-by row and the grid/list toggle on one line. */
@media (max-width: 768px) {
    .results-header {
        gap: 8px;
    }
    .sort-wrap {
        flex: 1;
        min-width: 240px;
        gap: 6px;
    }
    .sort-wrap .select-wrap {
        flex: 1;
        min-width: 0;
    }
    .sort-wrap select {
        width: 100%;
        min-width: 0;
    }
    .sort-wrap .view-toggle {
        margin-left: 0;
        flex-shrink: 0;
    }
}

.welcome-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 40px 0px;
    text-align: center;
}

.welcome-card h2 {
    font-size: var(--base-font-size);
    margin: 0 0 10px;
    color: var(--text);
}

.welcome-card p {
    font-size: var(--base-font-size);
    color: black;
    margin: 0 auto;
    line-height: 1.55;
    text-align: justify;
    overflow-wrap: break-word;
}

.result-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.journal-card {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.journal-card:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    border-color: black;
}

.card-left {
    flex: 1;
    min-width: 0;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cover-image {
    width: 100px;
    height: 138px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #f3f4f6;
    flex-shrink: 0;
}

.cover-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--base-font-size);
    color: var(--muted);
    text-align: center;
    padding: 4px;
}

.journal-title {
    color: #2373ad;
    font-size: var(--title-font-size);
    margin: 0 0 6px;
    line-height: 1.35;
    font-weight: bold;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}

.journal-publisher {
    font-size: var(--base-font-size);
    color: var(--muted);
    margin: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.journal-issn {
    font-size: var(--base-font-size);
    color: var(--muted);
    margin: 4px 0 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.issn-separator {
    margin: 0 6px;
}

@media (max-width: 768px) {
    .journal-issn .issn-line,
    .journal-issn .issn-separator {
        display: block;
    }
    .journal-issn .issn-separator {
        display: none;
    }
}

.card-right {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    gap: 0;
    flex-shrink: 0;
    width: 50%;
    min-width: 220px;
}

/* Grid view header */
.grid-header {
    display: flex;
    align-items: flex-end;
    padding: 0 0 6px;
    margin-bottom: 0;
}

.grid-header-left {
    flex: 1;
    min-width: 0;
}

.grid-header-right {
    display: flex;
    justify-content: flex-end;
    gap: 0;
    flex-shrink: 0;
    width: 50%;
    min-width: 220px;
}

.grid-header-label {
    flex: 1;
    text-align: center;
    font-size: var(--base-font-size);
    letter-spacing: 0.3px;
    color: var(--muted);
    padding: 0 8px;
    margin-left: -1px;
}

.grid-header-label:first-child {
    margin-left: 0;
}

.info-pill {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    padding: 16px 12px;
    background: var(--card);
    color: var(--text);
    font-size: var(--base-font-size);
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s;
    border-right: 1px solid var(--border);
    border-left: none;
    min-height: 100px;
}

.info-pill:first-child {
    border-right: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.info-pill:last-child {
    border-right: 1px solid var(--border);
    border-left: none;
}

.info-pill .label {
    flex-shrink: 0;
    opacity: 0.85;
    font-size: var(--base-font-size);
    line-height: 1.2;
    color: var(--muted);
    font-weight: 700;
}

.info-pill .value {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--base-font-size);
    line-height: 1.2;
    word-break: normal;
    color: var(--text);
    padding: 6px 0;
}

.info-pill .as-of {
    flex-shrink: 0;
    font-size: var(--tag-font-size);
    color: var(--muted);
    opacity: 0.8;
    line-height: 1;
    min-height: 1em;
}

@media (min-width: 801px) {
    .info-pill {
        justify-content: center;
        position: relative;
    }
    .info-pill .value {
        flex: 0 0 auto;
    }
    .info-pill .as-of {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 10px;
    }
}


/* Quota info icon */
.quota-info-trigger {
    font-size: var(--base-font-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 5px;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    color: var(--muted);
    transition: color 0.2s;
}

.quota-info-trigger:hover {
    color: var(--primary);
}

.quota-info-trigger svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Quota info popup */
.quota-info-popup {
    display: none;
    position: absolute;
    z-index: 1000;
    background: #1f2937;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: var(--base-font-size);
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
}

.quota-info-popup.show {
    display: block;
}

.quota-info-popup::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #1f2937;
}

/* Position popup below when near top edge */
.quota-info-popup.below {
    bottom: auto;
    top: calc(100% + 8px);
}

.quota-info-popup.below::before {
    top: auto;
    bottom: 100%;
    border-top: none;
    border-bottom: 4px solid #1f2937;
}

.quota-info-popup.left {
    left: auto;
    right: 0;
    transform: none;
}

.quota-info-popup.left::before {
    left: auto;
    right: 14px;
    transform: none;
}

.status-note {
    font-size: var(--base-font-size);
    color: var(--muted);
    margin-top: 8px;
    line-height: 1.4;
}

.empty-state {
    padding: 50px 20px;
    text-align: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.empty-state h3 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: var(--base-font-size);
}

.empty-state p {
    color: var(--muted);
    margin: 0;
    font-size: var(--base-font-size);
}

.ta-pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 28px;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

.page-link {
    display: inline-block;
    padding: 8px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.page-link.disabled {
    color: var(--muted);
    cursor: not-allowed;
}

.page-link.page-nav {
    padding: 8px 18px;
}

.ta-pagination .page-link:hover,
.ta-pagination .page-link:visited:hover,
.ta-pagination .page-link:focus {
    z-index: 2;
    color: var(--primary) !important;
    text-decoration: none !important;
    background-color: #e9ecef !important;
    border-color: var(--border) !important;
}

.page-go-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

.page-go-input {
    padding: 8px 10px;
    font-size: var(--base-font-size);
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card);
    color: var(--text);
    text-align: center;
    outline: none;
}

.page-go-input:focus {
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.page-go-btn {
    padding: 8px 14px;
    font-size: var(--base-font-size);
    font-weight: 600;
    border: none;
    border-radius: 4px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}


.per-page-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-top: 20px;
    margin-left: auto;
    margin-right: auto;
    padding: 8px 16px;
    width: fit-content;
}

.per-page-label {
    font-size: var(--base-font-size);
    color: var(--muted);
}

.per-page-options {
    display: flex;
    align-items: center;
    gap: 8px;
}

.per-page-option {
  display: inline-block;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  line-height: normal;
}

.per-page-option:hover {
  z-index: 2;
  color: var(--primary) !important;
  text-decoration: none !important;
  background-color: #e9ecef !important;
  border-color: var(--border) !important;
}

.per-page-option.active {
  color: var(--primary);
  border-color: var(--border);
  cursor: default;
}

.per-page-option.active:hover {
  color: var(--primary) !important;
  background-color: #dee2e6;
  border-color: var(--border);
}



/* View toggle buttons */
.view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 10px;
}

.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
}

.view-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.view-toggle-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* List view */
.list-view {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.list-header {
    display: flex;
    align-items: baseline;
    padding: 10px 14px;
    background: #EFEEEE;
    border-bottom: 2px solid var(--border);
    font-size: var(--base-font-size);
    color: var(--muted);
}

.list-header .list-col-publisher,
.list-header .list-col-quota,
.list-header .list-col-subject,
.list-header .list-col-oa,
.list-header .list-col-issn,
.list-header .list-col-eissn {
    color: var(--muted);
}

.list-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    font-size: var(--base-font-size);
    color: var(--text);
}

.list-row:last-child {
    border-bottom: none;
}

.list-row:hover {
    background: #eef2ff;
}

.list-row:focus {
    outline: 2px solid var(--text);
    outline-offset: -2px;
}

.list-col {
    flex-shrink: 0;
    padding-right: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: inherit;
}

.list-col-quota {
    overflow: visible;
}

.list-col-title {
    flex: 2.5;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-col-publisher {
    flex: 1;
    color: var(--text);
}

.list-col-quota {
    flex: 1;
    min-width: 90px;
    color: var(--text);
}

/* Keep the quota text and the info toggle on one line in list rows. */
.list-row .list-col-quota {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    white-space: nowrap;
}

.list-row .list-col-quota .quota-info-trigger {
    margin-left: 0;
}

/* List view quota value container */
.list-col-quota .value {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    white-space: nowrap;
    overflow: visible;
    width: 100%;
}

/* List view quota number */
.list-col-quota .quota-number {
    flex: 1;
    text-align: center;
    padding-right: 22px;
}


@media (min-width: 801px) and (max-width: 1100px) {
.list-col-quota .quota-info-popup {
        bottom: auto;
        top: calc(100% + 8px);
        left: 50%;
        transform: translateX(-50%);
        width: 260px;
        max-width: 80vw;
        white-space: normal;
        word-break: break-word;
        text-align: center;
    }
    .list-col-quota .quota-info-popup::before {
        top: auto;
        bottom: 100%;
        border-top: none;
        border-bottom: 4px solid #1f2937;
    }
    .list-col-quota .quota-info-popup.left {
        left: auto;
        right: 0;
        transform: none;
    }
    .list-col-quota .quota-info-popup.left::before {
        left: auto;
        right: 14px;
        transform: none;
    }
    .list-view .list-row:last-child .quota-info-popup {
        top: auto;
        bottom: calc(100% + 8px);
    }
    .list-view .list-row:last-child .quota-info-popup::before {
        bottom: auto;
        top: 100%;
        border-bottom: none;
        border-top: 4px solid #1f2937;
    }
}
/* List view as-of date */
.list-as-of {
    font-size: var(--base-font-size);
    color: var(--muted);
    margin-top: 2px;
}

.list-col-subject {
    flex: 1.5;
    color: var(--text);
}

.list-col-oa {
    flex: 1.2;
    color: var(--text);
}

.list-col-issn {
    flex: 0.8;
    color: var(--text);
}

.list-col-eissn {
    flex: 0.8;
    color: var(--text);
}

.list-journal-title {
    font-weight: 600;
    color: #2373ad;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-row:hover .list-journal-title {
    text-decoration: underline;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.available {
    background: #16a34a;
}

.status-dot.unavailable {
    background: #dc2626;
}

.list-as-of {
    font-size: var(--base-font-size);
    color: var(--muted);
    margin-left: 4px;
}

.ta-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.ta-modal-backdrop.active {
    display: flex;
}

.ta-modal {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 800px;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ta-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 28px 32px 20px;
    border-bottom: 1px solid var(--border);
}

.ta-modal-title-wrap {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.ta-modal-title {
    font-size: clamp(1.1rem, 4vw, 1.55rem);
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.35;
    color: var(--text);
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}

.ta-modal-title a {
    color: var(--primary);
    text-decoration: underline;
}

.ta-modal-title a:hover {
    text-decoration: underline;
}
.ta-external-link-icon {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        color: black;
        vertical-align: middle;
}
.ta-modal-publisher {
    font-size: var(--base-font-size);
    color: var(--muted);
    margin: 0;
}

.ta-modal-cover {
    width: 100px;
    height: 138px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #f3f4f6;
    flex-shrink: 0;
}

.ta-modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 0 0 8px;
}

.ta-modal-close:hover {
    color: var(--text);
}

.ta-modal-body {
    padding: 28px 32px;
    overflow-y: auto;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px 32px;
}

.detail-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 16px;
    color: var(--muted);
    letter-spacing: 0.2px;
    margin: 0 0 8px;
    text-transform: none;
}

.ta-detail-value {
    font-size: var(--base-font-size);
    color: var(--text);
    margin: 0;
    line-height: 1.5;
    word-break: break-word;
    flex: 1;
}

.ta-detail-tag {
    flex-shrink: 0;
    font-size: var(--tag-font-size);
    color: var(--muted);
    margin: auto 0 0;
    opacity: 0.8;
    line-height: 1;
    min-height: 1em;
    word-break: break-word;
    margin-top: 8px;
    margin-bottom: 0;
}

.detail-value a {
    color: var(--text);
    text-decoration: underline;
}

@media (max-width: 1024px) {
    .journal-card {
        flex-direction: column;
        align-items: stretch;
    }

    .card-left {
        padding: 20px 24px;
    }

    .card-right {
        width: 100%;
        min-width: 0;
        border-top: 1px solid var(--border);
    }

    .grid-header {
        display: none;
    }

    .info-pill:nth-child(2),
    .info-pill:last-child {
        display: none;
    }

    .info-pill:first-child {
        flex: 1 1 100%;
        min-width: 0;
        min-height: 0;
        border: none;
    }
}

@media (max-width: 800px) {
    input::placeholder {
        font-size: 12px;
    }
    .page {
        flex-direction: column;
        padding: 16px;
    }
    .main,
    .sidebar { display: contents; }
    .sidebar {
        width: auto;
        border: none;
        padding: 0;
        background: transparent;
    }
    .refine-panel {
        order: 2;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 8px;
        box-shadow: var(--shadow);
        padding: 20px 16px;
        margin-bottom: 16px;
    }

    .main {
        padding: 0;
    }
    .search-bar-wrap {
        order: 1;
        margin-bottom: 16px;
    }
    .results-panel {
        order: 3;
    }

    .journal-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-right {
        width: 100%;
        flex-wrap: wrap;
        border: none;
    }
    .info-pill {
        flex: 1 1 50%;
        min-width: 140px;
        box-sizing: border-box;
        border: none;
        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }
    .info-pill:first-child {
        border-left: none;
        border-right: 1px solid var(--border);
    }
    .info-pill:nth-child(2) {
        border-left: none;
        border-right: none;
    }
    .info-pill:last-child {
        flex-basis: 100%;
        border-left: none;
        border-right: none;
        border-top: none;
    }

    .grid-header-right {
        width: 100%;
        min-width: 0;
        border-left: none;
    }

    .grid-header-label {
        display: none;
    }

    .info-pill:nth-child(2),
    .info-pill:last-child {
        display: none;
    }
    .info-pill:first-child {
        flex: 1 1 100%;
        min-width: 0;
        border-right: none;
        border-top: none;
        border-bottom: none;
        justify-content: flex-start;
        align-items: flex-start;
        text-align: left;
        padding-left: 0;
        padding-right: 0;
    }
    .detail-grid { grid-template-columns: 1fr; }

    /* Mobile list view: only show quota */
    .list-header .list-col-publisher,
    .list-header .list-col-subject,
    .list-header .list-col-oa,
    .list-header .list-col-issn,
    .list-header .list-col-eissn,
    .list-row .list-col-publisher,
    .list-row .list-col-subject,
    .list-row .list-col-oa,
    .list-row .list-col-issn,
    .list-row .list-col-eissn {
        display: none;
    }
    .list-header .list-col-title,
    .list-row .list-col-title {
        flex: 2;
    }
    .list-header .list-col-quota,
    .list-row .list-col-quota {
        flex: 1;
        min-width: 90px;
    }
    .list-row .list-journal-title {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    .list-as-of {
        display: none;
    }

    /* Mobile quota tooltip: align right */
    .list-col-quota .quota-info-popup {
        left: auto !important;
        right: 0 !important;
        transform: none !important;
        width: 260px !important;
        max-width: 85vw !important;
        white-space: normal !important;
        word-break: break-word !important;
        text-align: center;
    }
    .list-col-quota .quota-info-popup::before {
        left: auto !important;
        right: 12px !important;
        transform: none !important;
    }
}

@media (max-width: 480px) {
    .search-bar {
        flex-wrap: wrap;
        border-radius: 6px;
    }

    .search-bar .field-select-wrap,
    .search-bar .input-wrap,
    .search-bar .clear-btn,
    .search-bar button[type="submit"] {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .search-bar .field-select-wrap select,
    .search-bar input {
        width: 100%;
        border-left: none;
    }

    .modal {
        max-width: 100%;
        max-height: 95vh;
        margin-top: auto;
        border-radius: 12px 12px 0 0;
    }
    .modal-backdrop.active {
        align-items: flex-end;
    }
    .modal-close {
        top: 10px;
        right: 10px;
    }
}

/* Back to top button */
.top-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 124px;
    height: 73px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #f3f3f3 0%, #f3f3f3 100%);
    border: 1px solid #2f322c;
    border-radius: 9px;
    box-shadow: 0 3px 3px rgba(70, 75, 60, 0.20), 0 1px 1px rgba(70, 75, 60, 0.12);
    cursor: pointer;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    padding: 0;
    overflow: hidden;
}

.top-button.visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

.top-button:hover {
    background: linear-gradient(180deg,  #f3f3f3 0%, #cdcdcd 50%);
    box-shadow: 0 4px 6px rgba(70, 75, 60, 0.25), 0 2px 2px rgba(70, 75, 60, 0.15);
}

.top-button-icon {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
}

.top-button-arrow {
    display: block;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 7px solid #2f322c;
    position: relative;
}

.top-button-arrow::after {
    content: "";
    position: absolute;
    left: -1.5px;
    top: 7px;
    width: 3px;
    height: 11px;
    background: #2f322c;
    border-radius: 1px;
}

.top-button-divider {
    width: 1px;
    height: 100%;
    background: #2f322c;
    flex-shrink: 0;
}

.top-button-text {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 5px;
    color: #2f322c;
    text-transform: uppercase;
    padding-left: 5px;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

@media (max-width: 480px) {
    .top-button {
        width: 100px;
        height: 60px;
        bottom: 16px;
        right: 16px;
    }
    .top-button-text {
        font-size: 12px;
        letter-spacing: 4px;
    }
}