/* Lorebook surface layout. Typography and controls belong to window-components.css. */
.lore-window { --window-width: 1024px; --window-max-height: min(92dvh, 880px); }
.lore-window .ui-window__body { display: grid; align-content: start; gap: 12px; }
.lore-toolbar { justify-content: flex-start; }
.lore-attach, .lore-entry-picker { display: flex; align-items: flex-end; gap: 8px; }
.lore-attach .ui-field, .lore-entry-picker .ui-field { flex: 1; min-width: 0; }
.lore-columns { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr); gap: 16px; }
.lore-books, .lore-columns form { min-width: 0; }
.lore-columns form { gap: 12px; overflow: visible; }
.lore-book-select { flex: 1; min-width: 0; justify-content: flex-start; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.lore-book-select[aria-current="true"] { border-color: var(--color-accent); }
.lore-entry-fields { display: grid; min-width: 0; margin: 0; padding: 0; border: 0; gap: 12px; }
.lore-entry-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lore-content { min-height: 160px; resize: vertical; }
#lore-entry-uid { width: 100%; }
@media (max-width: 767px) {
    .lore-columns { grid-template-columns: minmax(0, 1fr); }
    .lore-attach, .lore-entry-picker { flex-wrap: wrap; }
    .lore-attach .ui-field, .lore-entry-picker .ui-field { flex-basis: 100%; }
}

/* V3 import reuses the shared window chrome. */
.v3-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.v3-fields, #v3-preparation { display: grid; min-width: 0; gap: 12px; }
.v3-library-names { display: grid; min-width: 0; gap: 6px; }
#v3-book-names { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 8px; min-width: 0; }
.v3-book-name-field { min-width: 0; }
.v3-filter-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.v3-filter-row > .ui-label { flex: 0 0 auto; white-space: nowrap; }
.v3-filter-row > .ui-control { flex: 1 1 auto; width: 0; min-width: 0; }
.v3-tools-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.v3-selection-tools { display: flex; align-items: center; gap: 6px; min-width: 0; }
.v3-sort { display: flex; align-items: center; flex: 0 0 auto; justify-content: flex-end; gap: 8px; min-width: 0; margin-left: auto; }
.v3-sort .ui-label { flex: 0 0 auto; white-space: nowrap; }
.v3-sort .ui-control { flex: 0 0 18vw; width: 18vw; min-width: max(15vw, 64px); max-width: 240px; }
.v3-selection-tools > .ui-button { padding-inline: 6px; }
.v3-selection-tools > .ui-hint { flex: 0 0 auto; white-space: nowrap; color: #fff; font-weight: 700; }
.v3-entries { min-height: 300px; max-height: 400px; overflow: auto; min-width: 0; }
.v3-entry-tables { display: grid; gap: 14px; }
.v3-entry-group { min-width: 0; }
.v3-book-heading { margin: 0 0 6px; overflow-wrap: anywhere; }
.v3-entry-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.v3-entry-table th, .v3-entry-table td { padding: 4px 6px; border-bottom: 1px solid var(--color-border, #ddd); text-align: left; vertical-align: middle; }
.v3-entry-table th { font-size: .85em; }
.v3-entry-table th:first-child, .v3-entry-table .v3-check-cell { width: 56px; text-align: center; }
.v3-entry-table .v3-state-col, .v3-entry-table .v3-state-cell { width: 48px; text-align: center; }
.v3-entry-table input[type="checkbox"] { width: auto; max-width: 100%; }
.v3-entry-table .v3-title-cell { overflow-wrap: anywhere; }
.v3-window .v3-entry-table .lore-book-select { display: block; width: 100%; min-width: 0; height: auto; min-height: 32px; max-height: none; white-space: normal; overflow-wrap: anywhere; text-align: left; justify-content: flex-start; }
.v3-entry-table [aria-current="true"] { border-color: var(--color-accent); }
.v3-state-ready { color: #16803c; }
.v3-state-pending { color: #c62828; }
.v3-accepted-summary { min-width: 0; }
.v3-accepted-summary .ui-label { margin-bottom: 6px; }
.v3-issues { max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; }
.v3-accepted-table { width: max-content; min-width: 100%; table-layout: auto; }
.v3-accepted-table .v3-title-cell { white-space: nowrap; }
#v3-import-report > .ui-notice { padding-top: 4px; }
#v3-import-report .v3-report-heading { display: block; margin: 0 0 4px; }
.v3-library-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.v3-address { overflow-wrap: anywhere; }
@media (max-width: 767px) {
 .v3-columns { grid-template-columns: minmax(0, 1fr); }
 .v3-entries { min-height: 300px; max-height: min(48dvh, 380px); }
 .v3-tools-row { gap: 4px; }
 .v3-selection-tools { gap: 3px; }
 .v3-sort { gap: 4px; }
 .v3-sort .ui-label, .v3-selection-tools > .ui-button, .v3-selection-tools > .ui-hint { font-size: 9px; }
 .v3-sort .ui-control { flex-basis: 18vw; width: 18vw; min-width: max(15vw, 58px); max-width: 82px; }
 .v3-selection-tools > .ui-button { padding-inline: 3px; }
 .v3-entry-table th, .v3-entry-table td { padding: 4px; }
 .v3-entry-table th:first-child, .v3-entry-table .v3-check-cell { width: 44px; }
 .v3-entry-table .v3-state-col, .v3-entry-table .v3-state-cell { width: 38px; }
}

/* Selection layout only; controls retain the shared window sizing. */
.sv3-choice { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
#sv3-books:not(:empty) { min-height: 72px; }

/* V3 editor: local layout, shared window controls/chrome. */
.ve-columns { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.ve-fields { display: grid; min-width: 0; gap: 12px; }
.ve-fields .ui-field { min-width: 0; }
.ve-fields summary { cursor: pointer; }
#ve-entries { height: auto; max-height: 300px; }
#ve-entry-fields { display: grid; min-width: 0; gap: 12px; }
@media (max-width: 767px) { .ve-columns { grid-template-columns: minmax(0, 1fr); } #ve-entries { max-height: 150px; } }

/* Catalog actions never compete with the book title for a narrow text column. */
#v3-library .v3-library-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
#v3-library .v3-library-summary { display: flex; align-items: center; gap: 12px; min-width: 0; }
:is(#v3-library, #sv3-picker) .v3-library-cover { flex: 0 0 48px; width: 48px; height: 72px; object-fit: contain; border-radius: var(--radius-sm); background: var(--color-surface); }
#v3-library .v3-library-name { display: grid; gap: 4px; }
.v3-library-title { overflow-wrap: anywhere; }
#v3-library .ui-order-row__actions { display: flex; flex-wrap: wrap; gap: 6px; }
#v3-library .v3-library-action { flex: 0 0 var(--window-button-height); width: var(--window-button-height); min-width: var(--window-button-height); padding: 0; }
.sv3-selection { display: grid; gap: 8px; min-width: 0; }
.sv3-book-description { display: block; overflow-wrap: anywhere; }
#sv3-picker { --window-width: 800px; }
#sv3-picker .sv3-choice { align-items: start; }
#sv3-picker input[type=checkbox] { flex: 0 0 auto; width: 20px; height: 20px; }
#sv3-picker .v3-library-name { display: grid; gap: 4px; }
@media (max-width: 767px) {
 #v3-library .v3-library-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
 #v3-library .ui-order-row__actions { justify-content: flex-end; }
}
