/* Shared authoring controls. Loaded after workspace layout styles.
   Keep geometry stable across hover/focus. Public prose is intentionally excluded. */
.homer-ui {
    --homer-control-height:36px;
    --homer-control-font:14px;
    --homer-control-gap:8px;
    --homer-primary:var(--wa-colors-default-main-primary-medium,#1e6d9e);
    --homer-primary-hover:var(--wa-colors-default-main-primary-bright,#2483bd);
    --homer-primary-active:var(--wa-colors-default-main-primary-dark,#185880);
    --homer-create:var(--wa-colors-default-main-create-medium,#0b4b26);
    --homer-create-hover:var(--wa-colors-default-main-create-bright,#07612f);
    --homer-create-active:var(--wa-colors-default-main-create-dark,#002e16);
    --homer-danger-hover:var(--wa-colors-default-main-danger-bright,#9f0e11);
    --homer-danger-active:var(--wa-colors-default-main-danger-dark,#560608);
    --homer-button-neutral:var(--homer-panel);
    --homer-button-hover:var(--homer-border);
    --homer-tab-surface:var(--homer-bg);
}
/* All application chrome has square corners, including third-party editor chrome. */
.homer-ui :is(button,input,select,textarea,.btn,.nav-link,.dropdown-menu,.modal-content,.alert,.badge,.homer-manuscript-tile,.homer-corkboard-chapter,.homer-corkboard-scene,.homer-word-goal,.homer-stats-table-wrap,.tox-tinymce,.tox-tbtn,.tox-menu) {
    border-radius:0 !important;
}
/* Form values retain the same surface when focused; only the focus indicator changes. */
.homer-ui.homer-ui :is(input.form-control,textarea.form-control,select.form-control,.homer-input):not(.homer-corkboard-scene *) {
    box-sizing:border-box; background-color:var(--homer-input) !important;
    color:var(--homer-text) !important; border:1px solid var(--homer-border) !important;
    font-family:inherit; font-size:var(--homer-control-font); padding:7px 10px; box-shadow:none;
}
.homer-ui.homer-ui :is(input.form-control,select.form-control):not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([multiple]):not(.homer-corkboard-scene *) { height:var(--homer-control-height); min-height:var(--homer-control-height); }
.homer-ui.homer-ui textarea.form-control { line-height:1.5; min-height:96px; }
.homer-ui.homer-ui :is(input,select,textarea):not([type="hidden"]):focus-visible { outline:2px solid var(--homer-accent); outline-offset:1px; }
.homer-ui.homer-ui :is(input,select,textarea):disabled { opacity:.55; cursor:not-allowed; }
.homer-ui.homer-ui :is(input,textarea)[readonly] { color:var(--homer-muted) !important; }
.homer-ui .form-control-description { font-size:12px; line-height:1.5; margin:6px 0 0; }
.homer-ui :is(input[type="checkbox"],input[type="radio"]) { accent-color:var(--homer-accent); vertical-align:middle; margin-right:6px; }
/* Semantic button variants match Prodromos; navigation is a separate component. */
.homer-ui .btn:not(.mode-change) { box-sizing:border-box; min-height:var(--homer-control-height); font-size:var(--homer-control-font); line-height:20px; padding:7px 12px; font-family:inherit; box-shadow:none; }
.homer-ui .btn.btn-primary:not(.mode-change):not(.homer-label-add) { background:var(--homer-primary) !important; color:#ebeef5 !important; border-color:transparent !important; font-weight:400; }
.homer-ui .btn.btn-primary:not(.mode-change):not(.homer-label-add):is(:hover,:focus-visible) { background:var(--homer-primary-hover) !important; }
.homer-ui .btn.btn-primary:not(.mode-change):not(.homer-label-add):active { background:var(--homer-primary-active) !important; }
.homer-ui :is(.btn.btn-success,.homer-settings-action-create) { background:var(--homer-create) !important; color:#ebeef5 !important; border-color:transparent !important; font-weight:700; }
.homer-ui :is(.btn.btn-success,.homer-settings-action-create):is(:hover,:focus-visible) { background:var(--homer-create-hover) !important; }
.homer-ui :is(.btn.btn-success,.homer-settings-action-create):active { background:var(--homer-create-active) !important; }
.homer-ui :is(.btn.btn-secondary,.btn.btn-default):not(.mode-change) { background:var(--homer-button-neutral) !important; color:var(--homer-text) !important; border:1px solid var(--homer-border); }
.homer-ui :is(.btn.btn-secondary,.btn.btn-default):not(.mode-change):is(:hover,:focus-visible) { background:var(--homer-button-hover) !important; }
.homer-ui :is(.btn.btn-danger,.homer-settings-action-delete) { background:#47484a !important; color:#ebeef5 !important; border-color:transparent !important; }
.homer-ui :is(.btn.btn-danger,.homer-settings-action-delete):hover { background:var(--homer-danger-hover) !important; }
.homer-ui :is(.btn.btn-danger,.homer-settings-action-delete):is(:active,:focus-visible) { background:var(--homer-danger-active) !important; }
.homer-ui .btn:disabled,.homer-ui .btn.disabled { opacity:.5; cursor:not-allowed; }
.homer-ui :is(button,a):focus-visible { outline:2px solid var(--homer-accent); outline-offset:2px; }
/* Icon actions stay square. Full-width actions can wrap without clipping. */
.homer-ui .homer-label-manager :is(.homer-label-add,.homer-label-remove) { padding:0; width:var(--homer-control-height); height:var(--homer-control-height); }
.homer-ui .homer-tree-create-actions button { border-radius:0; }
/* Prodromos secondary tabs: neutral hover, selected tab joins the pane. */
.homer-ui.homer-ui .nav-tabs { gap:0; border:0; }
.homer-ui.homer-ui .nav-tabs .nav-link {
    border:0 !important; border-radius:0 !important; box-shadow:none !important;
    padding:14px 20px; font-weight:400; color:var(--homer-muted); text-decoration:none;
}
.homer-ui.homer-ui .nav-tabs .nav-link:not(.active):is(:hover,:focus-visible) { background:var(--homer-panel) !important; color:var(--homer-muted) !important; }
.homer-ui.homer-ui .nav-tabs .nav-link.active,
.homer-ui.homer-ui .nav-tabs .nav-link.active:is(:hover,:focus-visible) { background:var(--homer-tab-surface) !important; color:var(--homer-text) !important; }
.homer-ui .homer-settings-header { --homer-tab-surface:var(--homer-settings-surface); }
.homer-ui.homer-ui .nav-tabs .nav-link :is(i,span,svg) { color:inherit !important; }
.homer-ui.homer-ui .nav-tabs .nav-link:focus-visible { outline-offset:-3px; }
/* Top-level modes retain their taller toolbar geometry and neutral hover. */
.homer-ui.homer-ui .homer-display-navigation :is(.mode-change,a):not(.active):hover { background:var(--homer-panel) !important; color:var(--homer-text) !important; text-decoration:none; }
.homer-ui.homer-ui .homer-display-navigation .mode-change.active { background:var(--homer-bg) !important; color:var(--homer-text) !important; }
/* Text links are underlined on hover; button and navigation labels never are. */
.homer-ui a:not(.btn):not(.nav-link):not(.mode-change):not(.homer-reader-prose a):hover { text-decoration:underline; }
.homer-ui :is(.btn,.nav-link,.mode-change):hover { text-decoration:none !important; }
.homer-ui .dropdown-menu .dropdown-item { color:var(--homer-text); border-radius:0; }
.homer-ui .dropdown-menu .dropdown-item:is(:hover,:focus-visible) { background:var(--homer-selected); color:var(--homer-text); }
/* Side-panel form spacing is shared by scene, chapter, image, and manuscript tabs. */
.homer-ui #homer-right-content .homer-tab-content-item { margin:0 0 20px; }
.homer-ui #homer-right-content .header-title { margin:0 0 8px; }
.homer-ui #homer-right-content .homer-tab-content-item-container { margin-left:0; }
.homer-ui #homer-right-content .form-control { margin-bottom:0; }
.homer-ui #homer-manuscript-delete .ibox-content { background:var(--homer-panel); border:1px solid var(--homer-border); padding:20px; color:var(--homer-text); }
.homer-ui #homer-manuscript-delete form .btn { margin-top:12px; }
@media(prefers-reduced-motion:reduce) {
    .homer-ui :is(.btn,.nav-link,.dropdown-item,input,select,textarea) { transition:none !important; }
}
/* Intentional compact controls and paper-coloured Cancel actions. */
.homer-ui .homer-tree-create-actions .btn { min-height:28px; padding:0; }
/* A text action uses button semantics without a button surface. */
.homer-ui .homer-corkboard-edit-actions .homer-corkboard-edit-cancel {
    appearance:none; display:inline; width:auto; min-width:0; height:auto; min-height:0;
    padding:0; margin:0; border:0 !important; background:transparent !important;
    box-shadow:none !important; color:var(--homer-text) !important; opacity:1;
    font:inherit; line-height:1.5; text-align:left; cursor:pointer;
}
.homer-ui .homer-corkboard-scene .homer-corkboard-edit-actions .homer-corkboard-edit-cancel { color:var(--cork-ink) !important; }
.homer-ui .homer-corkboard-edit-actions .homer-corkboard-edit-cancel:is(:hover,:focus-visible) {
    background:transparent !important; text-decoration:underline;
}
.homer-ui .btn.btn-sm:not(.mode-change) { min-height:28px; padding:3px 8px; font-size:12px; line-height:20px; }
.homer-ui #athena-article-top-nav { display:flex; flex-wrap:wrap; align-items:center; gap:4px; }
.homer-ui #athena-article-top-nav .btn { margin:0; }


/* Borderless Manuscripts dialogs over a darker, shared backdrop. */
.homer-ui .modal .modal-content,
body.homer-editor-page .modal .modal-content {
    border:0 !important;
    outline:0;
    border-radius:0 !important;
}
body:has(.homer-ui) > .modal-backdrop { background-color:#000; }
body:has(.homer-ui) > .modal-backdrop.show,
body:has(.homer-ui) > .modal-backdrop.in { opacity:.85; }

/* Word statistics use violet, distinct from primary actions and Create. */
.homer-ui #homer-wordcount-module { background:#59417f !important; border-color:#795ba5 !important; color:#fff !important; }
.homer-ui #homer-wordcount-module:is(:hover,:focus-visible) { background:#6a4e95 !important; border-color:#9474bd !important; }
.homer-ui #homer-wordcount-module:active { background:#493469 !important; }
.homer-ui .homer-toolbar-actions .homer-public-view { display:inline-flex; align-items:center; gap:6px; }

/* Review uses the same label strip and draft controls as Corkboard. */
.homer-ui .homer-synopsis-card { position:relative; padding-top:24px; }
.homer-ui .homer-synopsis-card > .homer-corkboard-label-strip { position:absolute; top:0; left:0; width:100%; }
.homer-ui .homer-review-goal { display:inline-flex; gap:10px; align-items:center; color:var(--homer-text); }
.homer-ui .homer-review-done { padding:3px 7px; background:var(--homer-create); color:#fff; font-size:11px; }
.homer-ui .homer-review-done[hidden] { display:none; }
.homer-ui .homer-synopsis-wordcount { display:inline-flex; align-items:center; gap:6px; }
.homer-ui .homer-review-insert { list-style:none; margin:12px 0; }
.homer-ui .homer-review-draft { list-style:none; padding:16px; border:1px solid var(--homer-border); background:var(--homer-panel); margin:12px 0; }
.homer-ui .homer-review-draft .homer-corkboard-edit-form { display:block; margin:0; }
.homer-ui .homer-review-draft .homer-corkboard-edit-form > label { display:block; margin:12px 0; color:var(--homer-text); }
.homer-ui .homer-review-draft .homer-corkboard-edit-actions .homer-corkboard-edit-cancel { color:var(--homer-text) !important; }
.homer-ui .homer-review-draft .homer-corkboard-draft-label { position:static; width:100%; height:36px; padding:6px 10px; background:var(--homer-input); color:var(--homer-text); border:1px solid var(--homer-border); transition:none; }


.homer-ui .homer-synopsis-card > .homer-synopsis-body-field[hidden],
.homer-ui .homer-synopsis-card > .homer-synopsis-tags[hidden] { display:none !important; }
.homer-ui .homer-review-collapsed .homer-synopsis-metadata { margin-bottom:0; }

.homer-ui .homer-review-grip { flex:0 0 28px; width:28px; height:36px; border:0; padding:0; color:var(--homer-muted); background:transparent; cursor:grab; touch-action:none; }
.homer-ui .homer-review-grip:hover { color:var(--homer-text); background:var(--homer-panel); }
.homer-ui .homer-review-grip:active { cursor:grabbing; }
.homer-ui .homer-review-placeholder { list-style:none; border:2px dashed var(--homer-accent); background:var(--homer-selected); margin-bottom:16px; }
.homer-ui .homer-review-list > .ui-sortable-helper { list-style:none; }
.homer-ui .homer-review-order-status:empty { display:none; }
.homer-ui .homer-review-order-status { color:var(--homer-muted); font-size:12px; }

.homer-ui .parts-synopsis > .homer-review-toolbar { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:16px; width:100%; margin:0 0 16px; text-align:left; }
.homer-ui .homer-review-toolbar > h1 { margin:0 !important; padding:0; min-width:0; width:100%; max-width:none; text-align:left !important; justify-self:start; overflow-wrap:anywhere; }
.homer-ui .homer-review-toolbar > .btn.homer-review-collapse-all {
    display:inline-flex; align-items:center; justify-content:center; justify-self:end;
    box-sizing:border-box; height:var(--homer-control-height); min-height:var(--homer-control-height);
    margin:0 !important; padding:0 12px !important; width:auto; font-size:14px; line-height:20px;
    font-weight:400; white-space:nowrap; border:0 !important; border-radius:0 !important;
}
.homer-ui .homer-review-toolbar > .btn.homer-review-collapse-all:active { background:var(--homer-input) !important; }

/* Icon-bearing search needs space beyond the shared form padding. */
.homer-ui.homer-ui .homer-toolbar-search input.homer-version-search-input { padding-left:36px; }
.homer-ui .homer-toolbar-search > i { left:12px; width:16px; font-size:14px; text-align:center; }

/* Review is a workspace mode, not a manuscript-settings surface. */
.homer-ui #homer-center-content:has(> .homer-review-container),
.homer-ui #homer-center-content > .homer-review-container { background:var(--homer-bg) !important; }
.homer-ui .homer-review-container { min-height:100%; box-sizing:border-box; }
.homer-ui .homer-review-container .homer-part-synopsis.homer-synopsis-card {
    background:var(--homer-panel) !important; color:var(--homer-text);
    border:1px solid var(--homer-border) !important; border-radius:0 !important;
    box-shadow:none; padding:24px 16px 16px; margin-bottom:16px;
}
.homer-ui .homer-review-container .homer-synopsis-actions .btn {
    width:36px; height:36px; min-height:36px; padding:0; display:inline-flex;
    align-items:center; justify-content:center; border:0 !important;
    background:var(--homer-border) !important; color:var(--homer-text) !important;
}
.homer-ui .homer-review-container .homer-synopsis-actions .homer-synopsis-edit:hover { background:var(--homer-input) !important; }
.homer-ui .homer-review-container .homer-synopsis-actions .homer-synopsis-trash:is(:hover,:focus-visible) { background:var(--homer-danger-hover) !important; color:#fff !important; }
.homer-ui .homer-review-container .homer-synopsis-metadata { padding-bottom:12px; border-bottom:1px solid var(--homer-border); }
.homer-ui .homer-review-container .homer-review-collapsed .homer-synopsis-metadata { border-bottom:0; padding-bottom:0; }

/* Chapter Write list: stable square actions with a shared icon centre. */
.homer-ui .homer-folder-item-actions { align-items:center; justify-content:flex-end; gap:8px; }
.homer-ui .homer-folder-item-actions button {
    display:inline-flex; align-items:center; justify-content:center;
    flex:0 0 36px; width:36px; height:36px; min-height:36px;
    padding:0; margin:0; float:none; line-height:1; vertical-align:middle;
}
.homer-ui .homer-folder-item-actions button i { display:block; margin:0; line-height:1; }
@media (min-width:1101px) {
    .homer-ui .homer-folder-item { grid-template-columns:minmax(0,1fr) 100px 145px 80px; }
}

/* Article connections: shared initial/AJAX tag markup, following Prodromos Tag. */
.homer-ui .homer-part-related-list { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:8px; }
.homer-ui .homer-part-related-list:empty { display:none; }
.homer-ui .homer-connection-tag { display:inline-flex; align-items:center; max-width:100%; height:26px; padding:0; border:0; border-radius:0; background:var(--homer-primary-hover); color:#ebeef5; vertical-align:middle; }
.homer-ui .homer-connection-tag .homer-connection-title { display:block; min-width:0; max-width:200px; padding:0 8px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#ebeef5; font-size:12px; line-height:26px; text-decoration:none; }
.homer-ui .homer-connection-remove { display:inline-flex; align-items:center; justify-content:center; align-self:stretch; flex:0 0 26px; width:26px; height:26px; margin:0; padding:0; border:0; background:var(--homer-primary-active); color:#ebeef5; font-size:10px; cursor:pointer; }
.homer-ui .homer-connection-remove:hover { background:var(--homer-danger-hover); }
.homer-ui .homer-connection-remove:focus-visible,.homer-ui .homer-connection-title:focus-visible { outline:2px solid var(--homer-accent); outline-offset:2px; }
.homer-ui .homer-connection-remove:disabled { opacity:.5; cursor:wait; }
.homer-ui :is(.homer-part-related-input,.homer-part-pov-input) { width:100%; }
.homer-ui :is(.homer-part-related-results,.homer-part-pov-results):not(:empty) { padding:8px; border:1px solid var(--homer-border); background:var(--homer-input); max-height:260px; overflow:auto; }
.homer-ui .homer-connection-result { display:block; width:100%; padding:8px; margin:0; border:0; background:transparent; color:var(--homer-text); text-align:left; font:inherit; cursor:pointer; }
.homer-ui .homer-connection-result:is(:hover,:focus-visible) { background:var(--homer-selected); outline:2px solid var(--homer-accent); outline-offset:-2px; }
.homer-ui .homer-connection-error { color:#ffadad; margin-top:8px; }

/* Connection titles are tag labels, not prose links. */
.homer-ui .homer-connection-tag a.homer-connection-title:is(:hover,:focus,:active) { color:#ebeef5 !important; text-decoration:none !important; background:var(--homer-primary); }

.homer-ui .homer-part-tags-container { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:8px; }
.homer-ui .homer-part-tags-container:empty { display:none; }
.homer-ui .homer-part-tag.homer-connection-tag { display:inline-flex; height:26px; padding:0; margin:0; border:0; border-radius:0!important; background:var(--homer-primary-hover); }
.homer-ui .homer-connection-tag button.homer-connection-title { height:26px; padding:0 8px; margin:0; border:0; border-radius:0; background:transparent; color:#ebeef5; font:inherit; font-size:12px; line-height:26px; cursor:pointer; }
.homer-ui .homer-part-tag.homer-connection-tag .homer-connection-remove { margin:0; padding:0; width:26px; height:26px; border-radius:0!important; }
.homer-ui .homer-connection-tag button.homer-connection-title:is(:hover,:focus,:active) { color:#ebeef5!important; text-decoration:none!important; background:var(--homer-primary); }

/* Notices are borderless; actions within warnings stay in the amber palette. */
.homer-ui .alert,
.homer-ui .homer-chapter-publication-status,
.homer-ui .homer-manuscript-publication-container > .label {
    border:0 !important; box-shadow:none !important;
}
.homer-ui .alert.alert-warning .btn.btn-primary:not(.mode-change) {
    background:#704600 !important; color:#fff !important; border-color:transparent !important;
}
.homer-ui .alert.alert-warning .btn.btn-primary:not(.mode-change):is(:hover,:focus-visible) {
    background:#573600 !important; color:#fff !important;
}
.homer-ui .alert.alert-warning .btn.btn-primary:not(.mode-change):active { background:#402800 !important; }
.homer-ui .alert.alert-warning .btn:focus-visible { outline:2px solid #fff; outline-offset:2px; }
