/* Owner-only photo management on the character library. */

body.character-shell .character-library-admin-actions,
body.character-shell .character-photo-editor {
  --ink: #e9ecef;
  --paper: #1f2328;
  --moss: #6ea8fe;
  --wine: #adb5bd;
  --panel: #2b3035;
  --line: #495057;
  --muted: #adb5bd;
  --danger: #ea868f;
  color-scheme: dark;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] body.character-shell .character-library-admin-actions,
[data-theme="light"] body.character-shell .character-photo-editor {
  --ink: #212529;
  --paper: #ffffff;
  --moss: #0d6efd;
  --wine: #6c757d;
  --panel: #f8f9fa;
  --line: #dee2e6;
  --muted: #6c757d;
  --danger: #dc3545;
  color-scheme: light;
}

body.character-shell .character-library-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

body.character-shell .character-library-heading-row > h1 {
  margin-bottom: 0;
}

body.character-shell .character-library-admin-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-left: auto;
}

body.character-shell .character-library-admin-actions[hidden] {
  display: none;
}
body.character-shell .character-photo-editor[hidden],
body.character-shell .character-photo-form[hidden],
body.character-shell .character-photo-section[hidden] {
  display: none;
}

body.character-shell .character-photo-editor {
  margin: 0 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: var(--paper);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
}

body.character-shell .character-photo-editor-header,
body.character-shell .character-photo-editor-footer,
body.character-shell .character-photo-character-list,
body.character-shell .character-photo-offsite-list,
body.character-shell .character-photo-artist-row,
body.character-shell .character-photo-offsite-row,
body.character-shell .character-photo-section-header,
body.character-shell .character-photo-edit-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

body.character-shell .character-photo-editor-header,
body.character-shell .character-photo-section-header {
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

body.character-shell .character-photo-editor-heading,
body.character-shell .character-photo-section-heading {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-subhead);
  letter-spacing: 0;
}

body.character-shell .character-photo-editor-heading {
  font-size: 0.86rem;
}

body.character-shell .character-photo-section-heading {
  font-size: 0.78rem;
}

body.character-shell .character-photo-editor-body {
  display: grid;
  gap: 1.1rem;
}

body.character-shell .character-photo-section {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

body.character-shell .character-photo-form {
  display: grid;
  gap: 0.8rem;
}

body.character-shell .character-photo-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem 1rem;
}

body.character-shell .character-photo-field {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

body.character-shell .character-photo-field--wide {
  grid-column: 1 / -1;
}

body.character-shell .character-photo-checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

body.character-shell .character-photo-checkbox {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--moss);
}
body.character-shell .character-photo-label {
  color: var(--muted);
  font-family: var(--font-subhead);
  font-size: 0.7rem;
  font-weight: 700;
}

body.character-shell .character-photo-input,
body.character-shell .character-photo-textarea,
body.character-shell .character-photo-select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 2.35rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

body.character-shell .character-photo-textarea {
  min-height: 5.5rem;
  line-height: 1.45;
  resize: vertical;
}

body.character-shell .character-library-admin-button,
body.character-shell .character-photo-button,
body.character-shell .character-photo-character-pill,
body.character-shell .gallery-thumb-edit {
  min-height: 2.1rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-subhead);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
}

body.character-shell .character-library-admin-button:hover,
body.character-shell .character-library-admin-button[aria-expanded="true"],
body.character-shell .character-photo-button:hover,
body.character-shell .character-photo-button[aria-pressed="true"],
body.character-shell .character-photo-character-pill:hover,
body.character-shell .character-photo-character-pill[aria-pressed="true"],
body.character-shell .gallery-thumb-edit:hover,
body.character-shell .gallery-thumb-edit:focus-visible {
  border-color: var(--moss);
  background: color-mix(in srgb, var(--moss) 8%, var(--paper));
}

body.character-shell .character-library-admin-button {
  min-height: 1.75rem;
  padding: 0.25rem 0.65rem;
}

body.character-shell .character-photo-button:disabled {
  cursor: default;
  opacity: 0.4;
}

body.character-shell .character-photo-type-control {
  display: grid;
  gap: 0.45rem;
}


body.character-shell .character-photo-type-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.35rem;
}

body.character-shell .character-photo-type-option {
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-subhead);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
  text-align: center;
}

body.character-shell .character-photo-type-option:hover,
body.character-shell .character-photo-type-option:focus-visible,
body.character-shell .character-photo-type-option[aria-pressed="true"] {
  border-color: var(--moss);
  background: color-mix(in srgb, var(--moss) 8%, var(--paper));
}

body.character-shell .character-photo-type-custom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
}
body.character-shell .character-photo-character-list {
  gap: 0.4rem;
}

body.character-shell .character-photo-character-pill {
  min-height: 1.8rem;
  padding: 0.25rem 0.55rem;
}

body.character-shell .character-photo-preview {
  box-sizing: border-box;
  max-height: 14rem;
  overflow: auto;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.74rem;
  white-space: pre-wrap;
}

body.character-shell .character-photo-status {
  min-height: 1.2rem;
  color: var(--muted);
  font-family: var(--font-subhead);
  font-size: 0.72rem;
}

body.character-shell .character-photo-status[data-state="success"] {
  color: var(--moss);
}

body.character-shell .character-photo-status[data-state="error"] {
  color: var(--wine);
}

body.character-shell .gallery-thumb {
  position: relative;
}

body.character-shell .gallery-thumb-edit {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  min-height: 1.75rem;
  padding: 0.15rem 0.35rem;
  opacity: 0.92;
  z-index: 2;
}

@media (max-width: 700px) {
  body.character-shell .character-photo-form-grid {
    grid-template-columns: 1fr;
  }
}

body.character-shell .character-photo-offsite-list {
  display: grid;
  gap: 0.4rem;
}

body.character-shell .character-photo-offsite-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.4rem;
}

body.character-shell .lightbox-char-pill--offsite {
  border-color: color-mix(in srgb, #777 48%, var(--line));
  background: color-mix(in srgb, #777 14%, var(--panel));
  color: color-mix(in srgb, var(--ink) 74%, #777);
}

body.character-shell .lightbox-char-pill--offsite:hover,
body.character-shell .lightbox-char-pill--offsite:focus-visible {
  border-color: color-mix(in srgb, #777 64%, var(--line));
  background: color-mix(in srgb, #777 22%, var(--panel));
}

@media (max-width: 700px) {
  body.character-shell .character-photo-offsite-row {
    grid-template-columns: 1fr;
  }
}
body.character-shell .character-photo-queue-section {
  gap: 0.55rem;
}

body.character-shell .character-photo-queue-list {
  display: grid;
  gap: 0.4rem;
}

body.character-shell .character-photo-queue-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

body.character-shell .character-photo-queue-empty[hidden] {
  display: none;
}

body.character-shell .character-photo-queue-row {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: var(--panel);
}

body.character-shell .character-photo-queue-thumb-frame {
  display: block;
  width: 3rem;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
}

body.character-shell .character-photo-queue-thumb {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

body.character-shell .character-photo-queue-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

body.character-shell .character-photo-queue-title,
body.character-shell .character-photo-queue-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.character-shell .character-photo-queue-title {
  color: var(--ink);
  font-family: var(--font-subhead);
  font-size: 0.72rem;
  font-weight: 700;
}

body.character-shell .character-photo-queue-meta {
  color: var(--muted);
  font-size: 0.74rem;
}

body.character-shell .character-photo-queue-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.35rem;
}

@media (max-width: 520px) {
  body.character-shell .character-photo-queue-row {
    grid-template-columns: 2.6rem minmax(0, 1fr);
  }

  body.character-shell .character-photo-queue-thumb-frame {
    width: 2.6rem;
  }

  body.character-shell .character-photo-queue-actions {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

body.character-shell .character-photo-crop-control {
  display: grid;
  grid-template-columns: minmax(7rem, 9rem) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

body.character-shell .character-photo-crop-preview {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--wine) 30%, var(--line));
  background: color-mix(in srgb, var(--paper) 72%, var(--panel));
}

body.character-shell .character-photo-crop-preview-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.character-shell .character-photo-crop-preview-image[hidden] {
  display: none;
}

body.character-shell .character-photo-crop-sliders {
  display: grid;
  gap: 0.55rem;
}

body.character-shell .character-photo-crop-slider {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) 3.25rem;
  gap: 0.5rem;
  align-items: center;
}

body.character-shell .character-photo-crop-label,
body.character-shell .character-photo-crop-value {
  color: var(--muted);
  font-family: var(--font-subhead);
  font-size: 0.66rem;
  font-weight: 700;
}

body.character-shell .character-photo-crop-value {
  text-align: right;
}

body.character-shell .character-photo-crop-range {
  min-height: 1.5rem;
  padding: 0;
}

@media (max-width: 640px) {
  body.character-shell .character-photo-crop-control {
    grid-template-columns: 1fr;
  }

  body.character-shell .character-photo-crop-preview {
    width: min(9rem, 100%);
  }

  body.character-shell .character-photo-crop-slider {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  body.character-shell .character-photo-crop-value {
    text-align: left;
  }
}
