/* Fixed footer global TTS player — transport + caption + seek */
body.has-global-player {
  padding-bottom: calc(5.65rem + env(safe-area-inset-bottom, 0px));
}

body.has-global-player.gp-has-caption {
  padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px));
}

.global-player {
  --gp-bg: rgba(12, 14, 20, 0.94);
  --gp-border: rgba(142, 197, 255, 0.12);
  --gp-surface: rgba(26, 32, 48, 0.9);
  --gp-surface-hover: rgba(34, 42, 61, 0.95);
  --gp-accent: #8ec5ff;
  --gp-muted: #8f9bb3;
  --gp-text: #eceff6;
  --gp-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  --gp-btn-icon: 2.35rem;
  --gp-btn-play: 2.65rem;

  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--gp-bg);
  border-top: 1px solid var(--gp-border);
  backdrop-filter: blur(14px) saturate(1.15);
  box-shadow: var(--gp-shadow);
}

.gp-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.42rem 0.65rem calc(0.36rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.gp-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.gp-row-main {
  gap: 0.42rem;
}

.gp-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
}

.gp-text {
  min-width: 0;
}

.gp-title {
  font-family: "Noto Serif TC", "PingFang TC", serif;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gp-text);
  line-height: 1.25;
}

.gp-sub {
  font-size: 0.74rem;
  color: var(--gp-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gp-sub:empty {
  display: none;
}

.gp-meta-row {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  flex-wrap: wrap;
  min-width: 0;
}

.gp-caption {
  font-family: "Noto Serif TC", "PingFang TC", serif;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #d8e4f4;
  margin-top: 0.12rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.global-player.gp-has-caption .gp-sub {
  display: none;
}

.gp-offline {
  display: inline-block;
  margin-top: 0;
  padding: 0.06rem 0.42rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #9edfb8;
  border: 1px solid rgba(114, 201, 154, 0.45);
  background: rgba(114, 201, 154, 0.12);
  cursor: pointer;
  line-height: 1.4;
}

.gp-offline:hover {
  color: #c8f0d8;
  border-color: rgba(114, 201, 154, 0.7);
  background: rgba(114, 201, 154, 0.2);
}

.gp-offline.cached {
  color: #b8f5cc;
  border-color: rgba(114, 201, 154, 0.65);
  background: rgba(114, 201, 154, 0.22);
}

.gp-speed,
.gp-provider {
  font: inherit;
  font-size: 0.68rem;
  border-radius: 999px;
  border: 1px solid rgba(58, 69, 96, 0.9);
  background: var(--gp-surface);
  color: var(--gp-text);
  padding: 0.14rem 0.4rem 0.14rem 0.45rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238f9bb3' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.3rem center;
  padding-right: 1.1rem;
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.2;
  flex-shrink: 0;
}

.gp-provider {
  max-width: 6.5rem;
}

.gp-speed:hover,
.gp-provider:hover {
  border-color: rgba(142, 197, 255, 0.35);
}

.gp-speed {
  font-weight: 500;
}

.gp-resume {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.68rem;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid rgba(142, 197, 255, 0.35);
  background: linear-gradient(135deg, rgba(42, 64, 104, 0.9), rgba(34, 48, 72, 0.9));
  color: var(--gp-accent);
  padding: 0.16rem 0.5rem;
  white-space: nowrap;
  line-height: 1.2;
}

.gp-resume:hover {
  border-color: var(--gp-accent);
}

.gp-transport {
  display: flex;
  align-items: center;
  gap: 0.22rem;
  flex-shrink: 0;
}

.gp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--gp-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
}

.gp-btn:active {
  transform: scale(0.94);
}

.gp-btn-icon {
  width: var(--gp-btn-icon);
  height: var(--gp-btn-icon);
  border-radius: 50%;
  background: var(--gp-surface);
  border-color: rgba(58, 69, 96, 0.8);
  color: var(--gp-text);
}

.gp-btn-icon:hover {
  background: var(--gp-surface-hover);
  border-color: rgba(142, 197, 255, 0.35);
  color: var(--gp-accent);
}

.gp-btn-icon svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
  stroke: none;
  display: block;
  pointer-events: none;
}

.gp-ico {
  display: block;
  font-size: 0.82rem;
  line-height: 1;
  color: #eceff6;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  pointer-events: none;
  user-select: none;
}

.gp-ico-skip {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gp-ico-play {
  font-size: 0.78rem;
}

.gp-btn-play .gp-ico-play {
  color: #fff;
  font-size: 0.72rem;
}

.gp-btn-skip svg {
  width: 1.28rem;
  height: 1.28rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gp-btn-skip svg text {
  fill: currentColor;
  stroke: none;
}

.gp-btn-skip {
  width: calc(var(--gp-btn-icon) + 0.1rem);
  border-radius: 999px;
}

.gp-btn-play {
  width: var(--gp-btn-play);
  height: var(--gp-btn-play);
  border-radius: 50%;
  background: linear-gradient(145deg, #3d6fa8, #2a5080);
  border: 1px solid rgba(142, 197, 255, 0.45);
  box-shadow: 0 2px 10px rgba(42, 80, 128, 0.4);
  color: #fff;
}

.gp-btn-play:hover {
  background: linear-gradient(145deg, #4a7fb8, #325e90);
}

.gp-btn-play svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
  stroke: none;
  display: block;
  pointer-events: none;
}

.gp-btn-play .gp-icon-pause {
  width: 0.92rem;
  height: 0.92rem;
}

.gp-row-seek {
  gap: 0.4rem;
  padding: 0.12rem 0 0.04rem;
  align-items: center;
}

.gp-seek-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0.55rem 0;
  margin: -0.55rem 0;
  touch-action: none;
}

.gp-time {
  font-size: 0.68rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--gp-muted);
  min-width: 2.1rem;
  flex-shrink: 0;
}

.gp-time:last-of-type {
  text-align: right;
}

#gp-seek {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--gp-accent) 0%,
    var(--gp-accent) var(--gp-seek-pct, 0%),
    rgba(58, 69, 96, 0.85) var(--gp-seek-pct, 0%),
    rgba(58, 69, 96, 0.85) 100%
  );
  cursor: pointer;
  outline: none;
}

#gp-seek::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: transparent;
}

#gp-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--gp-accent);
  border: 2px solid #0c0e14;
  box-shadow: 0 0 0 1px rgba(142, 197, 255, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);
}

#gp-seek::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gp-accent);
  border: 2px solid #0c0e14;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(142, 197, 255, 0.45);
}

#gp-seek::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(58, 69, 96, 0.85);
}

#gp-seek:active::-webkit-slider-thumb {
  transform: scale(1.12);
}

@media (pointer: coarse) {
  .global-player {
    --gp-btn-icon: 2.5rem;
    --gp-btn-play: 2.8rem;
  }

  .gp-seek-wrap {
    padding: 0.75rem 0;
    margin: -0.75rem 0;
  }

  #gp-seek {
    height: 8px;
  }

  #gp-seek::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
    margin-top: -7px;
  }

  #gp-seek::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }

  #gp-seek::-moz-range-track {
    height: 8px;
  }
}

.gp-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--gp-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.gp-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.gp-toggle-track {
  width: 1.75rem;
  height: 1rem;
  border-radius: 999px;
  background: rgba(58, 69, 96, 0.9);
  border: 1px solid rgba(58, 69, 96, 1);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.gp-toggle-track::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: #c5cdd8;
  transition: transform 0.2s, background 0.2s;
}

.gp-toggle input:checked + .gp-toggle-track {
  background: rgba(42, 80, 128, 0.85);
  border-color: rgba(142, 197, 255, 0.45);
}

.gp-toggle input:checked + .gp-toggle-track::after {
  transform: translateX(0.75rem);
  background: var(--gp-accent);
}

#gp-audio {
  display: none;
}

@media (max-width: 520px) {
  body.has-global-player {
    padding-bottom: calc(5.85rem + env(safe-area-inset-bottom, 0px));
  }

  body.has-global-player.gp-has-caption {
    padding-bottom: calc(6.75rem + env(safe-area-inset-bottom, 0px));
  }

  .gp-row-main {
    flex-wrap: nowrap;
    gap: 0.32rem;
    align-items: flex-start;
  }

  .gp-transport {
    gap: 0.14rem;
    padding-top: 0.1rem;
  }

  .gp-meta-row {
    gap: 0.28rem;
  }

  .gp-speed {
    font-size: 0.66rem;
    padding: 0.14rem 0.34rem 0.14rem 0.38rem;
    padding-right: 1rem;
  }

  .gp-toggle-label {
    display: none;
  }

  .gp-resume {
    max-width: 5.5rem;
    padding: 0.18rem 0.45rem;
    font-size: 0.68rem;
  }

  .gp-caption {
    font-size: 0.74rem;
    -webkit-line-clamp: 2;
  }
}

@media (min-width: 640px) {
  body.has-global-player {
    padding-bottom: calc(5.2rem + env(safe-area-inset-bottom, 0px));
  }

  body.has-global-player.gp-has-caption {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
  }
}
