/* Shared editor components. Keep functional layout and semantic record colors in their owners. */
:root{--ui-control-height:44px;--ui-field-text:16px;--ui-label-text:14px;--ui-section-text:18px;--ui-gap:12px;--ui-panel-padding:20px;--ui-primary-bg:#936122;--ui-primary-ink:#fffaf0;--ui-danger:#a33232;--ui-control-bg:var(--menu-bg);--ui-field-bg:var(--search-bg)}
html[data-theme="night"]{--ui-primary-bg:#d6b779;--ui-primary-ink:#211c14;--ui-danger:#ffaaaa}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel){font-family:inherit;line-height:1.6}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) button{box-sizing:border-box;min-height:var(--ui-control-height);padding:8px 12px;border:1px solid var(--line-strong);border-radius:var(--ui-radius-control);background:var(--ui-control-bg);color:var(--text);font-family:inherit;font-size:var(--ui-text-body);font-weight:500;line-height:1.5;box-shadow:none;transform:none;cursor:pointer}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) button:hover:not(:disabled){background:linear-gradient(var(--gold-soft),var(--gold-soft)),var(--ui-control-bg);border-color:var(--gold);box-shadow:none;transform:none}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) button:disabled{opacity:.5;cursor:default;transform:none}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=hidden]),select,textarea){box-sizing:border-box;min-width:0;max-width:100%;min-height:var(--ui-control-height);padding:9px 12px;border:1px solid var(--line-strong);border-radius:var(--ui-radius-control);background:var(--ui-field-bg);color:var(--text);font-family:inherit;font-size:var(--ui-field-text);line-height:1.5;box-shadow:none}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) textarea{resize:vertical}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(input[type=checkbox],input[type=radio]){accent-color:var(--gold)}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(button,input,select,textarea,summary,a):focus-visible{outline:2px solid var(--focus,var(--gold));outline-offset:3px;box-shadow:none}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(label,legend){font-size:var(--ui-label-text);line-height:1.6;color:var(--text)}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) [role=status]{font-size:var(--ui-label-text);line-height:1.6;overflow-wrap:anywhere}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(input,textarea)::placeholder{color:var(--muted);opacity:1}
/* Save/submit and destructive actions share meaning as well as appearance. */
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(.ui-action-primary,.source-save-primary,.new-song-primary,:where(#lyricLrcSave)),
html[data-theme] body .admin-editor-actions>button[type=submit]{background:var(--ui-primary-bg);border-color:var(--ui-primary-bg);color:var(--ui-primary-ink);font-weight:700}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(.ui-action-primary,.source-save-primary,.new-song-primary,:where(#lyricLrcSave)):hover:not(:disabled),
html[data-theme] body .admin-editor-actions>button[type=submit]:hover:not(:disabled){background:var(--ui-primary-bg);color:var(--ui-primary-ink);border-color:var(--ui-primary-bg);box-shadow:inset 0 0 0 1px currentColor}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(.ui-action-danger,.source-row-remove,:where(#restoreApply)){background:var(--ui-control-bg);border-color:var(--ui-danger);color:var(--ui-danger)}
html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(.ui-action-danger,.source-row-remove,:where(#restoreApply)):hover:not(:disabled){color:var(--ui-danger);border-color:var(--ui-danger);background:var(--ui-control-bg);box-shadow:inset 0 0 0 1px currentColor}
html[data-theme] body .source-row-removed .source-row-remove{border-color:var(--line-strong);color:var(--text)}
/* Shared form sections, dialogs and action spacing. */
html[data-theme] body :is(.source-main-tools,.social-card-editor,.source-create-inline){padding:var(--ui-panel-padding);border:1px solid var(--line);border-radius:var(--ui-radius-card);background:var(--menu-bg);box-shadow:none}
html[data-theme] body :is(.clue-dialog,.contribution-dialog,.new-song-editor){box-sizing:border-box;max-width:calc(100vw - 24px);padding:var(--ui-panel-padding);border:1px solid var(--line);border-radius:var(--ui-radius-panel);background:var(--menu-bg);color:var(--text);box-shadow:none}
html[data-theme] body :is(.clue-dialog,.contribution-dialog,.new-song-editor)>:is(h2,h3),
html[data-theme] body .new-song-intro>h3{font-family:inherit;font-size:22px;font-weight:700;line-height:1.45;margin:0 0 16px}
html[data-theme] body :is(.source-editor-heading,.source-form-section,.source-main-add,.admin-panel-content)>:is(h2,h3,h4){font-family:inherit;font-size:var(--ui-section-text);font-weight:700;line-height:1.5}
html[data-theme] body :is(.source-meta-grid,.social-editor-meta,.social-content-fields,.social-edit-song-more,.source-row-more){gap:var(--ui-gap)}
html[data-theme] body :is(.source-meta-grid,.social-editor-meta,.social-content-fields,.social-edit-song-more,.source-row-more,.clue-inline-editor)>label{gap:6px;margin:0}
html[data-theme] body :is(.source-row-actions,.source-create-actions,.social-editor-actions,.admin-editor-actions,.clue-dialog .clue-actions,.new-song-actions,.ui-editor-actions){display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px}
html[data-theme] body :is(.source-quick-save,.social-editor-actions){padding:12px;border:1px solid var(--line-strong);border-radius:var(--ui-radius-card);background:var(--menu-bg);box-shadow:none;gap:8px}
html[data-theme] body :is(.source-quick-save,.social-editor-actions)>[role=status]{flex:1 1 100%;order:-1;margin:0;color:var(--muted)}
html[data-theme] body .clue-dialog .clue-actions{padding-top:16px;margin-top:16px;border-top:1px solid var(--line)}
html[data-theme] body :is(.social-edit-song,.admin-main .admin-comment-card,.admin-main .admin-backup-box,.admin-main .admin-photo-card){border-radius:var(--ui-radius-card);border-color:var(--line);box-shadow:none}
html[data-theme] body .admin-main .admin-panel-content{border-radius:var(--ui-radius-card);padding:var(--ui-panel-padding)}
html[data-theme] body .admin-main .admin-navigation{border-radius:var(--ui-radius-card)}
/* Navigation and selected filters retain a visible state after hover. */
html[data-theme] body .admin-navigation .admin-section-nav button{background:transparent;border-color:transparent;text-align:left}
html[data-theme] body .admin-navigation .admin-section-nav button[aria-pressed=true],
html[data-theme] body .admin-main :is(button[aria-pressed=true],.admin-counts button.is-active){background:linear-gradient(var(--gold-soft),var(--gold-soft)),var(--ui-control-bg);border-color:var(--gold);font-weight:700}
html[data-theme] body .admin-navigation .admin-section-nav button[aria-pressed=true]{box-shadow:inset 3px 0 var(--gold)}
/* The edit label is consistent across song, moment and social rows. */
html[data-theme] body .sources-main .source-compact-song-row>.source-row-toggle{width:56px;min-width:56px;padding:6px;font-size:var(--ui-text-body);border:1px solid var(--line-strong);background:var(--ui-control-bg);color:var(--text)}
html[data-theme] body .sources-main .source-compact-song-row>.source-row-toggle::after{display:none}
html[data-theme] body .sources-main .social-edit-song-top>button{min-width:56px}
html[data-theme] body :is(.source-main-tools,.admin-account,.admin-backup-box)>summary{min-height:44px;align-content:center;font-size:16px}
@media(max-width:600px){
 :root{--ui-panel-padding:14px}
 html[data-theme] body .sources-main :is(.source-quick-save,.social-editor-actions){padding:8px}
 html[data-theme] body .sources-main .source-editor-shortcuts button{font-size:14px;white-space:normal;padding-inline:4px}
 html[data-theme] body :is(.source-create-actions,.social-editor-actions,.ui-editor-actions)>button{flex:1 1 auto}
 html[data-theme] body .social-editor-meta{grid-template-columns:minmax(0,1fr)}
}
@media(forced-colors:active){
 html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) button{border-color:ButtonText;color:ButtonText;background:ButtonFace}
 html[data-theme] body :is(.admin-main,.source-main-tools,.source-row-more,.source-quick-save,.source-create-inline,.social-card-editor,.source-timeline-actions,.source-create-top,.clue-inline-editor,.clue-dialog,.clue-section,.contribution-dialog,.new-song-editor,.song-admin-panel) :is(.ui-action-primary,.source-save-primary,.new-song-primary,:where(#lyricLrcSave)){border:2px solid Highlight;color:ButtonText;background:ButtonFace}
}

/* Exact URL audit destination, retaining existing editor roles and colors. */
body .sources-main .audit-location-notice{padding:16px;margin:0 0 20px;border:1px solid var(--gold);border-radius:var(--ui-radius-card);background:var(--menu-bg);color:var(--text)}
body .sources-main .audit-location-notice p{font-size:14px;line-height:1.65;margin:8px 0;overflow-wrap:anywhere}
body .sources-main .audit-location-notice .ui-editor-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;justify-content:flex-start}
body .sources-main .audit-location-notice :is(button,a){min-height:44px;box-sizing:border-box;display:inline-flex;align-items:center;padding:8px 12px;border:1px solid var(--line-strong);border-radius:var(--ui-radius-control);background:var(--menu-bg);color:var(--text);font:inherit;font-size:14px}
body .sources-main .audit-location-match{outline:3px solid var(--gold);outline-offset:5px;scroll-margin-block:calc(var(--site-header-clearance,100px) + 24px) 160px}
body .sources-main label.audit-location-match{border-radius:var(--ui-radius-control);background:var(--gold-soft)}
@media(forced-colors:active){body .sources-main .audit-location-match{outline-color:Highlight}}

/* Compact source footer; details expand upward without moving the save action. */
html[data-theme] body .sources-main .source-quick-save{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:8px;padding:8px;bottom:max(calc(8px + env(safe-area-inset-bottom,0px)),var(--player-control-clearance,0px));width:100%;box-sizing:border-box}
html[data-theme] body .sources-main .source-quick-save>[role=status]{grid-column:1;grid-row:1;order:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}
html[data-theme] body .sources-main .source-quick-save>.source-save-primary{grid-column:3;grid-row:1;white-space:nowrap;min-width:max-content;padding:8px 12px}
.source-save-more{grid-column:2;grid-row:1;position:static}
html[data-theme] body .sources-main .source-save-more>summary{box-sizing:border-box;display:flex;align-items:center;justify-content:center;list-style:none;min-height:44px;padding:8px 12px;border:1px solid var(--line-strong);border-radius:var(--ui-radius-control);cursor:pointer;white-space:nowrap}
.source-save-more>summary::-webkit-details-marker{display:none}
html[data-theme] body .sources-main .source-save-more-panel{position:absolute;bottom:calc(100% + 10px);right:0;left:auto;width:min(320px,100%);max-width:100%;box-sizing:border-box;padding:12px;background:var(--menu-bg);border:1px solid var(--line-strong);border-radius:var(--ui-radius-card);max-height:50dvh;overflow:auto;display:grid;gap:10px;box-shadow:var(--shadow)}
html[data-theme] body .sources-main .source-save-more-panel .source-editor-shortcuts{display:grid;grid-template-columns:1fr;gap:6px;margin:0}
.source-save-more-panel p{margin:0;line-height:1.6;overflow-wrap:anywhere;font-size:13px}
@media(max-width:600px){
 body .sources-main .source-occurrence-song.has-important-imprint{--source-seal-size:40px;--source-seal-step:44px;--source-seal-edge:8px;min-height:60px;padding-bottom:6px;padding-right:calc(12px + var(--source-seal-count,1)*44px)}
 body .sources-main .source-occurrence-song.has-important-imprint>.important-song-impression{top:calc(50% - 20px);bottom:auto}
 body .sources-main .source-occurrence-song:has(>.important-song-impression~.important-song-impression~.important-song-impression){--source-seal-size:32px;--source-seal-step:34px;padding-right:114px}
 body .sources-main .source-occurrence-song:has(>.important-song-impression~.important-song-impression~.important-song-impression)>.important-song-impression{top:calc(50% - 16px)}
 body .sources-main .source-compact-song-row:not(.source-moment)>.source-occurrence-song{min-height:0}
}

/* Keep the native date picker while sizing its field like other editor inputs. */
html[data-theme] body :is(.source-main-tools,.source-row-more,.source-create-inline,.social-card-editor,.event-inline-editor,.admin-main,.new-song-editor) input[type=date]{-webkit-appearance:none;appearance:none;display:block;box-sizing:border-box;width:100%;inline-size:100%;min-width:0;min-inline-size:0;max-width:100%;max-inline-size:100%;flex-shrink:1;overflow:hidden;text-align:left}
html[data-theme] body :is(.source-main-tools,.source-row-more,.source-create-inline,.social-card-editor,.event-inline-editor,.admin-main,.new-song-editor) input[type=date]::-webkit-date-and-time-value{min-height:1.5em;text-align:left;max-width:100%;overflow:hidden}
html[data-theme] body .sources-main .source-meta-grid{min-width:0;max-width:100%;box-sizing:border-box}

/* Genre tools use the existing editor palette and wrap on small screens. */
html[data-theme] body .genre-editor-tools{grid-column:1/-1;min-width:0;overflow-wrap:anywhere}
html[data-theme] body .genre-quick-options{display:flex;flex-wrap:wrap;gap:8px}
html[data-theme] body .genre-quick-options button{min-height:44px;padding:8px 12px;font:inherit}
html[data-theme] body .genre-classification-preview{margin-top:12px;padding:12px;border:1px solid currentColor;border-radius:12px}
html[data-theme] body .genre-classification-preview p{margin:4px 0}

/* Shared mood editor and source menu adapt to narrow viewports. */
.mood-quick-options{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.mood-quick-options select{flex:1 1 140px;min-width:0;max-width:100%;min-height:44px;font:inherit}
.mood-quick-options button{min-height:44px;font:inherit}
.source-copy-menu{box-sizing:border-box;min-width:0;max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);overflow:auto}
.source-copy-menu button{min-height:44px;white-space:normal;overflow-wrap:anywhere}
.source-copy-menu button[aria-disabled="true"]{opacity:.7;cursor:default}

.card-tag-editor .card-tag-preview{min-width:0;overflow-wrap:anywhere}
.card-tag-editor .tag-row{display:flex;flex-wrap:wrap;gap:8px}
.card-tag-editor input,.card-tag-editor select{min-width:0;max-width:100%;min-height:44px;font:inherit}
.pending-card-list{display:grid;gap:8px}.pending-card-list button{min-height:44px;text-align:left;white-space:normal;overflow-wrap:anywhere}

.editor-recovery,.editor-conflict-review{margin:12px 0;padding:12px;border:1px solid var(--border,rgba(150,120,80,.3));border-radius:12px;min-width:0}.editor-recovery summary,.editor-conflict-review summary{min-height:44px;cursor:pointer;align-content:center}.editor-recovery button,.editor-conflict-review button{font:inherit;min-height:44px;margin:6px;max-width:100%;white-space:normal}.editor-conflict-review pre{font:inherit;white-space:pre-wrap;overflow-wrap:anywhere;margin:.5rem 0;max-height:16rem;overflow:auto}.editor-conflict-review section{border-top:1px solid var(--border,rgba(150,120,80,.3));padding:8px 0}.editor-recovery :focus-visible,.editor-conflict-review :focus-visible{outline:3px solid currentColor;outline-offset:2px}

.editor-save-check,.editor-save-notice{padding:12px;margin:12px 0;border:1px solid var(--line);border-radius:12px;background:var(--panel);color:var(--text);overflow-wrap:anywhere}.editor-save-check button,.editor-save-notice button{font:inherit;min-height:44px;margin:4px;white-space:normal}.editor-save-notice{display:flex;flex-wrap:wrap;align-items:center;gap:8px}.editor-save-notice span{flex:1 1 220px}

/* Narrow screens and enlarged text: keep footer actions reachable. */
@media(max-width:400px){
 html[data-theme] body .sources-main .source-quick-save{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px}
 html[data-theme] body .sources-main .source-quick-save>[role=status]{grid-column:1/-1;grid-row:1}
 html[data-theme] body .sources-main .source-quick-save>.source-save-primary{grid-column:2;grid-row:2;min-width:0;white-space:normal;overflow-wrap:anywhere;padding:8px}
 html[data-theme] body .sources-main .source-save-more{grid-column:1;grid-row:2;min-width:0}
 html[data-theme] body .sources-main .source-save-more>summary{min-width:0;white-space:normal;padding:8px}
}
html[data-theme] body .sources-main .source-save-more-panel{overscroll-behavior:contain;max-height:min(50dvh,360px)}
html[data-theme] body .sources-main .source-save-more-panel :is(button,summary){max-width:100%;min-width:0;white-space:normal;overflow-wrap:anywhere;min-height:44px}
#adminVersionCheck{overflow-wrap:anywhere}
#adminVersionCheck button{min-height:44px;max-width:100%;white-space:normal;margin:4px}
#adminVersionCheck small{display:block;margin-top:8px}

/* Collection preview shares editor controls and spacing. */
.song-collection .collection-content{padding:12px;display:grid;gap:12px;min-width:0}
.song-collection input[type=url],.song-collection select,.song-collection textarea{box-sizing:border-box;width:100%;min-width:0;max-width:100%}
.song-collection .collection-actions{display:flex;flex-wrap:wrap;gap:8px}
.song-collection .collection-preview{display:grid;gap:12px;min-width:0}
.song-collection fieldset{min-width:0;margin:0;padding:12px;border:1px solid var(--line,#d9cdb9);border-radius:12px;display:grid;gap:10px}
.song-collection .collection-choice{display:flex;align-items:flex-start;gap:10px;overflow-wrap:anywhere}
.song-collection input[type=checkbox]{flex:0 0 20px;width:20px;height:20px;margin:2px 0}
.song-collection a,.song-collection p{overflow-wrap:anywhere}
.song-collection button{min-height:44px}

html[data-theme] body .sources-main .source-save-more-panel :is(button,summary){text-align:center;justify-content:center;line-height:1.5;font-size:15px;padding:10px 12px;width:100%;box-sizing:border-box}

html body #editorSaveNotice.editor-save-toast{position:fixed;inset:auto auto calc(24px + env(safe-area-inset-bottom,0px)) 50%;transform:translateX(-50%);z-index:10000;box-sizing:border-box;max-width:calc(100vw - 32px);width:max-content;margin:0;padding:12px 18px;border:1px solid var(--line-strong);border-radius:12px;background:var(--menu-bg,#fffaf0);color:var(--text);box-shadow:0 4px 20px #0002;pointer-events:none;font-size:14px;line-height:1.5}
html body #editorSaveNotice.editor-save-toast span{flex:0 1 auto}
