/* Use paired control colors for disclosure panels in every theme. */
html body main #work-details-later {
    background: var(--ui-soft, #eee9e7) !important;
    color: var(--ui-ink, #29262b) !important;
    border-color: var(--ui-border, #a79ca0) !important;
}
html body main #work-details-later > summary,
html body main #work-details-later > summary :is(strong, small, .details-chevron) {
    background: transparent !important;
    color: var(--ui-ink, #29262b) !important;
    -webkit-text-fill-color: var(--ui-ink, #29262b) !important;
}
html body main #work-details-later > summary small { opacity: .85; }
html body main #work-details-later > summary { min-height: 72px; }

/* Draft creation: one primary action, followed by a quieter return action. */
html body main .quick-start-actions {
    justify-content: flex-start !important;
    align-items: center;
}
html body main #save-work-draft.secondary-save-draft {
    --ui-action-bg: var(--ui-field);
    --ui-action-ink: var(--ui-ink);
    background: var(--ui-field) !important;
    color: var(--ui-ink) !important;
    opacity: 1;
}

/* One grouped horizontal rail on desktop and mobile. */
html body main :is(#new-chapter-form, #edit-chapter-form) .chapter-toolbar.gm-grouped-toolbar {
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin !important;
    scrollbar-color: var(--ui-border, #a79ca0) var(--ui-field, #fffdf9);
    background: var(--ui-field, #fffdf9) !important;
    color: var(--ui-ink, #29262b) !important;
    border-color: var(--ui-border, #a79ca0) !important;
    box-sizing: border-box !important;
}
html body main :is(#new-chapter-form, #edit-chapter-form) .chapter-toolbar.gm-grouped-toolbar::after { display: none !important; }
html body main :is(#new-chapter-form, #edit-chapter-form) .chapter-toolbar.gm-grouped-toolbar::-webkit-scrollbar {
    display: block !important;
    width: auto !important;
    height: 6px !important;
}
html body main :is(#new-chapter-form, #edit-chapter-form) .chapter-toolbar.gm-grouped-toolbar::-webkit-scrollbar-thumb {
    background: var(--ui-border, #a79ca0);
    border-radius: 999px;
}
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar > .gm-editor-row {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-flow: row nowrap !important;
    align-items: center;
    gap: 8px !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    white-space: nowrap !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
}
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar .gm-editor-group {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    min-width: 0;
    padding-inline-end: 8px;
    border-inline-end: 1px solid var(--ui-border, #a79ca0);
}
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar .gm-editor-group:last-child { padding-inline-end: 0; border: 0; }
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar .gm-editor-inserts {
    padding-inline-start: 10px !important;
    border-top: 0;
    border-inline-start: 1px solid var(--ui-border, #a79ca0);
}
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar :is(button, select) {
    flex: 0 0 auto;
    width: auto !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    white-space: nowrap !important;
    box-sizing: border-box;
}
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar :is(.gm-history-button, button[data-format]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    min-width: 44px !important;
    padding: 0 !important;
}
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar .gm-history-button svg { width: 20px; height: 20px; }
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar #chapter-font { width: 132px !important; min-width: 0 !important; }
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar #chapter-size { width: 88px !important; min-width: 0 !important; }
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar #chapter-align { width: 104px !important; min-width: 0 !important; }
html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar #writer-tools-toggle { margin: 0 !important; }
@media (max-width: 700px) {
    html body main :is(#new-chapter-form, #edit-chapter-form) .chapter-toolbar.gm-grouped-toolbar { padding: 8px !important; }
    html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar #chapter-font { width: 124px !important; }
    html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar #chapter-size { width: 76px !important; }
    html body main :is(#new-chapter-form, #edit-chapter-form) .gm-grouped-toolbar #chapter-align { width: 92px !important; }
}

/* Match the typing caret to the editor ink in light and dark themes. */
html body main :is(#chapter-text, #edit-chapter-text) {
    caret-color: currentColor !important;
}
html body main :is(#chapter-text, #edit-chapter-text) * {
    caret-color: inherit !important;
}


/* Keep scene-break choices beside the sticky toolbar, even deep in a chapter. */
html body > #scene-break-picker.gm-floating-scene-picker {
    position: fixed !important;
    z-index: 1000 !important;
    box-sizing: border-box;
    width: 330px;
    margin: 0 !important;
    padding: 10px;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--ui-border, #a79ca0);
    border-radius: 8px;
    background: var(--ui-field, #fffdf9);
    color: var(--ui-ink, #29262b);
    box-shadow: 0 6px 22px rgba(0, 0, 0, .2);
}
html body > #scene-break-picker.gm-floating-scene-picker[hidden] { display: none !important; }
html body > #scene-break-picker.gm-floating-scene-picker button {
    flex: 1 0 70px;
    min-height: 44px;
    margin: 0;
    background: var(--ui-soft, #eee9e7) !important;
    color: var(--ui-ink, #29262b) !important;
    border: 1px solid var(--ui-border, #a79ca0);
    border-radius: 5px;
}
