/* css/components/auth.css */
/* ──────────────────────────────────────────────────────────────────────────
   Authentication modal, user widget (header), profile panel, sync status
   ────────────────────────────────────────────────────────────────────────── */

/* ── Auth modal overlay ────────────────────────────────────────────────── */
#auth-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, rgba(30,31,66,0.85) 0%, rgba(30,157,142,0.85) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#auth-modal-overlay.visible {
  opacity: 1;
}
#auth-modal-overlay.hiding {
  opacity: 0;
}

/* ── Auth modal card ────────────────────────────────────────────────────── */
.auth-modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  margin: 16px;
  box-shadow: 0 10px 40px rgba(45, 46, 95, 0.15);
  text-align: center;
  animation: authCardIn 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes authCardIn {
  from { transform: translateY(32px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.auth-brand-icon {
  width: auto;
  height: 64px;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 1.8rem;
  color: #fff;
  overflow: hidden;
}

.auth-brand-icon img {
  width: auto;
  height: 64px;
  display: block;
}

.auth-modal-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 8px;
}

.auth-modal-card p {
  color: var(--text-light);
  font-size: 0.95rem;
  margin: 0 0 32px;
}

/* ── Google sign-in button ─────────────────────────────────────────────── */
.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.auth-google-btn:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(30,58,138,0.15);
  transform: translateY(-1px);
}
.auth-google-btn:active:not(:disabled) {
  transform: translateY(0);
}
.auth-google-btn:disabled {
  cursor: not-allowed;
}

.auth-google-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Auth loader ─────────────────────────────────────────────────────────── */
#auth-loader {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--text-light);
  font-size: 0.875rem;
}
#auth-loader i {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Auth error ──────────────────────────────────────────────────────────── */
#auth-error-msg {
  display: none;
  margin-top: 14px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  color: #b91c1c;
  font-size: 0.85rem;
}

/* ── Auth modal footer ────────────────────────────────────────────────────── */
.auth-modal-footer {
  margin-top: 24px;
  color: var(--text-light);
  font-size: 0.78rem;
  line-height: 1.5;
}
.auth-modal-footer a {
  color: var(--primary);
  text-decoration: none;
}
.auth-modal-footer a:hover {
  text-decoration: underline;
}

/* ── Auth divider ────────────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-light);
  font-size: 0.82rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

/* ── Guest sign-in button ────────────────────────────────────────────────── */
.auth-guest-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  background: transparent;
  border: 2px dashed #cbd5e1;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-medium);
  cursor: pointer;
  transition: all 0.2s ease;
}
.auth-guest-btn:hover {
  border-color: var(--secondary);
  color: var(--secondary);
  background: rgba(30, 157, 142, 0.04);
}
.auth-guest-btn i {
  font-size: 1rem;
}

/* ── Guest note ──────────────────────────────────────────────────────────── */
.auth-guest-note {
  margin-top: 10px;
  color: var(--text-light);
  font-size: 0.78rem;
  line-height: 1.4;
}

/* ── Header user widget ─────────────────────────────────────────────────── */
.user-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 12px 6px 6px;
  border-radius: 50px;
  background: rgba(45, 46, 95, 0.04);
  border: 1px solid rgba(45, 46, 95, 0.08);
  transition: background 0.2s;
  color: var(--text-dark);
  font-size: 0.875rem;
  font-weight: 500;
  user-select: none;
}
.user-widget:hover {
  background: rgba(45, 46, 95, 0.08);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.user-avatar-initials {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.user-name {
  max-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── User profile panel ──────────────────────────────────────────────────── */
.user-profile-panel {
  display: none;
  position: fixed;
  top: 72px;
  right: 20px;
  width: 300px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(45, 46, 95, 0.1);
  border: 1px solid var(--border-light);
  flex-direction: column;
  overflow: hidden;
  z-index: 8888;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.user-profile-panel.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.profile-panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff;
}

.profile-avatar-large {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.4);
}
.profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-initials-large {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.profile-info {
  min-width: 0;
}
.profile-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-email {
  font-size: 0.78rem;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Preferences ─────────────────────────────────────────────────────────── */
.profile-prefs {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pref-row label {
  font-size: 0.85rem;
  color: var(--text-medium);
  font-weight: 500;
  min-width: 70px;
  display: inline-flex;
  align-items: center;
  line-height: 1.25;
}
.pref-row select {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  color: var(--text-dark);
  background: #f8fafc;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.pref-row select:focus {
  border-color: var(--primary);
}

/* ── Profile sync status ─────────────────────────────────────────────────── */
.profile-sync-status {
  min-height: 20px;
  padding: 0 20px;
  font-size: 0.78rem;
  color: var(--text-light);
  transition: color 0.2s;
}
.profile-sync-status.syncing { color: var(--primary); }
.profile-sync-status.saved   { color: var(--completed); }
.profile-sync-status.error   { color: var(--incorrect); }

/* ── Sign out button ─────────────────────────────────────────────────────── */
.profile-signout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 20px 20px;
  padding: 10px 20px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 50px;
  color: #b91c1c;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.profile-signout-btn i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 0.95rem;
}
.profile-signout-btn:hover {
  background: #fee2e2;
  transform: translateY(-1px);
}

/* ── Global sync-status indicator ──────────────────────────────────────────── */
.sync-status {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 50px;
  font-weight: 500;
  vertical-align: middle;
}
.sync-status.syncing {
  background: #eff6ff;
  color: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}
.sync-status.synced {
  background: #f0fdf4;
  color: var(--completed);
}
.sync-status.error {
  background: #fef2f2;
  color: var(--incorrect);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}



/* ── Header sign-in button (guest / unauthenticated) ─────────────────── */
.header-signin-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}
.header-signin-btn:hover {
  background: var(--secondary);
  transform: translateY(-1px);
}
.header-signin-btn i {
  font-size: 0.8rem;
}

@media (max-width: 420px) {
  .header-signin-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    justify-content: center;
    padding: 0;
    gap: 0;
  }

  .header-signin-btn span {
    display: none;
  }

  .user-widget {
    padding: 4px;
    gap: 0;
  }

  .user-name {
    display: none;
  }
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .user-profile-panel {
    display: none !important;
  }
}

/* ── Full profile section (rendered in main-content) ─────────────────── */
.profile-section {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px 28px;
}

/* Apple-style full profile (Settings-like): calm gray canvas, grouped cards */
.profile-section--apple {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  letter-spacing: -0.01em;
  max-width: 680px;
  padding: 12px 16px 36px;
}
.profile-section--apple .profile-section-card {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  border: 1px solid rgba(60, 60, 67, 0.12);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 20px 20px 22px;
  margin-bottom: 12px;
}
.profile-section--apple .profile-section-card h3 {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-medium);
  margin-bottom: 14px;
  gap: 8px;
}
.profile-section--apple .profile-section-card h3 .material-symbols-outlined {
  font-size: 1.15rem;
  width: 1.2rem;
  height: 1.2rem;
  opacity: 0.85;
}
.profile-section--apple .profile-name {
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.profile-section--apple .profile-email {
  font-size: 0.9rem;
}
.profile-section--apple .profile-section-sub-badge {
  border-radius: 8px;
  font-weight: 500;
}
.profile-section--apple .pref-row {
  padding: 12px 0;
  border-top: 1px solid rgba(60, 60, 67, 0.08);
  margin: 0 -4px;
  padding-left: 4px;
  padding-right: 4px;
}
.profile-section--apple .profile-section-card .pref-row:first-of-type {
  border-top: none;
  padding-top: 0;
}
.profile-section--apple .pref-row select {
  border-radius: 10px;
  border: 1px solid rgba(60, 60, 67, 0.18);
  padding: 10px 12px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.9);
}
.profile-section--apple .profile-signout-btn {
  border-radius: 12px;
  font-weight: 500;
}

.profile-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.profile-section-header--apple h2 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--text-dark);
}
.profile-section-header .btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
}
.profile-section-header .btn-back i {
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.profile-section-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 16px rgba(45,46,95,0.07);
  border: 1px solid rgba(45, 46, 95, 0.06);
  padding: 28px;
  margin-bottom: 20px;
}
.profile-section-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 16px;
  line-height: 1.3;
}
.profile-section-card h3 .material-symbols-outlined {
  font-size: 1.35rem;
  line-height: 1;
  width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-section-avatar-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}
.profile-section-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-section-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-section-avatar .profile-initials-large {
  font-size: 1.4rem;
}
.profile-section-info .profile-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
}
.profile-section-info .profile-email {
  font-size: 0.85rem;
  color: var(--text-medium);
  opacity: 1;
}
.profile-section-sub-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 6px;
  line-height: 1.2;
}
.profile-section-sub-badge i {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  font-size: 0.85rem;
}
.profile-section-sub-badge.free {
  background: #e2e8f0;
  color: var(--text-medium);
}
.profile-section-sub-badge.premium {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309;
}

/* ── Animal avatar grid ─────────────────────────────────────────────── */
.animal-avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.animal-avatar-option {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  background: #f1f5f9;
}
.animal-avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.animal-avatar-option:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.animal-avatar-option.animal-avatar-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Avatar grid container (shown on click) */
.animal-avatar-grid-container {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* Edit hint overlay on profile avatar */
.profile-section-avatar {
  position: relative;
}
.profile-avatar-edit-hint {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.profile-section-avatar:hover .profile-avatar-edit-hint {
  opacity: 1;
}

/* Avatar grid pagination */
.animal-avatar-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--text-medium);
}
.animal-avatar-page-btn {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--text-dark);
  transition: background 0.15s;
}
.animal-avatar-page-btn:hover:not(:disabled) {
  background: #f1f5f9;
}
.animal-avatar-page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Animal avatar displayed in profile/header as circle */
.animal-avatar-circle {
  width: var(--avatar-img-size, 100%);
  height: var(--avatar-img-size, 100%);
  min-width: var(--avatar-img-size, 100%);
  min-height: var(--avatar-img-size, 100%);
  object-fit: cover;
  border-radius: 50%;
}

/* ── Premium plans section ───────────────────────────────────────────── */
.premium-plans-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Title row: back + “Choose your Pack” (mobile: title lives in header like iOS) */
.premium-plans-page-header {
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}
.premium-plans-header-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}
.premium-plans-header-titles h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.premium-plans-header-icon {
  font-size: 1.35rem;
  line-height: 1;
}
.premium-plans-header-desc {
  margin: 0;
  color: var(--text-medium);
  font-size: 0.88rem;
  line-height: 1.35;
}

@media (min-width: 769px) {
  .premium-plans-page-header {
    align-items: center;
    margin-bottom: 28px;
  }
  .premium-plans-header-titles h2 {
    font-size: 1.5rem;
  }
  .premium-plans-header-desc {
    font-size: 0.92rem;
  }
}
.premium-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.premium-plan-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(45,46,95,0.06);
  padding: 28px;
  text-align: center;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
}
.premium-plan-card:hover {
  transform: translateY(-2px);
}
.premium-plan-card.current {
  border-color: var(--secondary);
}
.premium-plan-card.recommended {
  border-color: var(--primary);
}
.premium-plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 50px;
  white-space: nowrap;
}
.premium-plan-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}
.premium-plan-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 6px;
}
.premium-plan-price {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 12px;
}
.premium-plan-price span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-medium);
}
.premium-plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  text-align: left;
}
.premium-plan-features li {
  padding: 6px 0;
  font-size: 0.85rem;
  color: var(--text-medium);
  display: flex;
  align-items: center;
  gap: 8px;
}
.premium-plan-features li i {
  color: var(--secondary);
  font-size: 0.75rem;
  flex-shrink: 0;
}
.premium-plan-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.premium-plan-btn.current-plan {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  text-align: center;
  background: #f0fdf4;
  color: var(--secondary);
  border: 2px solid var(--secondary);
  cursor: default;
}

.premium-plan-btn.current-plan .material-symbols-outlined,
.premium-plan-btn.current-plan i {
  flex-shrink: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.profile-section .premium-plan-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: auto;
  min-height: 44px;
  padding: 12px 22px;
}
.profile-section .premium-plan-btn .material-symbols-outlined,
.profile-section .premium-plan-btn i {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.premium-plan-btn.primary {
  background: var(--primary);
  color: #fff;
}
.premium-plan-btn.primary:hover {
  background: var(--secondary);
}
.premium-plan-btn.outline {
  background: transparent;
  color: var(--text-medium);
  border: 2px solid #e2e8f0;
}

.profile-pack-badges {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.profile-pack-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 9px;
}
.profile-pack-badge.admin { background: #111827; color: #fff; }
.profile-pack-badge.theory { background: rgba(59,130,246,0.12); color: #1d4ed8; }
.profile-pack-badge.exams { background: rgba(16,185,129,0.12); color: #047857; }
.profile-pack-badge.free { background: rgba(100,116,139,0.12); color: #475569; }

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .profile-section {
    max-width: 430px;
    padding: 0;
  }

  .profile-section-header {
    margin-bottom: 14px;
    padding: 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.94);
    box-shadow: 0 6px 20px rgba(45,46,95,0.07);
  }

  .profile-section-header .btn-back {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 14px;
  }

  .profile-section-header .btn-back .icon-btn-label {
    display: none;
  }

  .profile-section-header h2 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.1;
  }

  .profile-section--apple {
    padding: 8px 12px 32px;
  }

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

  .profile-section-header--apple h2 {
    font-size: 1.45rem;
  }

  .premium-plans-section {
    padding: 0 12px;
  }

  .premium-plans-page-header .premium-plans-header-titles h2 {
    font-size: 1.12rem;
    gap: 6px;
  }

  .premium-plans-page-header .premium-plans-header-icon {
    font-size: 1.15rem;
  }

  .premium-plans-page-header .premium-plans-header-desc {
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .profile-section-card {
    margin-bottom: 14px;
    padding: 18px;
    border-radius: 24px;
    box-shadow: 0 8px 24px rgba(45,46,95,0.08);
  }

  .profile-section-avatar-row {
    align-items: center;
    gap: 14px;
  }

  .profile-section-info {
    min-width: 0;
  }

  .profile-section-info .profile-name,
  .profile-section-info .profile-email {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .profile-pack-badges {
    gap: 6px;
  }

  .pref-row {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .pref-row label {
    min-width: 0;
  }

  .pref-row select {
    width: 100%;
  }

  .profile-signout-btn {
    width: 100%;
    margin: 8px 0 0;
  }
}

/* Duration selector — full width, no horizontal scroll; discount always visible */
.premium-duration-selector {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
  margin-bottom: 28px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
  padding: 0;
}
.premium-duration-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 10px 6px;
  border-radius: 14px;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  position: relative;
  text-align: center;
  line-height: 1.15;
  box-sizing: border-box;
}
.premium-duration-btn-label {
  font-size: clamp(0.62rem, 2.8vw, 0.82rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
@media (min-width: 480px) {
  .premium-duration-btn {
    padding: 12px 10px;
  }
  .premium-duration-btn-label {
    font-size: 0.85rem;
    white-space: normal;
  }
}
.premium-duration-btn.active {
  background: var(--primary);
  color: #fff;
}
.premium-duration-btn.active .premium-duration-badge {
  background: rgba(255, 255, 255, 0.95);
  color: #047857;
}
.premium-duration-badge {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #10b981;
  color: #fff;
  font-size: clamp(0.52rem, 2.2vw, 0.65rem);
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 8px;
  white-space: nowrap;
  max-width: 100%;
  line-height: 1.2;
}

@media (max-width: 380px) {
  .premium-duration-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .premium-duration-btn {
    min-height: 64px;
  }
}

/* Pack cards grid — 3 columns */
.premium-packs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}
.premium-pack-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(45,46,95,0.07);
  padding: 26px 22px;
  text-align: center;
  border: 2px solid transparent;
  position: relative;
  transition: transform 0.2s, border-color 0.2s;
}
.premium-pack-card:hover { transform: translateY(-3px); }
.premium-pack-card.pack-recommended { border-color: var(--primary); }
.premium-pack-card.pack-owned { border-color: var(--secondary); }
.premium-pack-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 50px;
  white-space: nowrap;
}
.premium-pack-icon { font-size: 2.2rem; margin-bottom: 10px; }
.premium-pack-name { font-size: 1.05rem; font-weight: 800; color: var(--text-dark); margin-bottom: 4px; }
.premium-pack-tagline { font-size: 0.8rem; color: var(--text-medium); margin-bottom: 14px; }
.premium-pack-price-big { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.premium-pack-price-period { font-size: 0.82rem; color: var(--text-medium); margin-bottom: 4px; }
.premium-pack-price-total { font-size: 0.78rem; color: var(--text-medium); margin-bottom: 16px; min-height: 18px; }
.premium-pack-features {
  list-style: none; padding: 0; margin: 0 0 18px; text-align: left;
}
.premium-pack-features li {
  padding: 5px 0; font-size: 0.83rem; color: var(--text-medium);
  display: flex; align-items: center; gap: 7px;
}
.premium-pack-features li i { color: var(--secondary); font-size: 0.72rem; flex-shrink: 0; }

/* Upgrade gates */
.upgrade-gate-overlay {
  position: fixed; inset: 0; z-index: 9990;
  background: rgba(30,31,66,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.upgrade-gate-card {
  background: #fff;
  border-radius: 24px;
  padding: 36px 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(45,46,95,0.18);
}
.upgrade-gate-icon { font-size: 3rem; margin-bottom: 12px; }
.upgrade-gate-title { font-size: 1.3rem; font-weight: 800; color: var(--text-dark); margin-bottom: 8px; }
.upgrade-gate-desc { font-size: 0.9rem; color: var(--text-medium); margin-bottom: 24px; line-height: 1.55; }
.upgrade-gate-actions { display: flex; flex-direction: column; gap: 10px; }
.upgrade-gate-btn-primary {
  padding: 13px; border: none; border-radius: 50px;
  background: var(--primary); color: #fff;
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.upgrade-gate-btn-secondary {
  padding: 11px; border: 2px solid rgba(45,46,95,0.2); border-radius: 50px;
  background: transparent; color: var(--text-medium);
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
}

/* ── Quicksteps Category Chooser (rendered in main-content) ──────────── */
.qs-chooser-section {
  width: 100%;
}
.qs-chooser-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.qs-category-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(45, 46, 95, 0.08);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  box-shadow: 0 4px 20px rgba(45, 46, 95, 0.08);
}
.qs-category-btn:hover {
  border-color: var(--primary);
  background: rgba(45, 46, 95, 0.03);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(45, 46, 95, 0.12);
}
.qs-category-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(45, 46, 95, 0.04);
  border-radius: 14px;
}
.qs-category-info {
  min-width: 0;
  flex: 1;
}
.qs-category-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
}
.qs-category-desc {
  font-size: 0.78rem;
  color: var(--text-medium);
  margin-top: 3px;
  line-height: 1.3;
}

