.link-svg {
    height: 1em;
    width: auto;
    vertical-align: -0.125em;
}

.link-favicon {
    height: 1em;
    width: 1em;
    vertical-align: -0.125em;
}

/* The generic link glyph after a favicon shows only when the favicon fails to load. */
.link-favicon + .bi {
    display: none;
}

.link-favicon[hidden] + .bi {
    display: inline-block;
}

/* As wide as the widest vendored logo (Open Library), so URL fields aren't ragged */
.link-icon {
    flex: none;
    width: 4.1em;
    padding: 0.375rem 0;
    text-align: right;
}

/* Bootstrap's default stripes are too severe */
.table {
    --bs-table-striped-bg: rgba(var(--bs-emphasis-color-rgb), 0.025);
}

.border-dashed {
    border-style: dashed;
}

fieldset.box {
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

fieldset.box > legend {
    float: none;
    width: auto;
    padding: 0 0.5rem;
    margin-bottom: 0;
    font-size: 1.25rem;
}

.tag-chips [data-entries] {
    display: contents;
}

.tag-chips .dropdown {
    flex: 1 1 8rem;
}

.tag-chips .form-control {
    border: 0;
    padding: 0;
    box-shadow: none;
    background: transparent;
}

.tag-chips:focus-within {
    border-color: rgba(var(--bs-primary-rgb), 0.5);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Fit the picture to the placeholder's width without cropping or stretching it. */
.picture {
    display: block;
    width: 10rem;
    height: auto;
    max-height: 20rem;
    object-fit: contain;
}

.picture-input {
    width: 10rem;
}

.picture-frame {
    position: relative;
    margin-bottom: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    border: var(--bs-border-width) dashed var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.picture-frame[data-has-picture] {
    border-style: solid;
}

.picture-frame:not([data-has-picture]) {
    height: 14rem;
}

.picture-frame > .picture {
    width: 100%;
}

.picture-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 2.5rem;
    color: var(--bs-secondary-color);
    text-align: center;
}

.picture-frame:not([data-has-picture]) > .picture,
.picture-frame:not([data-has-picture]) > [data-file-clear],
.picture-frame[data-has-picture] > .picture-placeholder {
    display: none;
}

.picture-frame > [data-file-clear] {
    --bs-btn-bg: var(--bs-body-bg);
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
}

.picture-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    display: none;
    font-size: 2rem;
    transform: translate(-50%, -50%);
}

.picture-input:has([data-browse]:disabled) .picture-frame {
    cursor: default;
}

.picture-input:not(:has([data-browse]:disabled)) .picture-frame:hover > .picture-hint {
    display: block;
}

.picture-input:not(:has([data-browse]:disabled)) .picture-frame:hover > :is(.picture, .picture-placeholder) {
    opacity: 0.4;
}

.picture-candidates {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
}

.picture-candidates:not(:has(> li)) {
    display: none;
}

.picture-candidates > [data-candidate="rejected"] img {
    opacity: 0.4;
}

.picture-candidates > [data-candidate="rejected"] [data-sources] {
    text-decoration: line-through;
}

.picture-input:has([data-browse]:disabled) [data-proposal-state="accepted"] {
    display: none;
}

/* Give every thumbnail a 5:7 portrait frame so a listing stays uniform even with uneven images. */
.thumbnail {
    width: 3.5rem;
    height: 4.9rem;
}

.thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.confirm {
    max-width: 30rem;
    padding: 0;
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
}

.confirm::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.confirm-header {
    padding: 1rem;
    background: var(--bs-tertiary-bg);
    border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}

.confirm-danger {
    color: #fff;
    background: var(--bs-danger);
    border-bottom-color: var(--bs-danger);
}

.confirm-body {
    padding: 1rem;
}

.confirm-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
}

/* The suggestions of a field reach past the edge of the dialog. */
.sequence-dialog {
    overflow: visible;
}

.sequence-number {
    flex: 0 0 4rem;
}

/* Show every enabled drop zone while a file or link is dragged over the page. */
[data-file-input]:not([data-state="empty"]) > [data-file-empty],
[data-file-input]:not([data-state="busy"]) > [data-file-busy],
[data-file-input]:not([data-state="staged"]) > [data-file-staged-name] {
    display: none;
}

[data-drop-zone] {
    position: relative;
}

/* A zone that contains a frame draws its overlay on the frame. */
html[data-drop-targets] [data-drop-zone]:not(:has([data-drop-frame], [data-url-field]:disabled))::after,
html[data-drop-targets] [data-drop-zone]:not(:has([data-url-field]:disabled)) [data-drop-frame]::after {
    content: attr(data-drop-zone) attr(data-drop-frame);
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: var(--bs-body-color);
    background: rgba(var(--bs-primary-rgb), 0.05);
    border: 2px dashed var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

html[data-drop-targets] [data-drop-zone][data-drop-active]::after,
html[data-drop-targets] [data-drop-zone][data-drop-active] [data-drop-frame]::after {
    background: rgba(var(--bs-primary-rgb), 0.15);
    border-color: var(--bs-primary);
}

.input-group > .dropdown {
    flex: 1 1 auto;
    min-width: 0;
}

.input-group > .dropdown > .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Every entry shares the columns of the box, the kind, the content, and the action. */
.holdings {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
}

.holdings > li {
    grid-column: 1 / -1;
}

.holding {
    display: grid;
    grid-template-columns: subgrid;
    align-items: center;
}

.holding:has([value="digital"]:checked) > .dropdown,
.holding:not(:has([value="digital"]:checked)) > [data-file-input],
.holding:has([data-state="busy"], [data-state="staged"]) > .holding-kind,
.holding:not(:has([data-state="busy"], [data-state="staged"])) > .holding-digital {
    display: none;
}

.work-people,
.work-title {
    flex: 2 1 0;
    min-width: 0;
}

.work-number {
    flex: 1 1 0;
    min-width: 0;
}

.work-people > * {
    display: flex;
    gap: 0.5rem;
}

.work-people > * > :first-child {
    flex: 3 1 0;
    min-width: 0;
}

.work-people > * > :last-child {
    flex: 2 1 0;
    min-width: 0;
}

#review-queue tbody[data-collapsed] > tr:not(:first-child),
#review-queue tbody:not([data-collapsed]) [data-when="collapsed"],
#review-queue tbody[data-collapsed] [data-when="expanded"] {
    display: none;
}

[data-list-entry] > .btn-check:checked + .btn,
[data-list-entry] > .btn-check:not(:checked) + .btn + .btn {
    display: none;
}

[data-list-entry]:has(> .btn-check:checked),
[data-list-entry]:has(> .btn-check:checked) :is(.form-control, .form-select, .form-control-plaintext, a:not(.btn)) {
    color: var(--bs-secondary-color);
    text-decoration: line-through;
}

[data-lockable] .form-control:disabled {
    background-color: transparent;
    border-color: transparent;
}

[data-lockable] .form-control:disabled::placeholder {
    color: transparent;
}

[data-list-entry] > .btn-check:focus-visible + .btn + .btn {
    border-color: var(--bs-btn-hover-border-color);
    box-shadow: var(--bs-btn-focus-box-shadow);
}

:root {
    /* Where the text of a .form-control starts, so a candidate sits under an input's text. */
    --input-inset: calc(0.75rem + var(--bs-border-width));
}

.candidates {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    column-gap: 1rem;
    padding-left: var(--input-inset);
}

.candidates:not(:has(> li)) {
    display: none;
}

.candidates > li {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
}

.candidates > li > :first-child {
    padding-left: 1em;
    text-indent: -1em;
}

.candidate-text {
    /* The box of .form-control, so the text sits where an input's text would. */
    padding: 0.375rem 0 0.375rem var(--input-inset);
    line-height: 1.5;
}

.identifier-kind {
    flex: none;
    width: 10rem;
}

[data-candidate="accepted"] {
    /* A list's candidates are .d-flex, whose display is !important. */
    display: none !important;
}

[data-candidate="rejected"] .candidate-text {
    text-decoration: line-through;
}

[data-list] > [data-candidate="rejected"] [data-proposal-state="accepted"] {
    display: none;
}

.candidates > [data-candidate="rejected"] > :first-child {
    text-decoration: line-through;
}

[data-candidate="pending"] [data-proposal-state="pending"],
[data-candidate="rejected"] [data-proposal-state="rejected"],
:is(.candidates, .picture-candidates):not(:has([data-candidate="accepted"])) [data-candidate="rejected"] [data-proposal-state="accepted"],
:is(.candidates, .picture-candidates):has([data-candidate="accepted"]) [data-candidate="rejected"] [data-proposal-state="pending"] {
    display: none;
}

:has(> [data-enrichment] form) > [data-enrich] {
    display: none;
}
