* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow-wrap: break-word;
}

main {
    color: white;
    background: #282828;
}

.overflow-hidden {
    overflow-y: hidden;
}

.theme-switcher {
    margin-top: 50px;
}

.theme-switcher label {
    width: 80px;
    display: block;
    height: 32px;
    background: url("img/dark-theme-icon.f8a7f986ab89.svg") no-repeat;
    background-size: contain;
}

main a {
    color: white;
}

    main.light {
        background: #FDFBEE;
        color: black;
    }

        main.light svg, main.light path {
            fill: #1D1B1B !important;
        }

        main.light .theme-switcher label {
            background: url("img/light-theme-icon.9814dcfc753a.svg") no-repeat;
        }

        main.light .article-container {
            box-shadow: 0 0 25.3px 0 rgba(0, 0, 0, 0.1);
        }

    main.light a {
        color: black;
    }

    main.light .article {
        background: #FDFBEE;
    }


        main.light .comments {
            border-top: 1px solid #1D1B1B;
        }

    main.light .comment-input-name, main.light .comment-input-text {
        color: black;
    }

body { 
    background: #282828;
}

body.light {
    background: #FDFBEE;
}

    /* Header */

    header {
    position: fixed;
    width: 100%;
    z-index: 6;
    background-color: #282828;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1vh 0;
}

.logo {
    width: 10%;
    line-height: 100%;
}

.menu {
    display: flex;
    gap: 15px;
    list-style: none;
}

.menu-link {
    text-decoration: none;
    color: white;
    font-weight: 500;
    font-size: 16px;
}

.burger-menu {
    display: flex;
    align-items: center;
}

button.burger-icon {
    background: none;
    border: 0;
    padding: 0;
}

.burger-icon {
    display: none;
    flex-direction: column;
    cursor: pointer;
    z-index: 2;
}

.bar {
    display: block;
    width: 40px;
    height: 2px;
    background-color: white;
    margin: 5px 0;
    border-radius: 3px;
}


@media screen and (max-width: 1000px) {

    header {
        padding: 2px 5%;
    }

    .logo {
        width: 23%;
    }

    .burger-icon {
        display: flex;
        order: 1;
    }

    .menu {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 2;
        gap: 30px;
        height: 100%;
        padding-left: 5%;
        padding-top: 120px;
        background-color: black;
    }

        .menu.active {
            display: flex;
        }
}

.parent-category {
    position: relative;
}

.sub-menu {
    background: black;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    position: absolute;
    top: 37px;
    left: 50%;
    transform: translateX(-50%);
    width: 130px;
}

    .sub-menu.iteration {
        top: 40%;
        left: 160px;
    }

@media screen and (max-width: 1000px) {

    .sub-menu {
        transform: none;
        position: static;
        padding-left: 0;
        gap: 30px;
        padding-top: 30px;
        padding-bottom: 0;
    }

    .burger-menu form {
        margin-right: 9px;
    }

}

 /* Dropdown menu */

    .dropdown {
        position: relative;
        display: inline-block;
    }

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #282828;
    min-width: 160px;
    z-index: 2;
    color: white;
}

.dropdown .show {
    display: block;
}

        .dropdown-content button {
            background-color: #282828;
            color: white;
            width: 100%;
            border: none;
            padding: 12px 16px;
            display: block;
            cursor: pointer;
            text-align: left;
        }


.dropbtn {
    background-color: #282828;
    color: white;
    padding: 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;
    font-family: 'SF Pro Display', sans-serif;
}

/* Ticker */

.ticker {
    overflow: hidden;
    background: url("img/gradient.2892312fe8e7.png") no-repeat;
    background-size: cover;
    padding: 0.8vh 0;
    position: fixed;
    height: fit-content;
    width: 100%;
    z-index: 1;
}

@media screen and (min-width: 1000px) {
    .ticker {
        position: fixed;
        height: fit-content;
        width: 100%;
    }
}

.ticker * {
    cursor: pointer;
}

.ticker__wrapper {
    display: flex;
    gap: 16px;
}

.ticker__item {
    font-family: 'SF Pro Display', sans-serif;
    font-size: 22px;
    font-weight: 500;
    color: white;
    animation: ticker 10s linear infinite;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    gap: 16px;
}

@keyframes ticker {
    0% {
        transform: translateZ(0);
    }

    to {
        transform: translate3d(-100%, 0, 0);
    }
}


 /* Footer */

 footer {
    background-color: #282828;
}

footer .container {
    padding: 7vh 0;
    color: white;
    gap: 48px;
    display: flex;
    flex-direction: column;
}

.footer-row1 {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

.footer-row1 > div {
    display: flex;
    gap: 30px;
}

.footer-row2 {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}

footer a {
    color: white;
    text-decoration: none;
}

@media screen and (max-width: 1000px) {

    footer .container {
        padding: 3vh 5%;
        gap: 30px;
    }

    .footer-row1 {
        flex-direction: column;
        align-items: start;
        gap: 30px;
    }

    .footer-row1 > div {
        display: flex;
    }

    .footer-row2 {
        display: flex;
        flex-wrap: wrap;
    }
}

/* Fonts */

    * {
        font-family: 'SF Pro Display', sans-serif;
        line-height: 140%;
    }

    @media screen {

        h1 {
            font-size: 32px;
        }

        .article p, .article a {
            font-size: 18px;
        }

        .article h2 {
            font-size: 28px;
        }

        .article-author h3, .article-author h3 a,
        .article-author h2, .article-author h2 a {
            font-size: 22px;
        }

        h3, h3 a,
        .card-text h2, .card-text h2 a {
            font-size: 24px;
        }

        p, li, a, .form, summary, details {
            font-size: 16px;
        }

        .card-text p {
            font-size: 14px;
        }
    }



    /* Paddings */

    @media screen and (min-width: 1000px) {

        main {
            padding: 30px 0 50px 0;
        }

        .container {
            width: 72.5%;
            max-width: 1380px;
            margin: auto;
        }

        .menu {
            align-items: center;
        }
    }

    @media screen and (max-width: 1000px) {

        main {
            padding: 40px 5%;
        }
    }

    h1 {
        margin-bottom: 30px;
    }

   
    /* Article cards */

    .articles-container {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 20px;
    }

    .article-card {
        box-shadow: 0px 2px 11.6px rgba(0, 0, 0, 0.1);
        background-color: #1D1B1B;
    }

    .card-text p {
        opacity: 50%;
    }

    @media screen and (min-width: 1000px) {
        .article-card:nth-child(1) {
            width: calc(((100% - 40px) / 3 * 2) + 20px);
        }

        .article-card {
            width: calc((100% - 40px) / 3);
        }

        .recommended.article-card {
            width: calc((100% - 20px) / 2) !important;
        }

        .card-image {
            padding: 14px 16px;
        }

        .card-text {
            margin-bottom: auto;
        }

        .card-footer, .card-text {
            padding: 15px 17px;
        }

            .card-text h3, .card-text h2 {
                margin-bottom: 8px;
            }
    }

    @media screen and (max-width: 1000px) {

        .article-card {
            width: 100%;
            border-radius: 10px;
        }

        .card-image {
            padding: 17px 8px;
        }

        .card-footer, .card-text {
            padding: 15px 17px;
        }

            .card-text h3, .card-text h2 {
                margin-bottom: 8px;
            }
    }

    .card-image {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        height: 231px;
        align-content: start;
    }

        .card-image p, .article-image p {
            padding: 7px 8px;
            background: #FDFBEE;
            height: fit-content;
            color: black;
            border-radius: 10px;
        }

    .article-card {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .card-content {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
    }

        .card-content .card-image {
            flex-shrink: 0;
            height: 231px;
        }

    .card-footer {
        margin-top: auto;
    }

    .card-image-wrapper {
    position: relative;
    height: 231px;
}

.card-image-link {
    display: block;
}

.card-categories {
    position: absolute;
    top: 14px;
    left: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    z-index: 2;
}

.card-categories a {
    pointer-events: auto;
}

.card-image-link {
    pointer-events: auto;
}

.card-image-link {
    position: relative;
    z-index: 1;
}

.card-categories {
    position: absolute;
    top: 14px;
    left: 16px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.card-image p,
.card-categories p {
    padding: 7px 8px;
    background: #FDFBEE;
    color: black;
    border-radius: 10px;
}

.card-image-link,
.card-image {
    height: 100%;
}


    /* Article cards: hover, active, focus  */

    .article-card {
        transition: box-shadow 0.25s ease;
    }

    .article-card h3 a,
    .article-card h2 a,
    .article-card p {
        transition: color 0.25s ease, opacity 0.25s ease;
    }

     @media screen and (min-width: 1000px) {
        .article-card:hover {
            box-shadow: 0px 0px 20px 0px #00000033;
        }

        .article-card:hover h3 a,
        .article-card:hover h2 a {
            color: #FF8181;
        }

        .article-card:hover p {
            opacity: 1;
        }

        .article-card:active * {
            opacity: 0.4;
        }

        .article-card:focus {
            border: 1px solid #CE5050;
        }
     }


    /* Button */

    .btn {
        background-color: black;
        color: white;
        padding: 10px 15px;
        text-decoration: none;
        cursor: pointer;
        display: block;
        width: fit-content;
        font-weight: 600;
        font-size: 16px;
    }

    /* Article page */


    .article-image {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        height: 360px;
        border-radius: 10px;
    }

.article {
    padding: 50px 0;
    background: #1D1B1B;
}

.article-container {
    border-radius: 10px 10px 0 0;
    width: 100%;
}

.article-features {
    display: flex;
    gap: 30px;
    align-items: center;
}

.comments {
    padding-top: 30px;
    border-top: 1px solid #828282;
}

.article-text {
    padding-bottom: 40px;
}

/* Footnotes. At rest the marker takes the text colour of the theme; the open one is red, with the red the site
   already uses on each background. */
.article-body {
    --footnote-accent: #FF8181;
}

main.light .article-body {
    --footnote-accent: #b42318;
}

/* A wide table scrolls inside its figure instead of the page; the default 40px figure margins are too much on a phone. */
.article-body figure.table {
    max-width: 100%;
    overflow-x: auto;
    margin: 1em 0;
}

/* The oembed script in article.html sets width=560 height=315; every allowed host (EMBED_HOSTS) is 16:9. */
.article-body iframe {
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
}

/* The marker and the word before it; see add_marker in app/footnotes.py. */
.footnote-anchor {
    white-space: nowrap;
}

/* One circle for the marker, the number of its note and the marker in the cabinet editor. No padding, so the width
   comes from min-width alone and the circle stays round up to 99. */
.footnote-ref,
.footnote-number,
.ck-content sup.footnote {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid;
    border-radius: 10px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* Raised with `top`, not vertical-align: super, which would make the line taller. The gap before is narrower than
   the word space after, so the marker reads as part of its own word. */
.footnote-ref,
.ck-content sup.footnote {
    position: relative;
    top: -0.35em;
    margin: 0 2px;
    border-color: color-mix(in srgb, currentColor 50%, transparent);
    background: color-mix(in srgb, currentColor 10%, transparent);
    color: inherit;
    vertical-align: baseline;
    cursor: pointer;
    transition: color .15s, border-color .15s, background-color .15s;
}

.footnote-ref:hover,
.footnote-ref[aria-expanded="true"],
.footnote-number {
    border-color: var(--footnote-accent);
    background: color-mix(in srgb, var(--footnote-accent) 14%, transparent);
    color: var(--footnote-accent);
}

.footnote-ref:focus-visible {
    outline: 2px solid var(--footnote-accent);
    outline-offset: 2px;
}

/* The notes of one block form a group: closer to each other than to the next paragraph. It takes no room while
   all its notes are closed. */
.footnote-notes {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footnote-notes:has(> .footnote-note:not([hidden])) {
    margin: 8px 0 16px;
}

/* The text is dimmed, not the whole note, so its number keeps the full colour of the open marker. */
.footnote-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: color-mix(in srgb, currentColor 80%, transparent);
    font-size: 0.85em;
}

/* display: flex above would otherwise override the browser's own rule for the hidden attribute. */
.footnote-note[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .footnote-ref {
        transition: none;
    }
}

.comment {
    padding-top: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #4F4F4F;
}

.comment-form {
    display: flex;
    flex-direction: column;
}

.comment-btn {
    color: white;
    background: #EB5757;
    border: none;
    padding: 8px 16px;
    font-weight: bold;
    line-height: 140%;
    font-size: 18px;
    width: fit-content;
    margin-top: 15px;
    cursor: pointer;
}

.comment-input-name {
    width: 220px;
    line-height: 140%;
    font-size: 18px;
    padding: 8px;
    background: none;
    border: 1px solid #828282;
    border-radius: 4px;
    margin-bottom: 10px;
    color: white;
}

    .comment-input-name::placeholder {
        color: #828282;
    }

.comment-input-text {
    color: white;
    line-height: 140%;
    font-size: 18px;
    padding: 8px;
    background: none;
    border: 1px solid #828282;
    border-radius: 4px;
    margin-bottom: 15px;
}

.comment-input-text::placeholder {
    color: #828282;
}

.comment-description {
    font-weight: 500; 
    width: 50%; 
    font-size: 26px; 
    line-height: 140%; 
    margin-top: 30px; 
    margin-bottom: 20px;
}


@media screen and (min-width: 1000px) {
    .article-wrapper {
            display: flex;
            padding-top: 30px;
            padding-bottom: 50px;
            gap: 20px;
        }

        .article-container {
            flex-grow: 1;
        }


        .article-image {
            padding: 16px 15px;
        }

    .article-text, .comments, .recommended-articles {
        padding-left: 11%;
        padding-right: 11%;
    }

    .article-features {
        flex-direction: column;
    }

    }

    @media screen and (max-width: 1000px) {

        .article {
            padding: 40px 5%;
            padding-top: 25px;
        }

        .article-image {
            margin: 0 8px;
            padding: 16px 15px;
        }

        .article-features {
            margin-bottom: 50px;
            justify-content: space-between;
        }

        .comment-description {
            width: 100%; 
        }

        .article-features {
            margin-bottom: 30px;
            margin-top: 30px;
            gap: 15px;
            border: 1px solid #828282;
            width: fit-content;
            margin-left: 5%;
            margin-right: 5%;
            padding: 20px 12px;
            width: 90%;
        }

        .theme-switcher {
            margin-top: 0;
        }
        

    }

    .comments form.form {
        gap: 10px;
    }

        .comments form.form .btn {
            margin-top: 10px;
        }



    /* Forms */

    input.form, textarea.form {
        padding: 10px 15px;
        border-color: rgba(0, 0, 0, 0.1);
    }

    form.form {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    fieldset.form {
        border: 0;
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
    }

    .form .btn {
        margin-top: 10px;
    }

    /* Editor cabinet */

details {
    margin-top: 8px;
    margin-bottom: 8px;
}

.toggle {
    padding-inline-start: 0em;
    list-style-type: none;
}

    /* Indent toggle children */
    .toggle > li > details {
        padding-left: 1.7em;
    }

        .toggle > li > details > summary {
            margin-left: -1.1em;
        }

form.categories-form {
    flex-direction: row;
    gap: 0;
}

    form.categories-form input {
        height: fit-content;
        width: fit-content;
        padding: 4px;
    }

    form.categories-form .btn {
        margin-top: 0;
        padding: 4px;
    }

@media screen and (max-width: 1000px) {
    form.categories-form {
        flex-direction: column;
        gap: 5px;
        margin-bottom: 25px;
    }
}



.article-main {
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex-grow: 1;
}

main li {
    margin-left: 5%;
    margin-top: 5px;
    margin-bottom: 5px;
}

main p {
    margin-top: 5px;
    margin-bottom: 5px;
}

.article-card, .card-image {
    border-radius: 10px;
}


.article img {
    width: 100%;
    max-width: 100%;
}

h2 {
    margin-bottom: 15px;
}

.unpublished {
    position: relative;
}

    .unpublished::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
    }


@media screen and (min-width: 1000px) {
   .article-features {
        position: fixed;
    }
    .article-container {
        margin-left: 100px;
    }
}

/*
    Author blocks
*/

.article-author {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 35px;
}

.author-img-overlay {
    overflow: hidden;
    width: 50px;
    height: 50px;
    border-radius: 50px;
}

.article {
    display: flex;
    flex-direction: column;
}

.article-author {
    align-self: center;
}

/* Co-authors sit side by side and wrap; the outer block keeps the spacing one author used to have. */
.article-authors {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px 40px;
    margin-bottom: 35px;
}

    .article-authors .article-author {
        margin: 0;
    }

main {
    margin-top: 74px;
}

@media screen and (max-width: 1000px) {
   main {
        margin-top: 52px;
    }
}

/* Search form */

.search-form {
    display: flex;
    align-items: stretch;
    height: 35px;
    background: white;
    border: 1px solid #828282;
    width: fit-content;
}

.search-form .form-field {
    padding: 10px;
    border: none;
    border-color: white;
    font-family: 'SF Pro Display', sans-serif;
    width: 250px;
}

.search-form .form-field::placeholder {
    color: #828282;
    margin-left: 6px;
}

.search-button {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    margin-right: 5px;
}

/* Editor forms: article publish/edit and book create/edit share one layout */

.back-link {
    margin: 0 0 8px;
}

    .back-link a {
        text-decoration: none;
        opacity: .7;
    }

.section-title {
    margin: 32px 0 16px;
}

.editor-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 860px;
    color: black;
}

    .editor-form .field {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .editor-form .field-label {
        font-weight: 600;
        font-size: 15px;
    }

    .field-hint {
        font-size: 13px;
        color: #6b6b6b;
    }

    .editor-form input[type=text],
    .editor-form input[type=datetime-local],
    .editor-form select,
    .editor-form textarea {
        width: 100%;
        box-sizing: border-box;
        padding: 10px 14px;
        border: 1px solid rgba(0, 0, 0, .15);
        border-radius: 6px;
        background: white;
        color: black;
        font: inherit;
        font-size: 16px;
    }

    .editor-form textarea {
        resize: vertical;
    }

    .editor-form .form-group {
        /* A fieldset defaults to min-inline-size: min-content, so a file input pushed it past a 320px screen. */
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 14px;
        margin: 0;
        padding: 16px 20px 20px;
        border: 1px solid rgba(0, 0, 0, .1);
        border-radius: 8px;
    }

    .editor-form legend {
        padding: 0 6px;
        font-weight: 700;
    }

    .editor-form .ck-editor__editable {
        min-height: 220px;
    }

.choice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
}

    .choice-row label, label.choice-row span {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

/* The <li> stays a list item so the browser numbers the byline order; the row layout sits on the block inside it. */
.author-picker {
    margin: 0 0 8px;
    padding-left: 22px;
}

    .author-pick {
        padding: 2px 0;
    }

    .author-pick-row {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .author-pick-name {
        flex-grow: 1;
    }

.cover-field {
    display: flex;
    align-items: center;
    gap: 20px;
}

.cover-thumb {
    width: 160px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.cover-thumb--portrait {
    width: 90px;
    height: 135px;
}

.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

    .form-actions .btn, .editor-form .btn {
        margin-top: 0;
    }

.btn-secondary {
    background: white;
    color: black;
    box-shadow: inset 0 0 0 1px black;
}

main a.btn-secondary {
    color: black;
}

/* Book PDF files: container queries, not media queries, because the form is capped at 860px and the window
   says little about the room the section has. */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Not .book-files: that is the row of download buttons on the book page. */
.book-files-editor {
    container: book-files-editor / inline-size;
}

.book-files-layout {
    display: grid;
    gap: 20px;
}

.book-files-main {
    container: book-file-list / inline-size;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.book-file-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Narrow: the label takes the full width, the controls sit under it. */
.book-file {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "body body" "move actions";
    gap: 8px 12px;
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 8px;
    background: white;
}

.book-file-body {
    grid-area: body;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.book-file-move {
    grid-area: move;
    display: flex;
    align-items: center;
    gap: 4px;
}

.book-file-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    justify-self: end;
}

.book-file-number {
    min-width: 1.5em;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.book-file-meta, .book-file-pending-note {
    font-size: 13px;
    color: #595959;
    overflow-wrap: anywhere;
}

@container book-file-list (min-width: 440px) {
    .book-file {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "move body actions";
        align-items: start;
        padding-left: 6px;
    }

    .book-file-move {
        flex-direction: column;
        gap: 0;
    }
}

/* WCAG 2.5.8 asks for 24px; 44px on touch screens. */
.icon-button {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: black;
    cursor: pointer;
}

    .icon-button svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .icon-button:hover:not(:disabled) {
        background: rgba(0, 0, 0, .06);
    }

    .icon-button:disabled {
        color: #b3b3b3;
        cursor: default;
    }

.icon-button--danger {
    color: #b42318;
}

@media (pointer: coarse) {
    .icon-button {
        width: 44px;
        height: 44px;
    }
}

.book-file-restore, .book-file-pending-note {
    display: none;
}

.book-file[data-pending] {
    background: #f4f4f4;
}

    .book-file[data-pending] input[type=text] {
        text-decoration: line-through;
        color: #595959;
    }

    .book-file[data-pending] .book-file-meta, .book-file[data-pending] [data-remove] {
        display: none;
    }

    .book-file[data-pending] .book-file-pending-note {
        display: block;
    }

    .editor-form .book-file[data-pending] .book-file-restore {
        display: block;
        margin: 0;
        padding: 8px 14px;
        font-size: 14px;
    }

.book-file-progress {
    height: 4px;
    border-radius: 2px;
    background: #e6e6e6;
    overflow: hidden;
}

    .book-file-progress span {
        display: block;
        height: 100%;
        background: black;
        transition: width .2s;
    }

.book-file:not([data-state=uploading]):not([data-state=processing]) .book-file-progress {
    display: none;
}

/* The server reports no compression progress, so the bar only shows that it is working. */
.book-file[data-state=processing] .book-file-progress span {
    width: 40% !important;
    animation: book-file-working 1.2s ease-in-out infinite alternate;
}

@keyframes book-file-working {
    from { transform: translateX(-100%); }
    to { transform: translateX(250%); }
}

@media (prefers-reduced-motion: reduce) {
    .book-file[data-state=processing] .book-file-progress span {
        animation: none;
        width: 100% !important;
        opacity: .5;
    }
}

.book-file[data-state=failed] {
    background: #fdf3f2;
    border-color: rgba(180, 35, 24, .35);
}

    .book-file[data-state=failed] .book-file-meta {
        color: #b42318;
    }

.book-file[data-state=ready] .book-file-meta {
    color: #1a7f37;
}

.book-files-drop {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 64px;
    padding: 12px 16px;
    border: 2px dashed rgba(0, 0, 0, .25);
    border-radius: 8px;
    text-align: center;
    font-size: 15px;
    cursor: pointer;
}

    .book-files-drop svg {
        flex: none;
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
    }

    .book-files-drop:hover, .book-files-drop.is-dragover {
        border-color: black;
        background: #fafafa;
    }

    .book-files-drop:focus-within {
        outline: 2px solid black;
        outline-offset: 2px;
    }

/* Mirrors the download button of the book page on its dark background. */
.book-files-preview {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-radius: 10px;
    background: #262626;
    color: #FDFBEE;
}

.book-files-preview-title {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #c9c7bb;
}

.book-files-preview-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.book-files-preview-button {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 18px;
    border-radius: 8px;
    background: #CE5050;
    color: white;
    font-weight: 600;
    overflow-wrap: anywhere;
}

    .book-files-preview-button .btn-meta {
        font-size: 13px;
        font-weight: 400;
        opacity: .85;
    }

    .book-files-preview-button.is-waiting {
        background: #5b3b3b;
    }

    .book-files-preview-button.is-ghost {
        background: transparent;
        border: 2px dashed rgba(253, 251, 238, .35);
        color: #c9c7bb;
    }

.book-files-preview-note {
    margin: 0;
    font-size: 13px;
    color: #c9c7bb;
}

@container book-files-editor (min-width: 680px) {
    .book-files-layout {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
        align-items: start;
    }

    /* Sticky only side by side (stacked it would cover the rows); the offset clears the fixed header. */
    .book-files-preview {
        position: sticky;
        top: 110px;
    }
}

main a.danger-link {
    color: #b42318;
}

.badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fff4d6;
    color: #7a5200;
}

/* Book page */

.book-page {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 48px;
    align-items: start;
    margin: 16px 0 64px;
}

.book-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 10px;
    background: #1c1b1b;
}

.book-info {
    /* A grid item defaults to min-width: auto, so a wide child stretches the 1fr column. */
    min-width: 0;
}

.book-info h1 {
    margin: 0 0 8px;
}

.book-author {
    margin: 0 0 20px;
    font-size: 18px;
    opacity: .7;
}

.book-summary {
    margin: 0 0 28px;
    font-size: 18px;
    line-height: 1.5;
}

.book-files {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.btn-download {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    background: #CE5050;
    color: white;
    border-radius: 8px;
    padding: 12px 18px;
}

main a.btn-download {
    color: white;
}

    .btn-download .btn-meta {
        font-size: 13px;
        font-weight: 400;
        opacity: .85;
    }

.book-annotation {
    margin-top: 40px;
    padding-top: 28px;
    border-top: 1px solid rgba(253, 251, 238, .15);
}

    .book-annotation h2 {
        margin: 0 0 12px;
    }

/* Editor images keep fixed width/height attributes, and `.article img` does not reach this page. */
.book-annotation img {
    max-width: 100%;
    height: auto;
}

@media screen and (max-width: 800px) {
    .book-page {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .book-cover {
        max-width: 240px;
    }

    .cover-field {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Editor form fixes: `hidden` must win over flex, one border per button, no list indent */
.editor-form [hidden] {
    display: none !important;
}

.editor-form button.btn, .form-actions .btn {
    border: 1px solid black;
}

.btn-secondary {
    box-shadow: none;
    border: 1px solid black;
}


/* Editor cabinet: section navigation and compact admin lists (articles, books, authors) */

.cabinet-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: 15px;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.cabinet-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 8px;
}

    main .cabinet-nav a {
        padding: 6px 12px;
        border: 1px solid rgba(0, 0, 0, .15);
        border-radius: 999px;
        text-decoration: none;
        font-size: 14px;
    }

        main .cabinet-nav a:hover {
            border-color: black;
        }

.cabinet-section {
    margin-top: 40px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, .08);
    scroll-margin-top: 16px;
}

.admin-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-width: 860px;
}

    .admin-list > li {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 10px 0;
        border-bottom: 1px solid rgba(0, 0, 0, .08);
    }

.admin-thumb {
    width: 64px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: #eee;
}

.admin-thumb--portrait {
    width: 32px;
    height: 48px;
}

.admin-thumb--round {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.admin-row-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

main a.admin-row-title {
    font-weight: 600;
    text-decoration: none;
}

.admin-actions {
    display: inline-flex;
    gap: 16px;
    flex-shrink: 0;
    font-size: 14px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
    max-width: 860px;
}

    .inline-form[hidden] {
        display: none;
    }

    .inline-form input[type=text] {
        flex: 1 1 200px;
        padding: 8px 12px;
        border: 1px solid rgba(0, 0, 0, .15);
        border-radius: 6px;
        font: inherit;
    }

    .inline-form .btn {
        margin: 0;
        border: 1px solid black;
    }

.category-tree summary {
    display: flex;
    align-items: baseline;
    gap: 12px;
    cursor: pointer;
}

.category-delete {
    font-size: 14px;
}

.link-button + .inline-form, details > .link-button {
    margin: 6px 0;
    font-size: 14px;
}

.add-panel {
    margin-top: 16px;
    max-width: 860px;
}

    .add-panel > summary {
        cursor: pointer;
        font-weight: 600;
        margin-bottom: 16px;
    }

@media screen and (max-width: 700px) {
    .admin-list > li {
        flex-wrap: wrap;
    }

    .admin-actions {
        width: 100%;
        padding-left: 78px;
    }
}

/* The site-wide list indent does not belong in admin lists */
.admin-list > li, .category-tree li {
    margin-left: 0;
}

.category-tree summary {
    list-style: none;
}

    .category-tree summary::before {
        content: '▸';
        width: 1em;
        opacity: .6;
    }

.category-tree details[open] > summary::before {
    content: '▾';
}
