:root {
  --cream: #FAF7F2;
  --cream-2: #F4EFE6;
  --surface: #FFFFFF;
  --ink: #1A2E26;
  --ink-soft: #5A6B63;
  --forest: #1F4D3F;
  --forest-deep: #143329;
  --caramel: #C4956C;
  --border: #E5DFD5;
  --border-strong: #D4CCBC;
  --success: #4A7C59;
  --error: #B85450;
  --shadow: 0 1px 2px rgba(20, 51, 41, 0.04), 0 8px 24px rgba(20, 51, 41, 0.06);
  --shadow-lg: 0 4px 12px rgba(20, 51, 41, 0.08), 0 24px 48px rgba(20, 51, 41, 0.10);
}

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

html, body {
  overscroll-behavior-y: contain;
}

body {
  font-family: 'Manrope', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 90% 10%, rgba(31, 77, 63, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(196, 149, 108, 0.06) 0%, transparent 40%);
}

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 40px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  background: var(--forest);
  border-radius: 11px;
  display: grid; place-items: center;
  color: var(--cream);
  font-family: 'Fraunces', serif;
  font-size: 19px;
  font-weight: 600;
  font-style: italic;
}
.brand-text { line-height: 1.2; }
.brand-text h1 {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 500;
}
.brand-text p {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 1px;
}

.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
}
.conn-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
}
.conn-dot.connected {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(74, 124, 89, 0.4);
  animation: pulse 2s infinite;
}
.conn-dot.error { background: var(--error); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 124, 89, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(74, 124, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 124, 89, 0); }
}

.view { display: none; flex-direction: column; flex: 1; }
.view.active { display: flex; animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero {
  text-align: center;
  margin: 16px 0 32px;
}
.hero h2 {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 12px;
}
.hero h2 em {
  font-style: italic;
  color: var(--caramel);
  font-weight: 400;
}
.hero p {
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 360px;
  margin: 0 auto;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}
.choice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow);
  width: 100%;
  font-family: inherit;
}
.choice-card:hover, .choice-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--forest);
}
.choice-icon {
  width: 56px; height: 56px;
  flex-shrink: 0;
  border-radius: 16px;
  background: var(--cream-2);
  display: grid; place-items: center;
  color: var(--forest);
}
.choice-card:nth-child(2) .choice-icon {
  background: rgba(196, 149, 108, 0.12);
  color: var(--caramel);
}
.choice-text { flex: 1; }
.choice-text h3 {
  font-family: 'Fraunces', serif;
  font-size: 19px;
  font-weight: 500;
  margin-bottom: 4px;
}
.choice-text p {
  font-size: 13px;
  color: var(--ink-soft);
}
.choice-arrow { color: var(--ink-soft); }

.privacy-note {
  margin-top: 28px;
  padding: 14px 16px;
  background: var(--cream-2);
  border-radius: 12px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
}
.privacy-note strong { color: var(--ink); font-weight: 600; }

.cabinet-card {
  margin-top: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.cabinet-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(to bottom, var(--cream-2), transparent);
  pointer-events: none;
}
.cabinet-mark {
  width: 52px; height: 52px;
  margin: 0 auto 16px;
  background: var(--forest);
  color: var(--cream);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 12px rgba(31, 77, 63, 0.15);
}
.cabinet-name {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}
.cabinet-name em {
  font-style: italic;
  color: var(--forest);
  font-weight: 600;
}
.cabinet-tagline {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}

.specialties {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 26px;
}
.pill {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 100px;
  background: var(--cream-2);
  color: var(--ink);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill-accent {
  background: rgba(184, 84, 80, 0.08);
  color: var(--error);
  border-color: rgba(184, 84, 80, 0.2);
  font-weight: 600;
}

.cabinet-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.contact-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--cream-2);
  text-decoration: none;
  color: var(--ink);
  transition: all 0.15s;
  border: 1px solid transparent;
}
.contact-row:hover, .contact-row:active {
  background: var(--surface);
  border-color: var(--forest);
  transform: translateY(-1px);
}
.contact-icon {
  width: 38px; height: 38px;
  background: var(--surface);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--forest);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.contact-text { flex: 1; min-width: 0; }
.contact-label {
  font-size: 10px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
  font-weight: 600;
}
.contact-value {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}
.contact-arrow {
  color: var(--ink-soft);
  flex-shrink: 0;
}

.cabinet-divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0 16px;
}

.privacy-line {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
}
.privacy-line strong { color: var(--ink); font-weight: 600; }

.sub-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.back-btn {
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.15s;
}
.back-btn:hover { background: var(--cream-2); }
.sub-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}
.field label .required { color: var(--error); }
.field-hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(31, 77, 63, 0.1);
}
.textarea { resize: vertical; min-height: 80px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235A6B63' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}

.file-zone {
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--cream-2);
  transition: all 0.15s;
}
.file-zone:hover { border-color: var(--forest); background: rgba(31, 77, 63, 0.03); }
.file-zone.has-file { border-style: solid; border-color: var(--forest); background: rgba(74, 124, 89, 0.05); }
.file-zone svg { color: var(--ink-soft); margin-bottom: 8px; }
.file-zone.has-file svg { color: var(--success); }
.file-zone-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.file-zone-hint { font-size: 12px; color: var(--ink-soft); }
.file-zone input[type="file"] { display: none; }

.file-options {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.file-options button {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.file-options button:hover { background: var(--cream-2); }

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 8px;
  user-select: none;
}
.check-row:hover { background: var(--cream-2); }
.check-row input[type="checkbox"], .check-row input[type="radio"] {
  width: 20px; height: 20px;
  accent-color: var(--forest);
  flex-shrink: 0;
}
.check-row span { font-size: 14px; }
.radio-group { display: flex; gap: 8px; }
.radio-group .check-row { flex: 1; justify-content: center; }

.signature-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.signature-wrap.signed {
  border-color: var(--forest);
  background: rgba(31, 77, 63, 0.02);
}
.signature-canvas {
  display: block;
  width: 100%;
  height: 180px;
  touch-action: none;
  cursor: crosshair;
  background-image:
    linear-gradient(to right, transparent 0, transparent calc(100% - 1px), var(--border) 100%),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      var(--border) 32px
    );
  background-size: 100% 100%;
}
.signature-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 14px;
  transition: opacity 0.2s;
}
.signature-wrap.signed .signature-placeholder { opacity: 0; }
.signature-baseline {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 32px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-strong) 8%, var(--border-strong) 92%, transparent);
  pointer-events: none;
}
.signature-x {
  position: absolute;
  left: 12px;
  bottom: 26px;
  color: var(--ink-soft);
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-style: italic;
  pointer-events: none;
  opacity: 0.6;
}
.signature-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 12px;
}
.signature-meta {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.4;
  flex: 1;
}
.signature-clear {
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.signature-clear:hover { background: var(--cream-2); color: var(--ink); }
.signature-clear:disabled { opacity: 0.4; cursor: not-allowed; }

.action-bar {
  margin-top: auto;
  padding-top: 20px;
}
.btn {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  background: var(--forest);
  color: var(--cream);
  box-shadow: 0 4px 14px rgba(31, 77, 63, 0.25);
}
.btn-primary:hover { background: var(--forest-deep); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.section-heading {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 500;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
.section-heading:first-child { margin-top: 0; }

.sending-overlay {
  position: fixed;
  inset: 0;
  background: rgba(250, 247, 242, 0.96);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}
.sending-overlay.active { display: flex; }

.sending-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  color: var(--forest);
}
.sending-icon svg {
  animation: rotate 2s linear infinite;
}
@keyframes rotate { to { transform: rotate(360deg); } }

.sending-icon.success { background: var(--success); color: white; }
.sending-icon.success svg { animation: none; }
.sending-icon.error { background: var(--error); color: white; }
.sending-icon.error svg { animation: none; }

.sending-title {
  font-family: 'Fraunces', serif;
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.sending-subtitle {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 28px;
  max-width: 320px;
}
.sending-progress {
  width: 100%;
  max-width: 280px;
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}
.sending-progress-bar {
  height: 100%;
  background: var(--forest);
  width: 0%;
  transition: width 0.3s;
}

.error-banner {
  background: rgba(184, 84, 80, 0.08);
  border: 1px solid rgba(184, 84, 80, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--error);
  display: none;
}
.error-banner.shown { display: block; }

.fatal-banner {
  background: rgba(184, 84, 80, 0.08);
  border: 1px solid rgba(184, 84, 80, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 13px;
  color: var(--error);
  text-align: center;
  line-height: 1.5;
}
