.reader-ambience {
  position: absolute;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: max(22px, env(safe-area-inset-left));
  z-index: 22;
  font-family: var(--sans);
  --ambience-accent: var(--amber);
  --ambience-soft: color-mix(in srgb, var(--amber) 12%, var(--panel));
}
.reader-ambience[hidden] { display: none; }
.reader-ambience button { font: inherit; cursor: pointer; }
.reader-ambience svg { width: 22px; height: 22px; flex-shrink: 0; }
.ambience-trigger {
  display: flex; align-items: center; gap: 9px;
  height: 44px; padding: 0 14px;
  color: var(--ink); background: var(--panel-glass);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transition: background .2s, border-color .2s, transform .2s;
}
.ambience-trigger-label { font-size: 12px; font-weight: 600; }
.ambience-trigger:hover, .is-open .ambience-trigger { border-color: var(--ambience-accent); background: var(--ambience-soft); }
.ambience-indicator { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0; }
.is-playing .ambience-indicator { opacity: 1; animation: ambience-breathe 2.8s ease-in-out infinite; }
.ambience-panel {
  position: absolute; bottom: calc(100% + 12px); left: 0;
  width: 300px; max-width: calc(100vw - 36px); padding: 17px;
  background: var(--panel-glass); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: saturate(140%) blur(20px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(18px) scale(.96); transform-origin: bottom left;
  transition: opacity .22s ease, transform .32s cubic-bezier(.2, .8, .2, 1), visibility .32s;
}
.is-open .ambience-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }
.ambience-heading { font-size: 13px; font-weight: 600; margin-bottom: 13px; }
.ambience-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.ambience-options button {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 9px; padding: 12px 2px 9px; border: 1px solid transparent;
  border-radius: 10px; background: transparent; color: var(--muted);
  transition: background .18s, color .18s, transform .18s;
}
.ambience-options span { font-size: 12px; line-height: 1.35; text-align: center; }
.ambience-options button:hover { background: var(--hover); color: var(--ink); transform: translateY(-2px); }
.ambience-options button[aria-pressed="true"] { color: var(--ink); background: var(--ambience-soft); border-color: var(--ambience-accent); }
.ambience-controls { display: flex; align-items: center; gap: 10px; padding-top: 13px; margin-top: 10px; border-top: 1px solid var(--line); color: var(--muted); }
.ambience-pause { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 10px; background: var(--ambience-soft); color: var(--ambience-accent); }
.ambience-pause:disabled { opacity: .4; cursor: default; }
.ambience-controls > svg { width: 16px; height: 16px; }
.ambience-controls input {
  flex: 1; width: 100%; min-width: 0; height: 24px; margin: 0;
  appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer;
  --ambience-track: linear-gradient(to right, var(--ambience-accent) var(--ambience-volume, 30%), var(--line-strong) var(--ambience-volume, 30%));
}
.ambience-controls input::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: var(--ambience-track); }
.ambience-controls input::-moz-range-track { height: 3px; border-radius: 3px; background: var(--ambience-track); }
.ambience-controls input::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 12px; height: 12px;
  margin-top: -4.5px; border: 0; border-radius: 50%; background: var(--ambience-accent);
}
.ambience-controls input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--ambience-accent); }
.ambience-volume-value { width: 36px; flex-shrink: 0; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.ambience-status { margin: 10px 0 0; min-height: 17px; font-size: 12px; line-height: 1.4; color: var(--muted); }
.reader-ambience :focus-visible { outline: 2px solid var(--ambience-accent); outline-offset: 3px; }
@keyframes ambience-breathe { 50% { opacity: .4; } }
@media (max-width: 1050px) {
  .reader-ambience { left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .ambience-trigger { width: 42px; height: 42px; padding: 0; justify-content: center; border-radius: 10px; }
  .ambience-trigger-label { display: none; }
  .ambience-indicator { position: absolute; right: 5px; top: 6px; }
  .ambience-panel { max-width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  .reader-ambience *, .reader-ambience *::before, .reader-ambience *::after { animation: none !important; transition: none !important; }
}
