/* Shared appearance authority. Page canvas/artwork is deliberately absent.
   Screen-only controls never alter the compact, ink-on-paper print contract. */
@media screen {
  body[data-appearance="shared"] {
    --appearance-heading: var(--theme-heading);
    --appearance-link: var(--theme-link);
    --appearance-link-hover: var(--theme-link-hover);
    --appearance-form-text: var(--theme-form-text);
    --appearance-form-background: var(--theme-form-background);
    --appearance-form-border: var(--theme-form-border);
    font-family: var(--theme-body-font, Lato, system-ui, sans-serif); }
  body[data-appearance="shared"]:not(.dyslexia-mode) :is(h1,h2,h3,h4) { font-family: var(--theme-heading-font, Georgia, serif); color: var(--appearance-heading, var(--theme-text)); }
  body[data-appearance="shared"] :is(.character-workspace,.character-editor-preview) {
    --appearance-heading: var(--sheet-heading, var(--theme-sheet-heading));
    --appearance-link: var(--sheet-accent, var(--theme-sheet-accent));
    --appearance-link-hover: var(--sheet-heading, var(--theme-sheet-heading));
    --appearance-form-text: var(--sheet-ink, var(--theme-sheet-ink));
    --appearance-form-background: var(--sheet-paper-alt, var(--theme-sheet-paper-alt));
    --appearance-form-border: var(--sheet-line, var(--theme-sheet-line));
  }
  body[data-appearance="shared"] :is(.campaign-disclosure,.hearth-book-info) {
    --appearance-heading: var(--theme-disclosure-foreground);
    --appearance-link: var(--theme-disclosure-link);
    --appearance-link-hover: var(--theme-disclosure-link-hover);
  }
  body[data-appearance="shared"].dyslexia-mode,
  body[data-appearance="shared"].dyslexia-mode :is(h1,h2,h3,h4,input,select,textarea,button) { font-family: OpenDyslexic, "Atkinson Hyperlegible", Verdana, sans-serif; letter-spacing: .025em; line-height: 1.6; }
  body[data-appearance="shared"] .topbar { color: var(--theme-header-text); }
  body[data-appearance="shared"] .brand small { color: var(--theme-header-muted); }
  body[data-appearance="shared"] .brand-mark { color: var(--theme-header-detail); }
  body[data-appearance="shared"] .sidebar { background: linear-gradient(180deg,var(--theme-sidebar),var(--theme-sidebar-end)); }
  body[data-appearance="shared"] .sidebar .sidebar-heading { color: var(--theme-sidebar-muted); }
  body[data-appearance="shared"] .sidebar .campaign-link { color: var(--theme-sidebar-text); }
  body[data-appearance="shared"] :is(.panel,.record-card,.empty-state) { border-radius: var(--theme-corner-style); }
  body[data-appearance="shared"] :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea) { color: var(--appearance-form-text); background: var(--appearance-form-background); border-color: var(--appearance-form-border); }
  body[data-appearance="shared"] dialog { color: var(--theme-text); background: var(--theme-dialog); }
  body[data-appearance="shared"] :is(a:not(.button),button,input,select,textarea,summary):focus-visible { outline: 3px solid var(--theme-focus); outline-offset: 3px; }
  body[data-appearance="shared"] :is(hr,.section-heading) { border-color: var(--theme-divider); border-bottom-style: var(--theme-divider-style); }
  body[data-appearance="shared"] :is(.panel,.record-card,.ll-detail,.ll-card,.markdown-body) a:not(.button) { color: var(--appearance-link); }
  body[data-appearance="shared"] :is(.panel,.record-card,.ll-detail,.ll-card,.markdown-body) a:not(.button):hover { color: var(--appearance-link-hover); }
  body[data-appearance="shared"] :is(.record-card,.pregen-card,.ll-card) { background: linear-gradient(145deg,var(--theme-card),var(--theme-card-end)); }
  body[data-appearance="shared"] :is(.record-card,.pregen-card,.ll-card):hover { background: linear-gradient(145deg,var(--theme-card-hover),var(--theme-card-hover-end)); }
  body[data-appearance="shared"] :is(.errorlist,.field-error,.message.error) { color: var(--theme-danger); }
  body[data-appearance="shared"] .message.success { color: var(--theme-success); }
  body[data-appearance="shared"] .message.warning { color: var(--theme-warning); }
  body[data-appearance="shared"] .message.info { color: var(--theme-info); }
  body[data-appearance="shared"] .button.primary:not(:disabled) { color: var(--theme-action-primary-foreground); background: var(--theme-action-primary-background); border-color: var(--theme-action-primary-border); }
  body[data-appearance="shared"] .button.primary:not(:disabled):hover { color: var(--theme-action-primary-hover-foreground); background: var(--theme-action-primary-hover-background); border-color: var(--theme-action-primary-hover-border); }
  body[data-appearance="shared"] .button.primary:not(:disabled):active { color: var(--theme-action-primary-active-foreground); background: var(--theme-action-primary-active-background); border-color: var(--theme-action-primary-active-border); }
  body[data-appearance="shared"] :is(.button.ghost,.button.secondary):not(:disabled) { color: var(--theme-action-secondary-foreground); background: var(--theme-action-secondary-background); border-color: var(--theme-action-secondary-border); }
  body[data-appearance="shared"] :is(.button.ghost,.button.secondary):not(:disabled):hover { color: var(--theme-action-secondary-hover-foreground); background: var(--theme-action-secondary-hover-background); border-color: var(--theme-action-secondary-hover-border); }
  body[data-appearance="shared"] :is(.button.ghost,.button.secondary):not(:disabled):active { color: var(--theme-action-secondary-active-foreground); background: var(--theme-action-secondary-active-background); border-color: var(--theme-action-secondary-active-border); }
  body[data-appearance="shared"] .button.danger:not(:disabled) { color: var(--theme-action-destructive-foreground); background: var(--theme-action-destructive-background); border-color: var(--theme-action-destructive-border); }
  body[data-appearance="shared"] .button.danger:not(:disabled):hover { color: var(--theme-action-destructive-hover-foreground); background: var(--theme-action-destructive-hover-background); border-color: var(--theme-action-destructive-hover-border); }
  body[data-appearance="shared"] .button.danger:not(:disabled):active { color: var(--theme-action-destructive-active-foreground); background: var(--theme-action-destructive-active-background); border-color: var(--theme-action-destructive-active-border); }
  body[data-appearance="shared"] .button[aria-pressed="true"] { color: var(--theme-action-selected-foreground); background: var(--theme-action-selected-background); border-color: var(--theme-action-selected-border); }
  body[data-appearance="shared"] .button:disabled { color: var(--theme-action-disabled-foreground); background: var(--theme-action-disabled-background); border-color: var(--theme-action-disabled-border); opacity: var(--theme-action-disabled-opacity); }
  body[data-appearance="shared"] .button:focus-visible { outline-color: var(--theme-action-focus); }
  .appearance-editor .appearance-sample { padding: 1rem; border: 1px var(--theme-divider-style) var(--theme-border); border-radius: var(--theme-corner-style); background: var(--theme-panel); color: var(--theme-text); }
  .appearance-sample a { color: var(--theme-link); }
  .appearance-sample a:hover { color: var(--theme-link-hover); }
  .appearance-success { color: var(--theme-success); }
  .appearance-danger { color: var(--theme-danger); }
  .appearance-warning { color: var(--theme-warning); }
}
.appearance-editor { text-align: left; max-width: 64rem; min-width: 0; }
.appearance-editor :is(h2,h3,p,label,select,input) { text-align: left; }
.appearance-editor input:not([type=hidden]), .appearance-editor select { width: 100%; max-width: 32rem; min-width: 0; }
.appearance-editor .field-grid { min-width: 0; }
.appearance-editor .field { min-width: 0; }
.appearance-editor .form-actions { justify-content: flex-start; flex-wrap: wrap; }
.appearance-editor [hidden] { display: none !important; }
body.campaign-settings-page .main-content { max-width: none; width: 100%; margin-left: 0; }
@media (max-width: 650px) { .appearance-editor .field-grid.two { grid-template-columns: minmax(0,1fr); } }
@media screen {
  /* Light ledger ink needs bounded paper while the surrounding canvas stays open. */
  body.lantern-ledger-theme .ll-header,
  body.lantern-ledger-theme .ll-toolbar,
  body.lantern-ledger-theme .ll-pagination,
  body.lantern-ledger-theme .campaign-settings-workspace > :is(h1,p) { padding: 1rem; border: 1px solid var(--theme-border); border-radius: var(--theme-corner-style); background: var(--theme-panel); }
  body.lantern-ledger-theme .campaign-settings-workspace { padding: 1rem; }
}

.appearance-editor input[type=color] { width: 4rem; height: 2.5rem; padding: .2rem; }

@media screen {
  /* Text over decorative paper uses the shared bounded reading-surface roles. */
  body[data-appearance="shared"] .hearth-book-info { background: var(--theme-disclosure-background); color: var(--theme-disclosure-foreground); border-radius: 3px; }
  body[data-appearance="shared"] .hearth-book-info h2,
  body[data-appearance="shared"] .hearth-book-info .hearth-book-info__description { color: var(--theme-disclosure-foreground); }
  body[data-appearance="shared"] .hearth-book-info .eyebrow { color: var(--theme-disclosure-accent); }
  body[data-appearance="shared"].dyslexia-mode .hearth-book-info .hearth-book-info__description { font-family: OpenDyslexic, "Atkinson Hyperlegible", Verdana, sans-serif; }
}

@media screen {
  .collection-resource-style {
    --appearance-heading: var(--theme-heading);
    --appearance-link: var(--theme-link);
    --appearance-link-hover: var(--theme-link-hover);
    --appearance-form-text: var(--theme-form-text);
    --appearance-form-background: var(--theme-form-background);
    --appearance-form-border: var(--theme-form-border);
    color: var(--theme-text);
    font-family: var(--theme-body-font);
  }
  .dyslexia-mode .collection-resource-style { font-family: OpenDyslexic, Verdana, sans-serif; }
}
