*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #8B3030;
  --blue-dark: #6B2020;
  --green: #2e7d52;
  --red: #c0392b;
  --grey-1: #f5efee;
  --grey-2: #ede5e4;
  --grey-3: #d9cece;
  --grey-5: #8a7878;
  --grey-7: #3c2e2e;
  --text: #1a1212;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(80,20,20,.10), 0 1px 2px rgba(80,20,20,.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background-color: #f0e6e4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='92' viewBox='0 0 80 92'%3E%3Cpath d='M40 4 L74 22 L74 70 L40 88 L6 70 L6 22 Z' fill='none' stroke='%238B3030' stroke-width='1' stroke-opacity='0.08'/%3E%3C/svg%3E");
  background-size: 80px 92px;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Status bar ── */
#status-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--grey-3);
  font-size: 13px;
  font-weight: 500;
}

.brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.brand-sub {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--grey-5);
}

#online-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  transition: background .3s, color .3s;
}

#online-badge.online  { background: #e3f0e8; color: #1e6e3e; }
#online-badge.offline { background: #f9e5e3; color: #a02020; }

#online-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

#online-badge.online::before  { background: var(--green); }
#online-badge.offline::before { background: var(--red); }

/* ── Progress bar ── */
#progress-wrap {
  background: #fff;
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--grey-3);
}

#progress-steps {
  display: flex;
  gap: 0;
  margin-bottom: 0;
}

.progress-step {
  flex: 1;
  text-align: center;
  padding: 8px 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--grey-5);
  border-bottom: 3px solid var(--grey-3);
  cursor: default;
  transition: color .2s, border-color .2s;
}

.progress-step.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.progress-step.done {
  color: var(--green);
  border-bottom-color: var(--green);
}

/* ── Main content ── */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ── Step panels ── */
.step-panel { display: none; }
.step-panel.active { display: block; }

.step-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Cards / field groups ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-7);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* ── Radio / toggle groups ── */
.radio-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.radio-btn {
  flex: 1;
  min-width: 80px;
  position: relative;
}

.radio-btn input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-btn label {
  display: block;
  text-align: center;
  padding: 10px 8px;
  border: 2px solid var(--grey-3);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}

.radio-btn input:checked + label {
  border-color: var(--blue);
  background: #e8f0fe;
  color: var(--blue);
}

/* ── Text inputs ── */
.text-input, .textarea-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--grey-3);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

.text-input:focus, .textarea-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(139,48,48,.15);
}

.textarea-input {
  resize: vertical;
  min-height: 90px;
}

/* ── Nested / conditional blocks ── */
.nested {
  margin-top: 12px;
  padding: 14px;
  background: var(--grey-1);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.nested .card-label { margin-bottom: 10px; }

/* ── Photo section ── */
.photo-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--grey-7);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--grey-3);
}

.photo-slot {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
}

.photo-slot-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--grey-7);
  padding-top: 2px;
}

.photo-slot-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.photo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.photo-btn:active { background: var(--blue-dark); }

.photo-btn svg { flex-shrink: 0; }

.photo-input { display: none; }

.thumb-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.thumb-strip img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--grey-3);
}

/* ── Navigation buttons ── */
.step-nav {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:active { background: var(--blue-dark); }

.btn-secondary {
  background: var(--grey-2);
  color: var(--grey-7);
}

.btn-secondary:active { background: var(--grey-3); }

.btn-success {
  background: var(--green);
  color: #fff;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* ── Review panel ── */
#review-content {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.review-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--grey-2);
  font-size: 14px;
}

.review-row:last-child { border-bottom: none; }

.review-key {
  flex: 0 0 48%;
  color: var(--grey-5);
  font-weight: 500;
}

.review-val {
  flex: 1;
  color: var(--text);
  word-break: break-word;
}

.review-photos {
  margin-top: 16px;
}

.review-photos-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-7);
  margin-bottom: 8px;
}

.review-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.review-thumb-grid img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--grey-3);
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--grey-7);
  color: #fff;
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: transform .3s, opacity .3s;
  z-index: 999;
  max-width: 90vw;
  text-align: center;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

#toast.success { background: var(--green); }
#toast.error   { background: var(--red); }

/* ── Hidden util ── */
.hidden { display: none !important; }
