/* Targeted image UI. Reuse LLI's secondary/primary buttons and theme tokens. */
.lli-image-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.lli-image-actions-end { justify-content: flex-end; }
.lli-image-actions > .lli-image-action {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 38px;
  max-width: 100%;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
  transform: none;
  box-shadow: none;
  transition: background-color .16s, border-color .16s;
}
.lli-image-actions > .lli-image-action.secondary {
  background: color-mix(in srgb, var(--surface) 93%, var(--blue));
  color: var(--ink);
}
.lli-image-actions > .lli-image-action.secondary:not(:disabled):hover {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--surface) 85%, var(--blue));
  text-decoration: none;
}
.lli-image-actions > .lli-image-action:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.lli-image-actions > .lli-image-action:disabled { cursor: not-allowed; opacity: .55; }
.lli-image-actions > [hidden], .lli-image-correction [hidden] { display: none !important; }

#imageGallery {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  align-items: stretch;
  gap: 18px;
}
#imageGallery .gallery-image-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
#imageGallery .gallery-image-button {
  flex: none;
  aspect-ratio: 4 / 3;
  border: 0;
  overflow: hidden;
  box-shadow: none;
}
#imageGallery .gallery-image-button img,
#imageGallery .gallery-image-button .gallery-image-placeholder {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  background: color-mix(in srgb, var(--surface) 94%, var(--muted));
}
#imageGallery .gallery-image-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  min-width: 0;
}
#imageGallery .gallery-prompt-label { font-size: 12px; font-weight: 600; color: var(--ink); }
#imageGallery .gallery-user-prompt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}
#imageGallery .gallery-image-meta { margin: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
#imageGallery .gallery-image-summary .lli-image-actions { margin-top: auto; }
.lli-prompt-dialog p { white-space: pre-wrap; font: inherit; line-height: 1.6; color: var(--photo-muted, var(--muted)); }

/* Same structural rows per gallery row, including unequal correction histories. */
@supports (grid-template-rows: subgrid) {
  #imageGallery .gallery-image-card {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 3;
    row-gap: 0;
  }
  #imageGallery .gallery-image-button { grid-row: 1; }
  #imageGallery .gallery-image-summary { grid-row: 2; }
  #imageGallery .gallery-image-card > .lli-image-correction { grid-row: 3; margin-top: 0; align-self: start; }
}
#imageView .lli-image-correction {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: auto;
  min-width: 0;
  margin: 12px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 96%, var(--blue));
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}
#imageGallery .gallery-image-card > .lli-image-correction { margin: auto 16px 16px; }
#imageView .lli-image-correction-title { display: block; }
#imageView .lli-image-correction-title strong { font-size: 13px; font-weight: 500; line-height: 1.6; }
#imageView .lli-image-correction-model,
#imageView .lli-image-correction-status { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0; overflow-wrap: anywhere; }
#imageView .lli-image-correction-editor { margin: 0; }
#imageView .lli-image-correction textarea { background: var(--surface); color: var(--ink); border-color: var(--line); }
#imageView .lli-image-correction-result { border-color: var(--line); margin: 0; min-width: 0; }
#imageView .lli-image-correction-result img { height: auto; aspect-ratio: auto; object-fit: contain; }
@supports (grid-template-rows: subgrid) {
  #imageGallery .gallery-image-card > .lli-image-correction { margin-top: 0; }
}
/* Existing global light/dark colors remain the source of truth. */
:root[data-theme=dark] :is(#imageGallery, #imageView .lli-image-correction, .photo-dialog .lli-image-actions) {
  --surface: var(--photo-bg, var(--lli-navy));
  --line: var(--photo-line, color-mix(in srgb, var(--lli-ice) 20%, var(--lli-navy)));
  --ink: var(--photo-ink, var(--lli-ice));
  --muted: var(--photo-muted, color-mix(in srgb, var(--lli-ice) 70%, var(--lli-navy)));
}
