:root {
  --bg: #F4F4F0;
  --card: #FFFFFF;
  --ink: #221E20;
  --muted: #6b6568;
  --brand: #8C0052;
  --brand-deep: #5B0035;
  --brand-darker: #3A0021;
  --brand-2: #8C0052;
  --danger: #E94B35;
  --warn-bg: #f5f0f2;
  --warn-border: #9a8a90;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(140, 0, 82, 0.10);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100dvh; }
body.camera-open { overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 0.85rem; background: var(--brand); color: #fff;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 10px rgba(58, 0, 33, 0.25);
}
.brand {
  display: flex; align-items: center; gap: 0.55rem;
  color: #fff; text-decoration: none; font-weight: 700; letter-spacing: 0.02em;
  min-width: 0;
}
.brand-logo {
  height: 36px; width: auto; max-width: 140px; object-fit: contain;
  background: #fff; border-radius: 6px; padding: 3px 6px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-title { font-size: 0.95rem; white-space: nowrap; }
.brand-sub { font-size: 0.68rem; font-weight: 500; opacity: 0.8; letter-spacing: 0.04em; }
.logout-form { margin: 0; flex-shrink: 0; }
.linkish {
  background: transparent; border: 0; color: #ffe9f4; text-decoration: underline;
  font: inherit; padding: 0.35rem 0.4rem; min-height: 44px;
}

.wrap { padding: 1rem; padding-bottom: calc(1.5rem + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }
.card, .hero {
  background: var(--card); border-radius: var(--radius); padding: 1.1rem;
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.hero h1, .card h1 { margin: 0 0 0.35rem; font-size: 1.45rem; }
.card h2 { margin: 1rem 0 0.5rem; font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0; }
.error { color: var(--danger); background: #fdecea; padding: 0.6rem 0.75rem; border-radius: 10px; }
.warn {
  background: var(--warn-bg); border-radius: 10px; padding: 0.75rem; margin: 0.75rem 0;
  border-left: 4px solid var(--brand);
}
.warn ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }

.brand-welcome { text-align: center; }
.brand-welcome .stack { text-align: left; }
.logo-stacked {
  display: block; width: min(180px, 55vw); height: auto; margin: 0.25rem auto 0.85rem;
}
.logo-stacked-sm { width: min(120px, 40vw); margin-bottom: 0.5rem; }
.login-card { max-width: 420px; margin-left: auto; margin-right: auto; }

.stack { display: flex; flex-direction: column; gap: 0.85rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.95rem; }
input, select, textarea {
  font: inherit; padding: 0.85rem 0.9rem; border-radius: 10px;
  border: 1px solid #d5cdd0; background: #fff; width: 100%;
  min-height: 48px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); border-color: var(--brand);
}
fieldset { border: 1px solid #e0d8db; border-radius: 12px; padding: 0.75rem; margin: 0; }
legend { font-weight: 700; padding: 0 0.25rem; }
.choice { font-weight: 500; display: flex; flex-direction: row; align-items: center; gap: 0.5rem; margin: 0.35rem 0; min-height: 44px; }
.choice input { width: auto; min-height: 0; }
.three { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
.entity-pick .choice { font-size: 1.05rem; padding: 0.35rem 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.9rem 1.05rem; border-radius: 12px; border: 0; font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; text-align: center; min-height: 48px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); }
.btn.primary:active { background: var(--brand-darker); }
.btn.secondary { background: #f3e6ee; color: var(--brand-deep); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid #d4b3c4; }
.btn.block { width: 100%; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 2rem; min-height: 0;
}

.lot-list, .page-list { list-style: none; padding: 0; margin: 0; }
.lot-list li a, .page-list li a {
  display: block; padding: 0.9rem 0; border-bottom: 1px solid #ebe4e7;
  text-decoration: none; color: inherit; min-height: 48px;
}
.lot-list .meta { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }
.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; background: #f3e6ee; color: var(--brand);
  padding: 0.15rem 0.45rem; border-radius: 999px; margin-left: 0.35rem;
}
.status-draft { background: #eee; color: #444; }
.status-complete { background: #f3e6ee; color: var(--brand-deep); }
.status-exported { background: #e8dff5; color: #5B0035; }

.crumb { display: flex; gap: 0.4rem; align-items: center; margin-bottom: 0.75rem; font-size: 0.9rem; }
.crumb a { color: var(--brand); }
.req {
  color: #fff; background: var(--danger); font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; margin-left: 0.35rem; padding: 0.12rem 0.4rem;
  border-radius: 999px; letter-spacing: 0.03em; vertical-align: middle;
}
.tip { margin: 0.2rem 0 0.5rem; color: var(--muted); font-size: 0.85rem; font-weight: 500; }

.photo-block {
  border: 1px dashed #d4b3c4; border-radius: 12px; padding: 0.75rem; background: #fbf7f9;
}
.photo-label { font-weight: 700; margin-bottom: 0.35rem; }
.photo-actions {
  display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.35rem;
}

.example-guide {
  margin: 0.35rem 0 0.75rem; padding: 0.5rem; background: #fff;
  border: 1px solid #e8d6df; border-radius: 10px; width: fit-content; max-width: 100%;
  box-shadow: none;
}
.example-guide img {
  display: block; width: min(160px, 100%); height: auto; border-radius: 8px;
}
.example-guide figcaption {
  margin-top: 0.35rem; font-size: 0.78rem; color: var(--muted); font-weight: 600;
  text-align: center;
}

.thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.thumb { position: relative; margin: 0; width: 88px; height: 88px; border-radius: 10px; overflow: hidden; background: #ddd; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del {
  position: absolute; top: 2px; right: 2px; width: 32px; height: 32px; border: 0;
  border-radius: 50%; background: rgba(0,0,0,0.65); color: #fff; font-size: 1.1rem; line-height: 1;
}

.missing-examples { margin: 0.75rem 0 1rem; }
.missing-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem; margin-top: 0.5rem;
}
.missing-card {
  display: flex; flex-direction: column; gap: 0.25rem; align-items: center;
  text-decoration: none; color: inherit; background: #fff; border: 1px solid #e8d6df;
  border-radius: 12px; padding: 0.55rem; text-align: center;
}
.missing-card img { width: 100%; max-width: 140px; height: auto; border-radius: 8px; }
.missing-label { font-weight: 700; font-size: 0.85rem; color: var(--brand-deep); }

.wizard-nav {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.5rem; align-items: center;
  position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%);
  padding: 0.75rem 0 calc(0.5rem + var(--safe-bottom)); margin-top: 0.5rem;
}
.wizard-nav .btn.primary { grid-column: 3; }
.wizard-nav .btn.ghost:first-child { grid-column: 1; justify-self: start; }
.actions { margin-top: 1rem; }
code { font-size: 0.85em; word-break: break-word; }
.meta-line { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }

/* —— In-app camera overlay —— */
.camera-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: #000; color: #fff;
  display: flex; flex-direction: column;
}
.camera-overlay[hidden] { display: none !important; }
.camera-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 0.85rem; padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
  background: rgba(34, 30, 32, 0.92); gap: 0.5rem;
}
.camera-top .shot-count { font-weight: 700; font-size: 0.95rem; }
.camera-top .btn { min-height: 44px; padding: 0.55rem 0.9rem; }
.camera-top .btn.ghost { color: #fff; border-color: rgba(255,255,255,0.35); }
.camera-stage {
  flex: 1; position: relative; min-height: 0; background: #111;
  display: flex; align-items: center; justify-content: center;
}
.camera-stage video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.camera-bottom {
  display: flex; flex-direction: column; align-items: stretch; gap: 0.55rem;
  padding: 0.75rem 0.85rem; padding-bottom: calc(0.85rem + var(--safe-bottom));
  background: rgba(34, 30, 32, 0.95);
}
.camera-draft-strip {
  display: flex; gap: 0.4rem; overflow-x: auto; min-height: 56px;
  padding-bottom: 0.15rem;
}
.camera-draft-strip .draft-thumb {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 8px;
  overflow: hidden; border: 2px solid var(--brand); background: #333;
}
.camera-draft-strip .draft-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-shutter-row {
  display: flex; align-items: center; justify-content: center; gap: 1.25rem;
}
.camera-shutter {
  width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff;
  background: var(--brand); box-shadow: 0 0 0 4px rgba(140, 0, 82, 0.35);
  cursor: pointer; padding: 0;
}
.camera-shutter:active { background: var(--brand-deep); transform: scale(0.96); }
.camera-hint { text-align: center; font-size: 0.8rem; color: #c8c0c3; margin: 0; }

/* —— Review sheet —— */
.review-sheet {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(34, 30, 32, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.review-sheet[hidden] { display: none !important; }
.review-panel {
  background: var(--card); color: var(--ink);
  width: 100%; max-width: 640px; max-height: min(92dvh, 900px);
  border-radius: 18px 18px 0 0; padding: 1rem 1rem calc(1rem + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 0.75rem;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.25);
}
.review-panel h2 { margin: 0; font-size: 1.15rem; }
.review-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.55rem; overflow-y: auto; flex: 1; min-height: 120px;
  padding: 0.15rem;
}
.review-item {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: #ddd;
}
.review-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.review-item .thumb-del {
  top: 4px; right: 4px; width: 36px; height: 36px; font-size: 1.25rem;
  background: rgba(34, 30, 32, 0.75);
}
.review-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.review-empty { color: var(--muted); text-align: center; padding: 1.5rem 0.5rem; }

@media (min-width: 720px) {
  .wrap { padding-top: 1.5rem; }
  .brand-logo { height: 40px; max-width: 180px; }
  .review-sheet { align-items: center; padding: 1rem; }
  .review-panel { border-radius: 18px; max-height: 85vh; }
}
