/* ═══════════════════════════════════════════════════════════════════
   authID Doc Capture — Styles
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* authID brand palette */
  --purple-900: #1a0e3a;
  --purple-800: #2c1a5a;
  --purple-700: #3d2878;
  --purple-600: #5841C4;
  --purple-500: #6d5aa3;
  --purple-400: #8B6FD4;
  --purple-300: #9480ce;
  --purple-200: #c4b8e8;
  --purple-100: #e8e2f5;
  --purple-50:  #f4f1fa;

  --green-600: #388E3C;
  --green-500: #4CAF50;
  --green-100: #E8F5E9;
  --green-50:  #f1f9f1;

  --red-500: #E53935;
  --red-100: #FFEBEE;

  --gray-900: #1a1a2e;
  --gray-700: #3d3d56;
  --gray-500: #6c6c80;
  --gray-400: #9696a8;
  --gray-300: #c4c4d0;
  --gray-200: #e2e2ea;
  --gray-100: #f0f0f5;
  --gray-50:  #f8f8fc;

  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(44, 26, 90, 0.06);
  --shadow-md: 0 4px 12px rgba(44, 26, 90, 0.08);
  --shadow-lg: 0 8px 30px rgba(44, 26, 90, 0.12);
  --shadow-xl: 0 16px 48px rgba(44, 26, 90, 0.16);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ──────────────────────────────────────────────────────── */

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

html {
  height: 100%;
  /* Matches the rendered gradient top color — fills behind the status bar on iOS */
  background: #ddd6f2;
}

body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--gray-900);
  background: var(--white);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

/* ── Global Hamburger ───────────────────────────────────────────── */

.hamburger-btn {
  position: absolute;
  top: calc(var(--safe-top) + 14px);
  right: 20px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
  transition: background 0.15s ease;
}

.hamburger-btn:active {
  background: rgba(255, 255, 255, 0.95);
}

.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--gray-700);
  border-radius: 2px;
}

/* Hide hamburger on non-welcome views (camera, etc.) */
.hamburger-btn.hidden {
  display: none;
}

/* ── Slide-out Drawer ──────────────────────────────────────────── */

#drawer-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background 0.35s ease;
}

#drawer-overlay.open {
  background: rgba(0, 0, 0, 0.35);
  pointer-events: all;
}

#drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 82%;
  max-width: 300px;
  background: var(--white);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

#drawer.open {
  transform: translateX(0);
}

#drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 20px) 20px 16px;
  border-bottom: 1px solid var(--gray-200);
}

#drawer-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

#drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

#drawer-list {
  padding: 12px 0 calc(var(--safe-bottom) + 24px);
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--gray-100);
}

.drawer-item:last-child {
  border-bottom: none;
}

.drawer-item:active {
  background: var(--gray-50);
}

.drawer-item.active {
  background: var(--purple-50);
}

.drawer-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--purple-50);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-item-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.drawer-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
}

.drawer-item-desc {
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.4;
}

.drawer-item-check {
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── App Shell ──────────────────────────────────────────────────── */

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--white);
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateX(40px);
  transition: opacity 0.35s var(--ease-out),
              transform 0.35s var(--ease-out),
              visibility 0s 0.35s;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition: opacity 0.35s var(--ease-out),
              transform 0.35s var(--ease-out),
              visibility 0s 0s;
  z-index: 1;
}

.view.exit-left {
  opacity: 0;
  transform: translateX(-40px);
}

/* ── Buttons ────────────────────────────────────────────────────── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--purple-600), var(--purple-400));
  color: var(--white);
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(88, 65, 196, 0.35);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(88, 65, 196, 0.3);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--purple-50);
  color: var(--purple-600);
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--purple-200);
  transition: transform 0.2s var(--ease-spring), background 0.2s ease;
}

.btn-secondary:active {
  transform: scale(0.97);
  background: var(--purple-100);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 14px 20px;
  background: var(--white);
  color: var(--gray-700);
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--gray-200);
  transition: transform 0.2s var(--ease-spring);
}

.btn-outline:active {
  transform: scale(0.97);
  background: var(--gray-50);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  color: var(--purple-600);
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}

.btn-ghost:active {
  background: var(--purple-50);
}

.back-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--gray-700);
  transition: background 0.15s ease;
}

.back-btn:active {
  background: var(--gray-100);
}

/* ══════════════════════════════════════════════════════════════════
   WELCOME VIEW
   ══════════════════════════════════════════════════════════════════ */

#view-welcome {
  background: var(--white);
}

.welcome-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.welcome-gradient {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 130% 55% at 50% -5%, var(--purple-200) 0%, transparent 75%);
  opacity: 0.85;
}

.welcome-pattern {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, var(--purple-200) 1px, transparent 1px),
    radial-gradient(circle at 80% 60%, var(--purple-200) 1px, transparent 1px),
    radial-gradient(circle at 60% 80%, var(--purple-200) 1px, transparent 1px);
  background-size: 60px 60px, 80px 80px, 100px 100px;
  opacity: 0.3;
}

.welcome-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 24px) 28px calc(var(--safe-bottom) + 24px);
  min-height: 100%;
}

.welcome-logo-wrap {
  width: 160px;
  margin-bottom: 20px;
}

.welcome-logo {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  mix-blend-mode: multiply;
}

.welcome-text {
  text-align: center;
  margin-bottom: 20px;
}

.welcome-text h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--purple-800);
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.welcome-text p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-500);
  max-width: 320px;
  margin: 0 auto;
}

.welcome-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 24px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.step-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--purple-50);
  color: var(--purple-600);
  flex-shrink: 0;
}

.step-text {
  display: flex;
  flex-direction: column;
}

.step-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--purple-400);
}

.step-desc {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
}

#btn-start {
  margin-bottom: 12px;
  max-width: 320px;
}

#btn-upload-alt {
  max-width: 320px;
}

/* ══════════════════════════════════════════════════════════════════
   CAMERA CAPTURE VIEW
   ══════════════════════════════════════════════════════════════════ */

#view-capture {
  background: #000;
}

.capture-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#camera-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Document guide overlay */
.doc-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.doc-guide {
  position: relative;
  width: 85%;
  max-width: 360px;
  aspect-ratio: 8.5 / 11;
  max-height: 55vh;
}

.doc-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(255, 255, 255, 0.8);
  border-style: solid;
  border-width: 0;
}

.doc-corner.tl {
  top: 0; left: 0;
  border-top-width: 3px;
  border-left-width: 3px;
  border-top-left-radius: 8px;
}

.doc-corner.tr {
  top: 0; right: 0;
  border-top-width: 3px;
  border-right-width: 3px;
  border-top-right-radius: 8px;
}

.doc-corner.bl {
  bottom: 0; left: 0;
  border-bottom-width: 3px;
  border-left-width: 3px;
  border-bottom-left-radius: 8px;
}

.doc-corner.br {
  bottom: 0; right: 0;
  border-bottom-width: 3px;
  border-right-width: 3px;
  border-bottom-right-radius: 8px;
}

.doc-guide-text {
  margin-top: 20px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Camera top bar */
.camera-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}

.cam-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border-radius: 50%;
  transition: background 0.15s ease;
}

.cam-btn:active {
  background: rgba(255,255,255,0.15);
}

.cam-btn.flash-on {
  color: #FFD54F;
}

.cam-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Camera bottom bar */
.camera-bottombar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 20px 28px calc(var(--safe-bottom) + 28px);
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
}

.cam-upload-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.4);
}

.cam-upload-btn:active {
  background: rgba(255,255,255,0.15);
}

.cam-spacer {
  width: 44px;
}

/* Capture button */
.capture-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s var(--ease-spring);
}

.capture-btn:active {
  transform: scale(0.92);
}

.capture-btn-inner {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease, background 0.15s ease;
}

.capture-btn:active .capture-btn-inner {
  transform: scale(0.9);
  background: var(--purple-200);
}

/* Shutter flash */
.shutter-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 100;
  animation: shutterFlash 0.3s ease-out forwards;
}

@keyframes shutterFlash {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════════
   REVIEW VIEW
   ══════════════════════════════════════════════════════════════════ */

.review-container {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--gray-50);
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
}

.review-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.review-image-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

#review-image {
  max-width: 100%;
  max-height: 60vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
}

.review-hint {
  text-align: center;
  font-size: 13px;
  color: var(--gray-400);
  padding: 0 28px 16px;
}

.review-actions {
  display: flex;
  gap: 12px;
  padding: 16px 20px calc(var(--safe-bottom) + 20px);
  background: var(--white);
  border-top: 1px solid var(--gray-100);
}

.review-actions .btn-primary {
  flex: 2;
}

/* ══════════════════════════════════════════════════════════════════
   PROCESSING VIEW
   ══════════════════════════════════════════════════════════════════ */

.processing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 28px;
  background: var(--white);
}

.processing-visual {
  margin-bottom: 40px;
}

.scan-doc-icon {
  position: relative;
  width: 100px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-doc-icon svg {
  position: relative;
  z-index: 1;
}

.scan-line {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--purple-600), transparent);
  border-radius: 2px;
  animation: scanLine 2s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(88, 65, 196, 0.4);
}

@keyframes scanLine {
  0%, 100% { top: 15px; opacity: 0.3; }
  50% { top: 90px; opacity: 1; }
}

.processing-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--purple-800);
  margin-bottom: 8px;
}

.processing-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 40px;
}

.processing-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 260px;
}

.proc-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--gray-400);
  transition: color 0.3s ease;
}

.proc-step.active {
  color: var(--purple-600);
  font-weight: 500;
}

.proc-step.done {
  color: var(--green-500);
}

.proc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-300);
  transition: background 0.3s ease, box-shadow 0.3s ease;
  flex-shrink: 0;
}

.proc-step.active .proc-dot {
  background: var(--purple-600);
  box-shadow: 0 0 0 4px rgba(88, 65, 196, 0.2);
  animation: pulse 1.5s infinite;
}

.proc-step.done .proc-dot {
  background: var(--green-500);
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(88, 65, 196, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(88, 65, 196, 0.08); }
}

/* ══════════════════════════════════════════════════════════════════
   SUCCESS VIEW
   ══════════════════════════════════════════════════════════════════ */

.success-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-top) + 60px) 24px calc(var(--safe-bottom) + 32px);
  min-height: 100%;
  background: var(--white);
}

.success-header {
  text-align: center;
  margin-bottom: 32px;
}

.success-check {
  margin-bottom: 20px;
  animation: checkPop 0.5s var(--ease-spring);
}

@keyframes checkPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.check-draw {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: drawCheck 0.6s 0.3s ease forwards;
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

.success-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.success-subtitle {
  font-size: 15px;
  color: var(--gray-500);
}

/* Extracted address card */
.extracted-address-card {
  width: 100%;
  max-width: 380px;
  background: var(--green-50);
  border: 1.5px solid #c8e6c9;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 32px;
}

.eac-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--green-600);
  margin-bottom: 10px;
}

.eac-value {
  display: flex;
  flex-direction: column;
  gap: 0;
  color: var(--gray-900);
  line-height: 1.5;
  margin-bottom: 12px;
}

.eac-value .addr-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.eac-value .addr-line {
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-700);
  line-height: 1.45;
}

.eac-confidence {
  display: flex;
  align-items: center;
  gap: 10px;
}

.confidence-bar {
  flex: 1;
  height: 4px;
  background: #c8e6c9;
  border-radius: 2px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: var(--green-500);
  border-radius: 2px;
  transition: width 0.8s var(--ease-out);
  width: 0;
}

.confidence-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--green-600);
  white-space: nowrap;
}

.success-actions {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   DEBUG VIEW
   ══════════════════════════════════════════════════════════════════ */

.debug-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--gray-50);
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.debug-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.debug-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* Debug cards */
.debug-card {
  background: var(--white);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  overflow: hidden;
}

.debug-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease;
}

.debug-card-header:active {
  background: var(--gray-50);
}

.debug-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}

.debug-card-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--purple-50);
  color: var(--purple-600);
}

.debug-card-chevron {
  color: var(--gray-400);
  transition: transform 0.25s var(--ease-out);
  flex-shrink: 0;
}

.debug-card.open .debug-card-chevron {
  transform: rotate(180deg);
}

.debug-card-body {
  display: none;
  padding: 0 16px 16px;
}

.debug-card.open .debug-card-body {
  display: block;
}

/* Debug: classification */
.classification-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--purple-50);
  color: var(--purple-800);
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.classification-conf {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 8px;
}

/* Debug: address highlight */
.debug-address-card {
  background: var(--green-50);
  border-color: #c8e6c9;
}

.debug-address-card .debug-card-title {
  color: var(--green-600);
}

.address-highlight {
  padding: 12px 14px;
  background: var(--green-100);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  color: var(--green-600);
  line-height: 1.5;
  border-left: 3px solid var(--green-500);
}

.address-source {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 8px;
}

/* Debug: KV pairs */
.kv-table {
  width: 100%;
  border-collapse: collapse;
}

.kv-table tr {
  border-bottom: 1px solid var(--gray-100);
}

.kv-table tr:last-child {
  border-bottom: none;
}

.kv-table td {
  padding: 8px 0;
  font-size: 13px;
  vertical-align: top;
}

.kv-key {
  color: var(--gray-500);
  font-weight: 500;
  padding-right: 12px;
  white-space: nowrap;
  width: 40%;
}

.kv-value {
  color: var(--gray-900);
  font-weight: 500;
  word-break: break-word;
}

.kv-conf {
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 400;
}

/* Debug: tables */
.doc-table-wrap {
  overflow-x: auto;
  margin-top: 4px;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.doc-table th,
.doc-table td {
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  text-align: left;
}

.doc-table th {
  background: var(--purple-50);
  font-weight: 600;
  color: var(--purple-700);
}

/* Debug: raw text */
.raw-text {
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  line-height: 1.6;
  color: var(--gray-700);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* ══════════════════════════════════════════════════════════════════
   ERROR VIEW
   ══════════════════════════════════════════════════════════════════ */

.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 28px calc(var(--safe-bottom) + 32px);
  background: var(--white);
  text-align: center;
}

.error-icon {
  margin-bottom: 24px;
  animation: errorShake 0.5s ease;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.error-container h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 12px;
}

.error-message {
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-500);
  margin-bottom: 28px;
  max-width: 300px;
}

.error-tips {
  width: 100%;
  max-width: 320px;
  text-align: left;
  padding: 16px;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  margin-bottom: 32px;
}

.error-tips h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
}

.error-tips ul {
  list-style: none;
}

.error-tips li {
  font-size: 13px;
  color: var(--gray-500);
  padding: 4px 0;
  padding-left: 18px;
  position: relative;
}

.error-tips li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple-300);
}

#btn-retry {
  max-width: 320px;
  margin-bottom: 8px;
}

#btn-error-home {
  max-width: 320px;
}

/* ══════════════════════════════════════════════════════════════════
   UTILITIES & RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */

/* Hide scrollbar but keep functionality */
.debug-scroll::-webkit-scrollbar,
.raw-text::-webkit-scrollbar {
  width: 4px;
}

.debug-scroll::-webkit-scrollbar-track,
.raw-text::-webkit-scrollbar-track {
  background: transparent;
}

.debug-scroll::-webkit-scrollbar-thumb,
.raw-text::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 2px;
}

/* Desktop: constrain to phone-like viewport */
@media (min-width: 600px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
  }

  #app {
    width: 390px;
    height: 844px;
    border-radius: 40px;
    box-shadow: 0 0 0 12px #1a1a2e, 0 0 80px rgba(88, 65, 196, 0.2);
    overflow: hidden;
  }
}
