/* 墨境 · workspaces. Presentation only; every selector is theme scoped.
 * Preview documents, memo paper, image assets and drawing surfaces deliberately
 * keep their original pixels and geometry. The stopped Poetry V is untouched.
 */

/* Shared project brief, including the compact reference card. */
body[data-theme="ink"] .ui-context-card {
  --project-context-bg: var(--ui-surface-1);
  --project-context-surface: var(--ui-surface-2);
  --project-context-border: var(--ui-line);
  --project-context-accent: var(--ui-accent);
  --project-context-accent-soft: var(--ui-accent-soft);
  border-color: var(--ui-line);
  background: var(--ink-glass, var(--ui-surface-1));
  color: var(--ui-text);
  box-shadow: var(--ui-shadow-panel);
}
body[data-theme="ink"] .ui-context-card:hover { border-color: var(--ui-line-strong); }
body[data-theme="ink"] .ui-context-card :is(.project-context-facts > span, .project-context-requirements, .project-reference-progress-panel, .project-workflow-compact) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-text);
}
body[data-theme="ink"] .ui-context-card :is(b, strong, .project-reference-groups dd) { color: var(--ui-text-strong); }
body[data-theme="ink"] .ui-context-card :is(small, .project-reference-secondary, .project-reference-identity > span, .project-reference-progress > summary) { color: var(--ui-text-muted); }
body[data-theme="ink"] .ui-context-card :is(.project-reference-groups dt, .project-context-head em, .project-reference-favorable, .project-context-facts .favorable) {
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
body[data-theme="ink"] .ui-context-card :is(.project-reference-edit, .project-context-requirements-edit) {
  border-color: var(--ui-line-strong);
  background: var(--ui-surface-2);
  color: var(--ui-accent);
}
body[data-theme="ink"] .ui-context-card :is(.project-reference-review, .project-context-requirements) {
  border-color: var(--ui-line-strong);
  background: var(--ui-warning-soft);
}
body[data-theme="ink"] .ui-context-card :is(.project-reference-identity, .project-context-open, .project-context-requirements-value) {
  border-color: transparent;
  background: transparent;
  color: inherit;
  box-shadow: none;
}
body[data-theme="ink"] .ui-context-card .project-reference-candidate-count { background: var(--ui-accent); color: var(--ui-text-on-accent); }
body[data-theme="ink"] .ui-context-card .project-context-route-badge { border-color: var(--ui-line-strong); background: var(--ui-accent-soft); color: var(--ui-accent); }

/* Naming-route evidence uses its own legacy leaf colors. */
body[data-theme="ink"] .name-pool-plan :is(.name-pool-overview h2, .name-pool-metrics b, .name-pool-route-cards h2) { color: var(--ui-text-strong); }
body[data-theme="ink"] .name-pool-plan :is(.name-pool-overview header small, .name-pool-rule strong, .name-pool-metrics > .primary b, .name-pool-history > summary > b, .name-pool-route-cards article > small) { color: var(--ui-accent); }
body[data-theme="ink"] .name-pool-plan :is(.name-pool-rule span, .name-pool-rule small, .name-pool-current-version span, .name-pool-metrics em, .name-pool-metrics small, .name-pool-overview header p) { color: var(--ui-text-muted); }
body[data-theme="ink"] .name-pool-plan .name-pool-route-cards article.disabled { opacity: 1; }

/* AI generation, smart selection, two-provider ranking and task progress. */
body[data-theme="ink"] :is(.smart-funnel-screen, .names-ai-combo-screen, .ai-name-ranking-modal, .task-screen, .project-style-screen) {
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.smart-funnel-screen, .names-ai-combo-screen, .project-style-screen) :is(
  .smart-workflow-overview, .smart-simple-current, .smart-simple-combo,
  .smart-funnel-zone, .smart-funnel-results, .smart-funnel-ai-combo-panel,
  .smart-funnel-style-picker-body, .smart-funnel-style-picker > summary,
  .smart-funnel-history-menu > div, .smart-simple-other-panel,
  .project-style-workflow, .project-style-round-card, .style-profile-card
) {
  border-color: var(--ui-line);
  background: var(--ui-surface-1);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.smart-funnel-screen, .names-ai-combo-screen, .project-style-screen) :is(
  .smart-workflow-steps > div, .smart-simple-process-node, .smart-simple-round-details article,
  .smart-funnel-provider-grid > div, .smart-funnel-stat-row > div,
  .smart-funnel-status-strip > div, .smart-funnel-task-row,
  .smart-funnel-list-groups > section, .ai-name-combo-group,
  .smart-funnel-name-card, .smart-funnel-empty, .style-name-row,
  .style-profile-card .grid > div, .style-profile-brief > span,
  .project-style-admin-tools, .smart-funnel-project-cell
) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.smart-funnel-screen, .names-ai-combo-screen, .project-style-screen) :is(
  .smart-funnel-result-tools, .smart-funnel-results-head.final, .smart-funnel-name-actions,
  .smart-funnel-process-head, .smart-funnel-saved-styles, .smart-funnel-style-summary,
  .smart-simple-current-head > strong, .smart-funnel-label-progress span,
  .smart-combo-provider-progress > span, .style-score-line span,
  .smart-funnel-style-summary b, .smart-funnel-saved-styles b
) {
  border-color: var(--ui-line);
  background: var(--ui-surface-3);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.smart-funnel-screen, .names-ai-combo-screen, .project-style-screen) :is(
  .smart-simple-current-head span, .smart-simple-current-head p, .smart-simple-command span,
  .smart-simple-process-node small, .smart-simple-round-details small, .smart-simple-round-details em,
  .smart-simple-combo p, .smart-workflow-steps small, .smart-workflow-title > span,
  .smart-funnel-task-title em, .smart-funnel-task-note, .ai-name-combo-group > small,
  .smart-funnel-ai-combo-panel > header small, .smart-funnel-project-cell .record-picker label
) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.smart-funnel-screen, .names-ai-combo-screen, .project-style-screen) :is(
  .smart-simple-command strong, .smart-simple-details summary, .smart-simple-filter-details summary,
  .smart-simple-result-tools summary, .smart-simple-complete-actions > strong,
  .smart-funnel-results-head h2 strong, .smart-funnel-round-head > div > span,
  .smart-funnel-current-list > span, .smart-funnel-style-summary > span,
  .smart-funnel-saved-styles > span, .smart-funnel-style-picker-body > header strong
) { color: var(--ui-accent); }
body[data-theme="ink"] :is(.smart-funnel-screen, .names-ai-combo-screen) :is(.smart-funnel-name-main, .smart-funnel-name-main:hover) {
  background: transparent;
  color: var(--ui-text-strong);
}
body[data-theme="ink"] .names-ai-combo-results .smart-funnel-name-grid.ai-combo-actions :is(.smart-funnel-name-card.final-name, .smart-funnel-name-actions) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
}
body[data-theme="ink"] .names-ai-combo-results .smart-funnel-name-grid.ai-combo-actions :is(.smart-funnel-name-actions button, .ai-combo-element-label) {
  border-color: var(--ui-line);
  background: var(--ui-surface-3);
  color: var(--ui-text);
}
body[data-theme="ink"] .names-ai-combo-results .smart-funnel-name-grid.ai-combo-actions .smart-funnel-name-actions button.active {
  border-color: var(--ui-line-strong);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
body[data-theme="ink"] :is(.ai-combo-provider-label, .ai-combo-new-label, .smart-funnel-name-main span, .smart-funnel-name-card summary em, .style-name-main span, .style-name-main em) {
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
body[data-theme="ink"] :is(.ai-combo-card-meta, .ai-combo-card-meta .ai-combo-rank) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.task-card, .task-progress, .style-provider-progress, .task-progress-completed-summary) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.task-stats, .seasonal-stats) > div { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] :is(.task-stats, .seasonal-stats) > div > span { color: var(--ui-text-muted); }
body[data-theme="ink"] .project-style-screen :is(.workflow-step, .first-round-flow > div, .first-round-more-menu > summary, .first-round-more-menu[open] > div) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] .project-style-screen :is(.workflow-step.current, .workflow-step.paused, .first-round-actions .first-round-all-action) { border-color: var(--ui-line-strong); background: var(--ui-warning-soft); color: var(--ui-warning); }
body[data-theme="ink"] .project-style-screen :is(.workflow-step > span, .first-round-flow > div:not(:last-child)::after) { background: var(--ui-surface-3); color: var(--ui-text-muted); }
body[data-theme="ink"] .project-style-screen :is(.first-round-flow > div.complete, .first-round-flow > div.retain) { border-color: var(--ui-line); background: var(--ui-success-soft); }
body[data-theme="ink"] .smart-funnel-screen :is(.smart-compact-style-popover, .smart-compact-stage-popover, .smart-compact-more-popover, .smart-compact-stage > summary) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] .smart-funnel-screen :is(.smart-compact-route, .smart-compact-stage > summary i) { background: var(--ui-accent-soft); color: var(--ui-accent); }
body[data-theme="ink"] .smart-funnel-screen :is(.smart-compact-title h2 strong, .smart-compact-style-trigger b, .smart-compact-stage.completed > summary span, .smart-compact-stage.next > summary span, .smart-funnel-name-card.review-name summary .smart-funnel-review-name) { color: var(--ui-accent); }
body[data-theme="ink"] :is(.task-badge, .style-provider-progress-state em, .smart-simple-process-node i, .smart-workflow-steps i, .smart-funnel-task-title > i) {
  background: var(--ui-surface-3);
  color: var(--ui-text-muted);
}
body[data-theme="ink"] :is(.task-card, .task-progress, .style-provider-progress, .smart-simple-process-node, .smart-funnel-task-row, .ai-name-combo-group).completed,
body[data-theme="ink"] :is(.smart-workflow-steps > div.completed, .smart-combo-provider-progress > span.completed) {
  border-color: var(--ui-success);
  background: var(--ui-success-soft);
}
body[data-theme="ink"] :is(.task-badge.completed, .task-stats .completed strong, .task-detail-hint, .smart-funnel-task-row.completed .smart-funnel-task-title strong, .smart-funnel-task-row.completed .smart-funnel-task-title em) { color: var(--ui-success); }
body[data-theme="ink"] :is(.task-badge.running, .task-stats .running strong) { color: var(--ui-info); }
body[data-theme="ink"] :is(.task-card.running, .task-progress.running, .smart-combo-provider-progress > span.running) { background: var(--ui-info-soft); }
body[data-theme="ink"] :is(.task-card, .task-progress, .style-provider-progress, .smart-simple-process-node, .smart-funnel-task-row).failed {
  border-color: var(--ui-danger);
  background: var(--ui-danger-soft);
}
body[data-theme="ink"] :is(.task-error, .task-badge.failed, .task-stats .failed strong, .smart-funnel-task-error, .smart-funnel-review-lines .risk, .smart-funnel-detail-reviews em) { color: var(--ui-danger); }
body[data-theme="ink"] :is(.task-card.paused, .task-card.partial, .task-progress.paused, .style-provider-progress.retrying, .smart-simple-process-node.running, .smart-simple-process-node.starting, .smart-funnel-label-readiness) {
  border-color: var(--ui-line-strong);
  background: var(--ui-warning-soft);
}
body[data-theme="ink"] :is(.task-badge.paused, .task-badge.partial, .style-provider-progress-state em.retrying, .smart-funnel-label-readiness strong, .task-stats .partial strong, .task-stats .paused strong) { color: var(--ui-warning); }
body[data-theme="ink"] :is(.smart-funnel-task-progress > i, .smart-funnel-task-providers i, .smart-ai-progress > i) { background: var(--ui-surface-4); }
body[data-theme="ink"] :is(.smart-funnel-task-progress > i > u, .smart-funnel-task-providers i > u, .smart-ai-progress > i > u) { background: var(--ui-accent); }

/* AI ranking surfaces; the existing animation canvas retains its pixels. */
body[data-theme="ink"] .ai-name-motion-field,
body[data-theme="ink"] .ai-name-motion-field[data-ai-motion-phase] {
  border-color: var(--ui-line);
  background: radial-gradient(ellipse at 50% 42%, rgba(74, 106, 130, .16), transparent 65%), var(--ui-canvas);
  color: var(--ui-text-strong);
}
body[data-theme="ink"] .ai-name-motion-scene .ai-name-motion-visual::before { background: radial-gradient(ellipse at 30% 35%, rgba(74, 106, 130, .16), transparent 65%), var(--ui-canvas); }
body[data-theme="ink"] .ai-name-motion-field .ai-name-motion-mark { border-color: var(--ui-line-strong); background: var(--ui-surface-1); color: var(--ui-accent); box-shadow: 0 0 64px rgba(215, 187, 133, .08); }
body[data-theme="ink"] .ai-name-motion-field .ai-name-motion-mark::before { border-color: var(--ui-line-strong); }
body[data-theme="ink"] .ai-name-motion-field .ai-name-motion-mark::after { background: radial-gradient(circle, rgba(215, 187, 133, .12), transparent 72%); }
body[data-theme="ink"] .ai-name-motion-field .ai-name-motion-title { color: var(--ui-text-strong); }
body[data-theme="ink"] .ai-name-motion-field :is(.ai-name-motion-subtitle, .ai-name-motion-track) { color: var(--ui-text-muted); }
body[data-theme="ink"] .ai-name-motion-field .ai-name-motion-play { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-accent); }
body[data-theme="ink"] :is(.ai-name-ranking-modal, .name-ranking-workspace, .smart-funnel-detail-modal) {
  border-color: var(--ui-line);
  background: var(--ui-surface-1);
  color: var(--ui-text);
}
body[data-theme="ink"] .names-selection-workspace-open :is(.name-ranking-workspace-toolbar, .name-ranking-compact-card, .name-ranking-compact-card.winner, .name-ranking-compact-actions) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
}
body[data-theme="ink"] .names-selection-workspace-open .name-ranking-workspace :is(.name-ranking-workspace-field, .name-ranking-results) { background: var(--ui-canvas); }
body[data-theme="ink"] .names-selection-workspace-open :is(.name-ranking-compact-title, .name-ranking-title-button, .name-ranking-title-button strong, .name-ranking-workspace-heading strong, .name-ranking-workspace-empty strong) { background: transparent; color: var(--ui-text-strong); }
body[data-theme="ink"] .names-selection-workspace-open :is(.name-ranking-workspace-heading span, .name-ranking-workspace-empty span, .name-ranking-compact-meta) { color: var(--ui-text-muted); }
body[data-theme="ink"] .names-selection-workspace-open :is(.name-ranking-compact-meta > span, .name-ranking-compact-labels > span) { background: var(--ui-accent-soft); color: var(--ui-accent); }
body[data-theme="ink"] .names-selection-workspace-open .name-ranking-workspace-notice { background: var(--ui-warning-soft); color: var(--ui-warning); border-color: var(--ui-line-strong); }

/* Style, seasonal sources, material collection, and rule workbenches. */
body[data-theme="ink"] :is(
  .seasonal-context-panel, .seasonal-theme-summary, .seasonal-derived-grid > div,
  .material-card, .material-summary-row > div, .material-choice-options,
  .material-pack-options, .material-group-selection, .material-ocr-modal,
  .material-ocr-candidates, .managed-rule-list, .managed-rule-editor,
  .ai-rule-panel details, .zodiac-rule-sidebar, .zodiac-rule-detail-pane,
  .zodiac-preview-pane, .zodiac-artwork-editor, .zodiac-artwork-card,
  .zodiac-catalog-card, .zodiac-char-card, .zodiac-rule-card,
  .style-profile-warning, .frequency-group, .aesthetic-section, .risk-panel
) {
  border-color: var(--ui-line);
  background: var(--ui-surface-1);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.managed-rule-list-item, .material-pack-chip, .material-staged-images span, .material-ocr-upload, .zodiac-traditional-reason, .zodiac-match-paths, .zodiac-test-item-button) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.style-char-tile, .style-name-tile, .seasonal-name-tile) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-text-strong);
}
body[data-theme="ink"] :is(.style-char-tile, .style-name-tile).pinyin-sorted { border-color: hsl(var(--pinyin-hue) 25% 42%); background: var(--ui-surface-2); }
body[data-theme="ink"] :is(.style-char-tile, .style-name-tile, .seasonal-name-tile) :is(span, em) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.style-char-tile.selected, .style-name-tile.favorite, .style-name-tile.candidate, .seasonal-name-tile.recommended, .managed-rule-list-item.active) {
  border-color: var(--ui-line-strong);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
body[data-theme="ink"] :is(.style-char-tile.selected strong, .style-name-tile.favorite em, .style-name-tile.candidate em, .seasonal-review-status) { color: var(--ui-accent); }
body[data-theme="ink"] .project-style-screen :is(.role-tabs, .seasonal-name-tabs, .style-profile-buttons) button.active { border-color: var(--ui-line-strong); background: var(--ui-accent-soft); color: var(--ui-accent); }
body[data-theme="ink"] .seasonal-screen .seasonal-derived-grid strong { color: var(--ui-text-strong); }
body[data-theme="ink"] .seasonal-screen :is(.seasonal-primary-fields .field > label, .seasonal-derived-grid > div > span) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.material-bulk-result, .material-bulk-result strong, .material-bulk-result em, .rule-version-badge) { background: var(--ui-success-soft); color: var(--ui-success); }
body[data-theme="ink"] :is(.material-bulk-result.has-invalid, .material-bulk-result.has-invalid strong, .managed-rule-locked, .zodiac-test-warning) { background: var(--ui-warning-soft); color: var(--ui-warning); border-color: var(--ui-line-strong); }
body[data-theme="ink"] :is(.managed-rule-list-item span, .managed-rule-list-item small, .managed-rule-number small, .managed-rule-history time) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.managed-rule-impact, .managed-rule-head span, .material-hit-badge, .material-hit-dot) { color: var(--ui-accent); }
body[data-theme="ink"] :is(.material-hit-badge, .material-hit-dot) { background: var(--ui-accent-soft); }
body[data-theme="ink"] :is(.zodiac-admin-workspace-tabs, .ai-rules-nav, .rule-category-switch) button.active { border-color: var(--ui-line-strong); background: var(--ui-accent-soft); color: var(--ui-accent); }

/* Formal poetry source library and project workbench (not Poetry V). */
body[data-theme="ink"] .poetry-project-screen {
  --poetry-ink: var(--ui-text-strong);
  --poetry-muted: var(--ui-text-muted);
  --poetry-accent: var(--ui-accent);
  --poetry-panel: var(--ui-surface-1);
  --poetry-surface: var(--ui-surface-2);
  --poetry-card: var(--ui-surface-2);
  --poetry-border: var(--ui-line);
  --poetry-soft: var(--ui-accent-soft);
  --poetry-source: var(--ui-surface-3);
}
body[data-theme="ink"] .poetry-project-screen :is(.poetry-project-name-card:hover, .poetry-project-count, .poetry-project-card-relation) { background: var(--ui-surface-2); border-color: var(--ui-line-strong); }
body[data-theme="ink"] .poetry-project-screen :is(.poetry-project-primary-filters label, .poetry-project-secondary-filters label, .poetry-project-check-filters label, .poetry-project-selected-work, .poetry-project-filter-note, .poetry-project-card-elements, .poetry-project-card-notes, .poetry-project-card-source-meta) { color: var(--ui-text-muted); }
body[data-theme="ink"] .poetry-project-screen :is(.poetry-project-filter-settings > summary, .poetry-project-source-details > summary, .poetry-project-active-filters > span, .poetry-project-collapsed-rail > span, .poetry-project-card-relation, .poetry-project-card-source-button, .poetry-project-card-actions button, .poetry-project-card-tags .match) { color: var(--ui-accent); }
body[data-theme="ink"] .poetry-project-screen :is(.poetry-project-count strong, .poetry-project-card-source, .poetry-project-result-actions select) { color: var(--ui-text-strong); }
body[data-theme="ink"] .poetry-project-screen .poetry-empty-result strong { color: var(--ui-text-strong); }
body[data-theme="ink"] .poetry-project-screen :is(.poetry-project-card-actions button.is-active, .poetry-project-warning-trigger) { background: var(--ui-accent-soft); color: var(--ui-accent); }
body[data-theme="ink"] :is(
  .poetry-manager-list, .poetry-manager-reader, .poetry-manager-materials,
  .poetry-manager-book, .poetry-manager-material-group, .poetry-manager-material-card,
  .poetry-manager-versions, .poetry-manager-editor > header, .poetry-manager-import[open],
  .poetry-surname-name-list > article, .poetry-surname-directory-list > button,
  .poetry-source-hover-panel, .poetry-material-editor-dialog,
  .poetry-archive-preview-dialog, .poetry-preview-group, .poetry-preview-material
) { border-color: var(--ui-line); background: var(--ui-surface-1); color: var(--ui-text); }
body[data-theme="ink"] :is(
  .poetry-manager-stats span, .poetry-manager-view-tabs, .poetry-manager-work-item,
  .poetry-manager-material-field, .poetry-manager-versions details,
  .poetry-source-line, .poetry-source-hover-head, .poetry-source-hover-panel > footer,
  .poetry-surname-source-list section, .poetry-preview-work, .poetry-preview-work > header,
  .poetry-preview-batch-summary, .poetry-preview-poem
) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] :is(.poetry-manager-work-fields, .poetry-material-editor-grid, .poetry-manager-search, .poetry-manager-category) :is(input, textarea, select) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] :is(.poetry-manager-work-item.selected, .poetry-manager-work-item:hover, .poetry-surname-directory-list > button.selected, .poetry-manager-book-meta span, .poetry-manager-book-meta em, .poetry-manager-material-card header span, .poetry-manager-import > summary, .poetry-manager-import[open] > summary) { border-color: var(--ui-line-strong); background: var(--ui-accent-soft); color: var(--ui-accent); }
body[data-theme="ink"] :is(.poetry-manager-book > h2, .poetry-manager-book > section.meaning > div, .poetry-manager-material-field p, .poetry-manager-versions pre, .poetry-source-hover-head h3, .poetry-surname-name-list > article > header strong, .poetry-name-summary-list > article > p, .poetry-preview-poem p, .poetry-preview-material dd, .poetry-preview-material > header strong) { color: var(--ui-text-strong); }
body[data-theme="ink"] :is(.poetry-manager-work-item small, .poetry-manager-work-item i, .poetry-manager-book-byline, .poetry-manager-material-card header em, .poetry-manager-material-card footer > span, .poetry-manager-material-card footer > small, .poetry-manager-material-group > header p, .poetry-manager-stats small, .poetry-manager-import-body > p, .poetry-source-line span, .poetry-source-hover-head p, .poetry-surname-directory-list small, .poetry-surname-source-list p) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.poetry-manager-stats strong, .poetry-manager-material-card strong, .poetry-manager-material-field h4, .poetry-manager-book > section h3, .poetry-manager-versions summary, .poetry-source-line b, .poetry-source-detail h4, .poetry-manager-list header > strong, .poetry-manager-materials header > strong, .poetry-surname-directory-list em, .poetry-surname-source-list span, .poetry-preview-group-head h3, .poetry-preview-work > header h3, .poetry-preview-poem strong) { color: var(--ui-accent); }
body[data-theme="ink"] :is(.poetry-manager-work-status span.enabled, .poetry-preview-counts span) { background: var(--ui-success-soft); color: var(--ui-success); }
body[data-theme="ink"] :is(.poetry-manager-work-status span.disabled, .poetry-manager-version-error) { background: var(--ui-danger-soft); color: var(--ui-danger); }
body[data-theme="ink"] :is(.poetry-manager-edit-note, .poetry-preview-issues, .poetry-preview-manual-review) { background: var(--ui-warning-soft); color: var(--ui-warning); }
body[data-theme="ink"] .poetry-source-detail-layer { background: rgba(3, 8, 13, .86); }

/* Delivery controls and review chrome. No selector enters a PDF/book page. */
body[data-theme="ink"] .delivery-desktop { --delivery-line: var(--ui-line); }
body[data-theme="ink"] .delivery-desktop .delivery-name-group {
  --delivery-group-accent: var(--ui-accent);
  border-color: var(--ui-line-strong);
  background: linear-gradient(180deg, var(--ui-surface-2), var(--ui-surface-1));
  color: var(--ui-text);
  box-shadow: var(--ui-shadow-panel);
}
body[data-theme="ink"] .delivery-desktop .delivery-name-group--primaryNames { --delivery-group-accent: var(--ui-success); }
body[data-theme="ink"] .delivery-desktop .delivery-name-group--extendedNames { --delivery-group-accent: var(--ui-text-muted); }
body[data-theme="ink"] .delivery-desktop .delivery-name-group.disabled { opacity: 1; border-color: var(--ui-line); }
body[data-theme="ink"] .delivery-desktop .delivery-name-group > :is(header, footer) { border-color: var(--ui-line); }
body[data-theme="ink"] .delivery-desktop .delivery-name-group > header :is(h3, strong, small) { color: var(--delivery-group-accent); }
body[data-theme="ink"] .delivery-desktop .delivery-name-group .delivery-name-group-chips span { border-color: var(--ui-line); background: var(--ui-surface-3); color: var(--ui-text-strong); }
body[data-theme="ink"] :is(
  .delivery-section, .delivery-request-strategy, .delivery-readiness,
  .delivery-review-dialog, .delivery-review-editor, .delivery-library-picker,
  .delivery-external-custom-dialog, .delivery-twin-dialog, .delivery-twin-panel,
  .delivery-template-builder, .delivery-formal-empty, .delivery-report-empty
) {
  border-color: var(--ui-line);
  background: var(--ui-surface-1);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(
  .delivery-role-row, .delivery-name-group, .delivery-report-row,
  .delivery-template-module, .delivery-library-card, .delivery-library-group,
  .delivery-request-strategy-grid > div, .delivery-fact-grid > div,
  .delivery-external-group, .delivery-external-name, .delivery-task-recovery,
  .delivery-twin-member, .delivery-twin-child-workspace, .delivery-twin-provenance
) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(
  .delivery-review-header, .delivery-review-footer, .delivery-review-sections,
  .delivery-review-preview-head, .delivery-review-savebar, .delivery-role-floating-save,
  .delivery-smart-build, .delivery-template-module-index, .delivery-source-text,
  .delivery-name-group-chips > span, .delivery-twin-extended-members > span,
  .delivery-color-field, .delivery-report-round-toolbar
) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.delivery-review-preview, .delivery-review-pdf-stage) { background: var(--ui-canvas-deep); }
body[data-theme="ink"] :is(.delivery-readiness-grid > button, .delivery-review-sections > button, .delivery-role-choices button, .delivery-record-tabs button, .delivery-desktop-tabs button, .delivery-zone-tabs button, .delivery-library-tabs button) {
  border-color: var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.delivery-desktop-tabs, .delivery-record-tabs, .delivery-zone-tabs, .delivery-library-tabs, .delivery-role-choices, .delivery-review-sections) > button.active {
  border-color: var(--ui-line-strong);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
body[data-theme="ink"] :is(.delivery-readiness-grid > button.complete, .delivery-review-status, .delivery-readiness.ready, .delivery-publication-status.published) { background: var(--ui-success-soft); color: var(--ui-success); }
body[data-theme="ink"] :is(.delivery-readiness-grid > button.blocked, .delivery-readiness.blocked, .delivery-publication-status.withdrawn) { background: var(--ui-danger-soft); color: var(--ui-danger); }
body[data-theme="ink"] :is(.delivery-readiness-grid > button.warning, .delivery-review-facts-lock, .delivery-review-status.stale) { background: var(--ui-warning-soft); color: var(--ui-warning); }
body[data-theme="ink"] .delivery-readiness-grid > button em { color: inherit; }
body[data-theme="ink"] :is(.delivery-review-header p, .delivery-review-footer span, .delivery-review-editor-head p, .delivery-review-savebar span, .delivery-review-preview-head span, .delivery-review-sections > button small, .delivery-role-meta, .delivery-role-note, .delivery-report-meta, .delivery-template-module-copy span) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.delivery-review-header small, .delivery-review-editor-head small, .delivery-review-sections > strong, .delivery-review-sections > button span, .delivery-review-facts-lock span, .delivery-name-group > h3, .delivery-report-title) { color: var(--ui-accent); }

/* Memo chrome only: the editable paper remains the export's light document. */
body[data-theme="ink"] .memo-workspace { color: var(--ui-text); }
body[data-theme="ink"] :is(.memo-list, .memo-empty) { border-color: var(--ui-line); background: var(--ui-surface-1); color: var(--ui-text-muted); }
body[data-theme="ink"] .memo-list-item { color: var(--ui-text); background: transparent; }
body[data-theme="ink"] .memo-list-item.active { color: var(--ui-accent); background: var(--ui-accent-soft); }
body[data-theme="ink"] :is(.memo-header p, .memo-list-item small, .memo-list > p) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.memo-header small, .memo-save-state, .memo-preview-heading button) { color: var(--ui-accent); }
body[data-theme="ink"] :is(.memo-header > button, .memo-actions button) { border-color: var(--ui-line-strong); background: var(--ui-accent); color: var(--ui-text-on-accent); }
body[data-theme="ink"] .memo-actions button:not(:first-of-type) { background: var(--ui-surface-2); color: var(--ui-text); }

/* Portal users, customer admin, overview cards and release notes. */
body[data-theme="ink"] :is(.admin-overview-page, .admin-workbench) {
  /* Opaque color lets the existing brain iframe detect dark host mode. */
  background: var(--ui-canvas);
  color: var(--ui-text);
}
body[data-theme="ink"] .admin-overview-card {
  --card-accent: var(--ui-accent);
  --card-soft: var(--ui-accent-soft);
  --card-orb: rgba(215, 187, 133, .07);
  border-color: var(--ui-line);
  background: var(--ink-glass, var(--ui-surface-1));
  box-shadow: var(--ui-shadow-panel);
}
body[data-theme="ink"] :is(.admin-overview-title > span, .admin-overview-card-copy h2, .admin-overview-title p) { color: var(--ui-text-muted); }
body[data-theme="ink"] :is(.admin-overview-title h1, .admin-overview-card-copy strong) { color: var(--ui-text-strong); }
body[data-theme="ink"] :is(.admin-brain-panel, .admin-current-panel, .admin-overview-band, .admin-overview-health, .admin-completion-visual, .admin-active-record, .admin-recent-row, .admin-task-row, .admin-quick-card, .customer-stat-strip, .customer-list-toolbar, .customer-list-footer, .pm-panel, .pm-grants article, .release-summary-grid article, .release-entry-content, .release-entry-version, .release-change-group) {
  border-color: var(--ui-line);
  background: var(--ui-surface-1);
  color: var(--ui-text);
}
body[data-theme="ink"] :is(.admin-kpi-card, .admin-task-list button, .admin-library-strip button, .admin-backup-latest, .pm-generated code) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] :is(.admin-overview-health-list button, .admin-kpi-card > span, .admin-quick-mark, .pm-generated code, .pm-loading) { color: var(--ui-accent); }
body[data-theme="ink"] .pm-page { --input-bg: var(--ui-surface-2); }
body[data-theme="ink"] .pm-badge { background: var(--ui-surface-3); color: var(--ui-text-muted); }
body[data-theme="ink"] .pm-badge.pm-good { background: var(--ui-success-soft); color: var(--ui-success); }
body[data-theme="ink"] :is(.pm-error, .pm-form-error) { color: var(--ui-danger); }
body[data-theme="ink"] .release-history-hero { border-color: var(--ui-line-strong); background: linear-gradient(135deg, var(--ui-surface-2), var(--ui-surface-1)); }
body[data-theme="ink"] .release-history-page :is(.release-summary-grid strong, .release-entry-version strong, .release-change-group h3, .release-entry-content > header > div > span) { color: var(--ui-accent); }
body[data-theme="ink"] .release-history-page .release-change-group li { color: var(--ui-text); }

/* Rednote entry uses its local palette; decorative cover artwork stays intact. */
body[data-theme="ink"] .xhs-creation-hub {
  --xch-ink: var(--ui-text-strong);
  --xch-muted: var(--ui-text-muted);
  --xch-bg: var(--ui-canvas);
  --xch-card: var(--ui-surface-1);
  --xch-card-border: var(--ui-line);
  --xch-note-bg: linear-gradient(145deg, var(--ui-surface-2), var(--ui-surface-1));
  --xch-note-border: var(--ui-line-strong);
  --xch-pill-bg: var(--ui-accent-soft);
  --xch-pill-border: var(--ui-line-strong);
  --xch-pill-ink: var(--ui-accent);
  --xch-label-bg: var(--ui-surface-3);
  --xch-label-ink: var(--ui-text-muted);
  --xch-note-label-bg: var(--ui-accent-soft);
  --xch-note-label-ink: var(--ui-accent);
  --xch-reply-button: var(--ui-accent);
  --xch-shadow: var(--ui-shadow-panel);
  --xch-hover-shadow: var(--ui-shadow-panel);
  color-scheme: dark;
}
body[data-theme="ink"] .xhs-creation-hub .xch-heading h1 { font-family: var(--ink-font-display); letter-spacing: .06em; }
body[data-theme="ink"] .xhs-creation-hub .xch-entry-button { color: var(--ui-text-on-accent); }

/* Comment workbench: reset its explicit light palette, not the site shell. */
body[data-theme="ink"] .xhs-reply-screen {
  --reply-ink: var(--ui-text);
  --reply-muted: var(--ui-text-muted);
  --reply-line: var(--ui-line);
  --reply-accent: var(--ui-accent);
  color: var(--ui-text);
}
body[data-theme="ink"] .xhs-reply-screen.xhs-reply--dual {
  --ui-text: inherit;
  --ui-text-strong: inherit;
  --ui-text-muted: inherit;
  --ui-line: inherit;
  --ui-surface-2: inherit;
  --ui-surface-3: inherit;
  --ui-surface-4: inherit;
}
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-composer, .xhs-result-pane, .xhs-compare-lane, .xhs-history, .xhs-final-panel, .xhs-drawer, .xhs-reply-history, .xhs-admin-corrections, .xhs-poetry-reply-card, .xhs-evidence-grid section) { border-color: var(--ui-line); background: var(--ui-surface-1); color: var(--ui-text); }
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-final-reply, .xhs-poetry-name-option, .xhs-history-list button, .xhs-admin-correction-body p) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] .xhs-reply--dual :is(.xhs-composer, .xhs-result-pane, .xhs-final-panel) { background: transparent; }
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-compare-reading, .xhs-compare-lane-head strong, .xhs-compare-nav > strong, .xhs-recent h2, .xhs-reply-head h1, .xhs-composer > label) { color: var(--ui-text-strong); }
body[data-theme="ink"] .xhs-reply-screen :is(input, textarea, select, .xhs-compare-text) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); caret-color: var(--ui-accent); }
body[data-theme="ink"] .xhs-reply-screen button { border-color: var(--ui-line-strong); background: var(--ui-accent); color: var(--ui-text-on-accent); }
body[data-theme="ink"] .xhs-reply-screen button:hover:not(:disabled) { border-color: var(--ui-accent); background: var(--ui-accent-strong); color: var(--ui-text-on-accent); }
body[data-theme="ink"] .xhs-reply-screen :is(button.secondary, .xhs-mode-tabs, .xhs-mode-tabs button, .xhs-compare-tabs, .xhs-compare-tabs button) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text-muted); }
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-mode-tabs button.active, .xhs-compare-tabs button[aria-selected="true"]) { background: var(--ui-accent-soft); color: var(--ui-accent); }
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-text-button, .xhs-context-toggle, .xhs-recent-list button) { border-color: var(--ui-line); background: transparent; color: var(--ui-text-muted); }
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-page-bar, .xhs-recent, .xhs-recent-list, .xhs-compare-lane-actions) { border-color: var(--ui-line); }
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-compare-state, .xhs-provider-ready, .xhs-compare-lane-actions label, .xhs-compare-lane-actions small, .xhs-recent-list time, .xhs-history-empty, .xhs-compare-selection, .xhs-final-count, .xhs-compare-toolbar small, .xhs-compare-empty) { color: var(--ui-text-muted); }
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-connection-warning, .xhs-compare-wait p, .xhs-compare-error-details summary) { background: var(--ui-warning-soft); color: var(--ui-warning); }
body[data-theme="ink"] .xhs-reply-screen .xhs-progress-track { background: var(--ui-surface-3); }
body[data-theme="ink"] .xhs-reply-screen .xhs-progress-track i { background: var(--ui-accent); }
body[data-theme="ink"] .xhs-reply-screen :is(.xhs-compare-lane.is-selected, .xhs-compare-lane.is-expanded) { border-color: var(--ui-line-strong); }

/* Note studio palette only changes UI tokens, never the 1080 × 1440 artwork. */
body[data-theme="ink"] :is(.xhs-note-studio, .xhs-minimal-editor, .xhs-note-minimal-editor) {
  --xts-ink: var(--ui-text-strong);
  --xts-muted: var(--ui-text-muted);
  --xts-bg: var(--ui-canvas);
  --xts-panel: var(--ui-surface-1);
  --xts-line: var(--ui-line);
  --xts-soft: var(--ui-surface-2);
  --xts-red: #e98c98;
  --xts-red-soft: rgba(233, 140, 152, .11);
  --xts-green: var(--ui-success);
  --xts-green-soft: var(--ui-success-soft);
  --xts-stage: var(--ui-canvas-deep);
  --xts-stage-dot: #293944;
  --xts-purple-soft: var(--ui-intelligence-soft);
  --xts-toolbar-gold: var(--ui-accent);
  color: var(--ui-text);
}
body[data-theme="ink"] .xhs-note-studio :is(.xhs-studio-hero, .xhs-current-context, .xhs-workbench, .xhs-studio-editor, .xhs-settings-drawer, .xhs-note-settings-drawer, .xhs-copy-library-editor, .xhs-copy-library-entry, .xhs-recent-notes, .xhs-private-notice, .xhs-reference-panel, .xhs-canvas-panel, .xhs-properties-panel, .xhs-note-tools, .xhs-note-workbench, .xhs-page-management, .xhs-ai-template-card) {
  border-color: var(--ui-line);
  background: var(--ui-surface-1);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow-panel);
}
body[data-theme="ink"] .xhs-note-studio :is(.xhs-property-section, .xhs-layer-row, .xhs-list-item, .xhs-layer-select, .xhs-inline-help, .xhs-note-export-bar, .xhs-copy-library-page, .xhs-copy-library-raw-text, .xhs-settings-template-section, .xhs-settings-current, .xhs-settings-ai, .xhs-studio-secondary-tools) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] .xhs-note-studio .xhs-studio-workspace { border-color: var(--ui-line); background: var(--ui-canvas); box-shadow: none; }
body[data-theme="ink"] .xhs-note-studio .xhs-studio-redbook { background: #a12b42; color: #fff; }
body[data-theme="ink"] .xhs-minimal-editor.xhs-template-studio-workbench:not(.xhs-background-library-workspace) > .xhs-studio-workspace > .xhs-template-library > .xhs-settings-template-section > footer.xhs-template-library-footer { border-color: #a12b42; background: #a12b42; color: #fff; }
body[data-theme="ink"] .xhs-note-studio :is(.xhs-list-item.active, .xhs-layer-row.active, .xhs-template-list-item.draft.active) { border-color: var(--ui-line-strong); background: var(--ui-accent-soft); color: var(--ui-accent); }
body[data-theme="ink"] :is(.xhs-dialog, .xhs-prompt-dialog, .xhs-prompt-more-menu, .xhs-template-page-context-menu, .xhs-ai-background-dialog, .xhs-reference-review) { border-color: var(--ui-line); background: var(--ui-surface-1); color: var(--ui-text); }
body[data-theme="ink"] :is(.xhs-dialog-input, .xhs-reference-review-head, .xhs-reference-review-summary, .xhs-reference-review-actions, .xhs-reference-review-item, .xhs-ai-background-loading, .xhs-ai-background-start) { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); }
body[data-theme="ink"] .xhs-template-studio-workbench:not(.xhs-background-library-workspace) .xhs-studio-workspace > :is(.xhs-workbench, .xhs-studio-editor) { border-color: var(--ui-line); box-shadow: var(--ui-shadow-panel); }
body[data-theme="ink"] .xhs-template-studio-workbench:not(.xhs-background-library-workspace) :is(.xhs-studio-editor-heading, .xhs-studio-tool-tabs, .xhs-page-manager, .xhs-studio-editor-footer, .xhs-studio-secondary-tools) { border-color: var(--ui-line); box-shadow: none; }
body[data-theme="ink"] .xhs-template-studio-workbench:not(.xhs-background-library-workspace) .xhs-studio-actionbar { border-color: var(--ui-line-strong); background: var(--ui-surface-1); box-shadow: var(--ui-shadow-panel); }
body[data-theme="ink"] .xhs-template-studio-workbench:not(.xhs-background-library-workspace) .xhs-studio-design-tools > .xhs-studio-assets-section { border-color: var(--ui-line); background: var(--ui-surface-2); color: var(--ui-text); box-shadow: inset 2px 0 var(--ui-line-strong); }
body[data-theme="ink"] .xhs-template-studio-workbench:not(.xhs-background-library-workspace) .xhs-studio-assets-section > .xhs-studio-background-heading { color: var(--ui-accent); }
body[data-theme="ink"] .xhs-template-studio-workbench:not(.xhs-background-library-workspace) .xhs-studio-assets-section > .xhs-studio-background-heading::after { border-color: var(--ui-line-strong); background: var(--ui-accent-soft); color: var(--ui-accent); }

body[data-theme="ink"] :is(.memo-header h1, .pm-heading h1, .admin-overview-title h1, .xhs-reply-head h1, .delivery-page-head h1) { font-family: var(--ink-font-display); color: var(--ui-text-strong); }
