/* ==========================================================================
   Mobile-First App Shell, Top Stats Bar, Bottom 5-Tab Navigation & Sheets
   ========================================================================== */

.app-shell {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg-canvas);
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (min-width: 500px) {
  .app-shell {
    border-left: 2px solid var(--border-default);
    border-right: 2px solid var(--border-default);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.06);
  }
}

/* Sticky Top Stats Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-canvas);
  border-bottom: 2px solid var(--border-default);
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  min-height: calc(var(--top-bar-height) + var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.top-stat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  transition: background-color 120ms ease, transform 80ms ease;
  min-height: 40px;
}

.top-stat-btn:active {
  background: var(--bg-subtle);
  transform: scale(0.95);
}

.top-stat-btn.course-btn {
  padding: 5px 8px;
  gap: 4px;
}

.flag-icon-wrap {
  width: 34px;
  height: 26px;
  border-radius: 7px;
  overflow: hidden;
  border: 2px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 0 var(--border-default);
}

.stat-value-streak { color: var(--duo-orange); }
.stat-value-streak.inactive { color: var(--text-muted); }
.stat-value-gems { color: var(--duo-blue); }
.stat-value-hearts { color: var(--duo-red); }

.double-xp-pill {
  font-size: 11px;
  font-weight: 900;
  background: var(--duo-purple);
  color: #fff;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 2px;
}

/* Main Scrollable Content Area */
.main-content {
  flex: 1;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 28px);
  position: relative;
}

/* Sticky Bottom 5-Tab Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  z-index: 50;
  background: var(--bg-canvas);
  border-top: 2px solid var(--border-default);
  padding: 6px 6px calc(var(--safe-bottom) + 8px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.nav-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 2px;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: background-color 140ms ease, border-color 140ms ease, transform 80ms ease;
  position: relative;
}

.nav-tab-btn:active {
  transform: scale(0.92);
}

.nav-tab-btn.active {
  background: var(--duo-blue-soft);
  border-color: var(--duo-blue-border);
}

.nav-tab-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-tab-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-secondary);
  line-height: 1.2;
  white-space: nowrap;
}

.nav-tab-btn.active .nav-tab-label {
  color: var(--duo-blue-dark);
}

.nav-badge-dot {
  position: absolute;
  top: 4px;
  right: 12px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--duo-red);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-canvas);
}

/* ==========================================================================
   Modals & Bottom Sheets (Authentic Mobile App Ergonomics)
   ========================================================================== */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  background: var(--scrim);
  animation: duo-fade-in 180ms ease;
}

.modal-root.top-sheet-mode {
  justify-content: flex-start;
}

.modal-root.center-mode {
  justify-content: center;
  padding: 16px;
}

.bottom-sheet {
  width: 100%;
  max-width: var(--app-max-width);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--bg-canvas);
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(var(--safe-bottom) + 22px);
  animation: duo-slide-up 240ms var(--ease-out);
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.2);
}

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 14px;
}

.top-sheet {
  width: 100%;
  max-width: var(--app-max-width);
  max-height: 84dvh;
  overflow-y: auto;
  background: var(--bg-canvas);
  border-radius: 0 0 24px 24px;
  padding: calc(var(--safe-top) + 14px) 18px 20px;
  border-bottom: 2px solid var(--border-default);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  animation: duo-pop 200ms var(--ease-out);
}

.center-dialog {
  width: 100%;
  max-width: 390px;
  background: var(--bg-canvas);
  border-radius: 22px;
  padding: 24px 20px;
  text-align: center;
  border: 2px solid var(--border-default);
  animation: duo-pop 240ms var(--ease-bounce);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-title {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-primary);
}

.sheet-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 22px;
  font-weight: 800;
}
.sheet-close-btn:active {
  background: var(--bg-subtle);
}

/* Course Switcher List */
.course-option-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.course-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 16px;
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: 0 3px 0 var(--border-default);
  text-align: left;
  transition: transform 80ms ease, border-color 120ms ease;
}

.course-option:active {
  transform: translateY(3px);
  box-shadow: none;
}

.course-option.active {
  border-color: var(--duo-blue);
  background: var(--duo-blue-soft);
  box-shadow: 0 3px 0 var(--duo-blue-border);
}

.course-option-info {
  flex: 1;
}

.course-option-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.course-option-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.course-option-xp {
  font-size: 13px;
  font-weight: 800;
  color: var(--duo-yellow-deep);
  background: var(--duo-yellow-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

/* Streak Calendar inside Sheet */
.streak-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-radius: 18px;
  background: var(--duo-orange-soft);
  margin-bottom: 16px;
}

.streak-big-num {
  font-size: 40px;
  font-weight: 900;
  color: var(--duo-orange);
  line-height: 1;
}

.streak-week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.streak-day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.streak-day-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
}

.streak-day-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 2px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: transparent;
}

.streak-day-dot.done {
  background: var(--duo-orange);
  border-color: var(--duo-orange-dark);
  color: #fff;
}

.streak-day-dot.today {
  border-color: var(--duo-orange);
  border-width: 3px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 66px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: calc(100% - 32px);
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: var(--bg-canvas);
  padding: 10px 18px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  animation: duo-pop 240ms var(--ease-bounce);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success {
  background: var(--duo-green);
  color: #fff;
}

.toast.gold {
  background: var(--duo-yellow);
  color: #5C3800;
}

/* FX Layer (Confetti) */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 220;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation: duo-confetti-fall var(--dur, 1.8s) linear forwards;
}
