/* Xblivian Voices player — one consistent control everywhere.
   Idle: Play only. Active: Pause/Resume + Stop + speed. Speed also opens on hover (mouse) or long-press (touch). */
.xv-player {
    --xv-size: 2rem;
    --xv-accent: #38bdf8;
    --xv-fg: #d6deeb;
    --xv-border: rgba(148, 163, 184, .28);
    --xv-bg: rgba(255, 255, 255, .04);
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    vertical-align: middle;
    line-height: 1;
}
.xv-player--sm { --xv-size: 1.75rem; }

.xv-btn {
    height: var(--xv-size);
    min-width: var(--xv-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: 0;
    border: 1px solid var(--xv-border);
    border-radius: .55rem;
    background: var(--xv-bg);
    color: var(--xv-fg);
    font-size: .76rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, border-color .16s ease, opacity .18s ease, max-width .2s ease, margin .2s ease;
}
.xv-btn:hover { background: rgba(56, 189, 248, .12); border-color: rgba(56, 189, 248, .45); color: #fff; }
.xv-btn:focus-visible { outline: 2px solid var(--xv-accent); outline-offset: 2px; }
.xv-btn i { font-size: .74rem; }
.xv-main .xv-label { padding-right: .15rem; }
.xv-main:has(.xv-label) { padding: 0 .65rem; }

.xv-player[data-state="playing"] .xv-main,
.xv-player[data-state="paused"] .xv-main { background: rgba(56, 189, 248, .16); border-color: rgba(56, 189, 248, .6); color: #e0f5ff; }
.xv-player[data-state="loading"] .xv-main { cursor: progress; opacity: .85; }
.xv-player[data-state="error"] .xv-main { border-color: rgba(251, 146, 60, .6); color: #fdba74; }

/* Secondary controls collapse to nothing until a playback session exists. */
.xv-stop,
.xv-speed-btn {
    max-width: 0;
    min-width: 0;
    margin-left: -.25rem;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    border-width: 0;
}
.xv-player[data-state="playing"] .xv-stop,
.xv-player[data-state="paused"] .xv-stop,
.xv-player[data-state="loading"] .xv-stop,
.xv-player[data-state="playing"] .xv-speed-btn,
.xv-player[data-state="paused"] .xv-speed-btn,
.xv-player.is-menu-open .xv-speed-btn {
    max-width: 3.2rem;
    min-width: var(--xv-size);
    margin-left: 0;
    opacity: 1;
    visibility: visible;
    border-width: 1px;
}
.xv-speed-btn { padding: 0 .4rem; font-size: .7rem; font-variant-numeric: tabular-nums; }

/* Right-aligned players grow to the left so Play/Pause never moves under the pointer. */
.xv-player--end { flex-direction: row-reverse; }
.xv-player--end .xv-stop,
.xv-player--end .xv-speed-btn { margin-left: 0; margin-right: -.25rem; }
.xv-player--end[data-state="playing"] .xv-stop,
.xv-player--end[data-state="paused"] .xv-stop,
.xv-player--end[data-state="loading"] .xv-stop,
.xv-player--end[data-state="playing"] .xv-speed-btn,
.xv-player--end[data-state="paused"] .xv-speed-btn,
.xv-player--end.is-menu-open .xv-speed-btn { margin-right: 0; }

.xv-speed-menu {
    position: fixed;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 4.5rem;
    padding: .3rem;
    border: 1px solid rgba(148, 163, 184, .3);
    border-radius: .65rem;
    background: #121722;
    box-shadow: 0 14px 34px rgba(2, 6, 23, .55);
    animation: xv-pop .12s ease-out;
}
.xv-speed-menu button {
    height: 2rem;
    padding: 0 .75rem;
    border: 0;
    border-radius: .45rem;
    background: transparent;
    color: #d6deeb;
    font-size: .8rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.xv-speed-menu button:hover,
.xv-speed-menu button:focus-visible { background: rgba(56, 189, 248, .14); color: #fff; outline: none; }
.xv-speed-menu button.is-selected { background: rgba(56, 189, 248, .22); color: #7dd3fc; }
@keyframes xv-pop { from { opacity: 0; transform: translateY(-3px); } }

/* Wrapper used when a player is placed automatically after a block of text. */
.kokoro-tts-controls { display: inline-flex; align-items: center; margin: .35rem 0; }

/* Legacy preview/stop buttons are replaced by the player. */
.kokoro-tts-preview-btn[hidden], [data-kokoro-stop][hidden] { display: none !important; }

@media (pointer: coarse) {
    .xv-player { --xv-size: 2.25rem; }
    .xv-player--sm { --xv-size: 2.1rem; }
}
@media (prefers-reduced-motion: reduce) {
    .xv-btn, .xv-speed-menu { transition: none; animation: none; }
}
