/* ============================================================================
   px-player.css — Unified player chrome + single-slot transitions.
   PIPLIX_DESIGN_GUIDELINE.md §7 (Player System) + §2 tokens + §10 motion.
   Requires px-tokens.css + px-base.css (PxFoundationAsset). Tokens only — no
   hardcoded value a token covers. Mobile-first; §2.9 breakpoints only.
   ============================================================================ */

[x-cloak] { display: none !important; }

/* ---- Full-screen canvas -------------------------------------------------- */
.px-player {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--px-bamboo-on);
  color: var(--px-ink-700);
  font: var(--px-text-body);
}

/* ---- §7.2 Chrome: [X] top-left · progress center · NOTHING right ---------- */
.ps-chrome {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 96px; /* balanced action areas keep progress truly centered */
  align-items: center;
  gap: var(--px-space-3);
  padding: var(--px-space-3) var(--px-space-4);
  position: sticky;
  top: 0;
  z-index: var(--px-z-player-chrome);
  background: var(--px-bamboo-on);
  max-width:1080px;
  width:100%;
  margin:0 auto;
  min-height:80px;
}

.ps-exit {
  width: 44px;            /* ≥44px touch target (§14) */
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--px-ink-500);
  border-radius: var(--px-radius-pill);
  line-height: 1;
  cursor: pointer;
  justify-self: start;    /* TOP-LEFT, always */
  transition: background-color var(--px-dur-fast) var(--px-ease-out),
              color var(--px-dur-fast) var(--px-ease-out);
}
.ps-exit:hover { background: var(--px-surface-100); color: var(--px-ink-700); }
.ps-exit:focus-visible { outline: 2px solid var(--px-info); outline-offset: 1px; }

.ps-icon {
  display: block;
  position: relative;
  flex: 0 0 auto;
  color: currentColor;
}
.ps-icon--close {
  width: 22px;
  height: 22px;
}
.ps-icon--close,
.ps-icon--settings,
.ps-icon--sound,
.ps-icon--chevron,
.ps-icon--arrow {
  background: currentColor;
  border: 0;
  border-radius: 0;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.ps-icon--close::before,
.ps-icon--close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  right: 2px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
.ps-icon--close::before { transform: translateY(-50%) rotate(45deg); }
.ps-icon--close::after { transform: translateY(-50%) rotate(-45deg); }
.ps-icon--close::before,
.ps-icon--close::after,
.ps-icon--settings::before,
.ps-icon--settings::after,
.ps-icon--sound::before,
.ps-icon--sound::after {
  display: none;
}
.ps-icon--close {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}
.ps-icon--settings {
  color: var(--px-ink-500);
  width: 24px;
  height: 24px;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}
.ps-icon--settings::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.ps-icon--settings::after {
  content: "";
  position: absolute;
  inset: -5px;
  background:
  linear-gradient(currentColor, currentColor) 50% 0 / 2px 5px no-repeat,
  linear-gradient(currentColor, currentColor) 50% 100% / 2px 5px no-repeat,
  linear-gradient(90deg, currentColor, currentColor) 0 50% / 5px 2px no-repeat,
  linear-gradient(90deg, currentColor, currentColor) 100% 50% / 5px 2px no-repeat;
}

.ps-icon--sound {
  width: 22px;
  height: 22px;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5zM15.5 8.5a5 5 0 0 1 0 7M19.1 5a10 10 0 0 1 0 14'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4V5zM15.5 8.5a5 5 0 0 1 0 7M19.1 5a10 10 0 0 1 0 14'/%3E%3C/svg%3E");
}
.ps-icon--sound::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 7px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 6px -4px 0 -2px currentColor, 6px 4px 0 -2px currentColor;
}
.ps-icon--sound::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 4px;
  width: 10px;
  height: 14px;
  border: 2px solid currentColor;
  border-left: 0;
  border-radius: 0 999px 999px 0;
}
.ps-icon--chevron,
.ps-icon--arrow {
  width: 10px;
  height: 10px;
}
.ps-icon--chevron {
  width: 16px;
  height: 16px;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.ps-icon--arrow {
  width: 18px;
  height: 18px;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
}

/* Progress: thin, centered, --px-brand fill (reuses .px-progress base). */
.ps-progress {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.ps-chrome__spacer,
.ps-chrome__actions {
  position: relative;
  width: 44px;
  justify-self: end;
}

.ps-chrome__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--px-space-2);
  width: auto;
}

/* Compact uploaded-audio controls. This intentionally contains no browser
   voice or text-to-speech options: lessons use only audio authored in admin. */
.ps-audio-settings {
  position: fixed;
  inset: 0;
  z-index: calc(var(--px-z-player-chrome) + 8);
  display: grid;
  place-items: center;
  padding: 16px;
}
.ps-audio-settings__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(2px);
}
.ps-audio-settings__panel {
  position: relative;
  width: min(460px, 100%);
  overflow: hidden;
  background: var(--px-surface-0);
  border: 1px solid var(--px-surface-200);
  border-radius: 20px;
  box-shadow: var(--px-shadow-lg);
}
.ps-audio-settings__head {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--px-surface-200);
}
.ps-audio-settings__head h2 {
  margin: 0;
  color: var(--px-ink-900);
  font-size: 20px;
  line-height: 1.25;
}
.ps-audio-settings__body {
  display: grid;
  gap: 18px;
  padding: 20px;
}
.ps-audio-settings__play,
.ps-audio-settings__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.ps-audio-settings__play > div {
  display: grid;
  gap: 3px;
}
.ps-audio-settings__play strong,
.ps-audio-settings__label strong {
  color: var(--px-ink-900);
  font-size: 16px;
}
.ps-audio-settings__play > div > span,
.ps-audio-settings__label span {
  color: var(--px-ink-500);
  font-size: 14px;
}
.ps-audio-play {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--px-brand);
  border-radius: 50%;
  background: var(--px-brand);
  color: var(--px-surface-0);
  cursor: pointer;
}
.ps-audio-play:disabled { opacity: .45; cursor: default; }
.ps-audio-play__triangle {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
}
.ps-audio-play__pause {
  width: 14px;
  height: 16px;
  border-left: 4px solid currentColor;
  border-right: 4px solid currentColor;
}
.ps-audio-settings__speed {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--px-surface-50);
  border-radius: var(--px-radius-md);
}
.ps-audio-settings__speed-controls {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
}
.ps-audio-settings__speed-controls button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--px-surface-200);
  border-radius: 50%;
  background: var(--px-surface-0);
  color: var(--px-ink-900);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.ps-audio-settings__speed-controls button:disabled { opacity: .4; cursor: default; }
.ps-audio-settings__speed-controls input {
  width: 100%;
  accent-color: var(--px-brand);
}
.ps-audio-settings__continue { width: 100%; }

.ps-settings__toggle,
.ps-speech-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--px-radius-pill);
  background: transparent;
  color: var(--px-ink-600);
  cursor: pointer;
  line-height: 1;
  transition: background-color 160ms var(--px-ease-out),
              border-color 160ms var(--px-ease-out),
              color 160ms var(--px-ease-out),
              transform 160ms var(--px-ease-out);
}
.ps-settings__toggle:hover,
.ps-speech-toggle:hover,
.ps-settings__toggle[aria-expanded="true"] {
  background: #eef7ff;
  border-color: #cfe8ff;
  color: var(--px-brand);
}
.ps-speech-toggle.is-active {
  color: var(--px-brand);
}
.ps-speech-toggle.is-playing .ps-icon--sound {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 5v14M16 5v14'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 5v14M16 5v14'/%3E%3C/svg%3E");
}
/* .ps-settings__toggle:hover,
.ps-speech-toggle:hover { transform: translateY(-1px); } */
.ps-settings {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: calc(var(--px-z-player-chrome) + 1);
  width: min(340px, calc(100vw - 24px));
  max-height: min(76vh, 620px);
  overflow: auto;
  padding: 14px;
  background: var(--px-surface-0);
  border: 1px solid #dce6ef;
  border-radius: 14px;
  box-shadow: var(--px-shadow-lg);
}
.ps-settings::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 16px;
  width: 12px;
  height: 12px;
  background: var(--px-surface-0);
  border-left: 1px solid #dce6ef;
  border-top: 1px solid #dce6ef;
  transform: rotate(45deg);
}
.ps-settings__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--px-space-3);
  margin-bottom: 12px;
}
.ps-settings__head div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ps-settings__head strong {
  color: var(--px-ink-900);
  font-size: 16px;
  line-height: 1.1;
}
.ps-settings__head span {
  color: var(--px-ink-500);
  font: var(--px-text-caption);
}
.ps-settings__head button {
  border: 0;
  background: #eef7ff;
  color: var(--px-brand);
  border-radius: var(--px-radius-pill);
  /* padding: 6px 11px; */
  font-weight: 600;
  cursor: pointer;
}
.ps-settings label {
  font: var(--px-text-caption);
  color: var(--px-ink-700);
}
.ps-settings__section {
  padding: 11px 0;
  border-top: 1px solid #edf2f7;
}
.ps-settings__section:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.ps-settings__section p {
  margin: 0 0 9px;
  color: var(--px-ink-900);
  font: var(--px-text-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ps-settings__switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
  min-width: 0;
}
.ps-settings__switch + .ps-settings__switch {
  margin-top: 0px;
}
.ps-settings input[type="checkbox"] {
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  appearance: none;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #e5e7eb;
  position: relative;
  cursor: pointer;
  transition: background-color var(--px-dur-fast) var(--px-ease-out),
              border-color var(--px-dur-fast) var(--px-ease-out);
}
.ps-settings input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--px-surface-0);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
  transition: transform var(--px-dur-fast) var(--px-ease-out);
}
.ps-settings input[type="checkbox"]:checked {
  background: var(--px-brand);
  border-color: var(--px-brand);
}
.ps-settings input[type="checkbox"]:checked::after {
  transform: translateX(14px);
}
.ps-settings__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}
.ps-settings__field span,
.ps-settings__sliders span {
  color: var(--px-ink-500);
}
.ps-settings select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #dce6ef;
  border-radius: 10px;
  background: #fbfdff;
  color: var(--px-ink-900);
  padding: 7px 9px;
}
.ps-settings__sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ps-settings__sliders label {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 8px;
}
.ps-settings__sliders input[type="range"] {
  width: 100%;
  accent-color: var(--px-brand);
}
.ps-settings__sliders b {
  font-weight: 600;
  color: var(--px-ink-700);
  text-align: right;
}
.ps-settings__links {
  position: sticky;
  bottom: -14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding-top: 11px;
  padding-bottom: 14px;
  margin-bottom: -14px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.92), var(--px-surface-0) 18px);
  border-top: 1px solid #edf2f7;
}
.ps-settings__links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 8px 10px;
  color: var(--px-ink-700);
  background: #fbfdff;
  border: 1px solid #edf2f7;
  border-radius: 10px;
  text-decoration: none;
  font: var(--px-text-caption);
  font-weight: 600;
}
.ps-settings__links a::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--px-brand);
  border-bottom: 2px solid var(--px-brand);
  transform: rotate(-45deg);
}
.ps-settings__links a:hover {
  color: var(--px-brand);
  border-color: #cfe8ff;
  background: #eef7ff;
}

/* Ling-style modal settings sheet. Overrides the earlier compact dropdown rules. */
.ps-settings__backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--px-z-player-chrome) + 1);
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(2px);
}
.ps-settings-fade-enter,
.ps-settings-fade-leave {
  transition: opacity 180ms var(--px-ease-out);
}
.ps-settings-fade-enter-start,
.ps-settings-fade-leave-end {
  opacity: 0;
}
.ps-settings-fade-enter-end,
.ps-settings-fade-leave-start {
  opacity: 1;
}
.ps-settings-panel-enter,
.ps-settings-panel-leave {
  transition: opacity 190ms var(--px-ease-out), transform 190ms var(--px-ease-out);
  transform-origin: center;
  will-change: opacity, transform;
}
.ps-settings {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  z-index: calc(var(--px-z-player-chrome) + 2);
  width: min(600px, calc(100vw - 32px));
  height: min(760px, calc(100dvh - 48px));
  max-height: none;
  overflow: hidden;
  padding: 0;
  background: var(--px-surface-0);
  border: 1px solid rgba(148, 163, 184, 0.7);
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.32), 0 2px 0 rgba(255,255,255,0.75) inset;
  transform: translate(-50%, -50%);
}
.ps-settings-panel-enter-start,
.ps-settings-panel-leave-end {
  opacity: 0;
  transform: translate(-50%, -48%) scale(0.975);
}
.ps-settings-panel-enter-end,
.ps-settings-panel-leave-start {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.ps-settings::before { display: none; }
.ps-settings[x-cloak] { display: none !important; }
.ps-settings__head {
  height: 86px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 0 26px;
  border-bottom: 1px solid #e8edf3;
}
.ps-settings__close {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--px-ink-600);
  line-height: 1;
  cursor: pointer;
  transition: background-color 160ms var(--px-ease-out), color 160ms var(--px-ease-out), transform 160ms var(--px-ease-out);
}
.ps-settings__close:hover {
  background: #f1f5f9;
  color: var(--px-ink-900);
  transform: rotate(6deg);
}
.ps-settings__body {
  height: calc(100% - 86px);
  overflow: auto;
  padding: 28px 24px 30px;
}
.ps-settings__title {
  margin: 0 0 0px;
  margin: 0 0 0px;
  color: var(--px-ink-800);
  font-size: 20px;
  line-height: 1.2;
  font-weight: 600;
}
.ps-settings__section {
  padding: 0;
  margin: 0 0 16px;
  border: 0;
}
.ps-settings__section h3 {
  margin: 16px 0 10px;
  color: var(--px-ink-800);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 600;
}
.ps-settings__section:first-of-type h3 { margin-top: 0; }
.ps-settings__section p { display: none; }
.ps-settings__row {
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  background: #f8fafc;
  border-top: 1px solid #e8edf3;
  color: var(--px-ink-700);
  text-decoration: none;
  font-size: 15px;
  line-height: 1.3;
  transition: background-color 160ms var(--px-ease-out), color 160ms var(--px-ease-out);
}
.ps-settings__row:first-of-type {
  border-top: 0;
  border-radius: 14px 14px 0 0;
}
.ps-settings__row:last-of-type {
  border-radius: 0 0 14px 14px;
}
.ps-settings__row:only-of-type {
  border-radius: 14px;
}
.ps-settings__row:hover {
  background: #f1f7ff;
}
.ps-settings__row-main {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.ps-settings__ico {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  color: var(--px-ink-600);
}
.ps-settings__link {
  cursor: pointer;
}
.ps-settings__link > .ps-icon--arrow {
  color: var(--px-ink-600);
  transition: transform 160ms var(--px-ease-out), color 160ms var(--px-ease-out);
}
.ps-settings__link:hover > .ps-icon--arrow {
  color: var(--px-brand);
  transform: translateX(2px);
}
.ps-settings__field {
  flex-direction: row;
  margin: 0;
}
.ps-settings__field select {
  width: min(260px, 48%);
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--px-ink-700);
  text-align: right;
  padding: 6px 4px;
  font: var(--px-text-body-sm);
}
.ps-settings__select {
  position: relative;
  width: min(290px, 54%);
  flex: 0 0 auto;
}
.ps-settings__select-btn {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 7px 10px 7px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--px-ink-700);
  font: var(--px-text-body-sm);
  cursor: pointer;
  text-align: right;
  transition: background-color 160ms var(--px-ease-out), border-color 160ms var(--px-ease-out), box-shadow 160ms var(--px-ease-out);
}
.ps-settings__select-btn span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ps-settings__select-btn .ps-icon--chevron {
  flex: 0 0 auto;
  color: var(--px-ink-500);
  transition: transform 160ms var(--px-ease-out);
}
.ps-settings__select-btn:hover,
.ps-settings__select-btn[aria-expanded="true"] {
  background: var(--px-surface-0);
  border-color: #dce6ef;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}
.ps-settings__select-btn[aria-expanded="true"] .ps-icon--chevron {
  transform: rotate(180deg);
}
.ps-settings__select-btn:focus-visible {
  outline: 2px solid rgba(255, 122, 26, 0.35);
  outline-offset: 2px;
}
.ps-settings__select-btn:disabled {
  cursor: not-allowed;
  color: var(--px-ink-400);
  opacity: 0.7;
}
.ps-settings__select-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 4;
  width: min(320px, calc(100vw - 56px));
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid #dce6ef;
  border-radius: 16px;
  background: var(--px-surface-0);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
}
.ps-settings__select-option {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--px-ink-800);
  cursor: pointer;
  text-align: left;
  transition: background-color 140ms var(--px-ease-out), color 140ms var(--px-ease-out);
}
.ps-settings__select-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.ps-settings__select-option small {
  color: var(--px-ink-500);
  font-weight: 600;
}
.ps-settings__select-option:hover {
  background: #fff4e8;
  color: #c2410c;
}
.ps-settings__select-option.is-selected {
  background: #ffedd5;
  color: #c2410c;
}
.ps-settings__select-option.is-selected::after {
  content: "";
  width: 8px;
  height: 14px;
  border-right: 2px solid #ea580c;
  border-bottom: 2px solid #ea580c;
  transform: rotate(45deg);
}
.ps-settings__select-option.is-selected small {
  display: none;
}
.ps-settings__select-empty {
  margin: 4px;
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--px-ink-500);
  font: var(--px-text-caption);
}
.ps-settings input[type="checkbox"] {
  width: 44px;
  height: 26px;
  border: 0;
  background: #dfe5ec;
  box-shadow: inset 0 0 0 2px rgba(148, 163, 184, 0.22);
}
.ps-settings input[type="checkbox"]::after {
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}
.ps-settings input[type="checkbox"]:checked {
  background: #ff9800;
  box-shadow: inset 0 0 0 2px rgba(255, 152, 0, 0.08);
}
.ps-settings input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}
.ps-settings__sliders {
  display: block;
  padding: 0;
}
.ps-settings__slider-row {
  min-height: 57px;
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: #f8fafc;
  border-top: 1px solid #e8edf3;
}
.ps-settings__slider-row:first-of-type {
  border-top: 0;
  border-radius: 14px 14px 0 0;
}
.ps-settings__slider-row:last-of-type {
  border-radius: 0 0 14px 14px;
}
.ps-settings__slider-row span {
  color: var(--px-ink-700);
}
.ps-settings__slider-row b {
  color: var(--px-ink-600);
  font-weight: 600;
  text-align: right;
}
.ps-settings input[type="range"] {
  width: 100%;
  height: 6px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff6a13 0%, #ff9800 var(--ps-range-pct, 50%), #d9e1ea var(--ps-range-pct, 50%), #d9e1ea 100%);
  cursor: pointer;
}
.ps-settings input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: transparent;
}
.ps-settings input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  border: 3px solid var(--px-surface-0);
  background: #ff7a1a;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
  transition: transform 160ms var(--px-ease-out), box-shadow 160ms var(--px-ease-out);
}
.ps-settings input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.08);
  box-shadow: 0 3px 12px rgba(249, 115, 22, 0.46);
}
.ps-settings input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: transparent;
}
.ps-settings input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: transparent;
}
.ps-settings input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid var(--px-surface-0);
  background: #ff7a1a;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}
.ps-settings__reset {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: #fff4e8;
  color: #c2410c;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 160ms var(--px-ease-out), transform 160ms var(--px-ease-out);
}
.ps-settings__reset:hover {
  background: #ffead5;
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .ps-chrome {
    grid-template-columns: 88px minmax(0, 1fr) 88px;
    min-height: 64px;
    padding: 10px 12px;
    gap: 10px;
  }
  .ps-chrome__actions {
    width: auto;
    gap: 8px;
  }
  .ps-audio-settings { align-items: end; padding: 10px; }
  .ps-audio-settings__panel { border-radius: 20px; }
  .ps-audio-settings__body { padding: 18px 16px max(18px, env(safe-area-inset-bottom)); }
  .ps-exit,
  .ps-settings__toggle,
  .ps-speech-toggle {
    width: 40px;
    height: 40px;
  }
  .ps-speech-toggle {
    display: grid;
  }
  .ps-progress {
    max-width: min(100%, 340px);
  }
  .ps-settings {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: auto;
    height: min(84dvh, 680px);
    border-radius: 20px;
    transform: none;
  }
  .ps-settings-panel-enter-start,
  .ps-settings-panel-leave-end {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  .ps-settings-panel-enter-end,
  .ps-settings-panel-leave-start {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  .ps-settings__head {
    height: 56px;
    padding: 0 14px;
  }
  .ps-settings__body {
    height: calc(100% - 56px);
    padding: 16px 14px max(20px, env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }
  .ps-settings__section h3 {
    margin: 14px 0 8px;
    font-size: 17px;
  }
  .ps-settings__title {
    margin-bottom: 12px;
    font-size: 19px;
  }
  .ps-settings__row {
    min-height: 52px;
    padding: 0 14px;
    font-size: 14px;
  }
  .ps-settings__field {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .ps-settings__field select {
    width: 100%;
    text-align: left;
    background: var(--px-surface-0);
    border: 1px solid #dce6ef;
    padding: 7px 9px;
  }
  .ps-settings__select {
    width: 100%;
  }
  .ps-settings__select-btn {
    justify-content: space-between;
    background: var(--px-surface-0);
    border-color: #dce6ef;
    text-align: left;
  }
  .ps-settings__select-menu {
    left: 0;
    right: 0;
    top: auto;
    bottom: calc(100% + 8px);
    width: 100%;
    max-height: min(230px, 42dvh);
  }
  .ps-settings__slider-row {
    min-height: 62px;
    grid-template-columns: 70px minmax(0, 1fr) 54px;
    gap: 10px;
    padding: 0 12px;
    font-size: 13px;
  }
  .ps-footer {
    min-height: 64px;
    padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  }
  .ps-continue {
    min-width: 136px;
  }
}

/* ---- Stage = the single render slot -------------------------------------- */
.ps-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);  /* shrinkable track: fixed-width content (chart canvas) can't blow the slot past the viewport */
  align-items: start;
  justify-items: center;
  align-content: start;
  padding:var(--px-space-8) var(--px-space-4) var(--px-space-4);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  position: relative;
}

/* THE one slot. Exactly one screen is ever inside it. The enter/exit states
   below are toggled imperatively by session.js; because the slot's content is
   physically cleared between screens, no back screen can ever bleed through. */
.ps-slot {
  width: 100%;
  max-width: 700px;
  min-width: 0;              /* grid item must be allowed to shrink below its content's intrinsic width */
  /* padding-bottom: var(--px-space-4); */
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--px-dur-base) var(--px-ease-out),
              transform var(--px-dur-base) var(--px-ease-out);
  will-change: opacity, transform;
}
.ps-slot.is-in  { opacity: 1; transform: translateY(0); }
.ps-slot.is-out { opacity: 0; transform: translateY(-8px); pointer-events: none; }

/* ---- Footer: primary pill BOTTOM-RIGHT (§7.2) ---------------------------- */
.ps-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: var(--px-space-8) var(--px-space-4) var(--px-space-6);
  padding-bottom: max(var(--px-space-4), env(safe-area-inset-bottom));
  border: 1px solid rgb(229,231,235,1);
  min-height:72px;
  transition: .3s all ease-in-out;
}
.ps-footer .__wrap{
  max-width:1080px;
  width:100%;
  margin:0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.ps-continue { min-width: 160px; }
.me-auto{margin-right:auto !important;}
.ms-auto{margin-left:auto !important;}
/* ---- §7.3 Intro / speech-bubble screen ----------------------------------- */
.ps-intro {
  display: flex;
  /* flex-direction: column; */
  align-items: center;
  gap: var(--px-space-5);
  text-align: center;
}
.ps-intro__avatar {
  width: 144px;
  height: 144px;
  display: grid;
  place-items: center;
  font-size: 64px;          /* emoji fallback only */
  line-height: 1;
}
.ps-intro__avatar-img { width: 100%; height: 100%; object-fit: contain; }

.ps-bubble {
  position: relative;       /* anchors the speech tail */
  background: var(--px-surface-0);
  border: 2px solid var(--px-surface-200);
  border-radius: var(--px-radius-lg);
  /* box-shadow: var(--px-shadow-card); */
  padding: var(--px-space-6);
  max-width: 480px;
  text-align: left;
  width:100%;
}
/* Speech-bubble tail pointing up to the character (§7.3 reference). */
.ps-bubble::before {
  content: "";
  position: absolute;
  top: 20%;
  left: -8px;
  width: 16px;
  height: 16px;
  background: var(--px-surface-0);
  border-left: 2px solid var(--px-surface-200);
  border-top: 2px solid var(--px-surface-200);
  border-radius: 4px 0 0 0;
  transform: translateX(-0%) rotate(-45deg);
}
.ps-bubble__name { color: var(--px-brand); margin: 0 0 var(--px-space-2); }

.ps-bubble .px-text-body{
  margin:0px;
}
.ps-intro__line.is-playback-blocked .ps-narration-word {
  color: inherit;
}
.ps-intro__word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.2em);
  transition: opacity 160ms ease, transform 160ms ease;
}
.ps-intro__word.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Step / placeholder cards (real components land in Slice 4) ----------- */
.ps-step,
.ps-placeholder,
.ps-complete {
  background: var(--px-surface-0);
  border-radius: var(--px-radius-lg);
  /* box-shadow: var(--px-shadow-card); */
  padding: var(--px-space-6);
  display: flex;
  flex-direction: column;
  gap: var(--px-space-3);
  align-items: flex-start;
}
.ps-complete { align-items: center; text-align: center; }
.ps-step__demo { margin-top: var(--px-space-2); }


/* .ps-step--r-streak */
.ps-step--r-streak .ps-chrome{display:none !important;}
.ps-step--r-streak .ps-stage{align-content: center;}
/* .ps-step--r-streak */

.ps-footer .__wrap{align-items:flex-start;}
.px-player.px-player--lesson-finale[class*='ps-step--']:not(.ps-step--intro) .ps-footer:where(.is-correct, .is-wrong) .ps-continue{width:auto;margin-top:calc(26px + 15px);}


/* ---- Responsive (§2.9). Same chrome, reflowed; X stays top-left. --------- */
@media (min-width: 768px) {
  .ps-intro__line {
    font-size: 20px;
    line-height: 1.55;
  }
}

@media (max-width: 480px) {       /* --px-bp-sm */
  .ps-stage {
    padding: var(--px-space-4);
    scrollbar-gutter: auto;
  }
  .ps-step--intro .ps-stage { padding: 44px 33px; }
  .ps-intro__avatar { width: 128px; height: auto; font-size: 52px; }
  /* Reference: the primary CTA is full-width pinned at the bottom on mobile. */
  .ps-footer { padding-left: var(--px-space-4); padding-right: var(--px-space-4);padding-top:var(--px-space-6); }
  /* .ps-continue { width: 100%; } */
  .ps-continue { width: 100%; }
  .px-player.px-player--lesson-finale[class*='ps-step--']:not(.ps-step--intro) .ps-continue{width:auto;}
  
}

@media (prefers-reduced-motion: reduce) {
  .ps-slot { transition: none; }
}

/* Quit-confirmation modal (clicking the close X mid-lesson) */
.ps-quit { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ps-quit__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.ps-quit__box {
  position: relative; background: var(--px-surface-0, #fff); border-radius: var(--px-radius-lg, 16px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28); padding: 28px 26px; max-width: 420px; width: 100%; text-align: center;
}
.ps-quit__title { margin: 0 0 8px; font-size: 20px; font-weight: 600; color: var(--px-ink-900, #0f172a); }
.ps-quit__text  { margin: 0 0 20px; color: var(--px-ink-600, #475569); line-height: 1.5; }
.ps-quit__actions { display: flex; flex-direction: column; gap: 10px; }
.ps-quit__actions .px-btn { width: 100%; }
.ps-quit__leave { color: var(--px-error, #ef4444); }


@media(max-width:767px){
  .ps-intro{flex-direction: column;align-items: start;}
  .ps-bubble::before{top: 0;left:13%;width:20px;height:20px;transform: translateY(-50%) rotate(45deg);}
  .ps-bubble .ps-bubble__name{font-size:20px;}
  .ps-bubble .px-text-body{font-size:20px;line-height:26px;}

  .ps-chrome{display:flex;flex-wrap:wrap;justify-content:space-between;}
  .ps-chrome .px-progress{order:2;max-width:100%;}
  .ps-video__frame{aspect-ratio:5 / 3;}

  .px-player--lesson-video.ps-step--concept .ps-concept__text .ps-concept__title{font-size:20px;}
  .px-player--lesson-video.ps-step--concept .ps-concept__text .ps-concept__body{font-size:18px !important;}
}
