.photo-add-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.photo-add-controls:not(.photo-add-controls-compact) > .photo-add-launch,
.photo-add-controls-compact > [data-photo-source-choice="auto"] {
  grid-column: 1 / -1;
}

.photo-library-launch {
  display: none;
  min-width: 92px;
}

.photo-add-touch-copy { display: none !important; }

.photo-full-resolution-choice {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}

.photo-full-resolution-choice input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.photo-full-resolution-choice strong,
.photo-full-resolution-choice small { display: block; }
.photo-full-resolution-choice strong { font-size: 13px; }
.photo-full-resolution-choice small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.photo-add-controls-compact {
  width: min(320px, 100%);
  flex: 0 1 320px;
}
.photo-add-controls-compact > .button { justify-content: center; }

body[data-page="inspection"] .photo-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: visible;
}

body[data-page="inspection"] .photo-card .annotated-image {
  aspect-ratio: 4 / 3;
  min-height: 0;
  overflow: hidden;
  border-radius: 9px 9px 0 0;
  background: var(--surface-2);
}

body[data-page="inspection"] .photo-card .photo-open-link,
body[data-page="inspection"] .photo-card .photo-open-link img {
  width: 100%;
  height: 100%;
}

body[data-page="inspection"] .photo-card .photo-open-link img {
  display: block;
  aspect-ratio: auto;
  object-fit: cover;
}

body[data-page="inspection"] .photo-card-body {
  grid-template-rows: minmax(34px, auto) auto;
  align-content: space-between;
  border-radius: 0 0 9px 9px;
  background: var(--surface);
}

body[data-page="inspection"] .photo-card-body:has(> .photo-space-caption) {
  grid-template-rows: auto minmax(34px, auto) auto;
}

body[data-page="inspection"] .photo-card-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
  gap: 6px;
  align-items: stretch;
}

body[data-page="inspection"] .photo-card-actions > .mini-button {
  min-width: 0;
  width: 100%;
}

.photo-card-menu-wrap { position: relative; min-width: 0; }
body[data-page="inspection"] .photo-menu-toggle {
  width: 44px;
  min-width: 44px;
  height: 100%;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.photo-card-menu {
  position: absolute;
  z-index: 12;
  right: 0;
  bottom: calc(100% + 6px);
  width: min(220px, calc(100vw - 40px));
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(0 0 0 / 28%);
}
.photo-card-menu[hidden] { display: none; }

body[data-page="inspection"] .photo-card-menu-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  color: var(--text);
  background: transparent;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

body[data-page="inspection"] .photo-card-menu-item:hover,
body[data-page="inspection"] .photo-card-menu-item:focus-visible {
  outline: 0;
  background: var(--surface-2);
}

body[data-page="inspection"] .photo-card-menu-delete {
  margin-top: 5px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 5px 5px;
  color: var(--danger);
}

.photo-upload-stage { display: grid; place-items: center; }
.photo-upload-status {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}
.photo-upload-status strong { font-size: 13px; line-height: 1.4; }
.photo-upload-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: photo-upload-spin .8s linear infinite;
}
.photo-card[data-photo-upload-state="error"] .photo-upload-spinner {
  border: 0;
  animation: none;
}
.photo-card[data-photo-upload-state="error"] .photo-upload-spinner::before {
  content: "!";
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid var(--danger);
  border-radius: 50%;
  color: var(--danger);
  font-weight: 800;
}

@keyframes photo-upload-spin { to { transform: rotate(360deg); } }

@media (pointer: coarse) {
  .photo-add-controls > [data-photo-source-choice="auto"] { grid-column: 1; }
  .photo-library-launch { display: inline-flex; align-items: center; justify-content: center; }
  .photo-add-desktop-copy { display: none !important; }
  .photo-add-touch-copy { display: block !important; }
  .photo-full-resolution-choice small { font-size: 13px; }
}

@media (max-width: 600px) {
  .photo-add-controls-compact { width: 100%; flex-basis: 100%; }
  body[data-page="inspection"] .photo-card-menu { width: min(240px, calc(100vw - 32px)); }
}

@media (prefers-reduced-motion: reduce) {
  .photo-upload-spinner { animation-duration: 1.8s; }
}
