:root {
  --apple-bg: #f5f5f7;
  --apple-card: #ffffff;
  --apple-border: rgba(0, 0, 0, 0.08);
  --apple-border-hover: rgba(0, 0, 0, 0.16);
  --apple-text: #1d1d1f;
  --apple-text-secondary: #86868b;
  --apple-text-tertiary: #6e6e73;
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-blue-light: rgba(0, 113, 227, 0.08);
  --apple-green: #34c759;
  --apple-green-light: rgba(52, 199, 89, 0.12);
  --apple-red: #ff3b30;
  --apple-red-light: rgba(255, 59, 48, 0.1);
  --apple-radius-sm: 8px;
  --apple-radius-md: 14px;
  --apple-radius-lg: 20px;
  --apple-radius-pill: 9999px;
  --apple-shadow-card: 0 10px 35px rgba(0, 0, 0, 0.06);
  --transition-smooth: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

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

html, body {
  min-height: 100%;
}

body {
  background-color: var(--apple-bg);
  color: var(--apple-text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input {
  font: inherit;
}

/* ========================================================
   TOPBAR APPLE STUDIO
   ======================================================== */
.navbar-apple-cert {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--apple-border);
  padding: 0.75rem 1.5rem;
}

.header-inner {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--apple-text);
  text-decoration: none;
  letter-spacing: -0.4px;
}

.brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--apple-blue);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--apple-blue);
}

.brand-separator {
  color: var(--apple-text-secondary);
  font-weight: 300;
}

.cert-course-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--apple-text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.verified-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid rgba(52, 199, 89, 0.35);
  border-radius: var(--apple-radius-pill);
  padding: 5px 12px;
  color: #15803d;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.verified-pill .status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--apple-green);
  box-shadow: 0 0 8px rgba(52, 199, 89, 0.7);
  display: inline-block;
}

.verified-pill.invalid {
  background: #fef2f2;
  border-color: rgba(255, 59, 48, 0.35);
  color: #b91c1c;
}

.verified-pill.invalid .status-indicator {
  background: var(--apple-red);
  box-shadow: 0 0 8px rgba(255, 59, 48, 0.7);
}

.btn-apple-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--apple-card);
  border: 1px solid var(--apple-border);
  color: var(--apple-text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.42rem 1rem;
  border-radius: var(--apple-radius-pill);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.btn-apple-back:hover {
  background: #e8e8ed;
  border-color: rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

/* ========================================================
   CERTIFICATE CONTAINER & CARD
   ======================================================== */
.certificate-page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 60px;
}

.certificate-card, .invalid-card {
  padding: clamp(24px, 4vw, 44px);
  border: 1px solid var(--apple-border);
  border-radius: var(--apple-radius-lg);
  background: var(--apple-card);
  box-shadow: var(--apple-shadow-card);
}

.certificate-intro {
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--apple-blue);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--apple-text);
}

.intro-text, .invalid-card p:not(.eyebrow) {
  margin: 10px auto 0;
  max-width: 620px;
  color: var(--apple-text-secondary);
  font-size: 1rem;
  line-height: 1.6;
}

/* ========================================================
   macOS WINDOW PREVIEW FRAME
   ======================================================== */
.certificate-preview-wrap {
  position: relative;
  max-width: 960px;
  margin: 32px auto 0;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--apple-radius-md);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
  background: #ffffff;
}

.mac-preview-bar {
  display: flex;
  align-items: center;
  background: #fbfbfd;
  padding: 10px 14px;
  border-bottom: 1px solid var(--apple-border);
  gap: 7px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }

.mac-preview-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--apple-text-secondary);
  margin-left: 6px;
}

.preview-screen {
  position: relative;
  overflow: hidden;
}

.certificate-preview {
  display: block;
  width: 100%;
  height: auto;
}

.preview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--apple-text);
  font-size: 0.95rem;
  font-weight: 500;
  transition: opacity 0.3s ease;
}

.preview-loading.ready {
  opacity: 0;
  pointer-events: none;
}

.spinner-dot {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 113, 227, 0.2);
  border-top-color: var(--apple-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================================
   4 DETAIL TILES
   ======================================================== */
.certificate-details {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 28px;
}

.detail-tile {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--apple-border);
  border-radius: var(--apple-radius-md);
  background: #fbfbfd;
  transition: var(--transition-smooth);
}

.detail-tile:hover {
  background: #ffffff;
  border-color: var(--apple-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.detail-label {
  display: block;
  margin-bottom: 6px;
  color: var(--apple-text-tertiary);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-tile strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--apple-text);
}

.detail-tile .folio {
  color: var(--apple-blue);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ========================================================
   ACTIONS
   ======================================================== */
.certificate-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.action-button, .copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: none;
  border-radius: var(--apple-radius-pill);
  padding: 11px 22px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition-smooth);
}

.action-button.primary {
  background: var(--apple-blue);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.25);
}

.action-button.primary:hover {
  background: var(--apple-blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 113, 227, 0.35);
}

.action-button.secondary {
  background: var(--apple-bg);
  border: 1px solid var(--apple-border);
  color: var(--apple-text);
}

.action-button.secondary:hover {
  background: #e8e8ed;
  border-color: rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.action-feedback {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--apple-green);
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ========================================================
   PUBLIC SHARE BOX
   ======================================================== */
.share-box {
  margin-top: 22px;
  padding: 18px 20px;
  border: 1px solid rgba(0, 113, 227, 0.2);
  border-radius: var(--apple-radius-md);
  background: #f0f7ff;
}

.share-box label {
  display: block;
  margin-bottom: 8px;
  color: var(--apple-blue);
  font-size: 0.85rem;
  font-weight: 700;
}

.url-row {
  display: flex;
  gap: 10px;
}

.url-row input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--apple-border);
  border-radius: var(--apple-radius-pill);
  padding: 10px 16px;
  background: #ffffff;
  color: var(--apple-text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
  transition: var(--transition-smooth);
}

.url-row input:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.copy-button {
  background: var(--apple-blue);
  color: #ffffff;
  padding: 9px 18px;
  font-size: 0.85rem;
}

.copy-button:hover {
  background: var(--apple-blue-hover);
}

.share-box p {
  margin: 8px 0 0;
  color: var(--apple-text-secondary);
  font-size: 0.82rem;
}

/* ========================================================
   INVALID CARD
   ======================================================== */
.invalid-card {
  text-align: center;
  border-color: rgba(255, 59, 48, 0.3);
  background: #fffafa;
}

.invalid-icon {
  font-size: 2.8rem;
  color: var(--apple-red);
  margin-bottom: 12px;
}

.footer-apple-cert {
  margin-top: 35px;
  color: var(--apple-text-secondary);
  font-size: 0.85rem;
  text-align: center;
}

#confetti {
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (max-width: 900px) {
  .certificate-details {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .certificate-details {
    grid-template-columns: 1fr;
  }
  .url-row {
    flex-direction: column;
  }
  .copy-button {
    width: 100%;
  }
}
