/* Update removal is secondary to the story link, and works on narrow screens. */
html body main .dashboard-updates :is(.gm-update-remove, .gm-clear-updates) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    min-height: 36px;
    margin: 8px 0 0 !important;
    padding: 7px 12px !important;
    border: 1px solid var(--ui-border, #a79ca0) !important;
    border-radius: 8px !important;
    background: var(--ui-soft, #eee9e7) !important;
    color: var(--ui-ink, #29262b) !important;
    -webkit-text-fill-color: var(--ui-ink, #29262b) !important;
    font: 600 .8rem/1.2 var(--font-ui, sans-serif) !important;
    box-shadow: none !important;
    cursor: pointer;
}
html body main .dashboard-updates :is(.gm-update-remove, .gm-clear-updates):disabled {
    opacity: .6;
    cursor: wait;
}
html body main .dashboard-updates .library-panel-heading { flex-wrap: wrap; }
html body main #clear-library-updates-message:empty { display: none; }

/* Writing and reading tools use the current skin's paired surface/text tokens. */
.gm-next-panel, .gm-next-dialog { color: var(--ui-ink, var(--text-color, #252b2f)); background: var(--ui-panel, var(--ui-field, #edf2f4)); border: 1px solid var(--ui-border, #80949d); border-radius: 14px; padding: 1.2rem; }
.gm-next-panel { margin: 1.3rem 0; }
.gm-next-panel summary { cursor: pointer; font-weight: 700; padding: .2rem 0; }
.gm-next-panel h2, .gm-next-dialog h2 { margin: 0 0 .7rem; }
.gm-next-panel p, .gm-next-dialog p { color: inherit; }
.gm-next-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .8rem 0; }
.gm-next-panel button, .gm-next-dialog button, .gm-next-panel .button-link { color: var(--ui-ink, #252b2f); background: var(--ui-field, #f2f6f7); border: 1px solid var(--ui-border, #80949d); padding: .65rem .9rem; border-radius: 9px; cursor: pointer; font: inherit; }
.gm-next-panel a, .gm-next-panel a:visited, .gm-next-dialog a, .gm-next-dialog a:visited { color: var(--ui-link, var(--ui-ink, #314e59)); }
.gm-next-panel button:disabled, .gm-next-dialog button:disabled { opacity: .55; cursor: default; }
.gm-next-panel label, .gm-next-dialog label { display: block; font-weight: 600; margin: .7rem 0 .25rem; }
.gm-next-panel input[type=text], .gm-next-panel input[type=search], .gm-next-panel textarea, .gm-next-dialog input[type=search], .gm-next-dialog input[type=text] { width: 100%; box-sizing: border-box; color: var(--ui-ink, #252b2f); background: var(--ui-field, #f2f6f7); border: 1px solid var(--ui-border, #80949d); border-radius: 8px; padding: .65rem; font: inherit; }
.gm-next-panel .gm-next-check { display: inline-flex; gap: .4rem; align-items: center; margin-right: 1rem; font-weight: 400; }
.gm-next-dialog { width: min(700px, calc(100vw - 2rem)); max-height: 85vh; box-sizing: border-box; overflow-y: auto; }
.gm-next-dialog::backdrop { background: rgb(0 0 0 / .6); }
.gm-next-dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.gm-next-results { display: grid; gap: .8rem; max-height: 45vh; overflow-y: auto; overflow-wrap: anywhere; }
.gm-next-result { border-top: 1px solid var(--ui-border, #80949d); padding-top: .7rem; }
.gm-next-result p { margin: .3rem 0 .7rem; font-size: .95em; white-space: pre-wrap; }
.gm-next-status { font: .9rem/1.5 system-ui, sans-serif; margin: .5rem 0; min-height: 1.4em; color: inherit; }
.gm-next-savebar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .4rem 0 0; }
.gm-next-savebar button { font: inherit; padding: .4rem .65rem; }
.gm-next-outline-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.gm-next-outline-grid textarea { min-height: 230px; resize: vertical; }
.gm-next-diff { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.gm-next-diff span { white-space: pre-wrap; padding: .5rem; border: 1px solid var(--ui-border, #80949d); border-radius: 6px; }
.gm-next-panel [hidden], .gm-next-dialog [hidden] { display: none !important; }
@media(max-width:600px) { .gm-next-outline-grid, .gm-next-diff { grid-template-columns: 1fr; } .gm-next-panel { padding: .9rem; } .gm-next-actions button { flex: 1 1 auto; } }

.gm-work-export-options { position: relative; color: var(--ui-ink); }
.gm-work-export-options > summary { list-style: none; cursor: pointer; border: 1px solid var(--ui-border); background: var(--ui-field); color: var(--ui-ink); border-radius: 9px; padding: .65rem .9rem; font: inherit; }
.gm-work-export-options > summary::after { content: " ▾"; }
.gm-work-export-options[open] > .gm-next-actions { position: absolute; z-index: 5; left: 0; top: 100%; width: max-content; max-width: min(320px,80vw); background: var(--ui-field); border: 1px solid var(--ui-border); padding: .8rem; border-radius: 10px; box-shadow: 0 6px 20px rgb(0 0 0 / .2); }
.gm-next-savebar { color: var(--ui-ink); background: transparent; padding: 0; }
.gm-next-savebar .gm-next-status { color: inherit !important; }
.gm-crossover-label { font-size: .85em; }

/* Keep occasional maintenance actions out of the writing flow. */
.gm-next-savebar .gm-next-status { margin: 0; font-size: .8rem; min-height: 1.2em; }
.gm-desk-utilities { display: flex; justify-content: flex-end; margin: 1rem 0 0; }
body main.writing-desk button.gm-desk-utility-link {
    background: transparent !important; color: var(--ui-ink) !important;
    border: 0 !important; box-shadow: none !important; border-radius: 4px !important;
    padding: .35rem .5rem !important; min-height: 40px; width: auto !important;
    font-size: .85rem !important; font-weight: 400 !important; text-decoration: underline;
    text-underline-offset: .2em; cursor: pointer;
}
body main.writing-desk button.gm-desk-utility-link:hover { text-decoration-thickness: 2px; }
body main.writing-desk button.gm-desk-utility-link:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 3px; }

/* Pasted/imported prose must use the active theme, including old saved chapters.
   Presentation only: no chapter content or saved formatting is rewritten. */
body main :is(#published-chapter-text, #preview-chapter-text, #chapter-text, #edit-chapter-text) {
    color: var(--ui-ink, #29262b) !important;
    background: var(--ui-field, #fffdf9) !important;
    -webkit-text-fill-color: currentColor !important;
}
body main :is(#published-chapter-text, #preview-chapter-text, #chapter-text, #edit-chapter-text)
    :is(p, span, font, div, section, article, blockquote, pre, code, h1, h2, h3, h4, h5, h6, strong, b, em, i, u, s, strike, del, sub, sup, small, ul, ol, li, a):not(.text-conversation, .text-conversation *, .gm-margin-comment-marker, .gm-margin-comment-marker *) {
    color: inherit !important; background: transparent !important;
    -webkit-text-fill-color: currentColor !important;
}
/* Keep the site's paired text-message bubble colors. */
body main :is(#published-chapter-text, #preview-chapter-text, #chapter-text, #edit-chapter-text) :is(.text-conversation, .text-conversation *) {
    -webkit-text-fill-color: currentColor !important;
}

/* Follow stays at the top; moderation controls sit quietly below profile stats. */
body main.author-page .gm-author-controls {
    margin: 1rem 0 1.4rem; padding: .7rem 0;
    border-top: 1px solid var(--ui-border); color: var(--ui-ink);
}
body main.author-page .gm-author-controls[hidden] { display: none !important; }
body main.author-page .gm-author-controls summary {
    width: fit-content; font: 600 .85rem/1.5 var(--font-ui, system-ui);
    cursor: pointer; padding: .35rem 0;
}
body main.author-page .gm-author-controls p {
    font: .85rem/1.5 var(--font-ui, system-ui); color: inherit; margin: .5rem 0;
}
body main.author-page .gm-author-controls-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
body main.author-page .gm-author-controls-actions button {
    width: auto !important; max-width: 100%; margin: 0 !important;
    min-height: 44px; padding: .55rem .8rem !important;
    font-size: .85rem !important; white-space: normal;
}
body main.author-page .author-heading-actions { justify-content: flex-start; min-width: 0; }
body main.author-page .author-heading-actions button { max-width: 100%; white-space: normal; }
@media (max-width: 600px) {
    body main.author-page .author-heading-row { flex-wrap: wrap; gap: .6rem; }
    body main.author-page .author-heading-actions { width: 100%; }
    body main.author-page .author-heading-actions button { width: auto !important; margin: 0 !important; min-height: 44px; }
}

/* Mobile chapter pages share one small outer margin and one comment lane.
   Width controls and saved font sizes continue to apply on larger screens. */
@media (max-width: 700px) {
    html body main.gm-chapter-reader {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 16px auto 24px !important;
        padding: 0 12px 32px !important;
        box-sizing: border-box !important;
    }
    html body main.gm-chapter-reader > :is(.chapter-header, #published-notes, #published-chapter-text, .chapter-navigation, .chapter-comments) {
        width: 100%; max-width: 100% !important; min-width: 0;
        box-sizing: border-box; overflow-wrap: anywhere;
    }
    html body main.gm-chapter-reader .chapter-header {
        margin: 0 auto; padding: 0 0 12px; text-align: center;
    }
    html body main.gm-chapter-reader #published-chapter-heading {
        width: 100%; max-width: 100%; min-width: 0;
        margin: 0 0 12px; padding: 0 0 12px; box-sizing: border-box;
        font-size: clamp(1.5rem, 6.5vw, 2rem) !important;
        line-height: 1.25; text-align: center !important;
        white-space: normal !important; overflow-wrap: anywhere;
    }
    html body main.gm-chapter-reader #published-work-title {
        max-width: 100%; white-space: normal; overflow-wrap: anywhere;
    }
    html body main.gm-chapter-reader .chapter-meta { flex-wrap: wrap; gap: .5rem 1rem; }
    html body main.gm-chapter-reader #published-notes {
        margin: .5rem 0 1rem; padding: 0 !important;
        white-space: pre-wrap; overflow-wrap: anywhere;
    }
    html body main.gm-chapter-reader #published-chapter-text {
        padding: 12px 28px 16px 0 !important;
        overflow: visible; overflow-wrap: anywhere;
    }
    html body main.gm-chapter-reader #published-chapter-text .gm-margin-target {
        padding-right: 0 !important; min-width: 0; max-width: 100%;
        box-sizing: border-box; overflow-wrap: anywhere;
    }
    html body main.gm-chapter-reader #published-chapter-text .gm-margin-comment-marker {
        right: -28px !important; top: .18em;
    }
    html body.gm-hide-margin-comments main.gm-chapter-reader #published-chapter-text {
        padding-right: 0 !important;
    }
    html body main.gm-chapter-reader #published-chapter-text :is(img, video, iframe) {
        max-width: 100% !important; height: auto;
    }
    html body main.gm-chapter-reader #published-chapter-text pre { white-space: pre-wrap; }
}

/* Keep collectible artwork legible without widening narrow Updates cards. */
html body main .dashboard-updates .gm-stamp-update { display: flex; align-items: flex-start; gap: 14px; }
html body main .dashboard-updates .gm-stamp-update-art { width: 72px; height: 72px; flex: 0 0 72px; object-fit: contain; }
html body main .dashboard-updates .gm-stamp-update-body { min-width: 0; flex: 1; overflow-wrap: anywhere; }
html body main .dashboard-updates .gm-stamp-update-body button + button { margin-left: 8px !important; }
@media(max-width: 400px) {
 html body main .dashboard-updates .gm-stamp-update { gap: 10px; }
 html body main .dashboard-updates .gm-stamp-update-art { width: 56px; height: 56px; flex-basis: 56px; }
}
