body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f0f2f5;
  margin: 0; padding: 0;
  overflow-x: hidden;
}
.app {
  display: flex; flex-wrap: wrap; max-width: 1200px; margin: 0 auto; padding: 1.5rem; gap: 2rem;
}
.form-section, .preview-section {
  flex: 1 1 320px; background: #ffffff; border-radius: 8px; padding: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
h1, h2 { margin-top: 0; }
label { display: flex; flex-direction: column; font-size: 0.9rem; margin-bottom: 0.75rem; }
input, textarea {
  margin-top: 0.25rem; padding: 0.4rem 0.6rem; border: 1px solid #ccd0d5; border-radius: 4px; font-size: 0.9rem; min-height: 44px; box-sizing: border-box; width: 100%;
}
textarea { min-height: 60px; resize: vertical; }
input[type="color"] { width: 100%; height: 44px; padding: 2px; cursor: pointer; }

.storage-notice {
  background: #e8f4fd; border-left: 4px solid #0052cc; padding: 0.75rem 1rem; border-radius: 4px;
  font-size: 0.85rem; margin-bottom: 1.5rem; color: #172b4d; line-height: 1.4;
}

.buttons { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
button { padding: 0.5rem 0.9rem; border-radius: 4px; border: none; cursor: pointer; background: #0052cc; color: #fff; font-size: 0.9rem; min-height: 44px; }
button:hover { background: #003f99; }
button.btn-secondary { background: #6b778c; }
button.btn-large { padding: 0.75rem 1.5rem; font-size: 1.1rem; font-weight: 600; }
button.btn-primary { background: #0052cc; }

.unlock-note {
  font-size: 0.85rem;
  color: #555;
  margin-top: 0.75rem;
  width: 100%;
}
.unlock-note a {
  color: #0052cc;
  text-decoration: underline;
}

.card-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.card {
  border-radius: 12px; padding: 1.5rem; box-sizing: border-box; transition: all 0.3s ease;
}
.card.portrait {
  background: var(--card-bg, #1c2a3a);
  color: var(--card-text, #ffffff);
  width: 320px; min-height: 560px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.card.landscape {
  background: var(--card-bg, #1c2a3a);
  color: var(--card-text, #ffffff);
  width: 520px; min-height: 320px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: center;
}
.card.landscape .card-header, .card.landscape .card-main, .card.landscape .card-contact, .card.landscape .card-social, .card.landscape .card-tagline { text-align: center; }
.card.landscape .card-qr { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-direction: column; justify-content: center; align-items: center; margin-top: 0; }

.card-header { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 1rem; }
.logo { max-width: 100px; max-height: 60px; margin-bottom: 0.5rem; object-fit: contain; }
.company-logo-text { font-weight: 700; font-size: 1.4rem; letter-spacing: 0.5px; }

.card-main { text-align: center; }
.card-main .name { font-size: 1.3rem; font-weight: 600; }
.card-main .title { font-size: 0.95rem; margin-top: 0.25rem; opacity: 0.9; }

.card-contact { margin-top: 1rem; text-align: center; }
.contact-row { font-size: 0.9rem; margin-bottom: 0.4rem; word-break: break-word; }

.card-social { margin-top: 0.8rem; display: flex; justify-content: center; flex-wrap: wrap; gap: 0.4rem; }
.social-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  font-size: 0.7rem; font-weight: bold; background: var(--card-text, #ffffff); color: var(--card-bg, #1c2a3a); text-decoration: none;
}

.card-tagline { margin-top: 1rem; font-size: 0.85rem; opacity: 0.9; text-align: center; font-style: italic; }

.card-qr { margin-top: 1rem; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.qr-container { background: #ffffff; padding: 10px; border-radius: 8px; display: inline-block; }
#qrcode { display: flex; justify-content: center; align-items: center; }
#qrcode img, #qrcode canvas { max-width: 180px !important; max-height: 180px !important; display: block; }
.card.landscape #qrcode img, .card.landscape #qrcode canvas { max-width: 160px !important; max-height: 160px !important; }

#previewSocial:empty { display: none; }

/* WATERMARK */
.card-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-15deg);
  font-size: 3rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 100;
  letter-spacing: 8px;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
  text-shadow: 0 0 2px rgba(0,0,0,0.1);
}

.card-lock {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 101;
  pointer-events: none;
  opacity: 0.85;
}

.lock-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.lock-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  letter-spacing: 0.5px;
  line-height: 1.3;
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-content {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f0f0f0;
  border-top: 4px solid #0052cc;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Unlocked state adjustments */
body.unlocked .card-watermark,
body.unlocked .card-lock {
  display: none !important;
}

/* MOBILE RESPONSIVENESS */
@media (max-width: 768px) {
  .app { flex-direction: column; padding: 1rem; gap: 1rem; }
  .form-section, .preview-section { flex: 1 1 100%; padding: 1rem; }
  
  .card.portrait, .card.landscape {
    width: 100%; max-width: 340px; margin: 0 auto; padding: 1rem; min-height: auto;
  }
  .card.landscape { grid-template-columns: 1fr; }
  .card.landscape .card-qr { grid-column: 1; grid-row: auto; margin-top: 1rem; }
  
  .buttons { flex-direction: column; }
  .buttons button { width: 100%; margin-bottom: 0.5rem; }
  
  #qrcode img, #qrcode canvas { max-width: 150px !important; max-height: 150px !important; }
}
