/* v18.8: compact listening setup and custom bottom sheet. */
.ear-settings-trigger {
  width: min(920px, 100%);
  min-height: 68px;
  margin: 0 auto 12px;
  padding: 10px 16px 10px 12px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 22px;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  border: 1px solid rgba(139, 92, 255, .12);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .7)),
    linear-gradient(105deg, #fff0f9, #f0efff 58%, #e9fbff);
  box-shadow: inset 0 2px 2px #fff, inset 0 -5px 12px rgba(144, 107, 191, .05);
  text-align: left;
  cursor: pointer;
}

.ear-settings-trigger-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff70c5, #a185f7 55%, #68dfe0);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, .65);
}

.ear-settings-trigger-icon svg,
.ear-settings-trigger > svg {
  width: 20px;
  height: 20px;
}

.ear-settings-trigger > svg {
  color: #9c61d4;
}

.ear-settings-trigger-copy {
  min-width: 0;
}

.ear-settings-trigger-copy b,
.ear-settings-trigger-copy small {
  display: block;
}

.ear-settings-trigger-copy b {
  font-size: 16px;
  line-height: 1.35;
}

.ear-settings-trigger-copy small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ear-training .ear-player {
  margin-top: 0;
}

body.ear-sheet-open {
  overflow: hidden;
}

body.ear-sheet-open .bottom-nav {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

body.ear-sheet-open #view-listen {
  animation: none;
  transform: none;
}

.ear-settings-sheet {
  position: fixed;
  z-index: 220;
  inset: 0;
  display: grid;
  align-items: end;
  pointer-events: none;
  visibility: hidden;
}

.ear-sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  border-radius: 0;
  background: rgba(37, 31, 75, .34);
  opacity: 0;
  backdrop-filter: blur(4px);
  transition: opacity .24s ease;
}

.ear-sheet-panel {
  position: relative;
  width: min(680px, 100%);
  max-height: min(86dvh, 820px);
  margin: 0 auto;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, .95);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  background: rgba(255, 253, 255, .98);
  box-shadow: 0 -22px 70px rgba(65, 43, 125, .2);
  transform: translateY(104%);
  transition: transform .3s cubic-bezier(.2, .85, .25, 1);
}

.ear-settings-sheet.open {
  pointer-events: auto;
  visibility: visible;
}

.ear-settings-sheet.open .ear-sheet-backdrop {
  opacity: 1;
}

.ear-settings-sheet.open .ear-sheet-panel {
  transform: translateY(0);
}

.ear-sheet-handle {
  width: 48px;
  height: 5px;
  margin: 10px auto 2px;
  border-radius: 5px;
  background: #ddd7ea;
}

.ear-sheet-header {
  padding: 10px 22px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid rgba(139, 92, 255, .1);
}

.ear-sheet-header span {
  color: #a052d2;
  font-size: 13px;
  font-weight: 900;
}

.ear-sheet-header h2 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.25;
}

.ear-sheet-header .icon-btn {
  width: 46px;
  height: 46px;
  min-width: 46px;
  color: #8e5bc1;
  background: #f3ecfb;
}

.ear-sheet-scroll {
  min-height: 0;
  overflow-y: auto;
  padding: 4px 22px 22px;
  overscroll-behavior: contain;
}

.ear-sheet-group {
  padding: 18px 0 4px;
}

.ear-sheet-group + .ear-sheet-group {
  margin-top: 12px;
  border-top: 1px solid rgba(139, 92, 255, .1);
}

.ear-sheet-group h3 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.35;
}

.ear-sheet-group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.ear-sheet-group-title > span {
  color: #a052d2;
  font-size: 15px;
  font-weight: 800;
  text-align: right;
}

.ear-sheet-segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ear-sheet-segmented button {
  min-height: 52px;
  font-size: 16px;
}

.ear-scene-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ear-scene-choice {
  min-width: 0;
  min-height: 52px;
  padding: 8px 14px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 20px;
  gap: 9px;
  align-items: center;
  color: #5a5373;
  border: 1px solid rgba(139, 92, 255, .12);
  border-radius: 45px;
  background: linear-gradient(180deg, #fff, #f7f4fc);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.ear-scene-choice > i {
  width: 18px;
  height: 18px;
  border: 2px solid #c8bfdc;
  border-radius: 50%;
}

.ear-scene-choice > svg {
  width: 19px;
  color: #fff;
}

.ear-scene-choice.active {
  color: #fff;
  border-color: rgba(255, 255, 255, .86);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .42), transparent 52%),
    linear-gradient(105deg, #ff75c7, #e77ee9 38%, #8ca4ff 70%, #6cded6);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, .75), inset 0 -5px 10px rgba(91, 71, 204, .08);
}

.ear-scene-choice.active > i {
  border: 5px solid #fff;
}

.ear-sheet-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.ear-sheet-options .ear-option {
  width: 100%;
  min-width: 0;
  justify-content: space-between;
  font-size: 16px;
  white-space: nowrap;
}

.ear-audio-note {
  margin-top: 20px;
  padding: 16px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 11px;
  color: #4f4b6a;
  border: 1px solid rgba(95, 202, 202, .25);
  border-radius: 18px;
  background: linear-gradient(135deg, #f1fffb, #f6f2ff);
}

.ear-audio-note > svg {
  width: 22px;
  color: #2caaa7;
}

.ear-audio-note b {
  font-size: 16px;
}

.ear-audio-note p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.ear-audio-note a {
  color: #9a52cf;
  font-size: 15px;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ear-sheet-footer {
  padding: 12px 22px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(139, 92, 255, .1);
  background: rgba(255, 255, 255, .98);
}

.ear-sheet-footer .primary-btn {
  width: 100%;
}

@media (max-width: 720px), (min-width: 721px) and (max-width: 960px) and (max-aspect-ratio: 1.2) {
  .listen-page-head.ear-mode-head {
    display: none;
  }

  #view-listen:has(.ear-training) {
    padding-top: 84px;
  }

  #view-listen:has(.ear-training) .listen-mode-tabs {
    margin-bottom: 10px;
  }

  .ear-settings-trigger {
    min-height: 66px;
    margin-bottom: 10px;
  }

  .ear-training .ear-player {
    min-height: 360px;
    margin-right: -4px;
    margin-left: -4px;
  }

  .ear-sheet-panel {
    max-height: 90dvh;
  }

  .ear-sheet-header,
  .ear-sheet-scroll,
  .ear-sheet-footer {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 520px) {
  .ear-sheet-header h2 {
    font-size: 24px;
  }

  .ear-scene-options {
    gap: 7px;
  }

  .ear-scene-choice {
    padding-inline: 11px;
    font-size: 15px;
  }

  .ear-sheet-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .ear-settings-trigger-copy small {
    font-size: 14px;
  }

  .ear-scene-options {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ear-sheet-backdrop,
  .ear-sheet-panel {
    transition-duration: .01ms;
  }
}
