:root {
  --red: #a6201d;
  --red-dark: #7d1715;
  --ink: #191916;
  --muted: #74716a;
  --canvas: #f3f0e9;
  --surface: #fff;
  --line: #ddd8cd;
  --visual-bottom: 0px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; touch-action: pan-y; }
body { width: 100%; margin: 0; background: var(--canvas); color: var(--ink); font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; overflow-x: hidden; }
button { font: inherit; touch-action: manipulation; }
button:focus-visible { outline: 3px solid rgba(166, 32, 29, .28); outline-offset: 2px; }
main { width: 100%; max-width: 560px; min-height: 100dvh; margin: 0 auto; padding: 0 18px calc(26px + env(safe-area-inset-bottom)); background: var(--canvas); }

.topbar { min-height: 74px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.brand-logo { width: 40px; height: 40px; flex: 0 0 40px; object-fit: contain; }
.brand-copy { min-width: 0; }
.brand-copy strong { display: block; font-size: 17px; line-height: 1.2; }
.brand-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.operator { min-width: 0; margin-left: auto; display: flex; align-items: center; gap: 7px; color: #55524c; font-size: 12px; font-weight: 700; }
.operator > span:last-child { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operator-avatar { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 50%; object-fit: cover; background: #e2ded5; color: #777169; font-size: 12px; font-weight: 800; }

.area-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 22px; }
.area { position: relative; min-width: 0; min-height: 92px; padding: 15px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.7); color: var(--ink); }
.area > span { display: block; margin-bottom: 11px; color: #aaa59c; font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.area > strong { font-size: 20px; }
.area > b { position: absolute; top: 14px; right: 14px; color: #a29e96; font-size: 11px; }
.area.selected { border: 2px solid var(--red); padding: 14px; background: #fff8f6; box-shadow: 0 4px 16px rgba(166,32,29,.08); }
.area.selected > b, .area.selected > span { color: var(--red); }

.photo-section { padding-top: 24px; }
body.photo-mode .photo-section { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.step { margin: 0 0 6px; color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.section-head h1 { margin: 0; font-size: 25px; }
.section-head h1 small { display: inline-block; margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.text-button { flex: 0 0 auto; min-height: 40px; padding: 0 4px; border: 0; background: transparent; color: var(--red); font-size: 13px; font-weight: 700; }
.empty-photo { display: grid; place-items: center; min-height: 180px; padding: 25px; border: 1px dashed #cbc5ba; border-radius: 12px; background: rgba(255,255,255,.45); color: var(--muted); text-align: center; }
.empty-photo strong { margin-top: 12px; color: #56534d; font-size: 14px; }
.empty-photo p { margin: 4px 0 0; font-size: 12px; }
.camera-icon { display: inline-block; width: 24px; height: 19px; border: 2px solid currentColor; border-radius: 5px; position: relative; }
.camera-icon::before { content: ""; position: absolute; left: 7px; top: 4px; width: 6px; height: 6px; border: 2px solid currentColor; border-radius: 50%; }
.camera-icon::after { content: ""; position: absolute; left: 4px; top: -5px; width: 8px; height: 4px; border-radius: 2px 2px 0 0; background: currentColor; }
.camera-icon.white { color: #fff; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo-item { min-width: 0; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.photo-item > div { position: relative; aspect-ratio: 4 / 3; background: #dedbd4; }
.photo-item img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo-item button { position: absolute; top: 7px; right: 7px; width: 32px; height: 32px; border: 1px solid rgba(255,255,255,.55); border-radius: 50%; background: rgba(0,0,0,.62); color: #fff; font-size: 21px; line-height: 28px; }
.photo-item p { display: flex; justify-content: space-between; gap: 6px; margin: 0; padding: 10px; font-size: 11px; }
.photo-item p span { color: var(--muted); }

.action-panel { width: 100%; padding-top: 24px; }
body.photo-mode .action-panel { position: fixed; z-index: 20; left: 50%; bottom: var(--visual-bottom); transform: translateX(-50%); width: min(560px, 100%); padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); background: rgba(243,240,233,.97); border-top: 1px solid rgba(221,216,205,.9); box-shadow: 0 -8px 24px rgba(44,37,26,.08); backdrop-filter: blur(12px); }
body.photo-mode .privacy { display: none; }
.primary, .secondary { min-width: 0; min-height: 54px; padding: 0 14px; border-radius: 10px; font-weight: 800; font-size: 16px; border: 0; white-space: nowrap; }
.primary { width: 100%; background: var(--red); color: #fff; box-shadow: 0 3px 0 var(--red-dark); }
.primary:active { transform: translateY(1px); box-shadow: 0 2px 0 var(--red-dark); }
.primary:disabled { background: #b9b5ad; box-shadow: none; color: #eee; }
.secondary { width: 100%; border: 1px solid #a7a198; background: var(--surface); color: #4d4a45; }
.secondary:disabled { opacity: .55; }
.primary .camera-icon { margin-right: 10px; vertical-align: -4px; }
.action-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 10px; align-items: stretch; }
.plus { margin-right: 3px; font-size: 20px; vertical-align: -1px; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.privacy { margin: 14px 0 0; color: #9b968d; text-align: center; font-size: 11px; line-height: 1.5; }
.notice { margin-bottom: 10px; padding: 10px 12px; border-left: 3px solid var(--red); border-radius: 6px; background: #fff0ed; color: #8e1e1c; font-size: 13px; }
.notice.success { border-color: #55735b; background: #eaf3ea; color: #42634a; }

.photo-viewer { width: 100%; max-width: 100vw; height: 100%; max-height: 100dvh; margin: 0; padding: 52px 14px 24px; border: 0; background: rgba(13,13,12,.96); color: #fff; }
.photo-viewer::backdrop { background: rgba(0,0,0,.78); }
.photo-viewer img { display: block; width: 100%; height: calc(100% - 42px); object-fit: contain; }
.photo-viewer p { margin: 14px 0 0; text-align: center; font-size: 13px; }
.photo-viewer button { position: absolute; z-index: 2; top: calc(10px + env(safe-area-inset-top)); right: 14px; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 26px; line-height: 32px; }

@media (max-width: 350px) {
  main { padding-inline: 14px; }
  .area-grid, .photo-grid { gap: 8px; }
  .area { min-height: 84px; padding: 12px; }
  .area.selected { padding: 11px; }
  .action-row { grid-template-columns: minmax(0, .95fr) minmax(0, 1.3fr); gap: 7px; }
  .primary, .secondary { padding-inline: 8px; font-size: 14px; }
  body.photo-mode .action-panel { padding-inline: 14px; }
}

@media (min-width: 700px) {
  body { padding: 20px; }
  main { min-height: calc(100dvh - 40px); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 60px rgba(44,37,26,.1); }
}
