:root {
  --wine: #900021;
  --wine-dark: #490C1C;
  --wine-light: #F9F2F4;
  --gold: #DEB17C;
  --gold-light: #F9F6E3;
  --black: #070707;
  --gray-1: #5F5F5F;
  --gray-2: #848484;
  --gray-3: #BDBDBD;
  --line: #CBCBCB;
  --line-light: #EBEBEB;
  --surface: #FFFFFF;
  --surface-2: #F9F9F9;
  --surface-3: #F2F2F2;
}

* { box-sizing: border-box; }
html { background: var(--surface); color: var(--black); font-family: Arial, Helvetica, sans-serif; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--surface); }
button, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 72px;
  padding: 0 max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-light);
  background: var(--surface);
}

.brand { border: 0; background: transparent; padding: 4px 0; color: var(--wine); font-size: 20px; font-weight: 800; letter-spacing: .16em; cursor: pointer; }
.network { display: flex; align-items: center; gap: 7px; color: var(--gray-2); font-size: 12px; }
.network span { width: 7px; height: 7px; background: var(--wine); border-radius: 50%; }
.network.offline span { background: var(--gray-3); }

main { width: min(100%, 760px); margin: 0 auto; }
.screen { display: none; padding: 48px 20px calc(40px + env(safe-area-inset-bottom)); }
.screen.active { display: block; }
.eyebrow { color: var(--wine); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; margin-bottom: 16px; }
h1 { margin: 0; color: var(--black); font-family: Georgia, 'Times New Roman', serif; font-size: clamp(42px, 12vw, 68px); font-weight: 400; line-height: .98; letter-spacing: -.04em; }
.intro { color: var(--gray-1); font-size: 16px; line-height: 1.6; margin: 22px 0 34px; max-width: 500px; }

.category-grid { display: grid; gap: 12px; }
.category-card { min-height: 104px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; padding: 18px 20px; border: 1px solid var(--line-light); background: var(--surface-2); color: var(--black); text-align: left; cursor: pointer; transition: border-color .2s, background .2s, transform .2s; }
.category-card:active { transform: scale(.99); }
.category-card:hover, .category-card.selected { border-color: var(--wine); background: var(--wine-light); }
.category-number { align-self: start; color: var(--gray-2); font-size: 11px; font-weight: 700; }
.category-name { font-family: Georgia, 'Times New Roman', serif; font-size: 30px; }
.arrow { color: var(--wine); font-size: 24px; }
.back-link, .text-button { border: 0; background: transparent; color: var(--wine); cursor: pointer; padding: 0; font-weight: 700; }
.back-link { margin-bottom: 36px; }
.selected-category { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; border-top: 1px solid var(--line-light); border-bottom: 1px solid var(--line-light); margin-bottom: 28px; }
.selected-category span { color: var(--gray-2); font-size: 13px; }
.selected-category strong { font-family: Georgia, 'Times New Roman', serif; font-size: 21px; font-weight: 400; }
.field { display: block; margin-bottom: 28px; }
.field > span { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--black); font-size: 13px; font-weight: 700; }
.field em { color: var(--gray-2); font-style: normal; font-weight: 400; }
textarea { width: 100%; resize: vertical; min-height: 112px; padding: 15px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--black); outline: none; }
textarea:focus { border-color: var(--wine); box-shadow: 0 0 0 2px var(--wine-light); }

.primary-button, .secondary-button, .complete-button { width: 100%; min-height: 54px; border: 1px solid var(--wine); padding: 14px 18px; font-weight: 700; cursor: pointer; }
.primary-button { display: flex; justify-content: space-between; align-items: center; color: var(--surface); background: var(--wine); }
.primary-button:hover { background: var(--wine-dark); border-color: var(--wine-dark); }
.secondary-button { color: var(--wine); background: var(--surface); }
.secondary-button:hover { background: var(--wine-light); }

.upload-screen { padding-top: 34px; }
.upload-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 26px; }
.upload-heading h1 { font-size: clamp(37px, 10vw, 54px); }
.item-reference { margin: 10px 0 0; color: var(--gray-2); font-size: 12px; letter-spacing: .05em; }
.stored-counter { min-width: 72px; text-align: right; color: var(--gray-2); font-size: 12px; padding-bottom: 5px; }
.stored-counter strong { display: block; color: var(--wine); font-family: Georgia, 'Times New Roman', serif; font-size: 34px; font-weight: 400; line-height: 1; }
.upload-note { display: flex; align-items: center; gap: 14px; padding: 15px; background: var(--gold-light); color: var(--gray-1); margin-bottom: 20px; }
.upload-note p { margin: 0; font-size: 12px; line-height: 1.5; }
.upload-note strong { color: var(--black); }
.cloud-mark { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border: 1px solid var(--gold); border-radius: 50%; color: var(--wine-dark); font-weight: 800; }

.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.photo-slot { position: relative; aspect-ratio: 1 / 1.08; overflow: hidden; border: 1px dashed var(--line); background: var(--surface-2); }
.photo-slot.empty { display: grid; place-items: center; cursor: pointer; }
.photo-slot.empty:hover { border-color: var(--wine); background: var(--wine-light); }
.slot-placeholder { text-align: center; color: var(--gray-2); }
.slot-placeholder b { display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto 9px; border: 1px solid var(--line); border-radius: 50%; color: var(--wine); font-size: 22px; font-weight: 400; }
.slot-placeholder span { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.photo-slot img { width: 100%; height: 100%; display: block; object-fit: cover; cursor: zoom-in; }
.photo-slot .shade { position: absolute; inset: auto 0 0; min-height: 58px; padding: 21px 9px 8px; background: linear-gradient(transparent, var(--black)); color: var(--surface); }
.slot-status { display: flex; justify-content: space-between; gap: 6px; align-items: center; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.mini-track { height: 2px; margin-top: 7px; background: var(--gray-2); }
.mini-track span { display: block; height: 100%; background: var(--gold); }
.delete-photo { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--surface); color: var(--wine); box-shadow: 0 2px 8px var(--gray-2); cursor: pointer; font-size: 18px; }
.photo-slot.failed { border-color: var(--wine); }
.photo-slot.failed .shade { background: var(--wine-dark); }

.upload-actions { display: grid; gap: 10px; margin-top: 16px; }
.overall-progress { margin: 24px 0; padding: 17px 0; border-top: 1px solid var(--line-light); border-bottom: 1px solid var(--line-light); }
.overall-progress > div:first-child { display: flex; justify-content: space-between; color: var(--gray-2); font-size: 12px; }
.overall-progress b { color: var(--black); }
.progress-track { height: 5px; margin-top: 11px; background: var(--surface-3); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--wine); transition: width .2s; }
.complete-button { color: var(--surface); background: var(--wine-dark); border-color: var(--wine-dark); }
.complete-button:disabled { color: var(--gray-2); background: var(--surface-3); border-color: var(--surface-3); cursor: not-allowed; }
.text-button { display: block; margin: 22px auto 0; }
.visually-hidden { position: fixed; opacity: 0; pointer-events: none; width: 1px; height: 1px; }

.complete-screen { padding-top: 70px; text-align: center; }
.complete-screen .intro { margin-left: auto; margin-right: auto; }
.success-mark { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 30px; border-radius: 50%; background: var(--wine); color: var(--surface); font-size: 32px; }
.completion-card { display: grid; grid-template-columns: 1fr auto; gap: 13px; margin: 32px 0; padding: 22px; background: var(--wine-light); text-align: left; }
.completion-card span { color: var(--gray-2); font-size: 12px; }
.completion-card strong { color: var(--wine-dark); font-size: 13px; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); width: min(calc(100% - 32px), 480px); padding: 13px 16px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; background: var(--wine-dark); color: var(--surface); font-size: 13px; transition: .25s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--black); }
.lightbox::backdrop { background: var(--black); }
.lightbox img { width: 100%; height: 100%; object-fit: contain; }
.lightbox button { position: fixed; z-index: 2; top: max(16px, env(safe-area-inset-top)); right: 16px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--surface); color: var(--black); font-size: 26px; cursor: pointer; }

@media (min-width: 640px) {
  .topbar { padding-left: 34px; padding-right: 34px; }
  .screen { padding-left: 34px; padding-right: 34px; }
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .category-card { min-height: 190px; grid-template-columns: 1fr auto; grid-template-rows: 1fr auto; }
  .category-number { grid-column: 1 / -1; }
  .category-name { align-self: end; }
  .arrow { align-self: end; }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
  .photo-slot:first-child { grid-column: span 2; grid-row: span 2; }
  .upload-actions { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
