/* Rūpestėlis ID — Capture PWA styles.
 * Visual language lifted from frontend/index.lt.html: warm off-white bg,
 * Fraunces display + DM Sans body, Rūpestėlis green primary, Rupi yellow.
 * Mobile-first; the app column is capped at ~430px like the NoseID backup.
 */
:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --border: #e8e5df;
  --text: #1a1a1a;
  --text-dim: #6b6560;
  --primary: #1b6b4a;
  --primary-light: #e8f5ee;
  --primary-dark: #0f4a32;
  --accent: #c45d2c;
  --rupi-yellow: #ffd53d;
  --rupi-yellow-light: #fff4c2;
  --gold: #8b7332;
  --danger: #c0392b;
  --danger-light: #fdecea;
  --ok: #1b6b4a;
  --warn: #c45d2c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1);
}

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

html,
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* The whole app lives in one centred mobile column. */
.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ─── App bar ─── */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.appbar .logo {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 19px;
  color: var(--primary-dark);
  text-decoration: none;
}
.appbar .logo span {
  color: var(--rupi-yellow);
  -webkit-text-stroke: 1px var(--gold);
}
.appbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.back-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 8px 2px 0;
  line-height: 1;
}
.lang-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* ─── Screen container ─── */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 20px 16px 32px;
  animation: fade 0.18s ease;
}
.screen.active {
  display: flex;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Typography ─── */
h1.title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
h2.subtitle {
  font-family: 'Fraunces', serif;
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 8px;
}
.lead {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 20px;
}
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}
.muted {
  color: var(--text-dim);
  font-size: 13px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s;
}
.btn:active {
  transform: scale(0.99);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 24px rgba(27, 107, 74, 0.28);
}
.btn-primary:active {
  background: var(--primary-dark);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--text);
}
.btn-ghost {
  background: transparent;
  color: var(--primary-dark);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row .btn {
  width: auto;
  flex: 1;
}
.btn-sm {
  padding: 11px 14px;
  font-size: 14px;
}

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card.accent {
  background: var(--rupi-yellow-light);
  border-color: var(--rupi-yellow);
}
.card.primary-tint {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ─── Forms ─── */
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.field .hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
input[type='text'],
input[type='email'],
input[type='tel'],
input[type='password'],
input[type='date'],
select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  color: var(--text);
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.field-row {
  display: flex;
  gap: 10px;
}
.field-row .field {
  flex: 1;
}

/* Segmented control (species, sex). */
.segmented {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.segmented button {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 10px 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
}
.segmented button.active {
  background: var(--primary);
  color: #fff;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.checkbox-field input {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

/* ─── Inline messages ─── */
.msg {
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  display: none;
}
.msg.show {
  display: block;
}
.msg.error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #f3c4be;
}
.msg.success {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #bfe3cd;
}

/* ─── Landing screen ─── */
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--rupi-yellow);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.feature-list {
  list-style: none;
  margin: 4px 0 8px;
}
.feature-list li {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.feature-list li:last-child {
  border-bottom: none;
}
.feature-list .ico {
  font-size: 18px;
  flex-shrink: 0;
}
.spacer {
  flex: 1;
}

/* ─── Camera / capture viewport ─── */
.viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #0a0d0c;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-md);
}
#cam-video,
#cam-frozen {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.oval-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* Status badge above the oval. */
.cam-badge {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 13, 12, 0.82);
  color: #fff;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s;
}
.cam-badge.good {
  background: rgba(27, 107, 74, 0.92);
}
.cam-badge.warn {
  background: rgba(196, 93, 44, 0.92);
}
/* Shot-progress dots. */
.shot-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
}
.shot-dots .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.shot-dots .dot.done {
  background: var(--rupi-yellow);
  border-color: var(--rupi-yellow);
}
.shot-dots .dot.current {
  background: #fff;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}
/* Brief flash when a shot is auto-captured. */
.capture-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.capture-flash.fire {
  animation: flash 0.4s ease;
}
@keyframes flash {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

/* The instruction line for the current of 5 shots. */
.shot-instruction {
  text-align: center;
  margin-bottom: 12px;
}
.shot-instruction .step {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}
.shot-instruction .what {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

/* Live quality gate readout. */
.gates {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
}
.gate-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.gate-row .g-label {
  font-size: 12px;
  color: var(--text-dim);
  width: 78px;
  flex-shrink: 0;
}
.gate-row .g-track {
  flex: 1;
  height: 5px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.gate-row .g-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s, background 0.2s;
}
.gate-row .g-fill.pass {
  background: var(--primary);
}
.gate-row .g-state {
  font-size: 14px;
  width: 20px;
  text-align: center;
}

/* Captured-shots thumbnail strip. */
.thumb-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.thumb-strip .thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid var(--primary);
}
.thumb-strip .thumb.placeholder {
  background: var(--bg);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 18px;
}

/* Upload progress list. */
.upload-list {
  list-style: none;
}
.upload-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.upload-list li:last-child {
  border-bottom: none;
}
.upload-list .u-ico {
  width: 22px;
  text-align: center;
}

/* ─── Pet profile view ─── */
.id-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.id-card .id-pet-name {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 900;
}
.id-card .id-meta {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 2px;
}
.id-card .id-rid {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.15);
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 14px;
  display: inline-block;
}
.id-card .id-tier {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--rupi-yellow);
  color: var(--text);
  padding: 4px 9px;
  border-radius: 999px;
  margin-top: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child {
  border-bottom: none;
}
.detail-row .d-key {
  color: var(--text-dim);
}
.detail-row .d-val {
  font-weight: 600;
  text-align: right;
}

/* Lost-mode banner / toggle. */
.lost-banner {
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.toggle-card .t-text {
  flex: 1;
}
.toggle-card .t-text strong {
  display: block;
  font-size: 15px;
}
.toggle-card .t-text span {
  font-size: 12px;
  color: var(--text-dim);
}
/* iOS-style switch. */
.switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s;
  cursor: pointer;
}
.switch .slider::before {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.switch input:checked + .slider {
  background: var(--danger);
}
.switch input:checked + .slider::before {
  transform: translateX(22px);
}

/* ─── QR display ─── */
.qr-frame {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  margin-bottom: 14px;
}
.qr-frame canvas {
  width: 100%;
  max-width: 260px;
  height: auto;
  image-rendering: pixelated;
}
.qr-frame .qr-caption {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 10px;
  word-break: break-all;
}

/* ─── Finder (public) screen ─── */
.finder-hero {
  text-align: center;
  padding: 8px 0 4px;
}
.finder-hero .paw {
  font-size: 44px;
}

/* ─── Spinner / loading ─── */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.dark {
  border-color: var(--border);
  border-top-color: var(--primary);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Full-screen blocking overlay (used during multi-step uploads). */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(250, 249, 246, 0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  text-align: center;
  padding: 24px;
}
.overlay.show {
  display: flex;
}
.overlay .overlay-text {
  font-size: 15px;
  color: var(--text-dim);
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 120;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Footer ─── */
.app-footer {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* ─── Install hint ─── */
.install-hint {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--primary-dark);
  margin-bottom: 14px;
  display: none;
  align-items: center;
  gap: 10px;
}
.install-hint.show {
  display: flex;
}
.install-hint button {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* Print: only the QR frame survives. */
@media print {
  body * {
    visibility: hidden;
  }
  #print-area,
  #print-area * {
    visibility: visible;
  }
  #print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 24px;
  }
  .no-print {
    display: none !important;
  }
}

/* Print-only header (hidden on screen, shown on paper). */
.print-only {
  display: none;
}
@media print {
  .print-only {
    display: block;
    text-align: center;
    margin-bottom: 16px;
  }
}
