@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --primary: #4E342E;
  --primary-dark: #6D4C41;
  --secondary: #8D6E63;
  --secondary-light: #D7CCC8;
  --accent: #EFEBE9;
  --bg: #ECEFF1;
  --bg-card: #ffffff;
  --text: #263238;
  --text-secondary: #607D8B;
  --text-muted: #90A4AE;
  --danger: #C62828;
  --danger-light: #FFEBEE;
  --danger-tag: #EF5350;
  --success: #2E7D32;
  --success-light: #E8F5E9;
  --warning: #F57F17;
  --warning-light: #FFF8E1;
  --border: #CFD8DC;
  --border-light: #ECEFF1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

::selection {
  background: var(--secondary);
  color: white;
}

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

html {
  scroll-behavior: smooth;
}

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

.app-container {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon {
  font-size: 2rem;
  line-height: 1;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-text h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-text p {
  font-size: 0.82rem;
  opacity: 0.8;
  font-weight: 400;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  flex: 1;
  padding: 12px 4px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: inherit;
  transition: all 0.2s ease;
  position: relative;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

.tab-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.tab-label {
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 16px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardStagger {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.35s ease both;
}

.card-stagger {
  animation: cardStagger 0.4s ease both;
}

/* Skeleton Loading */
.skeleton-container {
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton {
  background: linear-gradient(90deg, var(--accent) 25%, var(--bg) 50%, var(--accent) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-title {
  height: 28px;
  width: 60%;
}

.skeleton-line {
  height: 18px;
  width: 100%;
}

.skeleton-line.short {
  width: 45%;
}

.skeleton-card {
  height: 100px;
  width: 100%;
  border-radius: var(--radius);
}

.skeleton-card-large {
  height: 360px;
  width: 100%;
  border-radius: var(--radius-lg);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  line-height: 1;
}

.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-primary.btn-sm {
  padding: 8px 16px;
  font-size: 0.82rem;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--accent);
}

.btn-edit {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.btn-edit:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  transition: transform 0.15s ease;
}

.btn-icon:hover {
  transform: scale(1.15);
}

.btn-danger-sm {
  background: var(--danger);
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-secondary-sm {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-share {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-share:hover {
  background: rgba(255,255,255,0.25);
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Info Cards */
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.info-value {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  text-align: right;
}

.info-value.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.blood-type-badge {
  background: var(--danger-light);
  color: var(--danger);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
}

.card-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.tag-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #FFCDD2;
}

.tag-condition {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid #FFE082;
}

.info-list {
  list-style: none;
  padding: 0;
}

.info-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
  color: var(--text);
  padding-left: 16px;
  position: relative;
}

.info-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--secondary);
  font-weight: 700;
}

.info-list li:last-child {
  border-bottom: none;
}

.phone-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.phone-link:hover {
  text-decoration: underline;
}

.notes-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* Insurance Specific */
.insurance-provider-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.provider-icon {
  font-size: 2rem;
  line-height: 1;
}

.provider-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.plan-badge {
  display: inline-block;
  background: var(--bg);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.rx-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.rx-item {
  text-align: center;
  background: var(--bg);
  padding: 10px 8px;
  border-radius: var(--radius-sm);
}

.rx-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.rx-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}

/* Forms */
.edit-form {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.edit-form .section-title {
  margin-bottom: 20px;
}

.form-heading {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.form-group {
  margin-bottom: 14px;
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(84, 110, 122, 0.12);
}

.form-group textarea {
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.checkbox-group {
  margin-top: 4px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500 !important;
  color: var(--text) !important;
  font-size: 0.88rem !important;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: unset;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-divider {
  text-align: center;
  margin: 20px 0 16px;
  position: relative;
}

.form-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.form-divider span {
  background: var(--bg-card);
  padding: 0 12px;
  position: relative;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

/* Contacts */
.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.contact-card:hover {
  box-shadow: var(--shadow-md);
}

.contact-card.primary-contact {
  border-left: 3px solid var(--primary);
}

.primary-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.contact-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.contact-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-relation {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.contact-actions-top {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.confirm-delete {
  display: flex;
  gap: 4px;
}

.contact-phones {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.phone-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s ease;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.phone-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.phone-btn.alt {
  color: var(--text-secondary);
}

.phone-icon {
  font-size: 0.9rem;
}

.contact-notes {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding-left: 54px;
}

.contact-form {
  margin-bottom: 16px;
}

/* Emergency Card View */
.card-view {
  padding-bottom: 24px;
}

.emergency-card {
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  color: white;
}

.card-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(0,0,0,0.15);
}

.card-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--danger);
  padding: 4px 12px;
  border-radius: 4px;
}

.card-identity {
  padding: 20px 18px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.card-name {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.meta-item {
  font-size: 0.82rem;
  opacity: 0.9;
  font-weight: 500;
}

.blood-badge {
  background: rgba(255,255,255,0.2);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 700;
}

.donor-badge {
  background: rgba(46, 125, 50, 0.3);
  padding: 2px 10px;
  border-radius: 20px;
}

.card-section {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.card-section:last-child {
  border-bottom: none;
}

.card-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 8px;
}

.allergy-section {
  background: rgba(198, 40, 40, 0.2);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-tag {
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.card-tag.danger {
  background: rgba(239, 83, 80, 0.35);
  border: 1px solid rgba(239, 83, 80, 0.5);
}

.card-tag.condition {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
}

.card-med-list {
  list-style: none;
  padding: 0;
}

.card-med-list li {
  padding: 4px 0;
  font-size: 0.85rem;
  opacity: 0.9;
  padding-left: 14px;
  position: relative;
}

.card-med-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  opacity: 0.5;
}

.card-doctor {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}

.card-phone-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-sm);
  color: white;
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.card-phone-btn:hover {
  background: rgba(255,255,255,0.25);
}

.card-contacts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-contact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  gap: 10px;
}

.card-contact-info {
  min-width: 0;
}

.card-contact-name {
  font-size: 0.88rem;
  font-weight: 600;
  display: block;
}

.card-contact-rel {
  font-size: 0.75rem;
  opacity: 0.65;
}

.card-insurance {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-insurance-name {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-plan-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.card-insurance-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.82rem;
  opacity: 0.85;
}

.card-insurance-details strong {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.card-notes {
  font-size: 0.85rem;
  opacity: 0.85;
  line-height: 1.5;
  font-style: italic;
}

/* Responsive */
@media (max-width: 640px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-row.three-col {
    grid-template-columns: repeat(3, 1fr);
    flex-direction: row;
  }

  .app-header {
    padding: 18px 16px;
  }

  .main-content {
    padding: 12px;
  }

  .card-name {
    font-size: 1.2rem;
  }

  .contact-notes {
    padding-left: 0;
    margin-top: 10px;
  }

  .card-contact-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}


<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to your Emergency Card app. This is your personal medical and emergency info, always available on your phone.", "view": "card", "highlight_selector": ".app-header", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "Start by tapping the Medical tab to add your health details — blood type, allergies, medications, and conditions.", "view": "card", "highlight_selector": ".tab-btn:nth-child(2)", "wait_for": "user_interaction"},
  {"step": 3, "narration": "Fill in your medical information. All fields are optional — add what you'd want a first responder to know.", "view": "medical", "highlight_selector": ".empty-state .btn-primary", "wait_for": "user_interaction"},
  {"step": 4, "narration": "Next, add your emergency contacts — the people who should be called if something happens.", "view": "contacts", "highlight_selector": ".tab-btn:nth-child(3)", "wait_for": "user_interaction"},
  {"step": 5, "narration": "Add contact names, phone numbers, and relationships. The first contact is marked as your primary.", "view": "contacts", "highlight_selector": ".btn-primary", "wait_for": "user_interaction"},
  {"step": 6, "narration": "Add your insurance info in the Insurance tab — policy numbers, member ID, and pharmacy details.", "view": "insurance", "highlight_selector": ".tab-btn:nth-child(4)", "wait_for": "user_interaction"},
  {"step": 7, "narration": "Now tap the Card tab to see everything combined into a clean emergency card. You can share it with the share button.", "view": "card", "highlight_selector": ".tab-btn:nth-child(1)", "wait_for": "user_interaction"},
  {"step": 8, "narration": "Your card is always synced across devices. Open this app on your phone and everything will be there. Stay safe!", "view": "card", "highlight_selector": ".emergency-card", "wait_for": "tap_to_continue"}
]
-->

.private-card-gate {
  min-height: 320px;
}

.card-auth-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card-owner-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.18);
  color: white;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.btn-signout {
  opacity: 0.95;
}

.btn-signout:hover {
  background: rgba(255,255,255,0.3);
}

.card-qr-section {
  background: rgba(255,255,255,0.04);
}

.card-qr-wallet {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.card-qr-frame {
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.card-qr-svg {
  display: block;
  width: 180px;
  height: 180px;
}

.card-qr-caption {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.card-qr-caption strong {
  font-size: 0.9rem;
  font-weight: 700;
}

.card-qr-caption span {
  font-size: 0.78rem;
  line-height: 1.4;
  opacity: 0.8;
}

.card-qr-link {
  color: white;
  font-size: 0.74rem;
  opacity: 0.9;
  text-decoration: none;
  word-break: break-all;
}

.card-qr-link:hover {
  text-decoration: underline;
}

@media print {
  .app-header,
  .tab-nav,
  .btn-share,
  .btn-signout,
  .card-qr-link {
    display: none !important;
  }

  .main-content {
    padding: 0;
  }

  .card-view {
    padding: 0;
  }

  .emergency-card {
    box-shadow: none;
    border-radius: 0;
    color: #000;
    background: #fff;
  }

  .card-top-bar,
  .card-section,
  .card-identity {
    background: #fff !important;
    color: #000 !important;
    border-color: #ddd !important;
  }

  .card-badge,
  .card-owner-badge,
  .blood-badge,
  .donor-badge,
  .card-plan-badge,
  .card-tag,
  .card-phone-btn {
    color: #000 !important;
    background: #f2f2f2 !important;
    border-color: #ccc !important;
  }

  .card-qr-wallet {
    background: #fff;
    border-color: #bbb;
    padding: 10px;
    break-inside: avoid;
  }

  .card-qr-frame {
    box-shadow: none;
    border: 1px solid #000;
  }

  .card-qr-svg {
    width: 1.9in;
    height: 1.9in;
  }

  .card-qr-section {
    break-inside: avoid;
  }
}

.share-card {
  border-left: 3px solid var(--primary);
}

.share-header {
  margin-bottom: 8px;
}

.share-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 600;
}

.share-help {
  font-size: 0.86rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.share-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.share-feedback {
  margin-top: 12px;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.share-feedback.success {
  color: var(--success);
}

.share-feedback.error {
  color: var(--danger);
}

.shared-link-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.shared-link-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.shared-link-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.shared-link-code {
  flex: 1;
  min-width: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

.shared-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shared-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-card);
}

.shared-item.revoked {
  opacity: 0.65;
}

.shared-item-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.shared-item-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.shared-item-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.shared-item-link {
  font-size: 0.78rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.shared-item-link:hover {
  text-decoration: underline;
}

.shared-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.card-pdf-note {
  font-size: 0.78rem;
  opacity: 0.85;
}

.btn-share:disabled,
.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

@media print {
  .btn-share:disabled,
  .btn-primary:disabled {
    opacity: 1;
  }
}

.upload-help {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.upload-error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
}

.card-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.card-photo-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
}

.card-photo-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-photo-preview {
  width: 100%;
  aspect-ratio: 1.5 / 1;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

.card-photo-caption {
  display: block;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-photo-actions {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

.share-link-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  word-break: break-all;
  color: var(--text-secondary);
  margin-top: 4px;
}

.share-link-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .card-photo-grid {
    grid-template-columns: 1fr;
  }
}
