/* =============================================
   BIBLIOTECA — paleta Mist
   ============================================= */
.dash-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 52px) 24px calc(env(safe-area-inset-bottom, 0px) + 180px);
}

/* Library header */
.lib-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.lib-filter-btn {
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.lib-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.lib-headline {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: -0.022em;
  color: var(--ink);
}
.lib-headline em { font-style: italic; font-weight: 300; }
.lib-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* Plan row */
.dash-plan-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.dash-credits {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* Filter chips */
.dash-filters { margin-bottom: 18px; }
.filter-chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.filter-chips-row::-webkit-scrollbar { display: none; }

/* Legacy filter pill classes → s-chip compatible */
.filter-row { margin-bottom: 10px; }
.filter-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  display: block;
  margin-bottom: 8px;
}
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--faint);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-pill:hover { color: var(--ink); border-color: var(--ink); }
.filter-pill.active {
  background: var(--ink);
  color: var(--canvas);
  border-color: var(--ink);
}

/* Loading/error states */
.dash-loading {
  padding: 24px 0;
  color: var(--muted);
  font-size: 14px;
}

/* Skeleton biblioteca — feels faster than "Cargando…" plain text */
.lib-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 4px;
}
.lib-skel-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lib-skel-line {
  background: linear-gradient(90deg, rgba(0,0,0,0.05), rgba(0,0,0,0.10), rgba(0,0,0,0.05));
  background-size: 200% 100%;
  border-radius: 4px;
  height: 14px;
  animation: libSkelShimmer 1.2s ease-in-out infinite;
}
.lib-skel-title { width: 70%; height: 16px; }
.lib-skel-meta  { width: 45%; height: 11px; opacity: 0.7; }
@keyframes libSkelShimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .lib-skel-line { animation: none; }
}
.dash-error {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

/* Med list items */
.med-list { display: flex; flex-direction: column; gap: 8px; }
.med-card {
  background: var(--surface);
  border-radius: var(--r-card-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.med-card:hover { opacity: 0.9; }

.med-play-btn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: var(--ink);
  color: var(--canvas);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}
.med-play-btn:hover { opacity: 0.85; }
.med-play-btn.playing { background: var(--accent); }

.med-info { flex: 1; min-width: 0; }
.med-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.med-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.med-progress-bar {
  height: 2px;
  background: var(--faint);
  border-radius: 1px;
  margin-top: 6px;
  overflow: hidden;
}
.med-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.3s linear;
}

/* =============================================
   PERFIL — paleta Mist
   ============================================= */
.profile-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 52px) 24px calc(env(safe-area-inset-bottom, 0px) + 180px);
}

.profile-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.profile-settings-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 12px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s;
  margin-right: -12px;
}
.profile-settings-btn:hover { opacity: 1; }

/* Guest state */
.profile-guest {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 40px;
}
.profile-guest-avatar {
  width: 72px;
  height: 72px;
  border-radius: 36px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.profile-guest-title {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.profile-guest-sub { color: var(--muted); }

/* Identity */
.profile-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--ink);
  color: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  flex-shrink: 0;
}
.profile-identity-info {
  min-width: 0;
  flex: 1;
}
.profile-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-email {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-email:empty {
  display: none;
}
.profile-plan-info {
  font-size: 12px;
  color: var(--muted);
  /* opacity removida por contraste WCAG AA — audit Axe 2-may */
}

/* Level card */
.profile-level-card {
  background: var(--ink);
  color: var(--canvas);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.profile-level-eyebrow {
  color: var(--canvas);
  opacity: 0.5;
  margin-bottom: 6px;
  display: block;
}
.profile-level-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.profile-level-name em { font-style: italic; font-weight: 300; }
.profile-level-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}
.profile-level-bar {
  height: 100%;
  background: var(--canvas);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.profile-level-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--canvas);
  opacity: 0.55;
}

/* Stats grid */
.profile-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.profile-stats-grid .stat-number {
  font-size: 28px;
  letter-spacing: -0.05em;
}

/* Plan card (ink dark) */
.profile-plan-card {
  background: var(--ink);
  color: var(--canvas);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 14px;
}
.profile-plan-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.profile-plan-name-display {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.profile-plan-price-display {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.6;
}
.profile-manage-plan-btn {
  background: transparent;
  border: none;
  color: var(--canvas);
  font-family: var(--font-sans);
  font-size: 12px;
  opacity: 0.7;
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.profile-manage-plan-btn:hover { opacity: 1; }

.profile-cancel-sub-btn {
  display: block;
  margin-top: 14px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--canvas);
  font-family: var(--font-sans);
  font-size: 11px;
  opacity: 0.45;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.profile-cancel-sub-btn:hover { opacity: 0.75; }

.profile-cancelled-note {
  margin-top: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--canvas);
  opacity: 0.55;
  line-height: 1.45;
}

/* Welcome Premium 7d — pill destacada dentro de profile-plan-card cuando activa */
.profile-welcome-perk-note {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 11px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--canvas);
  opacity: 0.92;
  line-height: 1.35;
}
.profile-plan-credit-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}
.profile-plan-credit-bar {
  height: 100%;
  background: var(--canvas);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.profile-plan-credit-info {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.6;
}

/* Settings section */
.profile-settings-section {
  margin-bottom: 20px;
}
.profile-section-label {
  margin-bottom: 10px;
  display: block;
}
.profile-settings-rows {
  background: var(--surface);
  border-radius: var(--r-card);
  overflow: hidden;
}
.profile-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--faint);
}
.profile-setting-row:last-child { border-bottom: none; }
.profile-setting-row:hover { background: var(--canvas); }
.profile-setting-label {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
}
.profile-setting-value {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.profile-setting-value::after {
  content: '›';
  font-size: 18px;
  opacity: 0.5;
}
.profile-setting-locked .profile-setting-value {
  opacity: 0.4;
  cursor: default;
}
.profile-setting-locked:hover { background: transparent; }
.profile-setting-highlight .profile-setting-label { color: var(--accent); }
.profile-setting-nosuffix .profile-setting-value::after { display: none; }
.profile-setting-danger .profile-setting-label {
  color: #b12a2a;
  font-size: 13px;
}
.profile-setting-danger:hover { background: rgba(177, 42, 42, 0.05); }
.profile-setting-danger .profile-setting-value::after { display: none; }
.profile-setting-hint {
  font-size: 11px !important;
  /* opacity 0.55 removida por contraste WCAG AA — el --muted oscurecido (5:1)
     compensa visualmente. Audit Axe 2-may. */
  max-width: 60%;
  text-align: right;
}

/* Buzón row in profile */
.profile-buzon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px;
  cursor: pointer;
  background: var(--surface);
  border-radius: var(--r-card);
  margin-bottom: 14px;
  transition: background 0.15s;
}
.profile-buzon-row:hover { background: var(--canvas); }
.profile-buzon-label {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
}
.profile-buzon-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Habits & emotions cards */
.profile-habits-card,
.profile-emotions-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
}
.profile-habit-eyebrow { margin-bottom: 12px; display: block; }
.profile-habit-bars {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 72px;
  margin-bottom: 8px;
}
.profile-habit-bar {
  flex: 1;
  border-radius: 1px;
  background: var(--faint);
  min-height: 2px;
}
.profile-habit-bar.peak { background: var(--accent); }
.profile-habit-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 10px;
}
.profile-habit-insight {
  font-family: var(--font-display);
  font-size: 13px;
  font-style: italic;
  font-weight: 300;
  color: var(--ink);
  line-height: 1.5;
  letter-spacing: -0.01em;
  margin-top: 12px;
}
.profile-habit-insight em { font-weight: 400; }
.profile-emotion-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile-emotion-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.profile-emotion-label { font-size: 12px; color: var(--ink); width: 70px; }
.profile-emotion-bar-track {
  flex: 1;
  height: 6px;
  background: var(--canvas);
  border-radius: 3px;
  overflow: hidden;
}
.profile-emotion-bar-fill {
  height: 100%;
  background: var(--ink);
  opacity: 0.75;
  border-radius: 3px;
}
.profile-emotion-pct {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  width: 28px;
  text-align: right;
}

/* Sign out */
.profile-signout-btn {
  display: block;
  margin-top: 24px;
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--faint);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.profile-signout-btn:hover { border-color: var(--ink); color: var(--ink); }

/* =============================================
   STATS (shared)
   ============================================= */
.stat-value {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 1.6rem;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 5px;
}

/* Library item shared (also used in home recents via .med-card pattern) */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

/* Legacy dash-header kept for dashboard.html */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 52px) 0 28px;
}
.dash-headline {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 1.8rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.dash-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* =============================================
   MODAL — Cómo nos referimos a ti (perfil)
   ============================================= */
.profile-name-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(28, 18, 12, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.profile-name-overlay[style*="display:flex"],
.profile-name-overlay.active { display: flex !important; }
.profile-name-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--canvas);
  color: var(--ink);
  border-radius: 22px;
  padding: 28px 24px 22px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
  text-align: left;
}
.profile-name-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  opacity: 0.55;
}
.profile-name-close:hover { opacity: 1; background: rgba(0, 0, 0, 0.04); }
.profile-name-eyebrow {
  display: block;
  margin-bottom: 10px;
  opacity: 0.65;
}
.profile-name-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.15;
}
.profile-name-title em { font-style: italic; font-weight: 300; color: var(--accent, #A85A3D); }
.profile-name-sub {
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 16px;
}
.profile-name-input-field {
  width: 100%;
  background: var(--paper, #fff);
  border: 1px solid var(--line, rgba(42,28,20,0.12));
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease;
  margin-bottom: 14px;
  -webkit-appearance: none;
  appearance: none;
}
.profile-name-input-field:focus { border-color: var(--ink); }
.profile-name-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 18px;
  user-select: none;
}
.profile-name-toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
  cursor: pointer;
}
.profile-name-save {
  width: 100%;
  margin-bottom: 6px;
}
.profile-name-cancel {
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  padding: 10px 0;
}
