:root {
  color-scheme: light;
  font: 100%/1.5 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #182822;
  background: #f5f7f4;
  --muted: #50665a;
  --accent: #085844;
  --accent-hover: #064735;
  --soft: #e0eee6;
  --line: #cbd8d0;
  --surface: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button, summary, a[download] { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #287861; outline-offset: 3px; }

h1, h2, p, figure { margin: 0; }
h1 { font-size: clamp(2rem, 8vw, 3.5rem); line-height: 1.04; letter-spacing: -.055em; }
h2 { font-size: 1.2rem; line-height: 1.2; letter-spacing: -.02em; }

main {
  max-width: 38rem;
  margin-inline: auto;
  padding-inline: max(1.25rem, env(safe-area-inset-left)) max(1.25rem, env(safe-area-inset-right));
}

.page { padding-block: max(1.75rem, env(safe-area-inset-top)) max(1.75rem, env(safe-area-inset-bottom)); }
.start { min-height: 100svh; display: grid; grid-template-rows: 1fr auto; text-align: center; }
.start-content { align-self: center; display: grid; justify-items: center; gap: 1.5rem; padding-block: 2rem; }
.start-actions { display: grid; gap: .625rem; width: min(100%, 18rem); margin-top: .375rem; }
.guide-link { display: grid; place-items: center; min-height: 2.75rem; margin-top: -.75rem; padding-inline: .5rem; color: var(--muted); font-size: .875rem; text-underline-offset: .2em; }
.guide-link:hover { color: var(--accent); }
.privacy { justify-self: center; max-width: 27rem; color: var(--muted); font-size: .875rem; }
.privacy summary { width: fit-content; margin-inline: auto; padding: .625rem; text-decoration: underline; text-underline-offset: .2em; }
.privacy p { margin: .375rem .5rem 0; }

.camera-tile {
  display: grid;
  place-items: center;
  width: 5rem;
  height: 5rem;
  margin-bottom: .25rem;
  color: var(--accent);
  background: var(--soft);
  border: 1px solid #d2e6da;
  border-radius: 1.65rem;
}

.camera-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 1.4em;
  height: .98em;
  margin-top: .13em;
  border: .1em solid currentColor;
  border-radius: .23em;
}

.camera-tile .camera-mark { font-size: 1.75rem; }
.camera-mark::before { content: ""; position: absolute; top: -.24em; width: .55em; height: .2em; border: .1em solid currentColor; border-bottom: none; border-radius: .15em .15em 0 0; }
.camera-mark::after { content: ""; width: .57em; height: .57em; border: .1em solid currentColor; border-radius: 50%; }

.primary, .secondary, .quiet, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  min-height: 2.875rem;
  padding: .625rem .875rem;
  border: 1px solid transparent;
  border-radius: .8rem;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}

.primary { min-height: 3.5rem; background: var(--accent); color: #fff; }
.primary:hover:enabled { background: var(--accent-hover); }
.secondary { background: var(--surface); border-color: var(--line); color: var(--accent); }
.secondary:hover { background: var(--soft); }
.report-actions [aria-disabled="true"] { opacity: .55; }
.quiet { background: transparent; color: var(--accent); }
.quiet:hover { background: var(--soft); }
.back { margin-inline-start: -.875rem; }
.danger { color: #8a2c23; }
.danger-button { color: #fff; background: #8a2c23; }
.danger-button:hover { background: #742219; }

.notice {
  position: fixed;
  z-index: 1;
  bottom: max(1rem, env(safe-area-inset-bottom));
  inset-inline: max(1rem, calc((100% - 35rem) / 2));
  padding: .875rem 1rem;
  color: #fff;
  background: #223b30;
  border-radius: .8rem;
  box-shadow: 0 8px 22px #18282224;
  pointer-events: none;
}

.notice:empty { display: none; }
.notice.error { top: max(1rem, env(safe-area-inset-top)); bottom: auto; background: #842e25; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin-top: .35rem; }
.phases { display: flex; gap: .25rem; min-inline-size: 0; margin: 0 0 1rem; padding: .25rem; border: 1px solid var(--line); border-radius: .95rem; background: #eaf0eb; }
.phases label { position: relative; flex: 1; }
.phases input, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.phases span { display: block; padding: .575rem; text-align: center; color: var(--muted); font-weight: 650; border-radius: .7rem; cursor: pointer; }
.phases input:checked + span { color: var(--accent); background: var(--surface); box-shadow: 0 1px 3px #1828221a; }
.phases input:focus-visible + span { outline: 3px solid #287861; outline-offset: 1px; }
.report-actions { display: flex; gap: .625rem; }
.report-actions > * { flex: 1; }
.pdf-share { margin-top: .35rem; margin-inline-start: -.875rem; }
.help { color: var(--muted); font-size: .875rem; }
.export-help { margin-top: .75rem; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin: 1.8rem 0 .65rem; }
.section-heading p { font-size: .875rem; color: var(--muted); text-align: right; }
.photo-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.photo-list li { min-width: 0; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); }
.photo-row { display: flex; align-items: center; gap: .65rem; padding: .5rem .625rem; }
.photo-name { display: grid; gap: .1rem; flex: 1; min-width: 0; }
.photo-name strong { overflow-wrap: anywhere; }
.photo-row .quiet { flex-shrink: 0; padding-inline: .6rem; font-size: .875rem; }
.thumb { width: 3.25rem; height: 3.25rem; flex-shrink: 0; object-fit: cover; border-radius: .55rem; background: var(--soft); }
.photo-details { padding: 0 .75rem .75rem; }
.photo-details summary, .report-meta summary { color: var(--accent); font-weight: 650; padding-block: .65rem; }
.photo-details form, #reference-form { display: grid; gap: .5rem; margin-block: .5rem; }
.photo-details textarea, #reference { width: 100%; min-width: 0; padding: .625rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--surface); color: inherit; }
.photo-details textarea { resize: vertical; }
.input-row { display: flex; gap: .5rem; }
.download-box { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .65rem; padding: .75rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--soft); }
.save-error { flex-basis: 100%; color: #842e25; }
.report-meta { margin-top: 1.35rem; padding-top: .25rem; border-top: 1px solid var(--line); }
.report-meta .danger { margin-top: .65rem; margin-inline-start: -.875rem; }

.camera-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .65rem; }
.camera-header p { color: var(--muted); font-weight: 650; }
.camera-page h1 { font-size: clamp(1.9rem, 7vw, 2.85rem); }
.camera-instruction { margin-block: .375rem .85rem; color: var(--muted); }
.viewfinder { position: relative; display: grid; place-items: center; height: clamp(10rem, 43svh, 28rem); overflow: hidden; border-radius: 1.15rem; background: #142720; color: #fff; }
.viewfinder video { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewfinder #review-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #142720; }
.camera-message { padding: 1.25rem; text-align: center; max-width: 27rem; }
.camera-page.is-fallback .viewfinder { height: auto; min-height: 6rem; }
.saved-status { color: var(--accent); font-weight: 650; }
.reference-photo { display: flex; align-items: center; gap: .75rem; margin-top: .6rem; font-size: .875rem; color: var(--muted); }
.reference-photo img { width: 5.5rem; height: 3.5rem; object-fit: contain; background: var(--soft); border-radius: .5rem; }
.camera-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; gap: .5rem; margin-top: .85rem; }
.shutter { width: 4.45rem; height: 4.45rem; padding: 0; border: .15rem solid var(--accent); border-radius: 50%; background: var(--surface); }
.shutter::before { content: ""; display: block; margin: .3rem; aspect-ratio: 1; border-radius: 50%; background: var(--accent); }
.shutter:active::before { background: var(--accent-hover); transform: scale(.92); }
.shutter:disabled { opacity: .3; }
.import { grid-column: 1 / -1; }
.camera-page.is-fallback .camera-controls { grid-template-columns: 1fr; justify-items: stretch; }
.camera-page.is-fallback #skip-angle { order: 1; justify-self: center; }
.review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .85rem; }
.review-actions #retake-angle { grid-column: 1 / -1; justify-self: center; }
.review-actions #finish-camera.primary { grid-column: 1 / -1; }

dialog { width: min(25rem, calc(100% - 2rem)); padding: 1.25rem; border: 1px solid var(--line); border-radius: 1rem; color: inherit; background: var(--surface); }
dialog::backdrop { background: #14272076; }
dialog p { margin-block: .65rem 1.25rem; }
.dialog-actions { display: flex; justify-content: end; gap: .5rem; flex-wrap: wrap; }

@media (max-width: 365px) {
  main { padding-inline: .85rem; }
  .photo-row { gap: .4rem; }
  .thumb { width: 2.6rem; height: 2.6rem; }
}
