:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #273549;
  --bg-modal: #1e293b;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.16);

  --green-bg: rgba(34, 197, 94, 0.22);
  --green-border: #22c55e;
  --green-text: #86efac;

  --yellow-bg: rgba(234, 179, 8, 0.24);
  --yellow-border: #eab308;
  --yellow-text: #fde047;

  --red-bg: rgba(239, 68, 68, 0.22);
  --red-border: #ef4444;
  --red-text: #fca5a5;

  --radius: 16px;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* --- EKRAN LOGOWANIA HASŁEM --- */
.lock-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 3000;
}

.lock-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 34px 26px;
  width: 100%;
  max-width: 390px;
  text-align: center;
  box-shadow: var(--shadow);
}

.lock-icon {
  font-size: 2.8rem;
  margin-bottom: 10px;
}

.lock-box h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.lock-box p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 20px;
}

.lock-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lock-input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: 0.14em;
  outline: none;
  transition: border-color 0.15s;
}

.lock-input:focus {
  border-color: var(--primary);
}

.lock-error {
  display: none;
  color: #fca5a5 !important;
  font-weight: 600;
  margin-top: 12px !important;
  margin-bottom: 0 !important;
}

.lock-error.visible {
  display: block;
}

/* --- GŁÓWNY KONTENER --- */
.container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  flex: 1;
}

header.app-header {
  text-align: center;
  margin-bottom: 32px;
  padding-top: 8px;
}

header.app-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

header.app-header p {
  color: var(--text-muted);
  font-size: 0.98rem;
}

.view {
  display: none;
}
.view.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

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

/* Siatka quizów */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.quiz-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.quiz-card:hover,
.quiz-card:focus-visible {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  outline: none;
}

.quiz-card-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text);
}

.quiz-card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.quiz-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* POPUP startowy */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  position: relative;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 440px;
  padding: 32px 24px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}

.modal-close-x {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.modal-close-x:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border-color: #ef4444;
}

.modal-preview-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.modal-preview-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  transform: scale(1.05);
}

.modal-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-question {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.modal-quiz-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
  word-break: break-word;
}

.modal-info {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Przyciski + animacja paska ładowania 2.5s */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.1s ease, opacity 0.16s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.99);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.is-loading:disabled {
  opacity: 0.95;
}

.btn.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.28);
  transform: scaleX(0);
  transform-origin: left;
  animation: btnProgress 2.5s linear forwards;
  pointer-events: none;
}

@keyframes btnProgress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
}

/* Widok quizu */
.quiz-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.btn-exit {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-exit:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-exit-accent {
  border-color: var(--primary);
  color: var(--primary);
}

.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.badge-phase-review {
  background: rgba(234, 179, 8, 0.16);
  border-color: #eab308;
  color: #fde047;
}

.badge-errors {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 22px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(18px, 4vw, 28px);
  box-shadow: var(--shadow);
}

.retry-banner {
  display: none;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.retry-banner.visible {
  display: block;
}

.question-text {
  font-size: clamp(1.1rem, 2.8vw, 1.32rem);
  font-weight: 700;
  margin-bottom: 18px;
  white-space: pre-line;
}

.question-image-wrap {
  margin-bottom: 20px;
  text-align: center;
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.question-image-wrap img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  object-fit: contain;
  cursor: zoom-in;
  display: block;
  margin: 0 auto;
}

.image-zoom-hint {
  display: block;
  font-size: 0.78rem;
  color: #475569;
  font-weight: 600;
  margin-top: 8px;
}

.answers-hint {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.answers-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.answer-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: rgba(15, 23, 42, 0.55);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.answer-option:hover:not(:disabled) {
  border-color: #64748b;
  background: rgba(30, 41, 59, 0.95);
}

.answer-option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.answer-checkbox {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 800;
  margin-top: 1px;
  transition: all 0.14s ease;
}

.answer-option.selected .answer-checkbox {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.answer-content {
  flex: 1;
  word-break: break-word;
}

.answer-status-tag {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  display: none;
}

.answer-option.feedback-green {
  background: var(--green-bg) !important;
  border-color: var(--green-border) !important;
  color: var(--green-text) !important;
}
.answer-option.feedback-green .answer-checkbox {
  background: var(--green-border);
  border-color: var(--green-border);
  color: #052e16;
}
.answer-option.feedback-green .answer-status-tag {
  display: inline-block;
  background: rgba(34, 197, 94, 0.25);
  color: var(--green-text);
}

.answer-option.feedback-yellow {
  background: var(--yellow-bg) !important;
  border-color: var(--yellow-border) !important;
  color: var(--yellow-text) !important;
}
.answer-option.feedback-yellow .answer-checkbox {
  background: var(--yellow-border);
  border-color: var(--yellow-border);
  color: #422006;
}
.answer-option.feedback-yellow .answer-status-tag {
  display: inline-block;
  background: rgba(234, 179, 8, 0.28);
  color: var(--yellow-text);
}

.answer-option.feedback-red {
  background: var(--red-bg) !important;
  border-color: var(--red-border) !important;
  color: var(--red-text) !important;
}
.answer-option.feedback-red .answer-checkbox {
  background: var(--red-border);
  border-color: var(--red-border);
  color: #450a0a;
}
.answer-option.feedback-red .answer-status-tag {
  display: inline-block;
  background: rgba(239, 68, 68, 0.28);
  color: var(--red-text);
}

/* Ekran końcowy */
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 34px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 540px;
  margin: 16px auto;
}

.summary-icon {
  font-size: 3.4rem;
  margin-bottom: 12px;
}

.summary-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.summary-subtitle {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 26px;
}

.stat-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 12px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-value.errors-zero {
  color: #22c55e;
}

.stat-value.errors-some {
  color: #f87171;
}

.stat-label {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Podgląd pytań */
.preview-header-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.preview-header-box h2 {
  font-size: 1.35rem;
  margin-bottom: 4px;
}

.preview-header-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.preview-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.preview-q-text {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 14px;
  white-space: pre-line;
}

.preview-img-wrap {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
  text-align: center;
}

.preview-img-wrap img {
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
  cursor: zoom-in;
}

.preview-answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-answer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.5);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.preview-answer.is-correct {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green-text);
  font-weight: 600;
}

/* Lightbox powiększenia */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  background: #f8fafc;
  padding: 14px;
  border-radius: 12px;
  object-fit: contain;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}
