/* Main shell: fill viewport so the grid uses remaining height (avoids a gap under a fixed 100vh − Npx layout). */
#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.header-user-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.28rem 0.65rem 0.28rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--elevated, var(--surface));
  color: var(--text);
  font: inherit;
  cursor: pointer;
  max-width: min(280px, 40vw);
  text-align: left;
  flex-shrink: 0;
}

.header-user-indicator:hover {
  border-color: var(--accent, var(--border));
}

.header-user-status {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #3dba6e;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(61, 186, 110, 0.25);
}

.header-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.header-user-label {
  font-size: 0.68rem;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-album-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem 0.45rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-album-toolbar-left {
  flex: 1;
  min-width: 0;
}

.nav-album-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.nav-artist-filter-wrap {
  display: block;
  min-width: 0;
}

.nav-artist-filter-select {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 0.28rem 0.4rem;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.25;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.nav-album-toolbar-btn .icon-sprite {
  display: block;
}

/* Hidden-album toggle: eye = list omits hidden (click to show); eye-off = all albums listed (click to omit hidden). */
.nav-btn-toggle-hidden-albums .nav-hidden-icon--hide {
  display: none;
}
.nav-btn-toggle-hidden-albums.is-showing-all .nav-hidden-icon--show {
  display: none;
}
.nav-btn-toggle-hidden-albums.is-showing-all .nav-hidden-icon--hide {
  display: block;
}

.panel-left {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-left .nav-panel-pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.albums-nav-container {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* [hidden] must win over display:flex — otherwise the inactive navigator pane stays visible. */
.albums-nav-container[hidden],
.preset-nav-root[hidden] {
  display: none !important;
}

#tree-root.tree-root {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.tree-album-hidden > .tree-row .tree-label {
  font-style: italic;
  opacity: 0.88;
}

.preset-nav-root {
  padding: 0.25rem 0.15rem 0.5rem;
}

.header-dropdown-wrap {
  position: relative;
}

.header-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 12rem;
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 1400;
}

.header-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

/* display:block above would otherwise override the native [hidden] attribute. */
.header-dropdown-item[hidden] {
  display: none !important;
}

.header-dropdown-item:hover:not(:disabled) {
  background: var(--accent-row-bg);
}

.header-dropdown-item:active:not(:disabled) {
  background: var(--accent-row-bg-strong);
}

.header-dropdown-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--muted);
}

.header-dropdown-separator {
  height: 1px;
  margin: 0.25rem 0.35rem;
  background: var(--border);
}

.header-user-menu {
  min-width: 14rem;
}

.header-user-menu-head {
  padding: 0.45rem 0.55rem 0.35rem;
  line-height: 1.35;
}

.header-user-menu-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.header-user-menu-name {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-user-menu-email {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-user-menu-role {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.12rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.breadcrumb {
  padding: 0.35rem 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
  min-height: 1.75rem;
  flex-shrink: 0;
}

.layout {
  display: grid;
  grid-template-columns: 280px 6px minmax(360px, 1fr) 6px minmax(280px, 0.9fr);
  flex: 1 1 auto;
  min-height: 0;
}

/* Collapsed: keep middle/right columns equal width; hide only right-panel content. */
.layout[data-pma-workspace-right="collapsed"] #split-right {
  pointer-events: none;
  cursor: default;
}

.layout[data-pma-workspace-right="collapsed"] #panel-right #workspace-root {
  visibility: hidden;
  pointer-events: none;
}

.version-sidebar-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.version-sidebar-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0.5rem;
}

.version-sidebar-lead {
  font-size: 0.88rem;
  margin: 0;
}

.version-sidebar-lead .nowrap {
  white-space: nowrap;
}

.workspace-version-tag-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.workspace-version-tempo-card {
  margin-bottom: 0.65rem;
}

#workspace-version-tag-groups {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.layout[data-pma-workspace-right="version"] .version-sidebar-body {
  width: 100%;
  min-width: 0;
}

.panel {
  overflow: auto;
  padding: 0.75rem;
  background: var(--bg);
  min-width: 0;
}

/* Middle column: builder fills height; tag area scrolls inside (not the whole panel). */
.panel.panel-middle {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Right column: same flex discipline so version tag tabs / genre blocks span the full panel width */
.panel.panel-right {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel.panel-right #workspace-root {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.panel.panel-right #workspace-root > section.builder-shell {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

#workspace-version-tag-groups .tag-tabs.tag-tabs-builder,
#workspace-version-tag-groups .builder-tag-panel,
#workspace-version-tag-groups .tag-group-panel {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#workspace-version-tag-groups .tag-genre-sub,
#workspace-version-tag-groups .tag-group-chips-shell {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Navigator: single scrollbar on the panel, not a nested scroll on the tree pane. */
.panel-left .nav-panel-pane {
  overflow: visible;
}

.panel-middle .builder-shell,
.panel-right #workspace-root .builder-shell,
#builder-root {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#builder-root {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#builder-root .builder-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.builder-shell .builder-tags {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tag-tabs.tag-tabs-builder {
  display: flex;
  align-items: center;
}

.builder-tag-reset-spacer {
  flex: 1 1 auto;
  min-width: 0;
}

.builder-tag-reset {
  flex: 0 0 auto;
  margin-left: auto;
}

.builder-shell .builder-tags-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.builder-tag-popup-panel {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(1100px, 92vw);
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  min-width: min(640px, calc(100vw - 2rem));
  min-height: 420px;
  overflow: hidden;
  resize: both;
}

.builder-tag-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  flex: 0 0 auto;
}

.builder-tag-popup-panel .builder-tags-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.builder-tag-popup-panel .modal-actions {
  width: 100%;
  justify-content: flex-start;
  flex: 0 0 auto;
  padding-right: 0.85rem;
  padding-bottom: 0.15rem;
}

.builder-tag-popup-actions-spacer {
  flex: 1;
  min-width: 0.5rem;
}

.builder-tag-popup-panel .builder-suno-sliders {
  flex: 0 0 auto;
}

.builder-suno-sliders {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
  flex-wrap: wrap;
  margin: 0.2rem 0 0.6rem;
}

.builder-suno-slider-card {
  border: 1px solid var(--accent);
  background: var(--accent-row-bg-strong);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
  min-width: 15rem;
  flex: 1 1 15rem;
}

.builder-suno-slider-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.builder-suno-slider-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.builder-suno-slider-row .builder-tempo-include-cb {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin: 0;
  cursor: pointer;
}

.builder-suno-slider-row input[type="range"] {
  flex: 1 1 auto;
  min-width: 7.5rem;
}

.builder-suno-value-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  width: 5.2rem;
  flex: 0 0 5.2rem;
}

.builder-suno-value-wrap input[type="number"] {
  width: 4.25rem;
  margin: 0;
  padding: 0.15rem 0.3rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
}

.builder-suno-value-suffix {
  color: var(--muted);
  font-weight: 600;
}

.builder-suno-value-suffix-placeholder {
  visibility: hidden;
}

#builder-tempo-input {
  width: 4.25rem;
  margin: 0;
}

.splitter {
  background: var(--border);
  cursor: col-resize;
  align-self: stretch;
  min-height: 0;
}

/* Navigator, builder (edit), and workspace / tag column: framed regions */
#layout > .panel {
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-children {
  list-style: none;
  margin: 0.15rem 0 0.35rem 0;
  padding: 0;
  border-left: none;
}

/* Indent nested rows so track expanders line up with album title text; version rows use a matching spacer. */
.tree-album-root > .tree-children {
  padding-left: calc(1.6rem + 0.25rem);
}

.tree-row {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  margin: 0.1rem 0;
}

.tree-toggle {
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  cursor: pointer;
}

.tree-toggle-spacer {
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  pointer-events: none;
}

.tree-label {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
}

.tree-label[draggable="true"] {
  user-select: none;
  -webkit-user-select: none;
}

.tree-label-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-label.is-selected {
  border-color: var(--accent);
  background: var(--accent-row-bg);
}

/* Album/track labels are div[role=button] so native HTML5 drag works (draggable <button> is unreliable). */
.tree-label[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input.tree-label.tree-inline-rename {
  flex: 1;
  min-width: 0;
  font: inherit;
  line-height: inherit;
  cursor: text;
  border: 1px solid var(--accent);
  background: var(--elevated);
  color: var(--text);
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  box-sizing: border-box;
}

.tree-track .tree-label {
  font-size: 0.95rem;
}

.tree-version .tree-label {
  font-size: 0.82rem;
}

.builder label,
.builder-shell label,
.workspace label {
  display: block;
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.builder input[type="text"],
.builder-shell input[type="text"],
.builder textarea,
.builder-shell textarea,
.workspace textarea,
.workspace input[type="text"],
.workspace input[type="file"] {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
}

.metadata-section {
  margin: 0.25rem 0 0.5rem 0;
}

.metadata-section label {
  margin: 0.45rem 0 0.15rem 0;
}

#ws-album-desc,
#ws-album-worksheet,
#ws-track-desc,
#ws-track-worksheet,
#ws-style-prompt,
.ws-style-page-editor,
#ws-version-lyrics,
.ws-lyrics-page-editor {
  overflow-y: auto;
  resize: vertical;
}

#ws-lyrics-check.ws-lyrics-check-btn,
#ws-lyrics-tool.ws-lyrics-tool-btn {
  overflow: visible;
}

.modal-panel-lyrics-tool-result {
  width: min(720px, 100%);
  min-width: min(360px, 100%);
  min-height: 280px;
  max-width: min(1100px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  resize: both;
  overflow: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-lyrics-tool-result-head {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  /* Leave room for the absolute close × (top/right 0.6rem). */
  padding-right: 2.75rem;
  margin-bottom: 0.35rem;
}

.modal-lyrics-tool-result-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding-right: 0;
}

.modal-lyrics-tool-result-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.modal-lyrics-tool-result-body {
  margin: 0.35rem 0 0.85rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--elevated, var(--surface));
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 14rem;
  max-height: min(60vh, 36rem);
  font: inherit;
  line-height: 1.45;
}

#ws-version-lyrics,
.ws-lyrics-page-editor {
  white-space: pre-wrap;
}

.ws-lyrics-page-editor.is-lyrics-compare-view {
  cursor: default;
}

.ws-lyrics-page-editor.is-lyrics-compare-view .lyrics-compare-add {
  color: #c62828;
  background: rgba(198, 40, 40, 0.1);
}

.ws-lyrics-page-editor.is-lyrics-compare-view .lyrics-compare-del,
.ws-lyrics-page-editor.is-lyrics-compare-view del.lyrics-compare-del {
  color: #c62828;
  text-decoration: line-through;
  background: rgba(198, 40, 40, 0.1);
}

.rich-text-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.rich-text-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.rich-text-toolbar select {
  font-size: 0.85rem;
  max-width: 10rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.rich-text-toolbar .btn-small {
  padding: 0.15rem 0.45rem;
  min-width: 2rem;
}

.rich-text-toolbar .rich-text-wrap-cmd.is-active {
  font-weight: 700;
}

.rich-text-toolbar .rich-text-case-cycle {
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: -0.03em;
}

.rich-text-toolbar-sep {
  align-self: stretch;
  width: 1px;
  min-height: 1.25rem;
  margin: 0 0.1rem;
  background: var(--border);
  flex-shrink: 0;
}

.rich-text-selection-popup {
  position: fixed;
  z-index: 5000;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
}

.rich-text-selection-popup[hidden] {
  display: none !important;
}

.rich-text-toolbar--selection-popup {
  flex-wrap: nowrap;
  gap: 0.3rem;
}

.rich-text-toolbar--selection-popup select {
  max-width: 7.5rem;
}

/* Single rhythm for every large rich editor (workspace + modal). Default: no extra gap between lines or blocks. */
.rich-text-body {
  --rich-line-height: 1.25;
  --rich-block-gap: 0;
  min-height: 4.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--elevated);
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  line-height: var(--rich-line-height);
  outline: none;
}

/* Let inline line-height from the rich toolbar apply; do not force inherit onto those spans. */
.rich-text-body *:not([style*="line-height"]) {
  line-height: inherit;
}

/* Drop UA paragraph margins so spacing is only our block gap (consistent across browsers/fields). */
.rich-text-body p,
.rich-text-body div {
  margin: 0;
}

/* Adjacent block-level siblings: same gap everywhere (p or div stacks, contenteditable output). */
.rich-text-body :is(p, div) + :is(p, div) {
  margin-top: var(--rich-block-gap);
}

/*
 * When a span has font-size but no line-height, match document rhythm.
 * Inline line-height from the toolbar wins (no !important; same element’s style attribute beats this rule).
 */
.rich-text-body span[style*="font-size"]:not([style*="line-height"]) {
  line-height: var(--rich-line-height);
}

/* Comfortable line spacing (data-rich-text-density): looser leading and space between paragraphs when stored as comfortable. */
html[data-rich-text-density="comfortable"] .rich-text-body {
  --rich-line-height: 1.5;
  --rich-block-gap: 0.28em;
}

/*
 * Style Prompt model: one bordered shell, inner editor flush (no double border).
 * Shared by track edit fields and large-text modal.
 */
.prompt-workspace-textarea-shell,
#modal-large-text-rich-wrap,
#modal-field-notes-rich-wrap,
#scratchpad-rich-wrap {
  position: relative;
  margin-top: 0.15rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: visible;
  background: var(--elevated);
}

.prompt-workspace-textarea-shell > .rich-text-body,
#modal-large-text-rich-wrap > .rich-text-body,
#modal-field-notes-rich-wrap > .rich-text-body,
#scratchpad-rich-wrap > .rich-text-body {
  border: none;
  border-radius: 0;
  background: var(--elevated);
}

.modal-rich-field {
  margin-bottom: 0.75rem;
}

.modal-rich-body.modal-textarea {
  min-height: 280px;
  margin-bottom: 0;
}

.prompt-block-toolbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0.35rem 0 0.5rem 0;
}

.prompt-block-toolbar-end {
  justify-content: flex-end;
}

.prompt-block-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.prompt-block-footer-counter {
  margin-top: 5px;
}

.prompt-block-footer-end {
  justify-content: flex-end;
}

.prompt-char-count {
  font-size: 0.82rem;
  color: var(--muted);
}

.prompt-char-count.is-over-limit {
  color: #e87373;
  font-weight: 600;
}

.prompt-workspace-hint {
  margin: 0 0 0.65rem 0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.prompt-workspace-hint-before-save {
  margin: 0 0 5px 0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.prompt-workspace-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
}

.prompt-workspace-label {
  font-size: 0.92rem;
  color: var(--muted);
}

.prompt-workspace-toolbar {
  margin-top: 0.75rem;
  justify-content: flex-end;
}

.prompt-workspace-toolbar .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.builder-shell textarea {
  overflow-y: scroll;
  resize: vertical;
}

/* Style prompt lock: closed padlock when locked, open padlock when unlocked (only one visible). */
.prompt-workspace-style-lock-btn .style-prompt-lock-glyph {
  display: block;
}
.prompt-workspace-style-lock-btn:not(.is-prompt-locked) .style-prompt-lock-glyph--locked {
  display: none;
}
.prompt-workspace-style-lock-btn.is-prompt-locked .style-prompt-lock-glyph--unlocked {
  display: none;
}

.prompt-workspace-textarea-shell.is-style-prompt-locked .rich-text-body {
  cursor: not-allowed;
}

/* Lyrics prompt lock: same closed/open padlock semantics as style prompt. */
.prompt-workspace-lyrics-lock-btn .lyrics-prompt-lock-glyph {
  display: block;
}
.prompt-workspace-lyrics-lock-btn:not(.is-prompt-locked) .lyrics-prompt-lock-glyph--locked {
  display: none;
}
.prompt-workspace-lyrics-lock-btn.is-prompt-locked .lyrics-prompt-lock-glyph--unlocked {
  display: none;
}

.prompt-workspace-textarea-shell.is-lyrics-prompt-locked .rich-text-body {
  cursor: not-allowed;
}

/* Stack hint + vocal gender (same line as preset builder: label | checkboxes, no horizontal squeeze). */
.album-defaults-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  margin-top: 15px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.album-defaults-row > .album-default-genre-hint {
  flex: none;
  margin: 0;
}

.album-defaults-row > .builder-meta-row {
  flex: none;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.album-default-vocal-gender-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.25rem;
  min-width: 0;
}

.album-default-vocal-gender .inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: var(--text);
}

.builder-cover-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.builder-cover-thumb-img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
}

.builder-cover-placeholder {
  width: 160px;
  height: 160px;
  border: 2px dotted var(--border);
  border-radius: 10px;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.88rem;
  user-select: none;
}

.builder-cover-placeholder[hidden],
.builder-cover-thumb-img[hidden] {
  display: none;
}

.cover-context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 190px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--elevated);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 0.25rem;
}

.cover-context-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.cover-context-item:hover {
  background: var(--accent-row-bg);
}

.cover-context-item:active {
  background: var(--accent-row-bg-strong);
}

.cover-context-item:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.builder-album-head-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  /* Bottom-align cover with meta column so thumbnail base lines up with the last date row ("Last changed"). */
  align-items: end;
  width: 100%;
  min-width: 0;
}

.builder-album-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  width: 100%;
}

.builder-album-meta-head {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.builder-album-meta-fields {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  min-width: 0;
}

/* Override global .builder-shell label / input spacing for compact album meta rows */
.builder-album-meta-fields .builder-meta-row {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  align-items: center;
  column-gap: 0.5rem;
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.album-defaults-row .builder-meta-row {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.album-defaults-row .builder-meta-row.album-default-genre {
  column-gap: 5px;
}

.builder-album-meta-fields .builder-meta-label,
.album-defaults-row .builder-meta-label {
  text-align: left;
  justify-self: start;
  white-space: nowrap;
}

.builder-shell .builder-album-meta-fields .builder-meta-input,
.builder-shell .album-defaults-row .builder-meta-input {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin-top: 0;
  text-align: left;
  padding-top: calc(0.45rem / 2);
  padding-bottom: calc(0.45rem / 2);
  padding-left: 0.45rem;
  padding-right: 0.55rem;
}

.builder-album-name-readonly,
.builder-track-name-readonly {
  font-weight: 700;
  font-size: 18pt;
  line-height: 1.25;
}

.builder-meta-line {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.builder-meta-input {
  width: 100%;
  max-width: 28rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

select.builder-meta-input.builder-meta-select {
  cursor: pointer;
  appearance: auto;
}

/* Version builder: track meta mirrors track header but is not editable here */
.builder-shell .builder-version-meta-fields-readonly select.builder-meta-select:disabled {
  cursor: not-allowed;
  opacity: 0.95;
  background: var(--elevated);
  color: var(--text);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.45rem;
  min-width: 2.25rem;
}

.btn-icon .icon-sprite {
  display: block;
  flex-shrink: 0;
}

.btn-icon:hover:not(:disabled),
.icon-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-row-bg);
  color: var(--text);
}

.btn-icon:active:not(:disabled),
.icon-btn:active:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-row-bg-strong);
  color: var(--text);
}

.btn-icon[aria-pressed="true"],
.btn-icon.is-active,
.icon-btn[aria-pressed="true"],
.icon-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-row-bg-strong);
  color: var(--text);
}

.btn-icon:focus-visible,
.icon-btn:focus-visible,
.tag-fav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.builder-version-badge {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
}

.builder-version-badge code {
  font-size: 0.85em;
}

.builder-meta-dates {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
  margin-top: 0.25rem;
}

.metadata-summary-editable {
  cursor: pointer;
  text-decoration: underline dotted var(--summary-dotted);
}

.tree-context-item.is-disabled,
.tree-context-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--muted);
}

.tree-context-menu {
  position: fixed;
  /* Above rich-text floating toolbar (5000) and modal overlays (2000); below confirm/alert (2500) is overridden here. */
  z-index: 5100;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--elevated);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 0.25rem;
  /* Required when parent overlay uses pointer-events: none (floating NotePad). */
  pointer-events: auto;
}

.tree-context-sep {
  height: 1px;
  margin: 0.25rem 0.35rem;
  background: var(--border);
  pointer-events: none;
}

.tree-context-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.tree-context-item:hover {
  background: var(--accent-row-bg);
}

.tree-context-item:active {
  background: var(--accent-row-bg-strong);
}

.tree-context-item.is-danger {
  color: #f87171;
}

.tree-drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.tree-album-root.is-dragging,
.tree-track.is-dragging {
  opacity: 0.55;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--overlay-scrim);
  display: grid;
  place-items: center;
  padding: 1rem;
}

/* `display: grid` above wins over the `hidden` attribute in some UAs; force closed state. */
.modal-overlay[hidden] {
  display: none !important;
}

/* Confirm/alert must stack above other open modals (e.g. field notes, large-text). */
#modal-confirm.modal-overlay,
#modal-alert.modal-overlay,
#modal-rename.modal-overlay {
  z-index: 2500;
}

#modal-progress.modal-overlay,
#modal-busy.modal-overlay {
  z-index: 2600;
}

.modal-progress-message {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.4;
  min-height: 1.25rem;
}

.modal-busy-panel {
  width: min(420px, 100%);
  text-align: center;
}

.modal-busy-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 0.25rem 0 0.15rem;
}

.modal-busy-spinner {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent, var(--text));
  animation: tm-busy-spin 0.75s linear infinite;
}

.modal-busy-message {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.4;
}

@keyframes tm-busy-spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-progress-track {
  width: 100%;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.modal-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent, #3b82f6);
  transition: width 0.2s ease;
}

.modal-progress-percent {
  margin: 0.45rem 0 0;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
}

.modal-panel {
  position: relative;
  width: min(420px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.modal-close-x {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  min-width: 2rem;
  line-height: 1;
}

.modal-panel-wide {
  width: min(720px, 100%);
}

.modal-panel-style-library {
  width: min(520px, 100%);
  min-width: min(360px, 100%);
  min-height: 320px;
  max-width: min(900px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  resize: both;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.style-library-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 0.5rem;
}

.style-library-filter-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

#modal-style-prompt-library select.builder-meta-select,
#modal-style-library-add select.builder-meta-select {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.style-library-sort-btn {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.style-library-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 10rem;
  max-height: min(50vh, 28rem);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--elevated, var(--surface));
}

.style-library-list li {
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.style-library-list li:last-child {
  border-bottom: none;
}

.style-library-empty {
  padding: 0.85rem 0.9rem;
}

.style-library-list-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.style-library-list-item:hover {
  background: color-mix(in srgb, var(--accent, #4a90d9) 12%, transparent);
}

.style-library-list-item.is-active {
  background: color-mix(in srgb, var(--accent, #4a90d9) 22%, transparent);
}

.style-library-item-text {
  font-weight: 500;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.style-library-genre-heading {
  padding: 0.45rem 0.75rem 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--border) 35%, transparent);
  border-bottom: 1px solid var(--border);
  cursor: default;
  user-select: none;
}

.modal-panel-style-library-add {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-panel-style-library-add .modal-title,
.modal-panel-style-library-add .modal-consistency-hint {
  margin-bottom: 0;
}

.modal-panel-style-library-add .modal-actions {
  margin-top: 0.35rem;
  padding-top: 0.15rem;
  flex-shrink: 0;
}

.modal-panel-tips-crud {
  width: min(880px, 100%);
  max-height: min(92vh, 720px);
}

.tips-crud-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 1rem;
  margin-top: 0.5rem;
  min-height: min(52vh, 420px);
}

@media (max-width: 640px) {
  .tips-crud-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

.tips-crud-list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tips-crud-list-head {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.tips-crud-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.tips-crud-list li {
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.tips-crud-list li:last-child {
  border-bottom: none;
}

.tips-crud-list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.tips-crud-list-item:hover {
  background: var(--accent-row-bg);
}

.tips-crud-list-item.is-active {
  background: var(--elevated);
  font-weight: 600;
}

.tips-crud-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Tips modal: same shell + lyrics-style rich editor as version workspace */
.tips-crud-editor .tips-crud-rich-wrap {
  flex: 1;
  min-height: 220px;
  min-width: 0;
}

.tips-crud-editor .tips-crud-rich-wrap .rich-text-body {
  min-height: 200px;
}

.tips-crud-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.tips-crud-actions-spacer {
  flex: 1;
  min-width: 0.5rem;
}

.modal-preset-pick-hint {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.88rem;
}

.modal-preset-pick-chips-shell {
  margin-top: 0.5rem;
  max-height: min(40vh, 320px);
  overflow-y: auto;
  background: var(--surface);
}

.modal-preset-pick-chips-shell .tag-chips {
  margin-bottom: 0.35rem;
}

.modal-preset-pick-empty {
  padding: 0.65rem;
  margin: 0;
  font-size: 0.9rem;
}

/* Help: full manual + search (modal dialog pattern) */
.help-modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.help-panel-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 2;
}

.help-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  /* Leave room for the absolute close (X) control on the panel. */
  padding: 0.85rem 3.25rem 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.help-panel-title {
  margin: 0;
  font-size: 1.1rem;
  min-width: 0;
}

#help-download-pdf {
  flex: 0 0 auto;
  max-width: min(100%, 14rem);
  white-space: nowrap;
}

.help-panel-search {
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.help-search-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.help-search-input {
  margin-bottom: 0.35rem;
}

.help-search-status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1.1em;
}

.help-panel-body {
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  flex: 1;
}

@media (max-width: 720px) {
  .help-panel-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 35vh) minmax(200px, 1fr);
  }
}

.help-topic-list {
  margin: 0;
  padding: 0.5rem;
  overflow: auto;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: var(--surface);
}

@media (max-width: 720px) {
  .help-topic-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.help-topic-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1.35;
}

.help-topic-item:hover {
  background: var(--accent-row-bg);
}

.help-topic-item.is-active {
  background: var(--elevated);
  box-shadow: inset 0 0 0 1px var(--border);
  font-weight: 600;
}

/* Collapsible manual + Tips sections (native details) */
.help-topic-group {
  margin: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--elevated);
}

.help-topic-group + .help-topic-group {
  margin-top: 0.45rem;
}

.help-topic-group-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.45rem 0.5rem 0.35rem;
  line-height: 1.35;
}

.help-topic-group > summary::-webkit-details-marker {
  display: none;
}

.help-topic-group-summary::before {
  content: "▼";
  display: inline-block;
  font-size: 0.55rem;
  margin-right: 0.4rem;
  vertical-align: middle;
  opacity: 0.85;
  transition: transform 0.15s ease;
}

.help-topic-group:not([open]) .help-topic-group-summary::before {
  transform: rotate(-90deg);
}

.help-topic-group-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.35rem 0.45rem 0.5rem;
}

/* Upper help nav labels: WELCOME TO EVELYNN TRACK MANAGER V…, TIPS & TRICKS, VERSION CHANGES */
.help-topic-group-summary--branded {
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.help-changelog-pane {
  font-size: 0.9rem;
  line-height: 1.5;
}

.help-manual .help-changelog-version-title {
  margin: 1rem 0 0.4rem;
  font-size: 0.98rem;
  line-height: 1.35;
}

.help-manual .help-changelog-version-title:first-child {
  margin-top: 0;
}

.help-manual .help-changelog-entry {
  margin: 0 0 0.55rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.help-version-lead {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

.help-version-root {
  font-size: 0.88rem;
  line-height: 1.45;
}

.help-version-root details {
  margin: 0.15rem 0 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.help-version-root .help-version-major {
  border: none;
  background: transparent;
}

.help-version-major-body,
.help-version-minor-body {
  padding: 0.15rem 0 0.25rem 0.5rem;
}

.help-version-summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  padding: 0.25rem 0.4rem;
  color: var(--text);
  user-select: none;
}

.help-version-root details .help-version-summary::-webkit-details-marker {
  display: none;
}

.help-version-patch-list {
  margin: 0.15rem 0 0.35rem;
  padding-left: 1.1rem;
}

.help-version-patch-list li {
  margin: 0.2rem 0;
}

.help-topic-empty-hint {
  margin: 0.15rem 0 0.35rem;
  padding: 0 0.35rem;
  font-size: 0.82rem;
  line-height: 1.35;
}

.help-tip-body {
  line-height: 1.45;
}

.help-topic-content {
  margin: 0;
  padding: 0.85rem 1rem 1.1rem;
  overflow: auto;
  min-height: 0;
  min-width: 0;
  outline: none;
}

.help-empty {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.help-manual {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  min-width: 0;
}

.help-manual p {
  margin: 0 0 0.75rem;
}

.help-manual h3 {
  margin: 1rem 0 0.45rem;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.35;
}

.help-manual h3:first-child {
  margin-top: 0;
}

.help-manual ul,
.help-manual ol {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
}

.help-manual li {
  margin: 0.35rem 0;
}

.help-manual code {
  font-size: 0.88em;
}

.help-manual strong {
  font-weight: 600;
}

.modal-title {
  margin: 0 0 0.75rem 0;
  font-size: 1.05rem;
}

.modal-consistency-album-name {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.modal-consistency-hint {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.modal-license-status {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, var(--text) 8%);
}

.modal-license-status-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  font-size: 0.88rem;
}

.modal-license-status-label {
  color: var(--muted);
}

.modal-license-status-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.modal-license-status-days {
  margin: 0.15rem 0 0;
}

.modal-license-status-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 500;
}

.startup-splash-overlay {
  z-index: 12000;
  /* Always use the default dark theme, regardless of app theme. */
  --bg: #0b0f14;
  --surface: #121821;
  --border: #1e2836;
  --text: #e8eef7;
  --muted: #8b98a8;
  --accent: #5b8cff;
  --elevated: #0f141c;
  --overlay-scrim: rgba(0, 0, 0, 0.55);
  --accent-row-bg: rgba(91, 140, 255, 0.12);
  --warn: #e8b84a;
  background: var(--overlay-scrim);
  color: var(--text);
}

.startup-splash-panel {
  text-align: center;
  max-width: 420px;
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--text);
}

.modal-account-line {
  margin: 0.65rem 0;
}

.modal-account-line .modal-consistency-label {
  display: block;
  margin-bottom: 0.15rem;
}

.modal-account-value {
  display: block;
  word-break: break-word;
}

.modal-panel-account {
  width: min(440px, 100%);
}

.modal-account-password-section {
  margin: 1rem 0 0.35rem;
  padding: 0.75rem 0.85rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.modal-account-password-legend {
  padding: 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.modal-account-password-section .modal-consistency-label {
  display: block;
  margin: 0.55rem 0 0.2rem;
}

.modal-account-password-section .modal-input {
  width: 100%;
  box-sizing: border-box;
}

.modal-account-password-section .modal-backup-checkbox-label {
  margin-top: 0.65rem;
}

.modal-account-password-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

.modal-panel-admin {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(920px, calc(100vw - 2rem));
  min-width: min(480px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  min-height: 22rem;
  max-height: calc(100vh - 2rem);
  height: min(90vh, 720px);
  overflow: hidden;
  resize: both;
  padding-bottom: 0.85rem;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

.admin-metric {
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--elevated, var(--surface));
}

.admin-metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.admin-metric-label {
  font-size: 0.8rem;
  color: var(--muted, #888);
  margin-top: 0.2rem;
}

.admin-metric-db .admin-metric-value {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.admin-metric-db.is-warn {
  border-color: #c47a2c;
}

.admin-metric-db.is-critical {
  border-color: #c44;
}

.admin-metric-chart {
  display: flex;
  flex-direction: column;
}

.admin-metric-chart .admin-usage-chart-wrap {
  width: 100%;
  height: 1.15rem;
  margin-top: 0.25rem;
  border-radius: 3px;
  overflow: hidden;
}

.admin-metric-chart .admin-metric-label {
  margin-top: 0.25rem;
}

.admin-usage-chart {
  display: block;
  width: 100%;
  height: 100%;
}

.admin-usage-chart-line {
  fill: none;
  stroke: var(--accent, #3d8bfd);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.admin-usage-chart-area {
  fill: color-mix(in srgb, var(--accent, #3d8bfd) 22%, transparent);
  stroke: none;
}

.admin-usage-chart-dot {
  fill: var(--accent, #3d8bfd);
}

.modal-admin-section-title {
  margin: 0.25rem 0 0.5rem;
  font-size: 1rem;
}

.admin-ai-credits {
  margin: 1rem 0 0.25rem;
}

.modal-panel-admin > .prefs-section[data-admin-section],
.modal-panel-admin-user-stats > .prefs-section[data-admin-section] {
  margin-top: 0.75rem;
}

.modal-panel-admin .prefs-section-body .admin-users-head {
  margin-top: 0.15rem;
}

.admin-ai-credits .modal-admin-section-title {
  margin: 0 0 0.35rem;
}

.admin-ai-credits-wrap {
  max-height: 16rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--elevated, var(--surface));
}

.admin-ai-credits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.admin-ai-credits-table th,
.admin-ai-credits-table td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.admin-ai-credits-table th {
  position: sticky;
  top: 0;
  background: var(--elevated, var(--surface));
  z-index: 1;
  font-weight: 600;
}

.admin-ai-credits-table td.num,
.admin-ai-credits-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-ai-credits-table tr.is-empty td {
  color: var(--muted);
}

.admin-users-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.25rem 0 0.5rem;
}

.admin-users-head .modal-admin-section-title {
  margin: 0;
}

.admin-user-form {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--elevated, var(--surface));
}

.admin-user-form-title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.admin-user-form-grid {
  display: grid;
  gap: 0.35rem;
}

.admin-user-form-grid .modal-consistency-label {
  margin-top: 0.25rem;
}

.admin-user-form-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.admin-user-form-flags label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.admin-user-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.admin-users-table .admin-user-actions {
  text-align: right;
  white-space: nowrap;
}

.admin-users-table .admin-user-actions .btn + .btn {
  margin-left: 0.35rem;
}

.modal-panel-admin-user-stats {
  width: min(720px, 96vw);
  max-height: min(90vh, 720px);
  overflow: auto;
}

.admin-users-wrap {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.modal-panel-admin .modal-actions {
  flex: 0 0 auto;
  margin-top: 0.75rem;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-users-table th,
.admin-users-table td {
  text-align: left;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-users-table th {
  position: sticky;
  top: 0;
  background: var(--elevated, var(--surface));
  z-index: 1;
}

.admin-users-table td.admin-user-access,
.admin-users-table td.admin-user-class {
  white-space: nowrap;
}

.admin-users-table label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-right: 0.65rem;
  white-space: nowrap;
}

.startup-splash-version {
  text-align: center;
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.startup-splash-logo {
  width: min(220px, 70%);
  height: auto;
  max-height: 120px;
  object-fit: contain;
  margin: 0 auto 0.75rem;
  display: block;
}

.startup-splash-title {
  margin: 0 0 0.75rem;
  color: var(--text);
}

.startup-splash-line {
  margin: 0.25rem 0;
  color: var(--text);
}

.startup-splash-line .muted {
  color: var(--muted);
}

.startup-splash-warning {
  margin: 0.85rem 0 0.5rem;
  color: var(--warn);
}

.startup-splash-panel .btn.primary,
.startup-splash-panel button.primary {
  border-color: var(--border);
  background: var(--elevated);
  color: var(--text);
}

.startup-splash-panel .btn.primary:hover:not(:disabled),
.startup-splash-panel button.primary:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-row-bg);
  color: var(--text);
}

.modal-consistency-fields {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.25rem;
}

.modal-consistency-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal-backup-checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.prefs-print-subhead {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  margin: 0.85rem 0 0.4rem 0;
}

.prefs-section .prefs-print-subhead:first-of-type {
  margin-top: 0.35rem;
}

.modal-backup-folder-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 0.75rem;
}

.modal-backup-folder-row .modal-input {
  flex: 1;
  margin-bottom: 0;
}

.modal-restore-zip-row {
  align-items: center;
}

.modal-restore-zip-browse {
  flex: 0 0 auto;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}

#modal-restore-zip-name {
  cursor: pointer;
}

.modal-backup-schedule-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  margin-bottom: 0.75rem;
}

.pref-text-color-custom {
  margin: 0.35rem 0 0.5rem 0;
}

.pref-text-color-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pref-text-color-row input[type="color"] {
  width: 2.75rem;
  height: 2.25rem;
  padding: 0.125rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}

.pref-text-color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.pref-text-color-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.pref-text-color-row .modal-input {
  flex: 1;
  margin-bottom: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pref-text-color-preview {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.95rem;
  line-height: 1.45;
}

.pref-text-color-hint {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.modal-backup-schedule-sep {
  opacity: 0.65;
  user-select: none;
}

.prefs-section {
  margin: 0.35rem 0 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem 0.7rem;
}

.prefs-section-legend-wrap {
  padding: 0;
  margin: 0 0 0.35rem 0;
  width: 100%;
  float: left;
  font-weight: 600;
}

.prefs-section-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.35rem 0.4rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.prefs-section-toggle:hover {
  background: color-mix(in srgb, var(--elevated) 65%, transparent);
}

.prefs-section-toggle:focus-visible {
  outline: 2px solid var(--accent, #6b9fff);
  outline-offset: 2px;
}

.prefs-section-chevron {
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  flex-shrink: 0;
  margin-top: -0.15em;
  transition: transform 0.15s ease;
}

.prefs-section-toggle[aria-expanded="false"] .prefs-section-chevron {
  transform: rotate(-45deg);
}

.prefs-section-body {
  clear: both;
  width: 100%;
  box-sizing: border-box;
}

.prefs-admin-smtp-row {
  display: grid;
  grid-template-columns: minmax(6rem, 8rem) minmax(0, 1fr);
  gap: 0.75rem 1rem;
  align-items: end;
}

@media (max-width: 520px) {
  .prefs-admin-smtp-row {
    grid-template-columns: 1fr;
  }
}

.prefs-section-collapsed {
  padding-bottom: 0.55rem;
}

.modal-confirm-message {
  margin: 0 0 1rem 0;
  line-height: 1.45;
  color: var(--text);
}

.modal-confirm-apply-all-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.9rem 0;
  color: var(--muted);
}

.modal-confirm-apply-all-row[hidden] {
  display: none !important;
}

.modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem;
  margin-bottom: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.modal-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 280px;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}

.modal-textview {
  width: 100%;
  box-sizing: border-box;
  min-height: 280px;
  max-height: 58vh;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  white-space: pre-wrap;
  overflow: auto;
}

.modal-textview.modal-textview-compact {
  min-height: 0;
  max-height: none;
  padding: 0;
  margin-bottom: 0.25rem;
}

/* Match workspace rich editors: .modal-textarea comes later and must not change rhythm/padding. */
#modal-large-text-rich-wrap > .rich-text-body.modal-textarea,
#modal-field-notes-rich-wrap > .rich-text-body.modal-textarea {
  padding: 0.5rem 0.6rem;
  background: var(--elevated);
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  line-height: var(--rich-line-height, 1.25);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

#modal-license .modal-actions {
  width: 100%;
}

#modal-license .modal-actions .btn {
  flex: 1 1 0;
  min-width: 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#builder-fields .preset-freeform-block {
  width: 100%;
  min-width: 0;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
}

#builder-fields .preset-freeform-label {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

#builder-fields .preset-notes-textarea-full {
  display: block;
  width: 100%;
  max-width: none;
  min-height: 7rem;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
}

/* Preset builder: actions left, Vocal Gender (same control as album) aligned right */
#builder-fields .preset-builder-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem 1rem;
  width: 100%;
  margin: 0.75rem 0 0.5rem;
  box-sizing: border-box;
}

#builder-fields .preset-builder-actions-row .preset-builder-actions {
  margin: 0;
  flex: 0 0 auto;
}

#builder-fields .preset-builder-actions-row .preset-vocal-gender-wrap {
  margin-left: auto;
  flex: 0 1 auto;
  min-width: 0;
}

#builder-fields .preset-vocal-gender-wrap .builder-meta-row.album-default-vocal-gender {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  align-items: center;
  column-gap: 0.5rem;
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.tag-toolbar {
  margin: 0.5rem 0;
}

.tag-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  margin: 0.35rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}

.tag-tab {
  flex: 0 0 auto;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--elevated);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.tag-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-row-bg-strong);
  font-weight: 600;
  color: var(--text);
}

.tag-tabs-builder {
  margin-top: 0;
}

.builder-tag-panel {
  min-height: 4rem;
}

.tag-fav-section-title {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.tag-fav-empty {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.85rem;
}

.tag-manager-layout {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  width: 100%;
}

.tag-manager-preset-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.85rem;
  padding: 0.2rem 0.35rem;
}

.tag-manager-preset-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

/* Beat .builder-shell label { display: block } so the favorites row stays one line (matches preset builder). */
.builder-shell .tag-toolbar label.inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0.75rem 0;
}

.tag-chip {
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.tag-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-row-bg-strong);
  color: var(--text);
}

.tag-chip.is-tag-macro {
  border-color: var(--accent);
  background: var(--accent-row-bg-strong);
  color: var(--text);
}

.tag-chip.is-tag-macro.is-selected {
  border-color: var(--accent);
  background: var(--accent-row-bg-strong);
  color: var(--text);
  filter: saturate(2);
}

.tag-chip.is-fav {
  border-color: #f6c945;
}

.tag-group summary {
  cursor: pointer;
  font-weight: 600;
}

/* Subgroup column (genre nested details, or single shell for other groups). */
.tag-group .tag-genre-subgroups,
.tag-group-panel .tag-genre-subgroups {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.tag-genre-sub,
.tag-group-chips-shell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem 0.35rem 0.45rem;
  background: var(--bg);
}

.tag-genre-sub summary {
  font-weight: 500;
  font-size: 0.86rem;
  color: var(--muted);
}

#tag-manager-body .tag-genre-sub > summary.tm-section-summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  cursor: pointer;
}

#tag-manager-body .tag-genre-sub > summary.tm-section-summary::-webkit-details-marker {
  display: none;
}

#tag-manager-body .tag-genre-sub > summary.tm-section-summary::before {
  content: "▸";
  flex: 0 0 auto;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--muted);
}

#tag-manager-body .tag-genre-sub[open] > summary.tm-section-summary::before {
  content: "▾";
}

#tag-manager-body .tm-section-summary-title {
  flex: 1 1 auto;
  min-width: 0;
}

#tag-manager-body .tm-section-add-btn {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--elevated, var(--surface));
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#tag-manager-body .tm-section-add-btn:hover {
  border-color: var(--accent, var(--border));
  background: color-mix(in srgb, var(--elevated, var(--surface)) 70%, var(--accent, var(--border)));
}

.tag-genre-hint {
  margin: 0 0 0.65rem 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

.builder-presets-filter {
  margin-top: 0.35rem;
  margin-bottom: 0.5rem;
}

.builder-presets-filter-empty {
  margin: 0.35rem 0;
}

.ghost {
  color: var(--muted);
  font-size: 0.92rem;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.muted {
  color: var(--muted);
}

.actions {
  margin-top: 0.75rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.btn,
button.primary,
button.link {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  padding: 0.45rem 0.65rem;
  cursor: pointer;
}

/* Match default chrome (same as Save New in version workspace); primary is not a separate “blue” style. */
.btn:not(.btn-small):not(.btn-icon),
button.primary:not(.btn-small):not(.btn-icon) {
  min-height: 2.25rem;
}

.btn.primary,
button.primary {
  border-color: var(--border);
  background: var(--elevated);
  color: var(--text);
}

.btn:hover:not(:disabled),
button.primary:hover:not(:disabled),
button.link:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-row-bg);
  color: var(--text);
}

.btn:active:not(:disabled),
button.primary:active:not(:disabled),
button.link:active:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-row-bg-strong);
  color: var(--text);
}

.btn:focus-visible,
button.primary:focus-visible,
button.link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn.danger {
  border-color: rgba(255, 99, 99, 0.45);
  background: rgba(255, 99, 99, 0.12);
}

button.link {
  border: none;
  background: transparent;
  color: var(--accent);
  padding: 0.25rem 0;
}

.cover {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.cover-row {
  margin: 0.5rem 0 1rem 0;
}

.workspace-thumb {
  max-width: 120px;
  max-height: 120px;
  object-fit: cover;
}

.track-meta-extended .track-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.mini-list {
  margin: 0.25rem 0 0 1rem;
}

.track-versions-panel {
  margin: 0.5rem 0 1rem 0;
  padding: 0.5rem 0 0.75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.track-versions-title {
  margin: 0 0 0.35rem 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.track-versions-hint {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  line-height: 1.35;
}

.track-versions-list.mini-list {
  margin-left: 0;
}

.track-versions-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  margin: 0.35rem 0 0.5rem 0;
}

.track-version-actions {
  margin-top: 0.35rem;
}

.tag-chip-wrap {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.tag-action {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.82rem;
}

.tag-action-danger {
  border-color: rgba(255, 99, 99, 0.45);
  color: rgba(255, 163, 163, 0.95);
}

.btn-small {
  padding: 0.35rem 0.5rem;
  font-size: 0.88rem;
}

.tm-add {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.tm-add input {
  flex: 1;
}

.tm-group-footer {
  margin-top: 0.5rem;
}

.tag-inline-rename,
.tag-inline-confirm {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.tag-fav-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.tag-fav-btn:hover {
  border-color: var(--accent);
  background: var(--accent-row-bg);
  color: var(--text);
}

.tag-fav-btn:active {
  border-color: var(--accent);
  background: var(--accent-row-bg-strong);
  color: var(--text);
}

.tag-fav-btn.is-selected-fav {
  border-color: #f6c945;
  color: #f6c945;
  background: #ffffff;
}

.tag-inline-rename input[type="text"] {
  width: 10rem;
}

/* Tag manager: chip-styled inline edit (no separate save/cancel row) */
#tag-manager-body input.tag-chip.tm-tag-edit-input {
  appearance: none;
  -webkit-appearance: none;
  cursor: text;
  min-width: 3.5rem;
  max-width: min(20rem, 100%);
  font: inherit;
  line-height: 1.25;
  box-sizing: border-box;
}

#tag-manager-body input.tag-chip.tm-tag-edit-input:focus {
  outline: 2px solid var(--border);
  outline-offset: 1px;
}

#tag-manager-body .tm-pending-add {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
}

#tag-manager-body .tm-fav-spacer {
  width: 2.25rem;
  flex-shrink: 0;
}

.inline {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--muted);
}

.toast-root {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 6000;
  max-width: min(92vw, 36rem);
  box-sizing: border-box;
  pointer-events: none;
}

.toast {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  text-align: center;
}

.toast-success {
  border-color: rgba(80, 200, 120, 0.45);
}

.toast-error {
  border-color: rgba(255, 99, 99, 0.45);
}

.toast-warning {
  border-color: rgba(230, 180, 80, 0.55);
}

/* Themed hover/focus tooltips (replace native OS title popups) */
.tm-app-tooltip {
  position: fixed;
  z-index: 5500;
  max-width: min(22rem, calc(100vw - 16px));
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.01em;
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
  box-sizing: border-box;
}

/* Half-saturated theme fill so tooltips read clearly against saturated UI chrome */
.tm-app-tooltip::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  border: 1px solid color-mix(in srgb, var(--border) 55%, var(--text) 45%);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  filter: saturate(0.5);
}

.tm-app-tooltip[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-scrim);
}

.modal-card {
  position: relative;
  width: min(1200px, calc(100vw - 2rem));
  max-height: min(88vh, 960px);
  overflow: auto;
  margin: 6vh auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

#tag-manager-modal .modal-card {
  display: flex;
  flex-direction: column;
  overflow: auto;
  resize: both;
  box-sizing: border-box;
  width: min(1200px, calc(100vw - 2rem));
  min-width: min(420px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  min-height: 14rem;
  max-height: calc(100vh - 2rem);
}

#tag-manager-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: auto;
  box-sizing: border-box;
}

/* ScratchPad: global ideas notebook (Help-style persistent modal) */
.scratchpad-modal-panel {
  position: relative;
  width: min(960px, calc(100vw - 2rem));
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  resize: both;
  box-sizing: border-box;
  min-width: 520px;
  min-height: 360px;
}

.scratchpad-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.scratchpad-panel-title {
  margin: 0;
  font-size: 1.1rem;
  cursor: move;
  user-select: none;
}

.scratchpad-head-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.scratchpad-head-actions .btn.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  padding: 0;
  line-height: 1;
  box-sizing: border-box;
}

.scratchpad-head-actions .scratchpad-add {
  font-size: 1.2rem;
}

.scratchpad-head-actions .scratchpad-panel-close .icon-sprite {
  display: block;
}

.scratchpad-body-row {
  --scratchpad-list-width: 260px;
  display: grid;
  grid-template-columns: var(--scratchpad-list-width) 6px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.scratchpad-list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: none;
  background: var(--surface);
}

.scratchpad-sort-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.5rem 0.35rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.scratchpad-sort-label {
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}

.scratchpad-sort-controls {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  gap: 0.25rem;
}

.scratchpad-sort-select {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0.3rem 0.4rem;
  font-size: 0.82rem;
}

.scratchpad-sort-dir {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 0;
  line-height: 0;
}

.scratchpad-sort-dir-btn {
  appearance: none;
  border: none;
  background: transparent;
  box-shadow: none;
  margin: 0;
  padding: 0;
  width: 1rem;
  height: 0.55rem;
  min-width: 0;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scratchpad-sort-dir-btn::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 0.32rem solid transparent;
  border-right: 0.32rem solid transparent;
}

.scratchpad-sort-dir-btn--up::before {
  border-bottom: 0.4rem solid currentColor;
}

.scratchpad-sort-dir-btn--down::before {
  border-top: 0.4rem solid currentColor;
}

.scratchpad-sort-dir-btn:hover:not(:disabled) {
  color: var(--text);
  background: transparent;
  border: none;
}

.scratchpad-sort-dir-btn[aria-pressed="true"] {
  color: var(--text);
  font-weight: 600;
  background: transparent;
  border: none;
}

.scratchpad-sort-dir-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.scratchpad-note-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.scratchpad-note-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.scratchpad-note-item:hover {
  background: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
}

.scratchpad-note-item.is-active {
  background: color-mix(in srgb, var(--accent, #2563eb) 22%, var(--surface));
  font-weight: 600;
}

.scratchpad-note-item.is-untitled:not(.is-active) {
  color: var(--muted);
  font-style: italic;
}

.scratchpad-splitter {
  cursor: col-resize;
  background: var(--border);
  width: 6px;
  flex-shrink: 0;
  touch-action: none;
}

.scratchpad-splitter:hover {
  background: color-mix(in srgb, var(--accent, #2563eb) 35%, var(--border));
}

.scratchpad-edit-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.scratchpad-note-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.scratchpad-title-input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.scratchpad-created-at {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}

.scratchpad-rich-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--elevated);
}

.scratchpad-rich-wrap > .rich-text-body {
  flex: 1 1 auto;
  min-height: 8rem;
  overflow-y: auto;
  border: none;
  border-radius: 0;
  background: var(--elevated);
}

#modal-scratchpad .scratchpad-editor-body.modal-textarea,
.scratchpad-editor-body {
  min-height: 10rem;
}

/* ScratchPad: floating position (drag); scrim is click-through so the app stays usable underneath. */
#modal-scratchpad.scratchpad-overlay--floating {
  display: block;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

#modal-scratchpad.scratchpad-overlay--floating .scratchpad-modal-panel {
  pointer-events: auto;
}

#modal-scratchpad-panel.scratchpad--positioned {
  position: fixed;
  margin: 0;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
}

#modal-scratchpad-panel.scratchpad--dragging {
  user-select: none;
}

/* NotePad: floating position (drag); scrim is click-through so the app stays usable underneath. */
#modal-field-notes.notepad-overlay--floating {
  display: block;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

#modal-field-notes.notepad-overlay--floating .notepad-card {
  pointer-events: auto;
}

#modal-field-notes .modal-card {
  display: flex;
  flex-direction: column;
  overflow: auto;
  resize: both;
  box-sizing: border-box;
  width: min(640px, calc(100vw - 2rem));
  min-width: min(320px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  min-height: 12rem;
  max-height: calc(100vh - 2rem);
}

#modal-field-notes .notepad-card.notepad--positioned {
  position: fixed;
  margin: 0;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
}

#modal-field-notes-title.notepad-drag-handle {
  cursor: move;
  user-select: none;
}

.notepad-move-strip {
  flex: 0 0 auto;
  height: 10px;
  margin: 0.15rem 0 0.4rem;
  border-radius: 4px;
  cursor: move;
  user-select: none;
  background: color-mix(in srgb, var(--border, #d0d7de) 55%, transparent);
}

.notepad-move-strip:hover {
  background: color-mix(in srgb, var(--accent, #2563eb) 22%, var(--border, #d0d7de));
}

#modal-field-notes .notepad-card.notepad--dragging {
  user-select: none;
}

#modal-field-notes .notepad-card.notepad--positioned:not(.notepad--dragging) {
  cursor: default;
}

#modal-field-notes-rich-wrap.field-notes-modal-body {
  flex: 1 1 auto;
  min-height: 10rem;
  display: flex;
  flex-direction: column;
  margin-top: 0;
}

#modal-field-notes-rich-wrap > .rich-text-body {
  flex: 1 1 auto;
  min-height: 8rem;
  overflow-y: auto;
}

/* Tab strip: ‹ › and + share one horizontal line with page tabs */
.tab-strip-main {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-start;
  gap: 0.25rem;
  min-width: 0;
}

.tab-strip-scroll,
.tab-strip-add,
.notepad-tab-scroll,
.notepad-add,
.track-edit-tab-scroll,
.track-edit-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  align-self: center;
  box-sizing: border-box;
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.notepad-tabs-row .tab-strip-scroll.btn-icon,
.notepad-tabs-row .tab-strip-add.btn-icon,
.track-edit-tabs-row .tab-strip-scroll.btn-icon,
.track-edit-tabs-row .tab-strip-add.btn-icon {
  min-width: 2rem;
  padding: 0;
}

.tab-strip-scroll[hidden],
.notepad-tab-scroll[hidden],
.track-edit-tab-scroll[hidden] {
  display: none !important;
}

/* NotePad tabs (Microsoft Notepad-style) */
.notepad-tabs-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  margin: 0.25rem 0 0.5rem;
  min-width: 0;
}

.notepad-tabs {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 0.25rem;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  min-width: 0;
}

.notepad-tabs::-webkit-scrollbar {
  height: 6px;
}

.notepad-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  max-width: 14rem;
  min-height: 2rem;
  box-sizing: border-box;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border, #d0d7de);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--surface-muted, #f1f3f5);
  color: var(--text, #1f2328);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-size: 0.85rem;
  position: relative;
}

.notepad-tab.is-active {
  background: var(--surface, #fff);
  font-weight: 600;
  border-color: var(--accent, #2563eb);
}

.notepad-tab .notepad-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}

.notepad-tab.is-dragging {
  opacity: 0.5;
}

.notepad-tab.drop-before::before,
.notepad-tab.drop-after::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent, #2563eb);
}

.notepad-tab.drop-before::before {
  left: -2px;
}

.notepad-tab.drop-after::after {
  right: -2px;
}

.notepad-tab-rename {
  font: inherit;
  width: 9rem;
  max-width: 12rem;
  border: 1px solid var(--accent, #2563eb);
  border-radius: 3px;
  padding: 1px 4px;
}

.scratchpad-add {
  flex: 0 0 auto;
  align-self: center;
  font-size: 1.1rem;
  line-height: 1;
  min-width: 2rem;
}

/* Floating Find / Replace bar */
.rt-find-bar {
  position: fixed;
  z-index: 2147483646;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #d0d7de);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 280px;
}

.rt-find-bar[hidden] {
  display: none;
}

.rt-find-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.rt-find-bar input[type="text"] {
  flex: 1 1 auto;
  min-width: 7rem;
  font: inherit;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border, #d0d7de);
  border-radius: 4px;
}

.rt-find-bar .rt-find-count {
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
  min-width: 3rem;
  text-align: center;
}

.rt-find-bar .rt-find-case.is-active {
  color: var(--accent, #2563eb);
  outline: 1px solid var(--accent, #2563eb);
}

::highlight(rt-find-match) {
  background-color: rgba(255, 150, 50, 0.55);
  color: inherit;
}

.field-note-btn--filled {
  color: var(--accent, #2563eb);
}

.field-note-btn--filled .field-note-glyph--filled path[fill] {
  fill-opacity: 0.32;
}

#preset-manager-modal .modal-card {
  display: flex;
  flex-direction: column;
  overflow: auto;
  resize: both;
  box-sizing: border-box;
  width: min(720px, calc(100vw - 2rem));
  min-width: min(300px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  min-height: 12rem;
  max-height: calc(100vh - 2rem);
}

#preset-manager-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: auto;
  box-sizing: border-box;
}

.preset-manager-layout {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  flex: 1;
}

.preset-manager-toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 0;
}

.preset-manager-toolbar-row .preset-manager-ctx-tabs {
  flex: 1 1 auto;
  min-width: 0;
}

.preset-manager-ctx-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.preset-manager-chips-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem;
}

.preset-manager-chips-shell .tag-chips {
  align-items: flex-start;
}

/* Inline preset rename: same tree input treatment, shaped like a tag chip */
.preset-manager-chips-shell input.tree-label.tree-inline-rename.preset-pm-inline-rename {
  flex: 0 1 auto;
  min-width: 5.5rem;
  max-width: min(100%, 22rem);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.85rem;
}

.preset-manager-ctx-tabs .tag-tab.preset-tab-drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.preset-manager-chips-shell .tag-chip.builder-preset-chip.is-dragging-preset-chip {
  opacity: 0.55;
  cursor: grabbing;
}

.preset-manager-chips-shell .tag-chip.builder-preset-chip[draggable="true"] {
  cursor: grab;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 0.75rem 0.9rem;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  border-radius: 8px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
}

#tag-manager-body .preset-manager-toolbar-row {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  min-height: 2.25rem;
  margin: 0;
  padding: 0 0 0.35rem;
  position: relative;
  z-index: 2;
  overflow: visible;
}

#tag-manager-body .preset-manager-toolbar-row .preset-manager-ctx-tabs {
  flex: 0 1 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

#tag-manager-body .preset-manager-ctx-tabs .tag-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 2rem;
  margin: 0;
  line-height: 1.2;
  position: relative;
  z-index: 1;
}

#tag-manager-body .preset-manager-chips-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  position: relative;
  z-index: 0;
  margin-top: 0;
}

.tag-manager-nested-subgroups {
  margin-top: 0.25rem;
}

.tag-manager-nested-subgroups > .tag-genre-sub {
  margin-left: 0.15rem;
}

/* Tag manager: tab strip + scrollable tag area (matches builder tag scroll). */
#tag-manager-body .tag-manager-tags-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(70vh, 36rem);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.25rem;
}

#tag-manager-body .tag-manager-tag-groups {
  min-height: 12rem;
}

.tag-manager-genre-extras {
  margin-top: 0.5rem;
}

.tag-genre-extras-label {
  margin: 0 0 0.35rem 0;
  font-size: 0.85rem;
}

body.loading {
  cursor: wait;
}

/* V4.5.1 unified track editor */
#builder-root #builder-fields {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.track-edit-builder {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.5rem;
}

.track-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.track-edit-block-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.track-edit-block-btn {
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.track-edit-block-btn:hover {
  border-color: var(--accent);
}

.track-edit-block-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast, #fff);
}

.track-edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-left: auto;
}

/* Uniform square hit-targets for Style / Lyrics (and album) toolbar icons. */
.track-edit-actions .btn.btn-icon {
  box-sizing: border-box;
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.track-edit-actions .btn.btn-icon .icon-sprite {
  width: 18px;
  height: 18px;
}

.modal-panel-feedback {
  width: min(560px, 100%);
  min-width: min(360px, 100%);
  min-height: 320px;
  max-width: min(900px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  resize: both;
  overflow: auto;
}

.modal-feedback-details {
  width: 100%;
  min-height: 10rem;
  resize: vertical;
  box-sizing: border-box;
  font: inherit;
  line-height: 1.4;
}

.modal-panel-style-ai-result {
  width: min(640px, 100%);
  min-width: min(360px, 100%);
  min-height: 280px;
  max-width: min(960px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  resize: both;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.modal-style-ai-result-textarea {
  width: 100%;
  min-height: 12rem;
  flex: 1 1 auto;
  resize: vertical;
  box-sizing: border-box;
  font: inherit;
  line-height: 1.4;
}

.modal-style-ai-result-count-row {
  margin-top: 0.35rem;
  margin-bottom: 0.25rem;
}

.modal-actions-wrap {
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* .btn-icon sets display:inline-flex and overrides the native [hidden] attribute. */
#track-edit-actions [hidden],
#album-edit-actions [hidden] {
  display: none !important;
}

.track-edit-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.track-edit-block {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.35rem;
}

.track-edit-block[hidden] {
  display: none !important;
}

.track-edit-tabs-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  min-width: 0;
}

.track-edit-tabs {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 0.25rem;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.track-edit-tabs::-webkit-scrollbar {
  height: 6px;
}

.track-edit-tab {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px 8px 0 0;
  min-height: 2rem;
  box-sizing: border-box;
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.track-edit-tab.is-active {
  background: var(--elevated);
  border-bottom-color: var(--elevated);
  font-weight: 600;
}

.track-edit-tab-rename {
  font: inherit;
  width: 7rem;
  max-width: 14rem;
  min-width: 3rem;
  border: 1px solid var(--accent, #2563eb);
  border-radius: 4px;
  padding: 1px 4px;
  background: var(--surface);
  color: var(--text);
}

.track-edit-tab.is-renaming {
  cursor: text;
  padding: 0.2rem 0.35rem;
}

.track-edit-page {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.track-edit-page.is-active {
  display: flex;
}

.track-edit-pages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.track-edit-page .rich-text-field,
.track-edit-page .prompt-workspace-textarea-shell {
  flex: 1 1 auto;
  min-height: 8rem;
}

.track-edit-block[data-block="style"] .prompt-workspace-textarea-shell,
.track-edit-block[data-block="lyrics"] .prompt-workspace-textarea-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 10rem;
  overflow: visible;
}

/* Default: editor fills the bordered shell and panel. */
.track-edit-block[data-block="style"] .prompt-workspace-textarea-shell > .ws-style-page-editor:not([data-manual-height="1"]),
.track-edit-block[data-block="lyrics"] .prompt-workspace-textarea-shell > .ws-lyrics-page-editor:not([data-manual-height="1"]) {
  flex: 1 1 auto;
  min-height: 8rem;
  height: auto;
  width: 100%;
  box-sizing: border-box;
}

/* After manual resize: shell and page grow with the editor (same as theme/worksheet). */
.track-edit-block[data-block="style"] .prompt-workspace-textarea-shell:has(> .ws-style-page-editor[data-manual-height="1"]),
.track-edit-block[data-block="lyrics"] .prompt-workspace-textarea-shell:has(> .ws-lyrics-page-editor[data-manual-height="1"]) {
  flex: 0 1 auto;
  height: auto;
}

.track-edit-block[data-block="style"] .prompt-workspace-textarea-shell > .ws-style-page-editor[data-manual-height="1"],
.track-edit-block[data-block="lyrics"] .prompt-workspace-textarea-shell > .ws-lyrics-page-editor[data-manual-height="1"] {
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.track-edit-page .rich-text-body {
  min-height: 8rem;
}

.auth-page-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card {
  width: min(100%, 26rem);
  padding: 1.75rem;
  border: 1px solid var(--border, #444);
  border-radius: 0.75rem;
  background: var(--panel-bg, #1a1a1a);
}

.auth-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.auth-subtitle {
  margin: 0 0 1.25rem;
}

.auth-form {
  display: grid;
  gap: 0.65rem;
}

.auth-form[hidden] {
  display: none !important;
}

.auth-error {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.35rem;
  background: rgba(200, 60, 60, 0.15);
  color: #f5a5a5;
}

.auth-submit {
  margin-top: 0.35rem;
}

.auth-toggle-wrap {
  margin: 1rem 0 0;
  text-align: center;
}

.auth-hint {
  margin: 0;
  font-size: 0.85rem;
}

.auth-show-password {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.15rem 0 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.auth-show-password input {
  margin: 0;
}

/* Meta Tag Editor */
.modal-panel-meta-tags {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-sizing: border-box;
  width: min(960px, calc(100vw - 2rem));
  min-width: min(640px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  min-height: 22rem;
  max-height: calc(100vh - 2rem);
  height: min(92vh, 720px);
  overflow: hidden;
  resize: both;
  padding-bottom: 0.85rem;
}

.meta-tags-header {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.meta-tags-cover {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--elevated) 80%, var(--border));
  overflow: hidden;
  position: relative;
}

.meta-tags-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.meta-tags-cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  padding: 0.25rem;
}

.meta-tags-album-select {
  width: 100%;
  min-width: 0;
  margin-bottom: 0;
  align-self: end;
}

.meta-tags-folder-btn {
  flex-shrink: 0;
  align-self: end;
  margin: 0;
}

.meta-tags-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
  flex: 1 1 auto;
}

.meta-tags-table-wrap {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--elevated) 92%, var(--border));
}

.meta-tags-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.88rem;
}

.meta-tags-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--panel, var(--elevated)) 94%, var(--border));
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.55rem;
  white-space: nowrap;
}

.meta-tags-table th:nth-child(1),
.meta-tags-table td:nth-child(1) {
  width: 22%;
}

.meta-tags-table th:nth-child(2),
.meta-tags-table td:nth-child(2) {
  width: 20%;
}

.meta-tags-table th:nth-child(3),
.meta-tags-table td:nth-child(3) {
  width: 6%;
}

.meta-tags-table th:nth-child(4),
.meta-tags-table td:nth-child(4),
.meta-tags-table th:nth-child(5),
.meta-tags-table td:nth-child(5),
.meta-tags-table th:nth-child(6),
.meta-tags-table td:nth-child(6) {
  width: 14%;
}

.meta-tags-table th:nth-child(7),
.meta-tags-table td:nth-child(7) {
  width: 8%;
}

.meta-tags-table tbody td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  vertical-align: middle;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-tags-row.has-mapping td:first-child {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 70%, transparent);
}

.meta-tags-row:hover td {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.meta-tags-cell-file {
  font-weight: 500;
}

.meta-tags-row-track {
  width: 100%;
  min-width: 0;
  margin: 0;
  font-size: 0.85rem;
  padding: 0.25rem 0.35rem;
}

.meta-tags-cell-no,
.meta-tags-cell-year {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.meta-tags-empty {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
}

.meta-tags-folder-path {
  margin: 0;
  font-size: 0.78rem;
  word-break: break-all;
  flex: 0 0 auto;
}

.meta-tags-actions {
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .meta-tags-header {
    grid-template-columns: 64px minmax(0, 1fr) auto;
  }

  .meta-tags-table {
    table-layout: auto;
    font-size: 0.82rem;
  }
}
