* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #34a853;
  --danger: #ea4335;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #202124;
  --text-light: #5f6368;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(32px + var(--safe-bottom));
}

/* Header */
.header {
  text-align: center;
  padding: 48px 0 24px;
}

.header-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-top: 4px;
}

/* Cards / Steps */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  position: relative;
}

.step {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.step.active {
  opacity: 1;
  pointer-events: auto;
}

.step-badge {
  position: absolute;
  top: -10px;
  left: 20px;
  background: var(--primary);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Preview Area */
.preview-area {
  background: #f8f9fa;
  border: 2px dashed #dadce0;
  border-radius: 12px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
}

.preview-area.has-image {
  border-style: solid;
  border-color: var(--primary);
}

.placeholder {
  text-align: center;
  color: var(--text-light);
}

.placeholder-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}

.card-preview {
  width: 100%;
  height: auto;
  display: none;
  border-radius: 10px;
}

.card-preview.visible {
  display: block;
}

/* Buttons */
.capture-buttons {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  text-align: center;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #e8f0fe;
  color: var(--primary);
}

.btn-send {
  width: 100%;
  background: var(--success);
  color: white;
  padding: 16px;
  font-size: 18px;
  border-radius: 12px;
}

.btn-send:disabled {
  background: #dadce0;
  color: #9aa0a6;
  cursor: not-allowed;
}

.btn-send:not(:disabled):active {
  background: #2d9249;
}

.btn-reset {
  width: 100%;
  background: var(--card);
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 16px;
  font-size: 16px;
  border-radius: 12px;
}

/* OCR Status */
.ocr-status {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #e8f0fe;
  border-radius: 12px;
  margin-bottom: 16px;
  color: var(--primary);
  font-weight: 500;
}

.ocr-status.visible {
  display: flex;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #c5d8f8;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Textarea */
.textarea {
  width: 100%;
  padding: 14px;
  border: 1.5px solid #dadce0;
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
  background: #fafafa;
}

.textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.field {
  margin-top: 16px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
}

/* Email Preview */
.email-preview {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  font-size: 14px;
}

.email-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
}

.email-row .label {
  color: var(--text-light);
  font-weight: 600;
  min-width: 60px;
}

/* Send Status */
.send-status {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  text-align: center;
  font-weight: 600;
  display: none;
}

.send-status.success {
  display: block;
  background: #e6f4ea;
  color: var(--success);
}

.send-status.error {
  display: block;
  background: #fce8e6;
  color: var(--danger);
}

.send-status.sending {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #e8f0fe;
  color: var(--primary);
}

/* Parsed Card - Contact Header */
.contact-header {
  text-align: center;
  padding: 20px 0 16px;
  border-bottom: 1px solid #e8eaed;
  margin-bottom: 16px;
}

.contact-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.contact-title {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 4px;
}

.contact-company {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 4px;
}

/* Contact Fields */
.contact-fields {
  margin-bottom: 16px;
}

.field-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f3f4;
}

.field-row:last-child {
  border-bottom: none;
}

.field-icon {
  font-size: 20px;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
  padding-top: 2px;
}

.field-content {
  flex: 1;
  min-width: 0;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 2px;
}

.field-value {
  font-size: 15px;
  color: var(--text);
  word-break: break-word;
}

.field-link {
  color: var(--primary);
  text-decoration: none;
  display: block;
}

.field-link:active {
  opacity: 0.7;
}

/* Quick Actions */
.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-top: 8px;
  border-top: 1px solid #e8eaed;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 24px;
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  justify-content: center;
  min-width: 0;
  transition: opacity 0.2s;
}

.action-btn:active {
  opacity: 0.8;
}

.action-icon {
  font-size: 16px;
}

.action-label {
  white-space: nowrap;
}

/* iOS safe areas */
@supports (padding: env(safe-area-inset-top)) {
  .header {
    padding-top: calc(48px + env(safe-area-inset-top));
  }
}
