.sw {
  --c-btn: #243c69;
  --c-btn-active: #1e2f52;
  --c-text: #1f2937;
  --c-bubble: #f5f7fb;
  --c-bubble-brd: #e6e9ef;

  --fs-body: clamp(14px, 1.8vw, 16px);
  --fs-text: clamp(15px, 2vw, 18px);

  --dur-open: 560ms;
  --dur-close: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --panel-gap: 12px;
}

.sw-root {
  font-family: STV, Roboto, "Noto Naskh Arabic UI", Tahoma, Arial, sans-serif;
}

.sw {
  width: 100%;
  margin: 0 auto;
  color: var(--c-text);
  font-weight: 400;
  font-size: var(--fs-body);
  position: relative;
}

.sw * {
  border-radius: 0 !important;
  box-sizing: border-box;
}

.sw__toggle {
  background: var(--c-btn);
  color: #fff;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: clamp(0.5rem, 0.9vw, 0.8rem);
  padding-inline: 1rem 1.5rem;
  padding-block: clamp(0.6rem, 0.9vw, 1rem);
  font-size: clamp(14px, 1.8vw, 16px);
  font-weight: 700;
  min-height: 40px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.16s var(--ease-out), background 0.16s var(--ease-out);
  width: 180px;
  height: 50px;
  justify-content: center;
}
.sw__toggle:hover {
  transform: translateY(-1px);
}
.sw__toggle[aria-expanded="true"] {
  background: var(--c-btn-active);
}

.sw__icon {
  width: clamp(18px, 2.2vw, 22px);
  height: clamp(18px, 2.2vw, 22px);
  transform-origin: center;
  will-change: transform;
}
.sw__icon.wiggle {
  animation: sw-wiggle 0.6s var(--ease-out) both;
}
@keyframes sw-wiggle {
  0% {
    transform: scale(1) rotate(0);
  }
  25% {
    transform: scale(1.06) rotate(-6deg);
  }
  55% {
    transform: scale(1.06) rotate(6deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

.sw__panel {
  width: 100%;
  overflow: hidden;
  height: 0;
  opacity: 0;
  margin-top: 0;
  transition: height var(--dur-open) var(--ease-out),
    opacity var(--dur-open) var(--ease-out),
    margin-top var(--dur-open) var(--ease-out);
}
.sw__panel.is-open {
  opacity: 1;
  margin-top: var(--panel-gap);
}
.sw__panel[hidden] {
  display: none;
}

.sw__bubble {
  background: var(--c-bubble);
  border: 1px solid var(--c-bubble-brd);
  padding: 14px 16px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
  transform-origin: top;
  transition: transform 320ms var(--ease-out), filter 320ms var(--ease-out),
    opacity 320ms var(--ease-out);
}
.sw__panel:not(.is-open) .sw__bubble {
  opacity: 0.98;
  transform: translateY(4px) scaleY(0.995);
  filter: saturate(0.96);
}

.sw__text {
  width: 100%;
  font-size: var(--fs-text);
  line-height: 2.1;
  white-space: pre-wrap;
  word-spacing: 0.5px;
  min-height: 3.2em;
}
.sw__text.is-typing::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-inline-start: 2px;
  vertical-align: -0.15em;
  background: var(--c-btn);
  animation: sw-blink 0.9s steps(1, end) infinite;
}
@keyframes sw-blink {
  50% {
    opacity: 0;
  }
}

.sw__listen {
  margin: 14px 0 8px;
  font-weight: 700;
  color: var(--c-btn);
  text-align: right;
}

.sw__player {
  width: 100%;
  margin-top: 4px;
}

.sw-audio {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 8px 12px;
  margin: 0.3rem 0;
  background: var(--c-btn);
  color: #fff;
}

.sw-audio__play,
.sw-audio__volIco {
  background: 0;
  border: 0;
  color: inherit;
  cursor: pointer;
}
.sw-audio__play {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
}

.sw-range {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  direction: ltr !important;
}
.sw-range--seek {
  flex: 1 1 auto;
  min-width: 160px;
}
.sw-range--vol {
  flex: 0 0 140px;
  max-width: 180px;
}

.sw-range input {
  z-index: 1;
  width: 100%;
  appearance: none;
  background: transparent;
  border: 0;
  outline: 0;
  margin: 0;
  padding: 0;
}
.sw-range__track {
  position: absolute;
  top: 0;
  left: 0;
  height: 8px;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.5);
}
.sw-range__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 8px;
  width: 0;
  background-color: rgb(187, 187, 187);
}

.sw-audio input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 8px;
}
.sw-audio input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 0;
  border-radius: 50%;
  margin-top: -3px;
  cursor: pointer;
}
.sw-audio input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #fff;
  border: 0;
  border-radius: 50%;
  margin-top: -3px;
  cursor: pointer;
}

.sw-audio__seek {
  width: 100%;
}
.sw-audio__time {
  flex: 0 0 auto;
  direction: ltr !important;
  font-size: clamp(11px, 1.6vw, 14px);
  font-weight: 600;
  color: #e6e6e6;
  white-space: nowrap;
}
.sw-audio__vol {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 640px) {
  .sw-audio {
    flex-wrap: wrap;
    gap: 0.55rem;
  }
  .sw-range--seek {
    min-width: 120px;
  }
  .sw-range--vol {
    flex-basis: 110px;
  }
  /*   .sw-audio__time {
    order: 3;
  } */
}

@media (prefers-reduced-motion: reduce) {
  .sw__panel,
  .sw__bubble,
  .sw__toggle,
  .sw__icon {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 640px) {
  .sw-range input {
    height: 18px;
  }

  .sw-range__track,
  .sw-range__fill {
    top: 50% !important;
    transform: translateY(-50%) !important;
    height: 4px !important;
  }

  .sw-audio input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    border: 0;
    margin-top: 0;
  }

  .sw-audio input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    border: 0;
  }

  .sw-audio input[type="range"]::-moz-range-track {
    height: 4px;
    background: transparent;
  }
}
