:root {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-light: #e2e8f0;
  --border-hover: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md:
    0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --font-sans: "Plus Jakarta Sans", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-body {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.back-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
.back-link:hover {
  color: var(--text-main);
}
.close-sidebar {
  display: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-muted);
}
.brand-section {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2rem;
}
.brand-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}
.badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.progress-section {
  margin-bottom: 2rem;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.progress-header strong {
  color: var(--text-main);
  font-weight: 600;
}
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-app);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.5s ease;
}

.lesson-nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}
.nav-phase-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin: 1rem 0 0.5rem;
}
.nav-lesson-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
}
.nav-lesson-item:hover:not(.locked) {
  background: var(--bg-app);
  color: var(--text-main);
}
.nav-lesson-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #bfdbfe;
  font-weight: 600;
}
.nav-lesson-item.locked {
  opacity: 0.6;
  cursor: not-allowed;
}
.nav-lesson-title {
  display: block;
}
.nav-lesson-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 2px;
}

.premium-upsell {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
}
.premium-upsell p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.btn-primary-outline {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--primary);
  color: var(--primary);
  background: transparent;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary-outline:hover {
  background: var(--primary-light);
}

/* Main Content */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.app-header {
  background: var(--bg-surface);
  padding: 1.5rem 2rem 0;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
}
.phase-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}
#lessonTitle {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stats-group {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.btn-vip-status {
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}
.btn-vip-status.unlocked {
  background: var(--success-light);
  color: var(--success);
  border-color: #a7f3d0;
}

.tabs-container {
  position: relative;
}
.segmented-control {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg-tab {
  background: none;
  border: none;
  padding: 0 0 12px 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.seg-tab:hover {
  color: var(--text-main);
}
.seg-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.lesson-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--border-light);
  z-index: -1;
}
.lesson-progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.4s ease;
}

.app-content {
  flex: 1;
  padding: 2.5rem 2rem;
  overflow-y: auto;
}
.content-wrapper {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Exercise Tips / Hints */
.exercise-tip {
  background: var(--primary-light);
  color: var(--primary-hover);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  border: 1px dashed #bfdbfe;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.exercise-tip::before {
  content: "💡";
  font-size: 1.1rem;
}

/* Clean Practice Cards */
.clean-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  box-shadow: var(--shadow-sm);
  text-align: center;
  margin-bottom: 1.5rem;
  transition: border-color 0.3s;
}
.clean-card.success {
  border-color: var(--success);
  background: var(--success-light);
}
.clean-card.error {
  border-color: var(--danger);
  background: var(--danger-light);
}

.exercise-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Exercícios Specific UI (Slots & Builder) */
.sentence-prompt {
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.7;
  margin-bottom: 2.5rem;
  text-align: left;
}
.sentence-prompt .slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  padding: 0 12px;
  height: 36px;
  margin: 0 6px;
  border-bottom: 2px solid var(--text-light);
  background: rgba(241, 245, 249, 0.5);
  color: var(--primary);
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  vertical-align: baseline;
}
.sentence-prompt .slot.filled {
  border-bottom-color: var(--primary);
  background: transparent;
}
.sentence-prompt .slot.correct {
  border-bottom-color: var(--success);
  color: var(--success);
  background: var(--success-light);
}
.sentence-prompt .slot.incorrect {
  border-bottom-color: var(--danger);
  color: var(--danger);
  background: var(--danger-light);
  animation: shake 0.3s ease;
}
.slot-cue {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 400;
  font-style: italic;
}

.interactive-tray {
  min-height: 60px;
  padding: 1rem;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
}
.tray-placeholder {
  color: var(--text-light);
  font-size: 0.9rem;
  width: 100%;
  text-align: center;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}
.clean-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}
.clean-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.clean-pill.used {
  opacity: 0.3;
  pointer-events: none;
  box-shadow: none;
}
.pill-he {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Flashcards Minimalist */
.flashcard-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto 2rem;
  perspective: 1000px;
}
.flashcard-inner {
  width: 100%;
  height: 280px;
  position: relative;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard-inner.flipped {
  transform: rotateY(180deg);
}
.fc-side {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.fc-back {
  transform: rotateY(180deg);
  background: var(--primary-light);
  border-color: #bfdbfe;
}
.btn-audio-icon {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--primary);
  opacity: 0.7;
  transition: 0.2s;
}
.btn-audio-icon:hover {
  opacity: 1;
}
.fc-main {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}
.fc-sub {
  font-size: 1.2rem;
  color: var(--text-muted);
}
.fc-trans {
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
  text-align: center;
  line-height: 1.2;
}
.fc-context {
  font-size: 0.9rem;
  color: var(--text-main);
  font-style: italic;
  text-align: center;
}

.actions-row {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}
.btn-secondary {
  flex: 1;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: 0.2s;
  text-align: center;
}
.btn-secondary:hover {
  background: var(--bg-app);
}
.btn-primary {
  flex: 2;
  padding: 14px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: 0.2s;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-primary:disabled {
  background: var(--border-hover);
  cursor: not-allowed;
}

/* Feedback System */
.feedback-panel {
  margin-top: 1rem;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  display: none;
}
.feedback-panel.show-success {
  display: block;
  background: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.feedback-panel.show-error {
  display: block;
  background: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Vocabulário (Vault Redesign - Grid + Blur) */
.vault-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  width: 100%;
}
.vault-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
}
.vault-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.vault-fase-section {
  margin-bottom: 2rem;
  width: 100%;
}
.fase-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 0.5rem;
  text-align: left;
}
.vault-cat-details {
  background: transparent;
  margin-bottom: 1.5rem;
  width: 100%;
}
.cat-title {
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-light);
}
.cat-title::-webkit-details-marker {
  display: none;
}
.cat-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-surface);
  padding: 2px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-light);
}

.vault-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding-top: 1rem;
}
.vault-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: 0.2s;
  position: relative;
}
.vault-item:hover:not(.locked) {
  border-color: var(--border-hover);
}
.vault-item.mastered {
  border-left: 4px solid var(--success);
  background: var(--success-light);
  border-color: #a7f3d0;
}

.vault-item.locked {
  cursor: pointer;
  background: var(--bg-app);
  border-style: dashed;
}
.vault-item.locked .vi-words,
.vault-item.locked .vi-right,
.vault-item.locked .vi-id {
  filter: blur(4px);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}
.vault-item.locked::after {
  content: "🔒 VIP";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.95);
  padding: 4px 12px;
  border-radius: 99px;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

.vi-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.vi-id {
  font-size: 0.8rem;
  color: var(--text-light);
  width: 30px;
}
.vi-words {
  display: flex;
  flex-direction: column;
  text-align: left;
}
.vi-ph {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}
.vi-pt {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.vi-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.vi-he {
  font-size: 1.05rem;
  color: var(--text-light);
}
.vi-check {
  color: var(--success);
  font-weight: bold;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-backdrop.open {
  display: flex;
}
.modal-card {
  background: var(--bg-surface);
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  position: relative;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--warning);
  background: #fef3c7;
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 1rem;
}
.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.modal-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.perks-list {
  text-align: left;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.perk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
}
.perk-icon {
  color: var(--success);
  font-weight: bold;
}
.full-width {
  width: 100%;
  display: block;
  text-decoration: none;
  margin-bottom: 2rem;
  padding: 14px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
}
.vip-activation {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
}
.vip-activation p {
  font-size: 0.85rem;
  margin-bottom: 10px;
  color: var(--text-muted);
}
.activation-row {
  display: flex;
  gap: 8px;
}
.activation-row input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  outline: none;
}
.feedback-msg {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* Responsive */
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    left: -100%;
    width: 280px;
    z-index: 1000;
    box-shadow: var(--shadow-md);
  }
  .app-sidebar.open {
    left: 0;
  }
  .close-sidebar,
  .mobile-toggle {
    display: block;
  }
  .app-header {
    padding: 1rem;
  }
  .app-content {
    padding: 1.5rem 1rem;
  }
  .header-content {
    align-items: center;
  }
  .stats-group {
    display: none;
  }
  .sentence-prompt {
    font-size: 1.1rem;
  }
  .fc-main {
    font-size: 2.2rem;
  }
  .vault-grid-inner {
    grid-template-columns: 1fr;
  }
}
/* =========================================
   Exercise Navigation Buttons (Fix)
   ========================================= */
.ex-nav-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 680px;
  gap: 16px;
  margin-top: 1.5rem;
}

.btn-skip {
  background: white;
  border: 2px solid var(--border-light);
  color: var(--text-muted);
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 54px; /* גובה אחיד עם כפתור הבדיקה */
  font-family: inherit;
  white-space: nowrap;
}

.btn-skip:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: var(--text-main);
  background: var(--bg-app);
}

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

.btn-main-check {
  flex: 1;
  height: 54px; /* גובה אחיד */
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

/* =========================================
   Difficulty Level Badges (Gamification)
   ========================================= */
.diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
}

.diff-easy {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.diff-medium {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fef08a;
}
.diff-hard {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.diff-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 10px;
}

.diff-bar {
  width: 4px;
  background: currentColor;
  border-radius: 2px;
  opacity: 0.25;
}

.diff-bar:nth-child(1) {
  height: 60%;
}
.diff-bar:nth-child(2) {
  height: 80%;
}
.diff-bar:nth-child(3) {
  height: 100%;
}

.diff-easy .diff-bar:nth-child(1) {
  opacity: 1;
}
.diff-medium .diff-bar:nth-child(1),
.diff-medium .diff-bar:nth-child(2) {
  opacity: 1;
}
.diff-hard .diff-bar {
  opacity: 1;
}
