:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #101d33;
  background: #f1f5f7;
  --navy: #101d33;
  --emerald: #00654d;
  --muted: #4a5c70;
  --border: #d0dbe3;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.wrap { width: min(100% - 2rem, 48rem); margin-inline: auto; }
header { background: var(--navy); color: white; padding: 1.2rem 0; }
header strong { letter-spacing: .09em; font-size: 1.15rem; }
header p { margin: .3rem 0 0; color: #9de6ce; font-size: .75rem; letter-spacing: .13em; }
main { padding-block: 1.6rem 2.5rem; }
h1 { margin: 0; font-size: clamp(1.65rem, 5vw, 2.4rem); letter-spacing: -.035em; }
h2 { margin: 0; font-size: 1.15rem; }
.intro, #empty { color: var(--muted); }
.intro { margin: .4rem 0 1.2rem; }
.panel { background: white; border: 1px solid var(--border); border-radius: 1rem; padding: 1rem; margin-bottom: 1rem; }
.viewfinder { background: var(--navy); color: #d9e5ef; display: grid; place-items: center; aspect-ratio: 4 / 3; max-height: 24rem; border-radius: .7rem; overflow: hidden; }
video { display: block; width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin-top: .85rem; }
#add-gallery { grid-column: 1 / -1; }
button { min-height: 44px; padding: .55rem .45rem; border-radius: .55rem; border: 1px solid #b6c5d2; background: white; color: var(--navy); font: inherit; font-size: .9rem; font-weight: 650; cursor: pointer; }
.primary { color: white; background: var(--emerald); border-color: var(--emerald); }
button:disabled { color: #465668; background: #e9eef2; border-color: #d0dbe3; cursor: default; }
button:focus-visible { outline: 3px solid #138366; outline-offset: 3px; }
#status { margin: .65rem 0 0; color: var(--muted); font-size: .9rem; }
#status:empty { margin: 0; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .4rem; }
#counter { color: var(--emerald); font-size: .85rem; font-weight: 650; }
#photos, .photo-grid { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: .65rem; }
#photos li, .photo-grid li { display: grid; align-content: start; gap: .35rem; padding: .45rem; border: 1px solid var(--border); border-radius: .7rem; }
#photos img, .photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #e9eef2; border-radius: .35rem; }
#photos strong, .photo-grid strong { font-size: .85rem; color: var(--emerald); }
.instruction-fields { display: grid; gap: .55rem; }
.instruction-fields > label { font-weight: 650; }
textarea, select { width: 100%; border: 1px solid #b6c5d2; border-radius: .55rem; color: var(--navy); background: white; padding: .6rem; font: inherit; min-height: 44px; }
textarea { resize: vertical; }
.instruction-fields p { margin: 0; color: var(--muted); font-size: .9rem; }
.instruction-fields .actions { margin-top: 0; }
.voice-consent { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
.voice-consent input { width: 1.15rem; height: 1.15rem; accent-color: var(--emerald); }
#voice-preview { padding: .55rem; border-left: 3px solid var(--emerald); overflow-wrap: anywhere; }

@media (min-width: 36rem) {
  .capture { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #add-gallery { grid-column: auto; }
}

.generation-spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid #dce6e3;
  border-top-color: #08775b;
  border-radius: 50%;
  animation: generation-spin 750ms linear infinite;
}

@keyframes generation-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .generation-spinner { animation: none; }
}

.result-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1rem;
}

.result-images img {
  display: block;
  width: 100%;
  max-height: 28rem;
  object-fit: contain;
  border-radius: .65rem;
}

#result-prompt {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#optimization-status, #import-notice {
  margin: .65rem 0 0;
  color: var(--muted);
  font-size: .9rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
#optimization-status:empty, #import-notice:empty { margin: 0; }
#photos small, .photo-grid small { color: var(--muted); overflow-wrap: anywhere; }

#cloud-instructions {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#cloud-images img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

#assisted-references {
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
}

#assisted-references:empty { display: none; }

#assisted-downloads {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: .5rem;
}

#assisted-downloads:empty { display: none; }

#assisted-downloads li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

#assisted-downloads small { overflow-wrap: anywhere; }
