.filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}

.filters input, .filters select, .filters button {
    width: auto;
    margin: 0;
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
    height: auto;
}

.filters select {
    padding-right: 1.75rem;
}

.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.book-grid article {
    margin: 0;
    padding: 0.75rem;
}

.book-grid img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 4px;
}

.book-grid select {
    margin-bottom: 0.5rem;
    padding: 0.25rem 1.75rem 0.25rem 0.5rem;
    font-size: 0.8rem;
    height: auto;
}

.download-btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    margin: 0;
    width: 100%;
}

.btn-download {
    background: #1565c0;
    border-color: #1565c0;
    color: white;
}

.release-dialog {
    max-width: 90vw;
    width: 60rem;
}

.release-dialog table {
    font-size: 0.85rem;
}

.release-dialog form {
    margin: 0;
}

.actions form, .actions details {
    display: inline-block;
    margin: 0 0.25rem 0 0;
}

.actions button, .actions summary {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    margin: 0;
}

.error { color: #d32f2f; }

.book-cell {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.activity-cover {
    flex: 0 0 auto;
    display: block;
    width: 48px;
    height: 72px;
}

.activity-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 3px;
}

.activity-cover.placeholder {
    background: var(--pico-muted-border-color, #e2e2e2);
    border-radius: 3px;
}

.login-box {
    max-width: 24rem;
    margin: 4rem auto;
}

.logout-form {
    margin: 0;
}

.logout-form button {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    margin: 0;
}

.imports-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.imports-actions button, .imports-actions a {
    font-size: 0.85rem;
    padding: 0.3rem 0.8rem;
    margin: 0;
    width: auto;
}

.imports-list {
    font-size: 0.85rem;
}

.imports-list button {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    margin: 0;
}

.match-cell details {
    margin: 0.25rem 0 0;
}

.match-cell summary {
    font-size: 0.75rem;
}

.match-options form, .hc-option {
    margin: 0.25rem 0;
}

.hc-option {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.hc-option select {
    width: auto;
    margin: 0;
    font-size: 0.75rem;
    padding: 0.2rem 1.5rem 0.2rem 0.4rem;
    height: auto;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    background: var(--pico-secondary-background);
    color: var(--pico-secondary-inverse);
}

a.badge { color: white; text-decoration: none; }

.badge-ok { background: #2e7d32; color: white; }
.badge-err { background: #b71c1c; color: white; }

.badge-dl-available { background: #2e7d32; color: white; }
.badge-dl-downloading { background: #ef6c00; color: white; }
.badge-dl-failed { background: #b71c1c; color: white; }

.badge-icon {
    width: 1.15em;
    height: 1.15em;
    vertical-align: -0.2em;
}

.badge-pending {
    background: var(--pico-mark-background-color, #ffdd57);
    color: #333;
}

.cover-link { display: block; }

.title-link {
    color: inherit;
    text-decoration: none;
}

.title-link:hover { text-decoration: underline; }

.book-detail {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

/* the hardcover.app badges, between the series line and the status row */
.hardcover-links,
.match-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* the imports Match column is dense: keep the badge row tight to the title */
.match-badges {
    margin: 0.3rem 0;
}

.book-detail img {
    width: 200px;
    border-radius: 4px;
}

.edition {
    padding: 1rem;
}

.edition form {
    margin: 0;
}

/* the detail page's per-edition and download buttons: shrink-wrapped and
   ranged right, each its own button rather than a joined group */
.edition-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.3rem;
}

/* tighter than Pico's default form-element spacing, but the label keeps its
   full size — these read as controls beside the text, not as page CTAs */
.edition-actions button {
    width: auto;
    margin: 0;
    padding: 0.3rem 0.9rem;
}

.edition-files {
    margin: 0.5rem 0 0;
}

.edition-files table {
    font-size: 0.85rem;
}

/* the folder's total size, shown on the summary line so it reads without
   expanding the file list */
.dir-size {
    margin-left: 0.5rem;
    opacity: 0.7;
}

.edition-files + .edition-actions {
    margin-top: 0.5rem;
}

/* the picker's folded-away "Or download a new edition" tail, shown when the
   series' own labels lead */
.edition-options .new-edition {
    margin: 0.5rem 0 0;
}

.edition-options .new-edition summary {
    font-weight: bold;
}

/* the Imports picker's first option: a radio whose value is whatever is
   typed beside it */
.custom-option {
    display: block;
}

.custom-option > label {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
    align-items: baseline;
    margin: 0;
}

.custom-option > input[type="text"] {
    margin: 0.25rem 0 0 1.7rem;
    width: calc(100% - 1.7rem);
}

/* the picker sits inside a table row, so it inherits the row's tighter type */
.match-cell .edition-options {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
}

.match-cell .edition-options h5 {
    font-size: 0.85rem;
    margin: 0.75rem 0 0.15rem;
}

.match-cell .edition-options p {
    margin: 0 0 0.25rem;
}

.match-cell .edition-option {
    margin: 0.35rem 0;
}

.edition-option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
    align-items: baseline;
    margin: 0.5rem 0;
}

.edition-option strong,
.edition-option small {
    display: block;
}

.edition-option small {
    color: var(--pico-muted-color);
}

button.edition-option {
    text-align: left;
    width: 100%;
    grid-template-columns: 1fr;
}

.user-actions { white-space: nowrap; }
.user-actions form { display: inline-block; margin: 0 0.25rem 0 0; }
.user-actions button { padding: 0.15rem 0.6rem; font-size: 0.8rem; width: auto; }
.user-edit td { border-top: none; padding-top: 0; }
.user-edit details { margin-bottom: 0; }
