:root {
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  --accent: #0284c7;
  --accent-light: #f0f9ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px -12px rgba(29, 78, 216, 0.16);
  --radius: 16px;
}

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

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 45%, #f0f9ff 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================================================
   GÓRNY PASEK NAWIGACJI (TOPBAR)
   ============================================================================ */
.topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(214, 51, 132, 0.3);
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Kroki kreatora */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.step-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: #f1f5f9;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.step-pill:hover {
  background: #e2e8f0;
}

.step-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
  box-shadow: 0 2px 8px rgba(214, 51, 132, 0.12);
}

.step-pill.completed {
  background: var(--success-light);
  color: #047857;
  border-color: #a7f3d0;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

.step-pill.active .step-num {
  background: var(--primary);
  color: #fff;
}

.step-pill.completed .step-num {
  background: var(--success);
  color: #fff;
}

/* Pasek kredytów i konta */
.account-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credits-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #fff1f2, #f5f3ff);
  border: 1px solid var(--primary-border);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #831843;
}

.credits-count {
  font-size: 14px;
  font-weight: 900;
  color: var(--primary);
}

/* ============================================================================
   PRZYCISKI
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
  color: #fff;
  box-shadow: 0 8px 20px -4px rgba(214, 51, 132, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -4px rgba(214, 51, 132, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 8px 20px -4px rgba(16, 185, 129, 0.35);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -4px rgba(16, 185, 129, 0.45);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 11px;
  border-radius: 9px;
}

.btn-lg {
  padding: 16px 28px;
  font-size: 16px;
  border-radius: 14px;
}

/* ============================================================================
   WIDOKI (VIEWS)
   ============================================================================ */
.view-section {
  display: none;
  flex: 1;
  width: 100%;
}

.view-section.active {
  display: block;
}

.container-narrow {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ============================================================================
   WIDOK 1: LOGOWANIE TOKENEM
   ============================================================================ */
.login-wrapper {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 44px 40px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--primary-border);
  text-align: center;
}

.login-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 10px;
  color: var(--text);
}

.login-card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 26px;
}

.token-input {
  width: 100%;
  padding: 16px 18px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border: 2px solid var(--border);
  border-radius: 14px;
  outline: none;
  transition: all 0.2s;
  margin-bottom: 16px;
  font-family: inherit;
}

.token-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(214, 51, 132, 0.12);
}

.login-features {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}

.login-feature-item {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.4;
}

.login-feature-item strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  font-weight: 800;
  margin-bottom: 2px;
}

/* ============================================================================
   WIDOK 2: WGRANIE ZDJĘCIA I USTAWIENIA (KROK 1)
   ============================================================================ */
.section-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-step-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* Strefa wgrywania zdjęcia głównego */
.photo-upload-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: center;
}

.photo-preview-box {
  width: 240px;
  min-height: 240px;
  max-height: 320px;
  border-radius: 20px;
  border: 2px dashed var(--primary-border);
  background: #fdf2f8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  text-align: center;
  padding: 10px;
}

.photo-preview-box img {
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  display: block;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.photo-tips {
  background: #f8fafc;
  border-radius: 14px;
  padding: 18px 20px;
  border: 1px solid var(--border);
}

.photo-tips h4 {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text);
}

.photo-tips ul {
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 16px;
}

/* Siatka zdjęć dla poszczególnych miesięcy */
.month-photos-toggle {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.month-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.month-photo-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11px;
}

.month-photo-card.has-custom {
  border-color: var(--primary);
  background: var(--primary-light);
}

.month-photo-card-title {
  font-weight: 800;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.month-photo-thumb {
  width: 100%;
  height: 90px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-top: 2px;
}

.month-photo-thumb img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Karty wyboru opcji (Sylwetka, Włosy, Okulary) */
.options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.option-group {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.option-group label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
}

.option-group p {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.select-input,
.text-input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  outline: none;
}

.select-input:focus,
.text-input:focus {
  border-color: var(--primary);
}

/* Własne święta */
.custom-dates-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.custom-date-month-select {
  width: 170px;
}

.custom-date-day-select {
  width: 95px;
}

.custom-date-label-input {
  flex: 1;
  min-width: 200px;
}

.custom-dates-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: #831843;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.date-chip button {
  background: none;
  border: none;
  color: #be185d;
  font-weight: 900;
  cursor: pointer;
  font-size: 13px;
}

/* ============================================================================
   WIDOK 3: POSTĘP GENEROWANIA WSZYSTKICH STRON
   ============================================================================ */
.progress-bar-outer {
  width: 100%;
  height: 18px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 18px 0 10px;
}

.progress-bar-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent), #10b981);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.batch-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.batch-card-item {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  transition: all 0.25s;
}

.batch-card-item.generating {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(214, 51, 132, 0.15);
}

.batch-card-item.ready {
  border-color: var(--success);
  background: #f0fdf4;
}

.batch-card-item.failed {
  border-color: var(--danger);
  background: #fef2f2;
}

.batch-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.batch-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================================
   WIDOK 4: PODGLĄD TALII 13 KART, POPRAWKI I POBRANIE PDF A4
   ============================================================================ */
.deck-workspace {
  display: grid;
  grid-template-columns: 270px 1fr 340px;
  gap: 20px;
  padding: 20px 24px 40px;
  max-width: 1680px;
  margin: 0 auto;
  align-items: start;
}

.deck-sidebar {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 105px);
  overflow-y: auto;
  position: sticky;
  top: 82px;
}

.deck-sidebar h3 {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.deck-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.deck-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
}

.deck-item:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.deck-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.deck-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.deck-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.deck-item-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-status-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.status-ready {
  background: #dcfce7;
  color: #15803d;
}

.status-generating {
  background: #fce7f3;
  color: #be185d;
}

.status-empty {
  background: #f1f5f9;
  color: #64748b;
}

.status-failed {
  background: #fee2e2;
  color: #b91c1c;
}

/* Środkowa kolumna: Podgląd arkusza A4 */
.canvas-stage {
  background: #e2e8f0;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 760px;
  position: relative;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 640px;
  margin-bottom: 14px;
  background: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.a4-paper-wrapper {
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  border-radius: 4px;
  overflow: hidden;
  max-width: 640px;
  width: 100%;
  aspect-ratio: 2480 / 3508;
  position: relative;
}

#calendarCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

#calendarCanvas:active {
  cursor: grabbing;
}

/* Prawa kolumna: Akcje dla strony oraz pobieranie PDF A4 */
.deck-actions-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 82px;
}

.action-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.action-box h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
}

.action-box p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.pdf-box {
  background: linear-gradient(155deg, #ffffff 0%, #fdf2f8 100%);
  border: 2px solid var(--primary-border);
  box-shadow: var(--shadow-lg);
}

/* ============================================================================
   MODAL NAKŁADKI (EKSPORT PDF / ALERT)
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
}

.toast-banner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  z-index: 1200;
  display: none;
  max-width: 420px;
}

.toast-banner.show {
  display: block;
}

/* ============================================================================
   WYBÓR JĘZYKA (7 JĘZYKÓW - PILLS & KAFELKI)
   ============================================================================ */
.lang-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lang-bar-login {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
}

.lang-pill:hover {
  border-color: var(--primary-border);
  color: var(--text);
  background: #fdf2f8;
}

.lang-pill.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(214, 51, 132, 0.16);
}

.lang-tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
  gap: 10px;
}

.lang-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
  font-family: inherit;
}

.lang-tile:hover {
  border-color: var(--primary-border);
  background: #fff;
  transform: translateY(-1px);
}

.lang-tile.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 6px 16px rgba(214, 51, 132, 0.15);
}

.lang-tile-flag {
  font-size: 24px;
  line-height: 1;
}

.lang-tile-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.lang-tile.active .lang-tile-name {
  color: var(--primary);
}

.lang-tile-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.25;
}


/* ============================================================================
   KONTO DEMO I ZAPOBIEGANIE NADUŻYCIOM (TRYB DEMO)
   ============================================================================ */
.demo-login-box {
  margin-top: 14px;
  width: 100%;
}

.demo-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0 14px;
}

.demo-divider::before,
.demo-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.demo-divider span {
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* Wyróżniona ramka dla przycisku Demo */
.demo-card-highlight {
  background: linear-gradient(145deg, #fdf2f8 0%, #f5f3ff 60%, #fff 100%);
  border: 2px dashed #f472b6;
  border-radius: 18px;
  padding: 16px 14px 14px;
  box-shadow: 0 8px 24px -6px rgba(219, 39, 119, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  transition: all 0.25s ease;
}

.demo-card-highlight:hover {
  border-color: #db2777;
  box-shadow: 0 12px 30px -4px rgba(219, 39, 119, 0.25);
  transform: translateY(-1px);
}

.demo-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: #db2777;
  border: 1px solid #fbcfe8;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(219, 39, 119, 0.1);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 1.8s infinite;
}

@keyframes pulseGreen {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.btn-demo-prominent {
  width: 100%;
  padding: 16px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, #9333ea 0%, #db2777 55%, #f43f5e 100%);
  border: none;
  color: #ffffff;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 8px 24px -2px rgba(219, 39, 119, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
}

.btn-demo-prominent:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -2px rgba(219, 39, 119, 0.65);
  filter: brightness(1.06);
}

.btn-demo-prominent:active {
  transform: translateY(0);
}

.demo-btn-icon {
  font-size: 18px;
}

.demo-btn-text {
  flex: 1;
  text-align: center;
  letter-spacing: -0.2px;
}

.demo-btn-arrow {
  font-size: 18px;
  transition: transform 0.2s ease;
}

.btn-demo-prominent:hover .demo-btn-arrow {
  transform: translateX(4px);
}

.demo-sub-tag {
  font-size: 11px;
  font-weight: 700;
  color: #831843;
  text-align: center;
  margin: 0;
  line-height: 1.35;
}

.demo-alert {
  background: linear-gradient(135deg, #fdf4ff 0%, #f5f3ff 100%);
  border: 1.5px solid #d8b4fe;
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.08);
}

.demo-alert-icon {
  font-size: 26px;
  line-height: 1;
}

.demo-alert strong {
  display: block;
  font-size: 14px;
  color: #6b21a8;
  font-weight: 800;
  margin-bottom: 3px;
}

.demo-alert p {
  font-size: 12px;
  color: #4c1d95;
  margin: 0;
  line-height: 1.45;
}

.demo-upsell-box {
  background: linear-gradient(135deg, #831843 0%, #701a75 50%, #4c1d95 100%);
  border: none;
  box-shadow: 0 10px 25px rgba(131, 24, 67, 0.3);
  color: #fff;
}

/* ============================================================================
   ANIMOWANA KLEPSYDRA, ODLICZANIE CZASU I ETAPY MALOWANIA ILUSTRACJI
   ============================================================================ */

/* Obracająca się / przewracająca klepsydra */
.hourglass-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%);
  border: 2px solid #fbcfe8;
  box-shadow: 0 4px 14px rgba(219, 39, 119, 0.15);
  flex-shrink: 0;
}

.hourglass-large {
  width: 72px;
  height: 72px;
  border-width: 3px;
  box-shadow: 0 8px 24px rgba(219, 39, 119, 0.25);
  margin-bottom: 12px;
}

.hourglass-spinner {
  display: inline-block;
  font-size: 24px;
  line-height: 1;
  animation: hourglassFlip 2.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
  transform-origin: center center;
}

.hourglass-large .hourglass-spinner {
  font-size: 38px;
}

@keyframes hourglassFlip {
  0% {
    transform: rotate(0deg) scale(1);
  }
  40% {
    transform: rotate(180deg) scale(1.15);
  }
  50% {
    transform: rotate(180deg) scale(1);
  }
  90% {
    transform: rotate(360deg) scale(1.15);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

/* Pigułka odliczania czasu w dół */
.countdown-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  color: #38bdf8;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  white-space: nowrap;
}

/* Pasek pojedynczej karty i etapy */
.active-generation-banner {
  background: linear-gradient(135deg, #ffffff 0%, #fdf2f8 50%, #faf5ff 100%);
  border: 2px solid #f472b6;
  border-radius: 16px;
  padding: 16px 20px;
  margin: 18px 0;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  box-shadow: 0 8px 25px rgba(219, 39, 119, 0.12);
  animation: bannerFadeIn 0.3s ease;
}

@keyframes bannerFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.active-gen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.active-gen-label {
  font-size: 14px;
  font-weight: 900;
  color: #831843;
}

.active-gen-stage {
  font-size: 12px;
  font-weight: 600;
  color: #9d174d;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.active-gen-stage::before {
  content: '⚡';
  font-size: 11px;
}

.single-card-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(219, 39, 119, 0.12);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.single-card-progress-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ec4899, #8b5cf6, #3b82f6);
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width 0.9s ease-out;
  animation: progressGradientShine 2s linear infinite;
}

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

/* Nakładka szklana na podgląd arkusza w widoku talii (widok 3) */
.canvas-generating-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: bannerFadeIn 0.25s ease;
}

.overlay-modal-box {
  background: #ffffff;
  border: 2px solid #fbcfe8;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(219, 39, 119, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.overlay-headline {
  font-size: 17px;
  font-weight: 900;
  color: #831843;
  margin: 0 0 4px;
}

.overlay-subline {
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  margin: 0 0 14px;
}

/* Podsumowanie wybranego okresu kalendarza */
.period-summary-pill {
  margin-top: 16px;
  background: linear-gradient(135deg, #fdf2f8 0%, #f5f3ff 100%);
  border: 1.5px solid #f472b6;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 700;
  color: #831843;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(219, 39, 119, 0.08);
}

/* ============================================================================
   KOMPLEKSOWA RESPONSYWNOŚĆ I UX DLA TELEFONÓW I EKRANÓW DOTYKOWYCH
   ============================================================================ */

/* TABLETY I MNIEJSZE EKRANY (<= 1024px) */
@media (max-width: 1024px) {
  .deck-workspace {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 12px 48px;
  }
  
  /* Kolejność na ekranach dotykowych:
     1. Podgląd arkusza A4 i nawigacja
     2. Główne akcje (Pobranie PDF A4, Poprawka, Kadrowanie)
     3. Lista pozostałych kart talii */
  .canvas-stage {
    order: 1;
    min-height: auto;
    padding: 14px 10px;
    border-radius: 18px;
  }
  
  .canvas-toolbar {
    max-width: 100%;
    margin-bottom: 12px;
  }
  
  .a4-paper-wrapper {
    max-width: 580px;
    margin: 0 auto;
  }
  
  .deck-actions-panel {
    order: 2;
    position: static;
    max-height: none;
    gap: 14px;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
  }
  
  .deck-sidebar {
    order: 3;
    position: static;
    max-height: none;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
    border-radius: 18px;
  }
  
  .deck-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }
}

/* SMARTFONY I WĄSKIE EKRANY (<= 768px) */
@media (max-width: 768px) {
  /* GÓRNY PASEK NAWIGACJI (TOPBAR) */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 14px;
    gap: 10px;
  }

  .brand {
    justify-content: flex-start;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-sub {
    font-size: 10px;
  }

  /* Przewijalny horyzontalnie pasek kroków kreatora na telefonach */
  .wizard-steps {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding: 2px 0 4px;
    width: 100%;
  }

  .wizard-steps::-webkit-scrollbar {
    display: none;
  }

  .step-pill {
    padding: 7px 12px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .account-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .credits-badge {
    padding: 6px 12px;
    font-size: 11.5px;
  }

  /* WIDOK LOGOWANIA */
  .login-wrapper {
    padding: 20px 14px;
    min-height: calc(100vh - 120px);
  }

  .login-card {
    padding: 28px 18px;
    border-radius: 20px;
  }

  .login-card h1 {
    font-size: 21px;
  }

  .login-card p {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 20px;
  }

  .token-input {
    font-size: 16px; /* Zapobiega auto-zoomowi w iOS Safari */
    padding: 13px 14px;
    letter-spacing: 1px;
  }

  .btn-demo-prominent {
    padding: 14px 14px;
    font-size: 13.5px;
  }

  .login-features {
    gap: 8px;
    margin-top: 22px;
    padding-top: 18px;
  }

  .login-feature-item {
    font-size: 10.5px;
  }

  .login-feature-item strong {
    font-size: 13px;
  }

  /* WIDOK USTAWIEŃ (SETUP) */
  .container-narrow {
    padding: 16px 12px 48px;
  }

  .section-card {
    padding: 18px 14px;
    border-radius: 16px;
    margin-bottom: 16px;
  }

  .section-title {
    font-size: 17px;
  }

  .section-desc {
    font-size: 12px;
    line-height: 1.5;
  }

  .photo-upload-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .photo-preview-box {
    width: 100%;
    max-width: 250px;
    min-height: 200px;
    margin: 0 auto;
  }

  .photo-tips {
    padding: 14px 14px;
  }

  .photo-tips .btn {
    width: 100%;
  }

  .options-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  /* Dotykowe kontrolki o wysokości min 44px i czcionce 16px (brak auto-zooma w iOS) */
  .select-input,
  .text-input {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 12px;
  }

  /* Elastyczny pasek dodawania świąt na telefonie */
  .custom-dates-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .custom-date-month-select {
    flex: 2 1 140px;
    width: auto;
  }

  .custom-date-day-select {
    flex: 1 1 70px;
    width: auto;
  }

  .custom-date-label-input {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  .custom-dates-bar .btn {
    width: 100%;
  }

  /* Kafelki miesięcy (opcjonalne zdjęcia) w 2 czytelnych kolumnach */
  .month-photos-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .month-photo-card {
    padding: 8px;
  }

  .month-photo-thumb {
    height: 75px;
  }

  .period-summary-pill {
    font-size: 12px;
    padding: 10px 12px;
    line-height: 1.45;
  }

  /* Przyciski główne akcji na całą szerokość ekranu */
  #btnGenerateAllMain,
  #btnGenerateDemoMonth,
  #btnGenerateMissing,
  #btnGoToDeckDirect {
    width: 100% !important;
  }

  /* WIDOK GENEROWANIA (GENERATING) */
  .batch-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 16px;
  }

  .batch-card-item {
    padding: 10px 8px;
    border-radius: 12px;
  }

  .batch-thumb {
    height: 125px;
  }

  .active-generation-banner {
    padding: 12px 14px;
    gap: 12px;
  }

  .hourglass-wrapper {
    width: 42px;
    height: 42px;
  }

  .hourglass-spinner {
    font-size: 20px;
  }

  /* WIDOK TALII (DECK) */
  .canvas-stage {
    padding: 10px 6px;
  }

  .canvas-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .canvas-toolbar > div:first-child {
    flex: 1 1 160px;
  }

  .canvas-toolbar > div:last-child {
    display: flex;
    gap: 6px;
  }

  .canvas-toolbar .btn-sm {
    padding: 8px 12px;
    font-size: 11.5px;
  }

  .action-box {
    padding: 18px 16px;
    border-radius: 16px;
  }

  .action-box h3 {
    font-size: 14px;
  }

  /* PRZYCISKI - MINIMUM 44PX DLA WYGODY DOTYKU */
  .btn {
    min-height: 44px;
    font-size: 13.5px;
  }

  .btn-sm {
    min-height: 38px;
    font-size: 12px;
  }

  .btn-lg {
    min-height: 48px;
    font-size: 14.5px;
    padding: 14px 20px;
  }

  /* POWIADOMIENIE TOAST I MODALE */
  .toast-banner {
    left: 14px;
    right: 14px;
    bottom: 14px;
    text-align: center;
    font-size: 12px;
    padding: 11px 16px;
  }

  .modal-card {
    padding: 24px 18px;
    border-radius: 18px;
  }
}

/* BARDZO MAŁE SMARTFONY (<= 480px, np. iPhone SE, mniejsze ekrany Android) */
@media (max-width: 480px) {
  .topbar {
    padding: 8px 12px;
  }

  .credits-badge [data-i18n="creditsLabel"] {
    display: none;
  }

  .active-generation-banner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .active-gen-header {
    justify-content: center;
    flex-direction: column;
    gap: 6px;
  }

  .active-gen-stage {
    justify-content: center;
  }

  .overlay-modal-box {
    padding: 20px 14px;
    width: 95%;
  }

  .overlay-headline {
    font-size: 15px;
  }

  .overlay-subline {
    font-size: 12px;
  }

  .hourglass-large {
    width: 56px;
    height: 56px;
    margin-bottom: 8px;
  }

  .hourglass-large .hourglass-spinner {
    font-size: 28px;
  }

  .deck-list {
    grid-template-columns: 1fr;
  }

  .lang-tiles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
