:root {
  --ink: #1b1e33;
  --ink-soft: #5b5f7a;
  --bg: #f6f6fb;
  --surface: #ffffff;
  --brand: #252a4a;
  --brand-2: #3a4177;
  --accent: #12b3a0;
  --accent-ink: #063f38;
  --danger: #c74747;
  --border: #e4e4ef;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(27, 30, 51, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
}
.brand-icon { border-radius: 6px; display: block; }

.offline-pill {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255,255,255,0.16);
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}

main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.view h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 0 0 10px;
}

.lede {
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0 0 24px;
}

.feature-list {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.feature-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.feature-list strong { color: var(--ink); }

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 22px;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-lg { width: 100%; padding: 15px 22px; font-size: 1rem; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: 0.92; }

.btn-secondary {
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: none;
  font-weight: 500;
  padding: 10px 12px;
}

/* Form */
#cardForm {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.field em { color: var(--danger); font-style: normal; }
.field input,
.field textarea {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink);
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  outline: none;
  resize: vertical;
}
.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 179, 160, 0.15);
}

.form-error {
  background: #fdecec;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin: 0;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

/* Card view */
.card-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px;
}

.card-identity h1 {
  font-size: 1.35rem;
  margin-bottom: 2px;
}
.muted { color: var(--ink-soft); margin: 0 0 4px; font-size: 0.95rem; }

.description {
  margin: 10px 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
}

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 22px 0;
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.qr-canvas {
  background: #fff;
  padding: 10px;
  border-radius: 10px;
  line-height: 0;
  width: 220px;
  max-width: 100%;
}
.qr-canvas img, .qr-canvas canvas, .qr-canvas table, .qr-canvas svg {
  display: block;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
}
.qr-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.detail-list {
  margin: 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-list div { display: flex; flex-direction: column; }
.detail-list dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  font-weight: 600;
}
.detail-list dd {
  margin: 2px 0 0;
  font-size: 0.98rem;
  word-break: break-word;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-actions .btn-secondary,
.card-actions .btn-danger-ghost {
  width: 100%;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  z-index: 50;
}

/* Update banner */
.update-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  background: var(--brand);
  color: #fff;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: 480px;
  margin: 0 auto;
}
.update-banner:not([hidden]) { display: flex; }
.update-banner span { font-size: 0.88rem; }

/* Footer */
.app-footer {
  text-align: center;
  padding: 4px 20px 28px;
  color: var(--ink-soft);
}
.app-footer p {
  margin: 0;
  font-size: 0.78rem;
}

/* Share sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 40, 0.5);
  z-index: 80;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop:not([hidden]) { display: flex; }

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(20px + var(--safe-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: 6px auto 14px;
}

.sheet h2 {
  font-size: 1.1rem;
  margin: 0 0 16px;
  text-align: center;
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}

.share-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--ink);
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.share-option:active { background: var(--bg); }

.share-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.share-icon-whatsapp { background: #25d366; }
.share-icon-telegram { background: #29a9eb; }
.share-icon-viber { background: #7360f2; }
.share-icon-facebook { background: #1877f2; }
.share-icon-email { background: var(--brand-2); }
.share-icon-more { background: var(--ink-soft); }
.share-icon-download { background: var(--accent); color: var(--accent-ink); }

.sheet-note {
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 4px 0 16px;
}

@media (min-width: 480px) {
  .app-header { padding: 16px 28px; }
  main { padding: 36px 20px 48px; }
}
