.sf-esp {
    --sf-esp-font-size: 36px;
    --sf-esp-radius: 22px;
    --sf-esp-pad: clamp(22px, 4vw, 46px);
    --sf-esp-word-fade-in: 1.2s;
    --sf-esp-translation-fade-in: 1.45s;
    --sf-esp-stage-fade-out: 1.8s;
    --sf-esp-translation-lift: 14px;
    --sf-esp-exit-lift: -18px;
    --sf-esp-button-bg: linear-gradient(180deg, rgba(255,255,255,.28) 0%, rgba(255,255,255,.16) 46%, rgba(255,255,255,.08) 100%);
    --sf-esp-button-bg-hover: linear-gradient(180deg, rgba(255,255,255,.46) 0%, rgba(226,232,240,.26) 46%, rgba(148,163,184,.15) 100%);
    --sf-esp-button-border: rgba(255,255,255,.34);
    --sf-esp-button-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 8px 18px rgba(0,0,0,.18);
    --sf-esp-button-hover-shadow: inset 0 1px 0 rgba(255,255,255,.38), 0 8px 20px rgba(0,0,0,.20), 0 0 0 1px rgba(251,146,60,.52), 0 0 14px rgba(249,115,22,.18);
    --sf-esp-green: linear-gradient(180deg, #4ade80 0%, #22c55e 48%, #15803d 100%);
    --sf-esp-green-hover: linear-gradient(180deg, #86efac 0%, #22c55e 48%, #166534 100%);
    --sf-esp-orange: linear-gradient(180deg, #fdba74 0%, #f97316 48%, #c2410c 100%);
    --sf-esp-orange-hover: linear-gradient(180deg, #fed7aa 0%, #fb923c 48%, #c2410c 100%);
    --sf-esp-volume-filled: rgba(226,232,240,.92);
    --sf-esp-volume-empty: rgba(148,163,184,.38);
    --sf-esp-scrub-filled: #22c55e;
    --sf-esp-scrub-empty: rgba(148,163,184,.34);
    box-sizing: border-box;
    width: min(100%, 980px);
    margin: 32px auto;
    padding: var(--sf-esp-pad);
    border-radius: var(--sf-esp-radius);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.sf-esp *,
.sf-esp *::before,
.sf-esp *::after {
    box-sizing: border-box;
}

.sf-esp--dark {
    color: #fff;
    background:
        radial-gradient(circle at top left, rgba(255,255,255,.16), transparent 34%),
        linear-gradient(135deg, #111827 0%, #0b1020 55%, #020617 100%);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

.sf-esp--light,
.sf-esp--card {
    --sf-esp-button-bg: linear-gradient(180deg, #fff 0%, #e2e8f0 48%, #cbd5e1 100%);
    --sf-esp-button-bg-hover: linear-gradient(180deg, #fff 0%, #eef2f7 45%, #cbd5e1 100%);
    --sf-esp-button-border: rgba(100,116,139,.42);
    --sf-esp-button-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 7px 16px rgba(15,23,42,.12);
    --sf-esp-button-hover-shadow: inset 0 1px 0 rgba(255,255,255,1), 0 8px 18px rgba(15,23,42,.14), 0 0 0 1px rgba(249,115,22,.44), 0 0 12px rgba(249,115,22,.14);
    --sf-esp-volume-filled: rgba(71,85,105,.9);
    --sf-esp-volume-empty: rgba(148,163,184,.42);
    --sf-esp-scrub-empty: rgba(100,116,139,.28);
}

.sf-esp--light {
    color: #111827;
    background: radial-gradient(circle at top left, rgba(17,24,39,.08), transparent 34%), linear-gradient(135deg, #fff 0%, #f8fafc 100%);
    border: 1px solid rgba(17,24,39,.12);
    box-shadow: 0 18px 50px rgba(15,23,42,.10);
}

.sf-esp--card {
    color: #111827;
    background: #fff;
    border: 1px solid rgba(17,24,39,.12);
    box-shadow: 0 12px 35px rgba(15,23,42,.10);
}

.sf-esp--minimal {
    color: inherit;
    background: transparent;
    border: 1px solid currentColor;
    box-shadow: none;
}

.sf-esp__topbar {
    min-height: 42px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    position: relative;
    z-index: 3;
}

.sf-esp__meta {
    min-width: 74px;
    display: grid;
    gap: 5px;
    justify-items: start;
    font-variant-numeric: tabular-nums;
}

.sf-esp__round-indicator,
.sf-esp__sentence-indicator {
    font-size: 12px;
    line-height: 1.2;
    letter-spacing: .08em;
    font-weight: 750;
    opacity: .58;
    transition: opacity .3s ease, transform .3s ease;
}

.sf-esp__sentence-indicator {
    opacity: 0;
    transform: translateY(-2px);
}

.sf-esp__sentence-indicator.is-visible {
    opacity: .72;
    transform: translateY(0);
}

.sf-esp__round-indicator--dots,
.sf-esp__round-indicator--numbered {
    display: flex;
    gap: 6px;
    align-items: center;
}

.sf-esp__round-mark {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1px solid currentColor;
    opacity: .35;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity .25s ease, background .25s ease, transform .25s ease;
}

.sf-esp__round-indicator--dots .sf-esp__round-mark.is-current {
    opacity: .95;
    background: currentColor;
    transform: scale(1.16);
}

.sf-esp__round-indicator--numbered .sf-esp__round-mark {
    width: 22px;
    height: 22px;
    font-size: 10px;
    font-weight: 800;
}

.sf-esp__round-indicator--numbered .sf-esp__round-mark.is-current {
    opacity: 1;
    color: #fff;
    background: linear-gradient(180deg, #fdba74, #f97316);
    border-color: rgba(253,186,116,.75);
    transform: translateY(-1px);
}

.sf-esp__logo {
    display: block;
    width: auto;
    object-fit: contain;
    object-position: right top;
    opacity: .92;
}

.sf-esp__logo--small { max-height: 34px; max-width: 130px; }
.sf-esp__logo--medium { max-height: 48px; max-width: 180px; }
.sf-esp__logo--large { max-height: 64px; max-width: 240px; }

.sf-esp__title {
    margin: 0 0 18px;
    font-size: clamp(15px, 2vw, 18px);
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    opacity: .82;
    text-align: center;
}

.sf-esp__stage {
    min-height: clamp(230px, 32vw, 390px);
    display: grid;
    align-content: center;
    justify-items: center;
    text-align: center;
    gap: 22px;
    padding: clamp(18px, 4vw, 40px) 10px;
}

.sf-esp__status { display: none; }

.sf-esp__word {
    min-height: 1.28em;
    font-size: clamp(26px, 5vw, var(--sf-esp-font-size));
    line-height: 1.22;
    font-weight: 750;
    letter-spacing: .01em;
    max-width: 920px;
    opacity: 0;
    transform: translateY(0);
    transition: opacity var(--sf-esp-word-fade-in) ease, transform var(--sf-esp-stage-fade-out) ease;
    text-wrap: balance;
    will-change: opacity, transform;
}

.sf-esp__word.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.sf-esp__word.is-exiting {
    opacity: 0;
    transform: translateY(var(--sf-esp-exit-lift));
    transition-duration: var(--sf-esp-stage-fade-out);
}

.sf-esp__word.is-typing::after {
    content: "";
    display: inline-block;
    width: .08em;
    height: .95em;
    margin-left: .08em;
    vertical-align: -.08em;
    background: currentColor;
    opacity: .7;
    animation: sfEspCursor 1s steps(2, start) infinite;
}

.sf-esp__translation {
    min-height: 1.35em;
    font-size: clamp(18px, 3.2vw, 28px);
    line-height: 1.34;
    max-width: 850px;
    opacity: 0;
    transform: translateY(var(--sf-esp-translation-lift));
    transition: opacity var(--sf-esp-translation-fade-in) ease, transform var(--sf-esp-translation-fade-in) ease;
    color: inherit;
    will-change: opacity, transform;
}

.sf-esp__translation.is-visible {
    opacity: .88;
    transform: translateY(0);
}

.sf-esp__translation.is-exiting {
    opacity: 0;
    transform: translateY(var(--sf-esp-exit-lift));
    transition-duration: var(--sf-esp-stage-fade-out);
}

.sf-esp__scrubber-wrap {
    position: relative;
    width: 100%;
    margin: 2px 0 20px;
    padding-top: 17px;
}

.sf-esp__scrubber {
    --sf-esp-scrub-pct: 0%;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--sf-esp-scrub-filled) 0%, var(--sf-esp-scrub-filled) var(--sf-esp-scrub-pct), var(--sf-esp-scrub-empty) var(--sf-esp-scrub-pct), var(--sf-esp-scrub-empty) 100%);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.28), 0 1px 0 rgba(255,255,255,.12);
    cursor: pointer;
}

.sf-esp__scrubber::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(180deg, #fff 0%, #dbe3ec 100%);
    border: 1px solid rgba(71,85,105,.62);
    box-shadow: 0 2px 9px rgba(0,0,0,.34), 0 0 0 3px rgba(34,197,94,.10);
    transition: transform .16s ease, box-shadow .16s ease;
}

.sf-esp__scrubber::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(180deg, #fff 0%, #dbe3ec 100%);
    border: 1px solid rgba(71,85,105,.62);
    box-shadow: 0 2px 9px rgba(0,0,0,.34), 0 0 0 3px rgba(34,197,94,.10);
}

.sf-esp__scrubber:hover::-webkit-slider-thumb { transform: scale(1.08); box-shadow: 0 3px 11px rgba(0,0,0,.36), 0 0 0 4px rgba(34,197,94,.16); }

.sf-esp__scrubber-bubble {
    position: absolute;
    top: -6px;
    transform: translateX(-50%);
    min-width: 46px;
    padding: 4px 7px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: rgba(15,23,42,.94);
    box-shadow: 0 6px 16px rgba(0,0,0,.24);
    pointer-events: none;
    z-index: 6;
}

.sf-esp__scrubber-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 8px;
    height: 8px;
    transform: translateX(-50%) rotate(45deg);
    background: inherit;
}

.sf-esp__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.sf-esp__button,
.sf-esp__volume {
    appearance: none;
    border: 1px solid var(--sf-esp-button-border);
    border-radius: 999px;
    background: var(--sf-esp-button-bg) !important;
    color: inherit !important;
    box-shadow: var(--sf-esp-button-shadow) !important;
    text-shadow: 0 1px 0 rgba(0,0,0,.15);
}

.sf-esp__button {
    font: inherit;
    font-size: 14px;
    line-height: 1;
    min-height: 40px;
    padding: 11px 16px;
    cursor: pointer;
    transition: transform .18s ease, background .2s ease, opacity .16s ease, box-shadow .2s ease, border-color .2s ease;
}

.sf-esp__button svg,
.sf-esp__volume svg {
    width: 19px;
    height: 19px;
    display: block;
}

.sf-esp--light .sf-esp__button,
.sf-esp--light .sf-esp__volume,
.sf-esp--card .sf-esp__button,
.sf-esp--card .sf-esp__volume {
    text-shadow: 0 1px 0 rgba(255,255,255,.8);
}

.sf-esp__button:hover:not(:disabled),
.sf-esp__volume:hover {
    transform: translateY(-1px);
    background: var(--sf-esp-button-bg-hover) !important;
    border-color: rgba(251,146,60,.64);
    box-shadow: var(--sf-esp-button-hover-shadow) !important;
}

.sf-esp__button:disabled {
    cursor: not-allowed;
    opacity: .42;
}

.sf-esp__button--primary {
    font-weight: 800;
    min-width: 92px;
    padding-inline: 24px;
}

.sf-esp__button--primary.is-start {
    background: var(--sf-esp-green) !important;
    border-color: rgba(134,239,172,.58);
    color: #fff !important;
}

.sf-esp__button--primary.is-start:hover {
    background: var(--sf-esp-green-hover) !important;
    border-color: rgba(134,239,172,.82);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.34), 0 8px 20px rgba(0,0,0,.20), 0 0 15px rgba(34,197,94,.22) !important;
}

.sf-esp__button--primary.is-playing,
.sf-esp__button--speed.is-selected,
.sf-esp__button--mode.is-selected,
.sf-esp__button--resume-continue {
    background: var(--sf-esp-orange) !important;
    border-color: rgba(253,186,116,.68);
    color: #fff !important;
}

.sf-esp__button--primary.is-playing:hover,
.sf-esp__button--speed.is-selected:hover,
.sf-esp__button--mode.is-selected:hover,
.sf-esp__button--resume-continue:hover {
    background: var(--sf-esp-orange-hover) !important;
}

.sf-esp__button--primary.is-resume { background: var(--sf-esp-button-bg) !important; }

.sf-esp__button--icon {
    width: 42px;
    min-width: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sf-esp__button--primary.is-playing,
.sf-esp__button--primary.is-resume {
    width: 48px;
    min-width: 48px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sf-esp__button--speed { min-width: 66px; font-weight: 700; }
.sf-esp__button--mode { font-size: 13px; font-weight: 700; }

.sf-esp__mode-group {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}

.sf-esp .sf-esp__button:focus,
.sf-esp .sf-esp__button:active {
    color: inherit !important;
    outline: 2px solid transparent;
}

.sf-esp .sf-esp__button:focus-visible,
.sf-esp .sf-esp__volume input:focus-visible,
.sf-esp .sf-esp__volume button:focus-visible,
.sf-esp .sf-esp__scrubber:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

.sf-esp__volume {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 5px 12px 5px 7px;
    transition: transform .18s ease, background .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.sf-esp__mute {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    width: 30px;
    height: 28px;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 999px;
}

.sf-esp__volume input[type="range"] {
    --sf-esp-volume-pct: 100%;
    appearance: none;
    width: 118px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--sf-esp-volume-filled) 0%, var(--sf-esp-volume-filled) var(--sf-esp-volume-pct), var(--sf-esp-volume-empty) var(--sf-esp-volume-pct), var(--sf-esp-volume-empty) 100%);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.32), 0 1px 0 rgba(255,255,255,.16);
    cursor: pointer;
}

.sf-esp__volume input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
    border: 1px solid rgba(71,85,105,.55);
    box-shadow: 0 2px 8px rgba(0,0,0,.30);
}

.sf-esp__volume input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
    border: 1px solid rgba(71,85,105,.55);
    box-shadow: 0 2px 8px rgba(0,0,0,.30);
}

.sf-esp__timer {
    min-width: 116px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
    opacity: .86;
    white-space: nowrap;
}

/* Optional per-sentence teaching highlights. */
.sf-esp__highlight {
    position: relative;
    display: inline-block;
    will-change: transform, color, opacity, text-shadow;
}

.sf-esp__highlight--underline-color {
    color: inherit;
    text-shadow: none;
    transition: color .62s ease, text-shadow .62s ease;
}

.sf-esp__highlight--underline-color::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -.12em;
    height: .10em;
    min-height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, #fdba74 0%, #f97316 100%);
    transform: scaleX(0);
    transform-origin: left center;
    opacity: 0;
    transition: transform .62s ease, opacity .62s ease;
}

.sf-esp__highlight--underline-color.is-active {
    color: #fb923c;
    text-shadow: 0 0 10px rgba(249,115,22,.18);
}

.sf-esp__highlight--underline-color.is-active::after {
    transform: scaleX(1);
    opacity: 1;
}

.sf-esp__highlight--lift {
    transform: translateY(0);
}

.sf-esp__highlight--lift.is-active {
    animation: sfEspHighlightLift .95s cubic-bezier(.22,.75,.28,1) 1 both;
}

.sf-esp__word.has-highlight--spotlight .sf-esp__spotlight-rest {
    opacity: 1;
    transition: opacity .58s ease;
}

.sf-esp__word.has-highlight--spotlight.is-highlight-active .sf-esp__spotlight-rest {
    opacity: .25;
}

.sf-esp__highlight--spotlight {
    opacity: .82;
    transition: opacity .58s ease, text-shadow .58s ease;
}

.sf-esp__highlight--spotlight.is-active {
    opacity: 1;
    text-shadow: 0 0 11px rgba(255,255,255,.24);
}

/* No audio spinner/pulse. */
.sf-esp.is-playing-audio .sf-esp__stage::before {
    content: none !important;
    display: none !important;
}

.sf-esp__resume-prompt {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(2,6,23,.68);
    backdrop-filter: blur(5px);
}

.sf-esp__resume-prompt[hidden] { display: none !important; }

.sf-esp__resume-card {
    width: min(100%, 430px);
    display: grid;
    gap: 12px;
    text-align: center;
    padding: 24px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(30,41,59,.98), rgba(15,23,42,.98));
    color: #fff;
    border: 1px solid rgba(255,255,255,.22);
    box-shadow: 0 24px 70px rgba(0,0,0,.38);
}

.sf-esp__resume-card strong { font-size: 20px; }
.sf-esp__resume-card span { opacity: .75; font-variant-numeric: tabular-nums; }
.sf-esp__resume-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }

.sf-esp:fullscreen {
    width: 100vw;
    max-width: none;
    height: 100vh;
    margin: 0;
    border-radius: 0;
    padding: clamp(28px, 5vw, 72px);
    display: flex;
    flex-direction: column;
}

.sf-esp:fullscreen .sf-esp__stage {
    flex: 1 1 auto;
    min-height: 0;
}

@keyframes sfEspCursor {
    0%, 45% { opacity: .7; }
    46%, 100% { opacity: 0; }
}

@keyframes sfEspHighlightLift {
    0% { transform: translateY(0); }
    45% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .sf-esp *,
    .sf-esp *::before,
    .sf-esp *::after {
        animation: none !important;
    }
}

@media (max-width: 767px) {
    .sf-esp {
        --sf-esp-word-fade-in: 1.4s;
        --sf-esp-translation-fade-in: 1.8s;
        --sf-esp-stage-fade-out: 1.9s;
        --sf-esp-translation-lift: 14px;
        --sf-esp-exit-lift: -18px;
    }

    .sf-esp__topbar { min-height: 34px; }
    .sf-esp__logo--small { max-height: 28px; max-width: 110px; }
    .sf-esp__logo--medium { max-height: 38px; max-width: 145px; }
    .sf-esp__logo--large { max-height: 48px; max-width: 180px; }
}

@media (max-width: 560px) {
    .sf-esp {
        margin: 22px auto;
        border-radius: 16px;
    }

    .sf-esp__controls { justify-content: center; }
    .sf-esp__volume { max-width: 100%; }
    .sf-esp__volume input[type="range"] { width: min(150px, 38vw); }
    .sf-esp__mode-group { width: 100%; justify-content: center; }
    .sf-esp__button--mode { flex: 0 1 auto; }
}
