:root {
  color-scheme: light;
  --paper: #f8f7f2;
  --ink: #18251d;
  --muted: #5a655a;
  --line: #dddfd5;
  --green: #24523a;
  --lime: #dbf28d;
  --image-matte: #efeee7;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.shell {
  width: min(100% - 96px, 1200px);
  margin-inline: auto;
}
.site-header { border-bottom: 1px solid var(--line); }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  font-size: 15px;
  font-weight: 700;
}
.brand-mark, .success-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--green);
  color: var(--lime);
}
main { padding-bottom: calc(145px + env(safe-area-inset-bottom)); }
.intro { padding: 36px 0 28px; }
.step {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 12px;
}
.step span {
  border: 1px solid #c6d3bb;
  border-radius: 5px;
  padding: 3px 6px;
  font: 600 12px ui-monospace, monospace;
}
h1 {
  margin: 0;
  font-size: clamp(30px, 4.5vw, 48px);
  line-height: 1.2;
  letter-spacing: -.035em;
}
.intro-copy, .dialog-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}
.version-switch {
  display: inline-flex;
  gap: 4px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #efeee7;
}
.version-switch button {
  min-height: 44px;
  min-width: 94px;
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  color: var(--green);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}
.version-switch button:hover { background: #e3ead9; }
.version-switch button[aria-pressed="true"] {
  color: #fff;
  background: var(--green);
}
.gallery-header {
  scroll-margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 16px 0 12px;
}
.gallery-header h2 { font-size: 15px; margin: 0; }
.gallery-header span { font-size: 13px; color: var(--muted); }
.gallery {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}
.photo-card {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}
.photo-card[hidden], .remove-photo[hidden] { display: none; }
.photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: inherit;
}
.photo-open:focus-visible, .remove-photo:focus-visible { outline-offset: -3px; }
.photo-card:hover { border-color: #899d86; }
.empty-selection {
  margin: 16px 0;
  color: var(--muted);
  font-size: 15px;
}
.photo-card.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
}
.photo-card .photo-image {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: var(--image-matte);
}
.photo-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 40px;
  padding: 6px 11px;
  font: 600 13px ui-monospace, monospace;
}
.photo-card.is-selected .photo-label { background: #e9f2de; }
.check {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid #7e8d7e;
  border-radius: 50%;
}
[aria-pressed="true"] .check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
[aria-pressed="true"] .check::after { content: '✓'; }
.selected-only .check { display: none; }
.selected-only .photo-label { min-height: 44px; }
.remove-photo {
  position: absolute;
  right: 0;
  bottom: 0;
  min-width: 60px;
  height: 44px;
  border: 0;
  border-left: 1px solid #c9d7bf;
  color: var(--green);
  background: #e9f2de;
  font-size: 13px;
  font-weight: 700;
}
.remove-photo:hover { background: #dbe9d2; }

.selection-bar {
  position: fixed;
  z-index: 1;
  bottom: 0;
  width: 100%;
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
}
.selection-notice {
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--green);
  background: #e9f2de;
  font-size: 13px;
  line-height: 1.5;
}
.selection-notice:empty { display: none; }
.selection-notice.over { color: #714019; background: #f6ebd6; }
.selection-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.selection-summary { width: min(48%, 240px); }
.selection-actions { display: flex; flex-shrink: 0; gap: 8px; }
.selection-actions button { white-space: nowrap; }
.selection-count {
  margin: 0 0 6px;
  font-size: 14px;
  white-space: nowrap;
}
.selection-count strong {
  margin-left: 5px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}
.total { color: var(--muted); }
progress {
  display: block;
  width: 100%;
  height: 4px;
  border: 0;
  appearance: none;
  overflow: hidden;
  border-radius: 20px;
  background: #e4e6dc;
}
progress::-webkit-progress-bar { background: #e4e6dc; }
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }
.primary-button, .secondary-button {
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.primary-button { background: var(--lime); }
.primary-button:hover:not(:disabled) { background: #cbe978; }
.primary-button:disabled { background: #e9eae2; color: #626c61; cursor: default; }
.secondary-button { background: transparent; border-color: var(--line); }
.secondary-button:hover:not(:disabled) { background: #eeeee6; }
.secondary-button:disabled { color: #626c61; cursor: default; }

dialog {
  width: min(100% - 32px, 440px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 24px 80px #111d1b33;
}
dialog::backdrop { background: #131d16a8; }
dialog h2 { margin: 14px 0 0; font-size: 24px; }
.dialog-copy { margin: 8px 0 16px; }
.id-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; }
#photo-ids {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: none;
  color: var(--ink);
  background: #fff;
  font: 600 15px/1.6 ui-monospace, monospace;
  overflow-wrap: anywhere;
}
#copy-status { min-height: 20px; margin: 8px 0 10px; color: var(--green); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.photo-viewer {
  width: min(100% - 40px, 1000px);
  height: min(100dvh - 40px, 880px);
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  color: #f8f7f2;
  background: #17201a;
}
.photo-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.photo-viewer::backdrop { background: #101612d9; }
.viewer-header, .viewer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
}
.viewer-header p { margin: 0; font: 600 14px ui-monospace, monospace; }
.viewer-controls { justify-content: center; color: #d9e4d5; font-size: 13px; }
.viewer-button {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid #647267;
  border-radius: 8px;
  color: inherit;
  background: #29372e;
}
.viewer-button:focus-visible { outline-color: var(--lime); }
.viewer-button:disabled { opacity: .45; cursor: default; }
.viewer-controls .viewer-button { font-size: 25px; line-height: 1; }
.viewer-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  grid-auto-rows: minmax(0, 1fr);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  background: #0f1711;
}
.viewer-track::-webkit-scrollbar { display: none; }
.viewer-slide { scroll-snap-align: start; scroll-snap-stop: always; }
.viewer-slide .photo-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 950px) {
  .shell { width: calc(100% - 48px); }
  .gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
}
@media (max-width: 660px) {
  .shell { width: calc(100% - 32px); }
  .brand { min-height: 56px; }
  .intro { padding: 24px 0 20px; }
  .intro-copy { font-size: 14px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .photo-card { border-radius: 9px; }
  .selection-inner, .selection-actions { gap: 8px; }
  .selection-actions button { padding-inline: 12px; }
  dialog { padding: 20px; }
  .photo-viewer {
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-width: none;
    margin: 0;
    padding: 0;
    border-radius: 0;
  }
  .viewer-header { padding-top: calc(8px + env(safe-area-inset-top)); }
  .viewer-controls { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}
