html {
    scrollbar-gutter: stable;
    color-scheme: light dark;
}

/* ===== Bootstrap Overrides & Custom Theming ===== */

/* Active tab accent color — override Bootstrap's blue */
.nav-underline .nav-link.active,
.nav-underline .nav-link.active:hover,
.nav-underline .nav-link.active:focus {
    color: #c0392b !important;
    border-bottom-color: #c0392b !important;
}

.nav-underline {
    border-bottom: 1px solid var(--bs-border-color);
}

.nav-underline .nav-link {
    color: #555;
    font-size: 15px;
    margin-bottom: -1px;
}

.nav-underline .nav-link:hover {
    color: #333;
}

/* Dropdown toggle — strip Bootstrap's default box styling */
.toolbar .dropdown-toggle {
    font-style: italic;
    font-family: "Times New Roman", Times, serif;
    font-size: 16px;
    padding: 6px 10px;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    color: var(--bs-body-color);
    outline: none;
    transition: background 0.15s, color 0.15s;
}

.toolbar .dropdown-toggle:focus,
.toolbar .dropdown-toggle:active {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Black background on open trigger — Kobo style */
.toolbar .dropdown-toggle.show,
.toolbar .dropdown-toggle[aria-expanded="true"] {
    background: #000 !important;
    color: #fff !important;
}

.toolbar .dropdown-toggle::after {
    margin-left: 4px;
    vertical-align: middle;
}

/* Dropdown menu — sharp corners, pointer triangle, dividers */
.dropdown-menu {
    border-radius: 0 !important;
    padding: 0;
    border: 1px solid #ccc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-top: 0 !important;
}

.dropdown-menu > li + li {
    border-top: 1px solid #e0e0e0;
}

.dropdown-menu > li > .dropdown-item {
    padding: 10px 16px;
    font-size: 14px;
    font-family: "Times New Roman", Times, serif;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: #f5f5f5;
}

.dropdown-item[data-sort] {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sort-arrow {
    margin-left: auto;
}

/* Dropdown checkmark column */
.dropdown-item .check {
    display: inline-block;
    width: 18px;
    text-align: center;
    font-size: 13px;
}

/* Dark mode dropdown overrides */
[data-bs-theme="dark"] .dropdown-menu {
    border-color: #444;
}

[data-bs-theme="dark"] .dropdown-menu > li + li {
    border-top-color: #444;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background: #333;
}

/* Dark mode — fix text that becomes invisible */
[data-bs-theme="dark"] .nav-underline .nav-link {
    color: #aaa;
}

[data-bs-theme="dark"] .nav-underline .nav-link:hover {
    color: #ccc;
}

/* ===== Top Header Bar ===== */
.top-bar-outer {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bs-body-bg);
}

.top-bar-outer,
.top-bar {
    position: relative;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    padding-bottom: 10px;
}

.container-lg {
    max-width: 900px;
    --bs-gutter-x: 1.9rem;
}

.top-bar-logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 600;
    color: #c0392b;
    letter-spacing: 0.5px;
    text-decoration: none;
}

.top-bar-logo:hover {
    color: #a93226;
}

.top-bar-clock {
    font-size: 14px;
    font-weight: 500;
}

.top-bar-icons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.top-bar-icons button {
    background: none;
    border: none;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--bs-body-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.top-bar-icons button svg {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    display: block;
}

/* ===== Page Layout ===== */
.page {
    padding-bottom: 80px;
}

/* ===== Bottom Navigation ===== */
.bottom-nav-outer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    z-index: 100;
}

.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: 64px;
    margin-top: -1px;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    color: var(--bs-secondary-color);
    text-decoration: none;
    padding: 0 16px;
    border-top: 3px solid transparent;
}

.bottom-nav a.active {
    color: #c0392b;
    border-top-color: #c0392b;
    font-weight: 700;
}

.bottom-nav a svg {
    width: 22px;
    height: 22px;
}

/* Author & Collection list items */
#author-list .list-group-item,
#collection-list .list-group-item {
    font-family: "Times New Roman", Times, serif;
}

/* View toggle button — no circle, visible border only when open */
.toolbar .btn.rounded-circle {
    border: none;
    background: none;
    box-shadow: none;
    outline: none;
    color: var(--bs-body-color);
    font-size: 18px;
}

.toolbar .btn.rounded-circle.show,
.toolbar .btn.rounded-circle[aria-expanded="true"] {
    background: #000;
    color: #fff;
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 14px;
}

.toolbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--bs-body-color);
}

/* ===== Book Grid ===== */
.book-grid.row {
    --bs-gutter-x: 12px;
    --bs-gutter-y: 16px;
}

.book-card {
    display: flex;
    flex-direction: column;
}

.book-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.book-cover small {
    display: block;
    margin-top: 4px;
    font-weight: 400;
    opacity: 0.85;
}

/* Cover images — general rule: border hugs the image, not the container */
.cover-frame {
    position: relative;
    aspect-ratio: 2 / 3;
}

.cover-frame img {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 100%;
    max-height: 100%;
    border: 1px solid var(--bs-border-color);
    border-radius: 2px;
}

.audiobook-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    width: 26px;
    height: 26px;
    z-index: 2;
}

.book-list-cover-img .audiobook-badge {
    width: 19px;
    height: 19px;
    bottom: 4px;
    left: 4px;
}

.cover-frame .book-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

.book-cover-img {
    width: 100%;
}

.book-list-cover-img {
    width: 100px;
    min-width: 100px;
    aspect-ratio: auto;
}

.book-list-cover-img img {
    position: static;
    transform: none;
    display: block;
    width: 100%;
}

.book-list-cover-img .book-cover {
    position: static;
    aspect-ratio: 2 / 3;
    height: auto;
}


.home-cover-slot {
    position: absolute;
    height: 100%;
    bottom: 0;
}

.home-cover-slot .cover-frame {
    height: 100%;
    width: auto;
}

.home-cover-slot:nth-child(1) { left: 0; z-index: 3; height: 100%; }
.home-cover-slot:nth-child(2) { left: 120px; z-index: 2; height: 90%; }
.home-cover-slot:nth-child(3) { left: 240px; z-index: 1; height: 81%; }

.home-cover-single-slot {
    height: 100%;
}

.home-cover-single-slot .cover-frame {
    height: 100%;
    width: auto;
    aspect-ratio: 2 / 3;
}

.book-status {
    font-size: 16px;
    color: var(--bs-body-color);
    margin-top: 6px;
    font-family: "Times New Roman", Times, serif;
    letter-spacing: 0.5px;
}

.book-menu {
    font-size: 16px;
    color: var(--bs-secondary-color);
    letter-spacing: 1px;
    cursor: pointer;
}

/* ===== Book List ===== */
.book-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.book-list-thumb {
    width: 56px;
    min-width: 56px;
    aspect-ratio: 2 / 3;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 8px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    padding: 4px;
}

.book-list-info {
    flex: 1;
    min-width: 0;
}

.book-list-title {
    font-size: 19px;
    font-weight: normal;
    font-family: "Times New Roman", Times, serif;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-list-series {
    font-size: 14px;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    margin-top: 2px;
}

.book-list-author {
    font-size: 15px;
    color: var(--bs-secondary-color);
    margin-top: 2px;
    font-family: "Times New Roman", Times, serif;
}

.book-list-contributor {
    font-size: 13px;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-list-right {
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

.book-list-read-status {
    font-size: 17px;
    color: var(--bs-secondary-color);
    font-family: "Times New Roman", Times, serif;
}

.book-list-time-remaining {
    font-size: 15px;
    color: var(--bs-tertiary-color);
    margin-top: 2px;
    text-transform: uppercase;
}

.book-list-format {
    font-size: 13px;
    color: var(--bs-tertiary-color);
    margin-top: 2px;
}

/* ===== Series Links ===== */
a.book-card,
a.series-list-item {
    text-decoration: none;
    color: inherit;
}

/* ===== Series Detail Header ===== */
.series-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 2px solid #c0392b;
    margin-bottom: 4px;
}

.series-back-link {
    color: var(--bs-body-color);
    display: flex;
    align-items: center;
    text-decoration: none;
}

.series-detail-name {
    font-size: 17px;
    font-weight: 600;
}

/* ===== Series List ===== */
.series-list-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.series-list-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-self: stretch;
}

.series-list-title {
    font-size: 19px;
    font-weight: normal;
    font-family: "Times New Roman", Times, serif;
}

.series-list-author {
    font-size: 15px;
    color: var(--bs-secondary-color);
    margin-top: 2px;
}

.series-list-count {
    font-size: 15px;
    color: var(--bs-tertiary-color);
    margin-top: auto;
    font-family: "Times New Roman", Times, serif;
}

/* ===== Home Page ===== */
.home-reading {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.home-reading-span {
    grid-column: 1 / -1;
}

.home-reading-item {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    flex: 0 0 auto;
    min-width: 0;
}

.home-reading-span .home-reading-item {
    flex: 0 0 auto;
}

.home-reading-item .home-card-covers {
    height: 250px;
}

.home-grid.row {
    --bs-gutter-x: 20px;
    --bs-gutter-y: 24px;
    padding-top: 8px;
}

.home-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.home-card-covers {
    position: relative;
    height: 250px;
    margin-bottom: 8px;
    overflow: hidden;
}

.home-card-cover-single {
    width: 120px;
    aspect-ratio: 2 / 3;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.home-card-cover-stack {
    position: relative;
    height: 100%;
}



.home-card-label {
    font-size: 15px;
    font-family: "Times New Roman", Times, serif;
    color: var(--bs-secondary-color);
    margin-bottom: 8px;
}

.home-card-title {
    font-size: 16px;
    font-weight: 600;
    font-family: "Times New Roman", Times, serif;
}

.home-card-sub {
    font-size: 12px;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    margin-top: 2px;
}

/* ===== Settings Page ===== */
.settings-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0 8px;
    position: relative;
    border-bottom: 1px solid var(--bs-border-color);
    margin-bottom: 16px;
}

.settings-header h1 {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

.settings-close {
    position: absolute;
    right: 0;
    top: 10px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--bs-body-color);
    padding: 4px 8px;
    text-decoration: none;
}

.settings-page-title {
    font-size: 24px;
    font-weight: 600;
    padding: 8px 0 16px;
}

.settings-page-indicator {
    font-size: 13px;
    color: var(--bs-secondary-color);
    float: right;
    margin-top: 14px;
}

/* ===== More Page ===== */
.more-title {
    font-size: 24px;
    font-weight: 600;
    padding: 8px 0 16px;
}

/* ===== Book Detail Modal ===== */
.book-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding: 24px;
    overflow-y: auto;
}

.book-modal-backdrop.open {
    display: flex;
}

.book-modal {
    background: var(--bs-body-bg);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px 32px;
    position: relative;
}

.book-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--bs-body-color);
    line-height: 1;
}

.book-modal-title-bar {
    text-align: center;
    font-size: 15px;
    font-family: "Times New Roman", Times, serif;
    color: var(--bs-secondary-color);
    padding-bottom: 16px;
}

.book-modal-info {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
}

.book-modal-cover {
    width: 160px;
    min-width: 160px;
    aspect-ratio: auto;
    cursor: pointer;
}

.book-modal-cover-inner {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.book-modal-cover img {
    position: static;
    transform: none;
    max-width: 100%;
}

.book-modal-cover .book-cover {
    position: relative;
    min-height: 240px;
    aspect-ratio: 2 / 3;
}

.book-modal-meta {
    flex: 1;
}

.book-modal-book-title {
    font-size: 22px;
    font-weight: 600;
    font-family: "Times New Roman", Times, serif;
    margin-bottom: 4px;
}

.book-modal-series {
    font-size: 13px;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.book-modal-series a {
    color: inherit;
    text-decoration: none;
}

.book-modal-series a:hover {
    text-decoration: underline;
}

.book-modal-author {
    font-size: 16px;
    margin-bottom: 12px;
}

.book-modal-author a {
    color: inherit;
    text-decoration: none;
}

.book-modal-author a:hover {
    text-decoration: underline;
}

.book-modal-contributors {
    font-size: 14px;
    color: var(--bs-secondary-color);
    margin-bottom: 12px;
}

.book-modal-contributor-role {
    font-style: italic;
}

.book-modal-status-row {
    margin-bottom: 16px;
}

.book-modal-status {
    font-size: 15px;
    font-family: "Times New Roman", Times, serif;
    color: var(--bs-secondary-color);
}

.bm-status-menu-btn {
    background: none;
    border: none;
    color: var(--bs-secondary-color);
    font-size: 16px;
    letter-spacing: 2px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.book-modal-tabs {
    border-bottom: 1px solid var(--bs-border-color);
    margin-bottom: 16px;
}

.book-modal-tabs .nav-link {
    color: #555;
    font-size: 15px;
    margin-bottom: -1px;
    cursor: pointer;
}

.book-modal-tabs .nav-link.active {
    color: #c0392b !important;
    border-bottom-color: #c0392b !important;
}

[data-bs-theme="dark"] .book-modal-tabs .nav-link {
    color: #aaa;
}

.book-modal-tab-content {
    font-size: 15px;
    line-height: 1.6;
}

.book-modal-tab-content .detail-row {
    padding: 2px 0;
    font-family: "Times New Roman", Times, serif;
}

#user-modal {
    max-width: 350px;
    min-height: auto;
}

#settings-modal,
#device-modal {
    max-width: 550px;
    min-height: auto;
}

#manage-files-modal {
    max-width: 1400px;
    min-height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.manage-files-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.manage-files-section {
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.manage-files-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.manage-files-actions {
    display: flex;
    gap: 8px;
}

.mf-template-info {
    display: flex;
    gap: 16px;
    align-items: baseline;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.mf-template-display {
    font-family: "Times New Roman", Times, serif;
    font-size: 15px;
    color: var(--bs-secondary-color);
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.mf-template-example {
    font-family: "Times New Roman", Times, serif;
    font-size: 15px;
    color: #c0392b;
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.manage-files-table-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin-top: 8px;
    border: 1px solid var(--bs-border-color);
}

.manage-files-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.manage-files-table thead th {
    position: sticky;
    top: 0;
    background: var(--bs-tertiary-bg);
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--bs-border-color);
    font-weight: 600;
}

.manage-files-table tbody td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--bs-border-color);
    vertical-align: top;
    font-size: 11px;
}

.manage-files-table tbody tr.mf-row-rename td {
    background-color: var(--bs-info-bg-subtle);
}

.manage-files-table tbody tr.mf-row-conflict td {
    background-color: var(--bs-warning-bg-subtle);
}

#about-modal {
    max-width: 510px;
    min-height: auto;
}

#pair-modal {
    max-width: 350px;
    min-height: auto;
    transition: max-width 0.2s ease;
}

#pair-modal code {
    color: #c0392b;
}

#confirm-modal {
    max-width: 350px;
    min-height: auto;
}

#confirm-modal .book-modal-info {
    flex-direction: column;
}

#confirm-modal-message {
    white-space: pre-line;
}

#pair-modal.pair-modal-wide {
    max-width: 550px;
}

/* ===== Settings Tiles ===== */
.settings-tiles {
    padding: 0 4px;
}

.settings-tile {
    padding: 16px 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.settings-tile:last-child {
    border-bottom: none;
}

.settings-tile-label {
    font-size: 15px;
    font-weight: 500;
    color: var(--bs-body-color);
    margin-bottom: 6px;
}

.settings-tile-desc {
    font-size: 13px;
    color: var(--bs-secondary-color);
    margin-top: 6px;
    line-height: 1.4;
}

.settings-tile-error {
    font-size: 13px;
    color: #c0392b;
    margin-top: 4px;
    font-weight: bold;
}

.settings-tile-inline {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.settings-tile-inline .bm-edit-input {
    flex: 1;
    min-width: 0;
}

.settings-tile-inline .bm-edit-btn {
    height: 42px;
    padding-top: 0;
    padding-bottom: 0;
}

.settings-tile-validate-result {
    font-size: 13px;
    color: #c0392b;
    margin-top: 6px;
    min-height: 1em;
    word-break: break-all;
    white-space: pre-wrap;
}

.settings-tile-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-tile-toggle-row .settings-tile-label {
    margin-bottom: 0;
}

.settings-tile .bm-edit-input {
    width: 100%;
}

.settings-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.settings-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bs-border-color);
    border-radius: 12px;
    transition: background 0.2s;
    cursor: pointer;
}

.settings-toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--bs-body-bg);
    border-radius: 50%;
    transition: transform 0.2s;
}

.settings-toggle input:checked + .settings-toggle-slider {
    background: var(--bs-body-color);
}

.settings-toggle input:checked + .settings-toggle-slider::before {
    transform: translateX(20px);
}

.settings-error-banner {
    font-size: 14px;
    color: #c0392b;
    border: 2px solid #c0392b;
    padding: 10px 14px;
    margin-top: 16px;
    font-weight: bold;
    display: none;
}

.settings-footer {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

.settings-footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-save-status {
    font-size: 14px;
    color: var(--bs-secondary-color);
    display: none;
}

.about-modal-content {
    font-size: 15px;
    line-height: 1.6;
}

.about-modal-content p {
    margin-bottom: 12px;
}

.about-divider {
    margin: 20px 0 16px;
    border: none;
    border-top: 1px solid var(--bs-border-color);
}

.about-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 14px;
}

.about-version {
    font-size: 12px;
    color: var(--bs-secondary-color);
    text-align: center;
    margin-top: 24px;
}

.about-logo {
    color: #c0392b;
    font-size: 33px;
    font-weight: bold;
    text-align: center;
    margin-top: 8px;
}

.bm-data-info {
    font-size: 13px;
    color: var(--bs-secondary-color);
    margin-bottom: 12px;
}

#bm-data pre {
    background: #000000;
    color: #C4C4C4;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

#bm-data code {
    font-family: "Courier New", Courier, monospace;
}

#bm-data .json-key { color: #4EF3F3; }
#bm-data .json-string { color: #4EDC4E; }
#bm-data .json-number { color: #F3F34E; }
#bm-data .json-bool { color: #F34EF3; }
#bm-data .json-null { color: #4E4E4E; }

/* ===== Edit Book Modal ===== */
.bm-edit-form {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.bm-edit-cover-col {
    width: 160px;
    min-width: 160px;
}

.bm-edit-cover-col .cover-frame {
    aspect-ratio: auto;
}

.bm-edit-cover-col .book-cover {
    position: relative;
    min-height: 240px;
}

.bm-edit-btn {
    padding: 10px 24px;
    border: 2px solid var(--bs-body-color);
    border-radius: 0;
    background: transparent;
    color: var(--bs-body-color);
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
}

.bm-edit-btn:active {
    background: var(--bs-body-color);
    color: var(--bs-body-bg);
}

.bm-edit-cover-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 20px;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    z-index: 1;
}

.bm-edit-cover-remove:hover {
    background: rgba(0, 0, 0, 0.85);
}

.bm-edit-btn-disabled,
.bm-edit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.bm-edit-input.bm-edit-input-disabled,
.bm-edit-textarea.bm-edit-input-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--bs-border-color);
}

.bm-edit-input-disabled ~ .bm-edit-checkmark {
    border-color: var(--bs-border-color);
}

.bm-edit-error {
    font-size: 13px;
    color: #c0392b;
    margin-top: 4px;
    font-weight: bold;
}

.bm-edit-input-invalid {
    border-color: #c0392b;
}

.bm-edit-error-banner {
    font-size: 14px;
    color: #c0392b;
    border: 2px solid #c0392b;
    padding: 10px 14px;
    margin-top: 16px;
    font-weight: bold;
    display: none;
}

.bm-edit-btn-primary {
    background: var(--bs-body-color);
    color: var(--bs-body-bg);
}

.bm-edit-btn-primary:active {
    background: transparent;
    color: var(--bs-body-color);
}

.bm-edit-cover-upload {
    display: block;
    text-align: center;
    margin-top: 8px;
}

.bm-edit-fields {
    flex: 1;
}

.bm-edit-field {
    margin-bottom: 12px;
}

.bm-edit-label {
    font-size: 15px;
    color: var(--bs-body-color);
    margin-bottom: 4px;
}

.bm-edit-hint {
    font-size: 12px;
    font-style: italic;
    color: var(--bs-secondary-color);
}

.bm-edit-contributor-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    align-items: stretch;
}

.bm-edit-contributor-row > .bm-edit-contributor-name {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

.bm-edit-contributor-row > .bm-edit-contributor-role {
    flex: 0 0 200px;
    width: 200px;
}

.bm-edit-contributor-row > .bm-edit-contributor-remove {
    background: var(--bs-body-bg);
    border: 2px solid var(--bs-body-color);
    border-radius: 0;
    color: var(--bs-body-color);
    font-size: 20px;
    font-weight: bold;
    padding: 0;
    flex: 0 0 42px;
    height: 42px;
    width: 42px;
    cursor: pointer;
}

.bm-edit-contributor-remove:hover {
    color: #c0392b;
    border-color: #c0392b;
}

.bm-edit-add-contributor {
    background: none;
    border: none;
    color: var(--bs-body-color);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    text-decoration: underline;
}

.bm-edit-textarea {
    min-height: 240px;
    resize: vertical;
}

.bm-edit-checkbox {
    display: block;
    position: relative;
    width: 42px;
    height: 42px;
    cursor: pointer;
}

.bm-edit-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.bm-edit-checkmark {
    position: absolute;
    inset: 0;
    border: 2px solid var(--bs-body-color);
    background: var(--bs-body-bg);
}

.bm-edit-checkmark::after {
    content: "";
    display: none;
    position: absolute;
    left: 13px;
    top: 5px;
    width: 10px;
    height: 20px;
    border: solid var(--bs-body-color);
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

.bm-edit-checkbox input:checked ~ .bm-edit-checkmark::after {
    display: block;
}

.bm-edit-row {
    display: flex;
    gap: 12px;
}

.bm-edit-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 16px;
}

.bm-edit-warning {
    font-family: "Times New Roman", Times, serif;
    font-size: 14px;
    font-style: italic;
    color: var(--bs-secondary-color);
    max-width: 70%;
    line-height: 1.4;
}

.bm-edit-buttons {
    display: flex;
    gap: 8px;
}

/* ===== Combo Box (Autocomplete) ===== */
.bm-combo-wrap {
    position: relative;
}

.bm-combo-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border: 2px solid var(--bs-body-color);
    border-top: none;
}

.bm-combo-item {
    padding: 8px 10px;
    font-size: 15px;
    font-family: "Times New Roman", Times, serif;
    cursor: pointer;
}

.bm-combo-item:hover,
.bm-combo-item-active {
    background: var(--bs-body-color);
    color: var(--bs-body-bg);
}

.bm-combo-item + .bm-combo-item {
    border-top: 1px solid var(--bs-border-color);
}

/* Book card/list clickable */
.book-card {
    cursor: pointer;
}

.book-list-item {
    cursor: pointer;
}

/* Book menu dropdown */
.book-menu-dropdown .book-menu {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--bs-secondary-color);
    letter-spacing: 1px;
    cursor: pointer;
    padding: 0;
}

/* ===== Search Modal ===== */
.search-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding: 24px;
    overflow-y: auto;
}

.search-modal-backdrop.open {
    display: flex;
}

.search-modal {
    background: var(--bs-body-bg);
    width: 100%;
    max-width: 900px;
    padding: 24px 32px;
    position: relative;
}

.search-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--bs-body-color);
    line-height: 1;
}

.search-modal-title-bar {
    text-align: center;
    font-size: 15px;
    font-family: "Times New Roman", Times, serif;
    color: var(--bs-secondary-color);
    padding-bottom: 16px;
}

.search-input-wrap {
    position: relative;
    margin-bottom: 16px;
}

.search-input-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--bs-secondary-color);
    pointer-events: none;
}

.search-input,
.bm-edit-input,
.bm-edit-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid var(--bs-body-color);
    border-radius: 0;
    font-size: 15px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    color-scheme: light dark;
    outline: none;
    font-family: "Times New Roman", Times, serif;
    box-sizing: border-box;
}

.bm-edit-input {
    height: 42px;
}

select.bm-edit-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23333'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
    padding-right: 24px;
}

.search-input {
    padding: 12px 12px 12px 44px;
    font-size: 16px;
}

.search-input::placeholder {
    color: var(--bs-secondary-color);
}

/* ===== Archived Book Styles ===== */

.book-card-archived .cover-frame img,
.book-list-item-archived .cover-frame img,
.book-card-archived .cover-frame .book-cover,
.book-list-item-archived .cover-frame .book-cover {
    filter: brightness(0.85) saturate(0.3);
}

.book-archived-label {
    float: right;
    font-size: 13px;
    color: var(--bs-secondary-color);
    font-style: italic;
}

.book-list-archived-label {
    font-size: 13px;
    color: var(--bs-secondary-color);
    font-style: italic;
}

/* ===== Responsive ===== */
@media (max-width: 575.98px) {
    .book-modal-backdrop {
        padding: 8px;
    }
    .book-modal-info {
        flex-direction: column;
        align-items: center;
    }
    .book-modal-cover {
        width: 120px;
        min-width: 120px;
    }
    .bm-edit-form {
        flex-direction: column;
    }
    .bm-edit-cover-col {
        width: 120px;
        min-width: 120px;
        margin: 0 auto;
    }
    .bm-edit-row {
        flex-direction: column;
    }
}

/* ===== Entity Edit Modal Book List ===== */
.entity-edit-book-list-header {
    font-family: "Times New Roman", Times, serif;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--bs-body-color);
}
.entity-edit-book-list {
    max-height: 260px;
    overflow-y: auto;
    margin-bottom: 16px;
    border: 2px solid var(--bs-border-color);
}
.entity-edit-book-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--bs-border-color);
}
.entity-edit-book-item:last-child {
    border-bottom: none;
}
.entity-edit-book-cover {
    width: 32px;
    min-width: 32px;
    height: 48px;
}
.entity-edit-book-cover .book-cover {
    font-size: 6px;
}
.entity-edit-book-title {
    font-family: "Times New Roman", Times, serif;
    font-size: 14px;
    line-height: 1.3;
}
.entity-edit-book-author {
    font-family: "Times New Roman", Times, serif;
    font-size: 12px;
    color: var(--bs-secondary-color);
}

/* ===== GLightbox Kobo Overrides ===== */
.glightbox-clean .goverlay {
    background: rgba(0, 0, 0, 0.9);
}

.glightbox-clean .gclose,
.glightbox-clean .gnext,
.glightbox-clean .gprev {
    background: none;
    border: none;
}

.glightbox-clean .gslide-image img {
    border: 1px solid var(--bs-border-color);
    border-radius: 2px;
}

/* ===== Sync Popover ===== */
.sync-popover-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
}

.sync-popover-backdrop.open {
    display: block;
}

.sync-popover-anchor {
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 calc(var(--bs-gutter-x, 1.5rem) * .5);
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
}

.sync-popover {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 20px 24px;
    width: 300px;
    pointer-events: auto;
}

.sync-popover-text {
    font-size: 16px;
    margin-bottom: 12px;
    line-height: 1.4;
    min-height: 22px;
}

.sync-popover-progress {
    width: 100%;
    height: 13px;
    background: var(--bs-border-color);
    margin-bottom: 12px;
}

.sync-popover-subtask-title {
    font-size: 13px;
    color: var(--bs-secondary-color);
    margin-bottom: 4px;
    line-height: 1.3;
    min-height: 17px;
}

.sync-popover-progress-bar {
    height: 100%;
    width: 0%;
    background: #444;
    transition: width 0.2s ease;
}

[data-bs-theme="dark"] .sync-popover-progress-bar {
    background: var(--bs-body-color);
}

.sync-popover-btn {
    display: block;
    width: 140px;
    padding: 8px 20px;
    border: 2px solid var(--bs-body-color);
    border-radius: 0;
    background: var(--bs-body-color);
    color: var(--bs-body-bg);
    font-family: "Times New Roman", Times, serif;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
}

.sync-popover-btn:active {
    background: transparent;
    color: var(--bs-body-color);
}

.sync-popover-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sync-popover-last-sync {
    font-size: 13px;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    margin-top: 12px;
    text-align: left;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 360px;
}

.login-field {
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--bs-body-color);
}

.login-error {
    font-size: 14px;
    color: #c0392b;
    font-weight: bold;
    min-height: 20px;
    margin-bottom: 8px;
}

.login-btn {
    width: 100%;
}

/* ===== Admin Pages (Users/Devices) ===== */
.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-list {
    display: flex;
    flex-direction: column;
}

.admin-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.admin-tile:last-child {
    border-bottom: none;
}

.admin-tile-info {
    flex: 1;
    min-width: 0;
}

.admin-tile-title {
    font-size: 18px;
    font-family: "Times New Roman", Times, serif;
    font-weight: normal;
}

.admin-tile-subtitle {
    font-size: 14px;
    color: var(--bs-secondary-color);
    margin-top: 2px;
}

.admin-tile-meta {
    font-size: 13px;
    color: var(--bs-tertiary-color);
    margin-top: 2px;
}

.admin-tile-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    margin-left: 12px;
    gap: 4px;
}

.admin-tile-delete {
    color: #c0392b;
    border-color: #c0392b;
}

.admin-tile-lock {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.admin-tile-lock-icon {
    font-size: 13px;
    color: #c0392b;
    font-weight: bold;
    cursor: help;
}

.admin-tile-unlock {
    font-size: 12px;
    padding: 2px 8px;
}

.admin-empty {
    font-size: 15px;
    color: var(--bs-secondary-color);
    font-family: "Times New Roman", Times, serif;
    text-align: center;
    padding: 32px 0;
}

.admin-empty-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--bs-body-color);
    margin-bottom: 8px;
}

.admin-empty-body {
    margin-bottom: 12px;
}

.admin-empty-countdown {
    font-size: 28px;
    font-weight: bold;
    color: var(--bs-body-color);
    letter-spacing: 2px;
}

.admin-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.pairing-status {
    font-size: 14px;
    color: var(--bs-secondary-color);
    font-family: "Times New Roman", Times, serif;
}

.pairing-active {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}

.pairing-active:active {
    background: #a93226;
}
