:root {
  --bg: #0a0f1a;
  --card: #131b2c;
  --card2: #1a2438;
  --text: #eef2f8;
  --muted: #8b97ab;
  --accent: #22c55e;
  --accent-dim: #16803c;
  --danger: #ef4444;
  --border: #243150;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}

#app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* Header */
#header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(10, 15, 26, 0.95);
  backdrop-filter: blur(8px);
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: 0.5px; }
.brand span { color: var(--accent); }
.progress-wrap {
  height: 5px; background: var(--card2); border-radius: 3px; margin: 10px 0 6px; overflow: hidden;
}
#progress-bar {
  height: 100%; width: 0; background: var(--accent); border-radius: 3px;
  transition: width 0.3s ease;
}
#step-label { font-size: 13px; color: var(--muted); }

/* Content */
#content { flex: 1; padding: 16px 16px 90px; max-width: 560px; width: 100%; margin: 0 auto; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

.section-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.section-desc { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

.field { margin-bottom: 16px; }
.field > label.flabel {
  display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; font-weight: 500;
}
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.field.error > label.flabel { color: var(--danger); }
.field.error input, .field.error textarea, .field.error .chips, .field.error .photo-box {
  border-color: var(--danger);
}

input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], input[type="date"], textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }

.unit-row { display: flex; align-items: center; gap: 10px; }
.unit-row input { flex: 1; }
.unit-row .unit { color: var(--muted); font-size: 15px; min-width: 36px; }

/* Chips (select / multiselect) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; border: 1px solid transparent; border-radius: var(--radius); }
.chip {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14.5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.chip.selected { background: var(--accent-dim); border-color: var(--accent); font-weight: 600; }

/* Boolean toggle */
.bool-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 14px;
}
.bool-row .blabel { font-size: 15px; flex: 1; line-height: 1.35; }
.seg { display: flex; gap: 6px; }
.seg button {
  border: 1px solid var(--border); background: var(--card2); color: var(--muted);
  border-radius: 10px; padding: 8px 16px; font-size: 14.5px; cursor: pointer;
}
.seg button.on-yes { background: var(--accent-dim); border-color: var(--accent); color: #fff; font-weight: 600; }
.seg button.on-no { background: #5b2330; border-color: var(--danger); color: #fff; font-weight: 600; }

.count-row { margin-top: 8px; }

/* Photos */
.photo-box {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 12px; background: var(--card);
}
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-thumb {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--card2);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: rgba(0,0,0,0.65); color: #fff; border: none;
  font-size: 14px; cursor: pointer; line-height: 1;
}
.photo-thumb .uploading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5); font-size: 12px; color: #fff;
}
.photo-add {
  aspect-ratio: 1; border-radius: 10px; border: 1.5px dashed var(--border);
  background: transparent; color: var(--muted); font-size: 26px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px;
}
.photo-add small { font-size: 11px; }

/* Review */
.review-block { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.review-block h3 { font-size: 15px; color: var(--accent); margin-bottom: 8px; }
.review-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.review-row:last-child { border-bottom: none; }
.review-row .q { color: var(--muted); flex: 1; }
.review-row .a { font-weight: 600; text-align: right; max-width: 55%; }

/* Signature */
.sig-block { margin-bottom: 20px; }
.sig-canvas-wrap {
  background: #fff; border-radius: var(--radius); overflow: hidden; position: relative;
  touch-action: none;
}
.sig-canvas-wrap canvas { display: block; width: 100%; height: 160px; }
.sig-clear {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.08);
  border: none; border-radius: 8px; padding: 5px 10px; font-size: 13px; color: #333; cursor: pointer;
}
.sig-hint { text-align: center; color: #aaa; font-size: 13px; position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); pointer-events: none; }

/* Nav */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(10, 15, 26, 0.95); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.btn {
  flex: 1; border: none; border-radius: var(--radius); padding: 15px;
  font-size: 16px; font-weight: 600; cursor: pointer; transition: opacity 0.15s;
}
.btn.primary { background: var(--accent); color: #04210f; }
.btn.secondary { background: var(--card2); color: var(--text); flex: 0 0 auto; padding: 15px 18px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Success screen */
.success { text-align: center; padding: 40px 10px; }
.success .big { font-size: 56px; margin-bottom: 12px; }
.success h2 { margin-bottom: 10px; }
.success p { color: var(--muted); margin-bottom: 8px; line-height: 1.5; }
.success .actions { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.success a.btn { text-decoration: none; display: block; }

.error-banner {
  background: #3a1520; border: 1px solid var(--danger); color: #ffb4b4;
  border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin-bottom: 14px;
  line-height: 1.5;
}
