@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Work+Sans:wght@400;500;600;700&display=swap');

:root {
  --stone: #EDE7D8;
  --card: #FBF8F0;
  --ink: #2E3620;
  --ink-soft: #5B6653;
  --grove: #5B6E3A;
  --grove-dark: #435328;
  --clay: #A85A32;
  --gold: #C99A3B;
  --error: #A63A2A;
  --error-bg: #F6E4DE;
  --success: #4C7A4C;
  --success-bg: #E6EEE0;
  --line: #DCD3BC;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(46, 54, 32, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--stone);
  color: var(--ink);
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, .field-label, .eyebrow {
  font-family: 'Fraunces', Georgia, serif;
}

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
  flex: 1;
}

/* ---- signature tendril motif ---- */
.tendril path {
  fill: none;
  stroke: var(--grove);
  stroke-width: 2.5;
  stroke-linecap: round;
}
.tendril circle { fill: var(--gold); }
.tendril-small { width: 34px; height: 14px; flex-shrink: 0; }
.tendril-header { width: 110px; height: 36px; margin-bottom: 8px; }
.tendril-corner {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 60px;
  height: 22px;
  opacity: 0.85;
}

/* ---- layout ---- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
}

/* ---- form controls ---- */
.field-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  font-family: 'Work Sans', sans-serif;
  font-size: 1.05rem;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input[type="text"]:focus,
input[type="password"]:focus {
  outline: 3px solid rgba(91, 110, 58, 0.35);
  outline-offset: 1px;
  border-color: var(--grove);
}

.search-row {
  display: flex;
  gap: 10px;
}
.search-row input { flex: 1; min-width: 0; }

.btn {
  font-family: 'Work Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 13px 20px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--grove);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--grove-dark); }
.btn-primary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.btn-block { width: 100%; display: block; margin-top: 14px; }

.link-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: 'Work Sans', sans-serif;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}
.link-btn:focus-visible { outline: 2px solid var(--grove); }

/* ---- result card ---- */
.result-card {
  border-color: var(--grove);
  background: linear-gradient(180deg, var(--card), #F6F2E6);
  animation: fade-slide 0.25s ease;
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.result-name {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  padding-right: 60px;
}
.result-secondary-label {
  margin-top: 14px;
}
.result-lease {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
}
.result-sub {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ---- photo capture ---- */
.photo-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 220px;
  border: 2px dashed var(--clay);
  border-radius: 12px;
  background: #FAF5EA;
  cursor: pointer;
  overflow: hidden;
  margin-bottom: 4px;
}
.photo-drop:focus-within { outline: 3px solid rgba(91, 110, 58, 0.35); }
.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--clay);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 24px;
  text-align: center;
}
.camera-icon { width: 40px; height: 40px; }
#photoPreview {
  width: 100%;
  height: 100%;
  max-height: 340px;
  object-fit: cover;
}
#photoPreview[hidden] { display: none; }

/* ---- persistent flow banner (final success/error, survives the reset) ---- */
.flow-banner {
  max-width: 480px;
  margin: 0 auto 16px;
  padding: 0 16px;
}
.flow-banner-inner {
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  animation: fade-slide 0.25s ease;
}
.flow-banner-inner.success { background: var(--success-bg); color: var(--success); }
.flow-banner-inner.error { background: var(--error-bg); color: var(--error); }

/* ---- status text ---- */
.status-text {
  margin: 10px 0 0;
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 8px;
}
.status-text.loading { background: #EFEADA; color: var(--ink-soft); }
.status-text.success { background: var(--success-bg); color: var(--success); }
.status-text.error, .error-text { background: var(--error-bg); color: var(--error); }
.error-text {
  margin: 12px 0 0;
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 8px;
}

@keyframes fade-slide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .result-card { animation: none; }
  .btn { transition: none; }
}

/* ---- auth page ---- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.auth-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.auth-sub {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 0 0 20px;
}
