/* --- SWIPE ANIMATIONS --- */
@keyframes slideOutLeft { 0% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(-60px); opacity: 0; } }
@keyframes slideInRight { 0% { transform: translateX(60px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { 0% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(60px); opacity: 0; } }
@keyframes slideInLeft { 0% { transform: translateX(-60px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }

.tab-content { display: none; width: 100%; }
.tab-content.active { display: block; opacity: 1; transform: translateX(0); }
.tab-content.slide-out-left { display: block; animation: slideOutLeft var(--swipe-speed) ease-in forwards; }
.tab-content.slide-in-right { display: block; animation: slideInRight var(--swipe-speed) ease-out forwards; }
.tab-content.slide-out-right { display: block; animation: slideOutRight var(--swipe-speed) ease-in forwards; }
.tab-content.slide-in-left { display: block; animation: slideInLeft var(--swipe-speed) ease-out forwards; }

.teacher-review-notice {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid rgba(229, 9, 20, 0.9);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(98, 4, 11, 0.98), rgba(30, 5, 8, 0.98));
    color: #fff;
    font-weight: 700;
    line-height: 1.4;
}

.teacher-review-notice--top {
    position: sticky;
    top: 0;
    z-index: 10050;
    width: 100%;
    margin: 0;
    border-width: 0 0 2px;
    border-radius: 0;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.36);
}

.teacher-review-notice--error {
    border-color: #ff3944;
    background: linear-gradient(135deg, rgba(124, 7, 15, 0.99), rgba(43, 5, 9, 0.99));
    color: #fff;
}

.teacher-review-exit-link {
    display: inline-flex;
    align-items: center;
    margin-left: 12px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.58);
    border-radius: 999px;
    color: #fff;
    font-size: 0.86em;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.teacher-review-exit-link:hover,
.teacher-review-exit-link:focus-visible {
    border-color: #fff;
    background: #fff;
    color: #b20710;
    outline: none;
}

body.light-mode .teacher-review-notice {
    background: #fff1f2;
    border-color: #ff8f98;
    color: #8f0b13;
    box-shadow: none;
}

body.light-mode .teacher-review-notice--error {
    background: #fff8df;
    border-color: #d89a00;
    color: #6c4300;
}

body.light-mode .teacher-review-exit-link {
    border-color: rgba(143, 11, 19, 0.45);
    color: #8f0b13;
}

body.light-mode .teacher-review-exit-link:hover,
body.light-mode .teacher-review-exit-link:focus-visible {
    background: #8f0b13;
    color: #fff;
}

@media (max-width: 700px) {
    .teacher-review-exit-link {
        margin: 8px 0 0;
    }
}

.points-award-overlay {
    position: fixed;
    top: max(18px, env(safe-area-inset-top));
    left: 50%;
    z-index: 2147483647;
    display: flex;
    align-items: baseline;
    gap: 12px;
    width: max-content;
    max-width: calc(100vw - 24px);
    padding: 8px 10px;
    border: 0;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    transform: translate(-50%, calc(-100% - 70px));
    opacity: 0;
    will-change: transform, opacity;
    -webkit-tap-highlight-color: transparent;
}

.points-award-overlay,
.rank-change-overlay,
.leaderboard-modal-overlay,
.leaderboard-help-overlay {
    --bg-primary: var(--container-bg-dark);
    --bg-secondary: #181818;
    --text-primary: var(--text-color-dark);
    --text-secondary: rgba(255, 255, 255, 0.72);
    --accent-primary: var(--primary-color);
    --border-color: #3a3a3a;
}

body.light-mode .points-award-overlay,
body.light-mode .rank-change-overlay,
body.light-mode .leaderboard-modal-overlay,
body.light-mode .leaderboard-help-overlay {
    --bg-primary: var(--container-bg-light);
    --bg-secondary: #f3f4f6;
    --text-primary: var(--text-color-light);
    --text-secondary: rgba(20, 20, 20, 0.68);
    --accent-primary: var(--primary-color);
    --border-color: #d9d9d9;
}

.points-award-overlay::before {
    content: "";
    position: absolute;
    inset: -12px -20px;
    z-index: -1;
    border-radius: 22px;
    background: color-mix(in srgb, var(--background-color-dark) 52%, transparent);
    backdrop-filter: blur(14px) brightness(0.72) saturate(0.72);
    -webkit-backdrop-filter: blur(14px) brightness(0.72) saturate(0.72);
    mask-image: radial-gradient(ellipse at center, #000 54%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 54%, transparent 100%);
}

body.light-mode .points-award-overlay::before {
    background: color-mix(in srgb, var(--container-bg-light) 82%, transparent);
    backdrop-filter: blur(14px) brightness(1.06) saturate(1.05);
    -webkit-backdrop-filter: blur(14px) brightness(1.06) saturate(1.05);
}

.points-award-total {
    color: var(--primary-color);
    font-size: clamp(1.55rem, 6vw, 2.25rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    text-shadow:
        0 1px 0 var(--background-color-dark),
        1px 0 0 var(--background-color-dark),
        0 -1px 0 var(--background-color-dark),
        -1px 0 0 var(--background-color-dark),
        0 4px 16px rgba(229, 9, 20, 0.38);
}

body.light-mode .points-award-total {
    text-shadow:
        0 1px 0 var(--container-bg-light),
        1px 0 0 var(--container-bg-light),
        0 -1px 0 var(--container-bg-light),
        -1px 0 0 var(--container-bg-light),
        0 4px 16px rgba(229, 9, 20, 0.28);
}

.points-award-gain {
    color: #22c55e;
    font-size: clamp(0.95rem, 3.8vw, 1.25rem);
    font-weight: 850;
    opacity: 0;
    transform: translateY(8px);
    text-shadow:
        0 1px 0 var(--background-color-dark),
        1px 0 0 var(--background-color-dark),
        0 -1px 0 var(--background-color-dark),
        -1px 0 0 var(--background-color-dark);
}

body.light-mode .points-award-gain {
    color: #16803a;
    text-shadow:
        0 1px 0 var(--container-bg-light),
        1px 0 0 var(--container-bg-light),
        0 -1px 0 var(--container-bg-light),
        -1px 0 0 var(--container-bg-light);
}

.points-award-overlay.is-entering,
.points-award-overlay.is-counting {
    opacity: 1;
    transform: translate(-50%, 0);
    transition: transform 0.95s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.points-award-overlay.is-entering .points-award-gain,
.points-award-overlay.is-counting .points-award-gain {
    animation: points-gain-rise 2.2s 0.62s ease-out both;
}

.points-award-overlay.is-exiting {
    opacity: 0;
    transform: translate(-50%, calc(-100% - 70px));
    transition: transform 0.72s cubic-bezier(0.7, 0, 0.84, 0), opacity 0.42s ease 0.12s;
}

@keyframes points-gain-rise {
    0% {
        opacity: 0;
        transform: translateY(9px);
    }
    25% {
        opacity: 1;
        transform: translateY(0);
    }
    72% {
        opacity: 1;
        transform: translateY(-5px);
    }
    100% {
        opacity: 0;
        transform: translateY(-22px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .points-award-overlay,
    .points-award-gain {
        transition-duration: 0.08s !important;
        animation-duration: 0.16s !important;
    }
}

.rank-change-overlay {
    position: fixed;
    top: max(22px, env(safe-area-inset-top));
    left: 50%;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-width: 160px;
    padding: 10px 18px;
    border: 0;
    border-radius: 18px;
    background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
    box-shadow: 0 12px 30px rgb(15 23 42 / 22%);
    backdrop-filter: blur(16px) saturate(1.15);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
    cursor: pointer;
    opacity: 0;
    transform: translate(-50%, -22px) scale(0.94);
    overflow: hidden;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
}

.rank-change-overlay.is-rank-start,
.rank-change-overlay.is-rank-arrow,
.rank-change-overlay.is-rank-complete {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
    transition: opacity 0.5s ease, transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
}

.rank-change-overlay.is-rank-exiting {
    opacity: 0;
    transform: translate(-50%, -18px) scale(0.97);
    transition: opacity 0.55s ease, transform 0.7s ease;
}

.rank-change-position {
    position: relative;
    color: var(--text-primary);
    font-size: clamp(1.25rem, 5vw, 1.65rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    white-space: nowrap;
}

.rank-change-position.is-previous {
    width: 58px;
    transform: translateX(0);
    text-align: center;
    transition:
        color 0.65s ease,
        opacity 0.65s ease,
        transform 1.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.rank-change-arrow {
    width: 42px;
    margin: 0 12px;
    opacity: 1;
    transform: scaleX(1);
    transform-origin: center;
    transition:
        width 1.15s cubic-bezier(0.16, 1, 0.3, 1),
        margin 1.15s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.48s ease,
        transform 1.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.rank-change-arrow svg {
    display: block;
    width: 42px;
    height: 22px;
    overflow: visible;
}

.rank-change-arrow path {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.rank-change-position.is-current {
    width: 58px;
    max-width: 58px;
    opacity: 0;
    transform: scale(0.9);
    text-align: center;
    transition:
        opacity 0.62s ease 0.22s,
        transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.rank-change-overlay.is-rank-arrow .rank-change-position.is-current,
.rank-change-overlay.is-rank-complete .rank-change-position.is-current {
    max-width: 58px;
    opacity: 1;
    transform: scale(1);
}

.rank-change-overlay.is-rank-arrow .rank-change-position.is-current {
    opacity: 0.28;
    transform: scale(0.96);
}

.rank-change-overlay.is-rank-complete .rank-change-position.is-current {
    opacity: 1 !important;
    transform: scale(1) !important;
    color: var(--accent-primary);
    text-shadow: 0 0 18px color-mix(in srgb, var(--accent-primary) 38%, transparent);
}

.rank-change-sweep {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -34%;
    z-index: 3;
    width: 28%;
    opacity: 0;
    background: linear-gradient(105deg, transparent 5%, rgb(255 255 255 / 20%) 28%, rgb(255 255 255 / 95%) 50%, rgb(255 255 255 / 24%) 72%, transparent 95%);
    filter: blur(1px);
    transform: skewX(-16deg);
    pointer-events: none;
}

.rank-change-overlay.is-rank-arrow .rank-change-sweep {
    animation: rank-change-sweep 1.55s 0.45s cubic-bezier(0.45, 0, 0.2, 1) both;
}

.rank-change-overlay.is-rank-complete .rank-change-position.is-previous {
    color: var(--text-secondary);
    opacity: 0.42;
}

.rank-change-shine {
    position: absolute;
    inset: -8px -12px;
    opacity: 0;
    background: linear-gradient(110deg, transparent 25%, rgb(255 255 255 / 90%) 48%, transparent 68%);
    transform: translateX(-130%);
    pointer-events: none;
}

.rank-change-overlay.is-rank-complete .rank-change-shine {
    animation: rank-change-twinkle 1.15s 0.15s ease-out both;
}

@keyframes rank-change-twinkle {
    0% { opacity: 0; transform: translateX(-130%); }
    24% { opacity: 0.85; }
    65% { opacity: 0.55; }
    100% { opacity: 0; transform: translateX(130%); }
}

@keyframes rank-change-sweep {
    0% { left: -34%; opacity: 0; }
    12% { opacity: 0.9; }
    78% { opacity: 0.8; }
    100% { left: 112%; opacity: 0; }
}

.leaderboard-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 12060;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(7px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.leaderboard-modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.leaderboard-modal {
    width: min(540px, 100%);
    max-height: min(620px, calc(100dvh - 72px));
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid color-mix(in srgb, var(--accent-primary) 22%, var(--border-color));
    border-radius: 24px;
    background: var(--bg-primary);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.leaderboard-modal-overlay.is-open .leaderboard-modal {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.leaderboard-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-modal-header p {
    margin: 0 0 3px;
    color: var(--accent-primary);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.leaderboard-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.leaderboard-modal-header button,
.leaderboard-help-modal header button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.4rem;
}

.leaderboard-help-btn {
    width: calc(100% - 32px);
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 16px 0;
    border: 1px solid color-mix(in srgb, var(--accent-primary) 24%, var(--border-color));
    border-radius: 12px;
    background: color-mix(in srgb, var(--accent-primary) 7%, var(--bg-secondary));
    color: var(--accent-primary);
    cursor: pointer;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 800;
}

.leaderboard-help-btn span {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-size: 0.72rem;
    line-height: 1;
}

.leaderboard-period-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 14px 16px 8px;
    padding: 4px;
    border-radius: 14px;
    background: var(--bg-secondary);
}

.leaderboard-period-tabs button {
    border: 0;
    border-radius: 10px;
    padding: 9px 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 750;
}

.leaderboard-period-tabs button.is-active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 5px 14px color-mix(in srgb, var(--accent-primary) 28%, transparent);
}

.leaderboard-fixed-list {
    min-height: 385px;
    display: grid;
    grid-template-rows: repeat(7, minmax(48px, 1fr));
    gap: 6px;
    padding: 7px 16px 16px;
    overflow: hidden;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.leaderboard-row {
    min-width: 0;
    display: grid;
    grid-template-columns: 48px 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 15px;
    background: var(--bg-secondary);
}

.leaderboard-fixed-list.is-exiting.exit-right .leaderboard-row:not(.is-skeleton) {
    animation: leaderboard-row-exit-right 0.34s ease-in both;
    animation-delay: calc(var(--leaderboard-row-index, 0) * 0.04s);
}

.leaderboard-fixed-list.is-exiting.exit-left .leaderboard-row:not(.is-skeleton) {
    animation: leaderboard-row-exit-left 0.34s ease-in both;
    animation-delay: calc(var(--leaderboard-row-index, 0) * 0.04s);
}

.leaderboard-fixed-list.is-pre-enter .leaderboard-row:not(.is-skeleton) {
    opacity: 0;
    transform: translateY(385px) scale(0.94);
}

.leaderboard-fixed-list.is-entering .leaderboard-row:not(.is-skeleton) {
    animation: leaderboard-row-enter-up 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--leaderboard-row-index, 0) * 0.075s);
}

.leaderboard-row.is-current-user {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border-width: 2px;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 12%, transparent);
}

.leaderboard-row.is-current-user::after {
    content: "";
    position: absolute;
    inset: -70% auto -70% -45%;
    width: 24%;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, #ffffff 60%, transparent), transparent);
    transform: skewX(-18deg) translateX(-220%);
    animation: leaderboard-current-user-sheen 3.2s ease-in-out infinite;
    pointer-events: none;
}

.leaderboard-row.is-rank-1 {
    border-color: #d6a600;
    background: linear-gradient(100deg, color-mix(in srgb, #f7c948 22%, var(--bg-secondary)), var(--bg-secondary) 70%);
}

.leaderboard-row.is-rank-2 {
    border-color: #9aa4b2;
    background: linear-gradient(100deg, color-mix(in srgb, #cbd5e1 25%, var(--bg-secondary)), var(--bg-secondary) 70%);
}

.leaderboard-row.is-rank-3 {
    border-color: #b87333;
    background: linear-gradient(100deg, color-mix(in srgb, #cd7f32 21%, var(--bg-secondary)), var(--bg-secondary) 70%);
}

.leaderboard-rank {
    color: var(--accent-primary);
    font-weight: 900;
    text-align: center;
}

.leaderboard-rank.is-three-digit {
    font-size: 0.8rem;
    letter-spacing: 0;
}

.leaderboard-rank.is-four-plus-digits {
    font-size: 0.68rem;
    letter-spacing: 0;
}

.leaderboard-flag-button {
    width: 30px;
    height: 22px;
    display: block;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
}

.leaderboard-flag {
    width: 30px;
    height: 22px;
    display: block;
    border-radius: 4px;
    object-fit: cover;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.leaderboard-flag.is-loading {
    background: linear-gradient(90deg, var(--border-color), var(--bg-primary), var(--border-color));
    background-size: 200% 100%;
    animation: leaderboard-shimmer 1.15s linear infinite;
}

.leaderboard-username {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    color: var(--text-primary);
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-points {
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 800;
    white-space: nowrap;
}

.leaderboard-message {
    grid-row: 1 / -1;
    align-self: center;
    margin: 0;
    color: var(--text-secondary);
    text-align: center;
}

.leaderboard-message.is-loading {
    animation: leaderboard-loading-pulse 0.9s ease-in-out infinite alternate;
}

.leaderboard-help-overlay {
    position: fixed;
    inset: 0;
    z-index: 12070;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.24s ease;
}

.leaderboard-help-overlay.is-open {
    opacity: 1;
}

.leaderboard-help-modal {
    width: min(430px, 100%);
    max-height: min(560px, calc(100dvh - 72px));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px;
    border: 1px solid color-mix(in srgb, var(--accent-primary) 24%, var(--border-color));
    border-radius: 22px;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
    opacity: 0;
    transform: translateY(22px) scale(0.94);
    transition: opacity 0.26s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.leaderboard-help-overlay.is-open .leaderboard-help-modal {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.leaderboard-help-overlay.is-closing .leaderboard-help-modal {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
}

.leaderboard-help-modal header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.leaderboard-help-modal h3 {
    margin: 0;
    font-size: 1.25rem;
}

.leaderboard-help-modal header button {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.35rem;
}

.leaderboard-help-list {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

.leaderboard-help-item {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: center;
    gap: 8px 10px;
    padding: 11px 12px;
    border: 1px solid var(--border-color);
    border-radius: 13px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.leaderboard-help-item.has-action {
    grid-template-columns: 112px minmax(0, 1fr) auto;
}

.leaderboard-help-item p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.35;
}

.leaderboard-help-limit {
    display: block;
    color: var(--text-primary);
    font-size: 0.76rem;
    font-weight: 800;
    text-align: left;
    white-space: nowrap;
}

.leaderboard-help-count-value {
    font-weight: 900;
}

.leaderboard-help-count-value.is-progress-light {
    color: #22c55e;
}

.leaderboard-help-count-value.is-progress-medium {
    color: #f59e0b;
}

.leaderboard-help-count-value.is-progress-dark {
    color: #ff1f1f;
}

.leaderboard-help-count-rest {
    color: var(--text-primary);
}

.leaderboard-help-count-suffix {
    color: var(--text-primary);
}

.leaderboard-help-activity-btn {
    flex: 0 0 auto;
    min-height: 38px;
    border: 0;
    border-radius: 12px;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem !important;
    font-weight: 850;
    line-height: 1 !important;
}

.leaderboard-help-activity-btn.is-flashcards {
    width: 44px;
    padding: 7px 10px;
}

.leaderboard-help-activity-btn.is-flashcards svg {
    display: block;
    width: 24px;
    height: 24px;
}

.leaderboard-help-activity-btn.is-study-now {
    padding: 9px 12px;
}

.leaderboard-help-done-btn {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    font: inherit;
    font-weight: 850;
}

@keyframes leaderboard-row-exit-right { to { opacity: 0; transform: translateX(125%); } }
@keyframes leaderboard-row-exit-left { to { opacity: 0; transform: translateX(-125%); } }
@keyframes leaderboard-row-enter-up {
    from { opacity: 0; transform: translateY(385px) scale(0.94); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes leaderboard-loading-pulse { to { opacity: 0.48; } }
@keyframes leaderboard-current-user-sheen {
    0%, 54% { transform: skewX(-18deg) translateX(-220%); }
    100% { transform: skewX(-18deg) translateX(760%); }
}
@keyframes leaderboard-shimmer { to { background-position: -220% 0; } }

@media (max-width: 420px) {
    .leaderboard-row {
        grid-template-columns: 38px 27px minmax(0, 1fr) minmax(58px, auto);
        gap: 7px;
        padding-inline: 8px;
    }

    .leaderboard-points {
        max-width: 74px;
        overflow: hidden;
        font-size: 0.72rem;
        text-overflow: ellipsis;
    }
}

.tab-image-container {
    position: relative;
    width: 100%;
    height: 250px;
    background-size: cover;
    background-position: center;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.deferred-bg-image {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
    filter: saturate(0.94);
    transition:
        opacity 0.55s ease,
        transform 0.65s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.45s ease;
}

.deferred-bg-image.is-loaded {
    opacity: 1;
    transform: none;
    filter: none;
}

.tab-image-container.deferred-bg-image {
    background-color: rgba(255, 255, 255, 0.06);
}

body.light-mode .tab-image-container.deferred-bg-image {
    background-color: #ececec;
}

.tab-image-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0);
    border-radius: 10px;
}

.tab-image-container h2 {
    position: relative;
    z-index: 1;
    color: var(--primary-color);
    margin: 0;
    padding: 0;
    border-bottom: none !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    text-align: center;
}


body.light-mode .tab-image-container h2 {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* --- TYPOGRAPHY & LISTS --- */
h2 {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid #333;
    padding-bottom: 15px;
    margin-bottom: 25px;
    font-size: 1.8em;
}
body.light-mode h2 { border-bottom-color: #eee; }

ul { list-style-type: none; padding: 0; }
li { margin-bottom: 15px; line-height: 1.6; font-size: 1.1em; }
p { line-height: 1.8; font-size: 1.1em; margin-bottom: 20px; }
.reading-content .title-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.reading-content h2 {
    margin-bottom: 0;
    width: 100%;
}

.reading-content h3 { color: var(--primary-color); margin-top: 30px; }
body.light-mode .reading-content h3 { color: #333; }

.article-part {
    position: relative;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.3s;
}

.article-part:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.article-part.editing {
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.2);
}

.reading-source-footer {
    margin-top: 28px;
    padding-top: 14px;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.35) 1.2px, transparent 1.3px);
    background-position: top left;
    background-repeat: repeat-x;
    background-size: 5px 2px;
    text-align: right;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.75);
}

.reading-source-footer span {
    display: inline-block;
}

body.light-mode .reading-source-footer {
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.2) 1.2px, transparent 1.3px);
    color: rgba(0, 0, 0, 0.65);
}

/* --- WARMUP & DISCUSSION HOVER EFFECTS --- */
#warmup li, #discussion li {
    padding: 15px 20px;
    border-left: 4px solid transparent;
    border-radius: 8px;
    transition: all 0.3s var(--smooth);
    cursor: default;
    position: relative;
}

#warmup li:hover, #discussion li:hover {
    background-color: rgba(229, 9, 20, 0.15); /* Light red tint */
    border-left-color: var(--primary-color); /* Red accent line */
    padding-left: 25px; /* Slide text */
    transform: scale(1.02); /* Lift */
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

body.light-mode #warmup li:hover, body.light-mode #discussion li:hover {
    background-color: rgba(229, 9, 20, 0.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

body.edit-mode-enabled #warmup li:hover,
body.edit-mode-enabled #discussion li:hover {
    padding-left: 56px;
}

/* --- INTERACTIVE QUESTIONS --- */
.question { margin-bottom: 30px; padding: 20px; padding-bottom: 40px; border-radius: 10px; transition: background-color 0.3s; position: relative; }
.question:hover { background-color: rgba(255,255,255,0.03); }
body.light-mode .question:hover { background-color: rgba(0,0,0,0.03); }
.question p { font-weight: 700; margin-bottom: 15px; }

.options li {
    padding: 15px 20px; border: 2px solid #444; border-radius: 8px; cursor: pointer;
    transition: all 0.3s var(--smooth); position: relative; background: transparent;
}
body.light-mode .options li { border-color: #ddd; }
.options li:hover { border-color: #888; transform: translateX(10px); background-color: rgba(255,255,255,0.05); }
body.light-mode .options li:hover {
    background-color: rgba(0,0,0,0.05);
}
.options li.selected { border-color: var(--primary-color); background-color: rgba(229, 9, 20, 0.1); transform: scale(1.02); font-weight: bold; }
body.light-mode .options li.selected {
    border-width: 3px;
    border-color: #c30f18;
    background-color: rgba(229, 9, 20, 0.14);
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.14);
}

.tf-question {
    padding: 20px; border: 2px solid #444; border-radius: 10px;
    display: flex; justify-content: space-between; align-items: center; gap: 20px;
    transition: all 0.3s var(--smooth); margin-bottom: 15px;
    position: relative;
    padding-bottom: 50px;
}

body:not(.edit-mode-enabled) .tf-question {
    padding-bottom: 20px;
}
body.light-mode .tf-question { border-color: #ddd; }
.tf-question:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.tf-options { display: flex; gap: 10px; }

.tf-btn {
    padding: 10px 25px; border: 2px solid transparent; background-color: #333; color: #fff;
    cursor: pointer; border-radius: 50px; font-weight: bold; transition: all 0.3s var(--bounce);
}
body.light-mode .tf-btn { background-color: #eee; color: #333; }
.tf-btn:hover { transform: scale(1.1); }
.tf-btn.selected { background-color: var(--primary-color); box-shadow: 0 0 15px var(--primary-color); color: white; }
body.light-mode .tf-btn.selected {
    background-color: rgba(229, 9, 20, 0.14);
    color: #8f0b13;
    border-color: #c30f18;
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.14);
}

/* Feedback Animations */
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulseGreen { 0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); transform: scale(1); } 50% { transform: scale(1.05); } 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); transform: scale(1); } }

.correct { background-color: var(--correct-color-dark) !important; border-color: #2f9246 !important; animation: pulseGreen 0.6s; }
.incorrect { background-color: var(--incorrect-color-dark) !important; border-color: #cf3c4f !important; animation: shake 0.4s; }
.missing { background-color: rgba(214, 126, 0, 0.2) !important; border-color: #d67e00 !important; }
body.light-mode .correct { background-color: var(--correct-color-light) !important; border-color: #2f9246 !important; }
body.light-mode .incorrect { background-color: var(--incorrect-color-light) !important; border-color: #cf3c4f !important; }
body.light-mode .missing { background-color: #fff3cd !important; border-color: #d99a00 !important; }
.show-correct { border-color: #2f9246 !important; box-shadow: 0 0 15px #2f9246; transform: scale(1.02); }

.teacher-review-missing-note {
    margin-top: 12px;
    color: #ffb347;
    font-weight: 700;
}

body.light-mode .teacher-review-missing-note {
    color: #8a5a00;
}

.answers-checked .tf-question.correct .tf-btn.selected {
    background-color: #2f9246 !important;
    color: #fff !important;
    border-color: #58c472 !important;
    box-shadow: 0 0 0 2px rgba(88, 196, 114, 0.24), 0 0 16px rgba(47, 146, 70, 0.45) !important;
}

.answers-checked .tf-question.incorrect .tf-btn.selected {
    background-color: var(--primary-color) !important;
    color: #fff !important;
    border-color: #ff6b74 !important;
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.24), 0 0 16px rgba(229, 9, 20, 0.4) !important;
}

body.light-mode .answers-checked .options li.selected {
    border-color: #c30f18 !important;
    border-width: 3px !important;
    background-color: #fde7e8 !important;
    box-shadow: none !important;
}

body.light-mode .answers-checked .options li.selected.correct {
    border-color: #2f9246 !important;
    border-width: 3px !important;
    background-color: #eef9f1 !important;
    box-shadow: none !important;
}

body.light-mode .answers-checked .options li.selected.incorrect {
    border-color: #c30f18 !important;
    border-width: 3px !important;
    background-color: #fde7e8 !important;
    box-shadow: none !important;
}

body.light-mode .answers-checked .tf-btn.selected {
    background-color: #fde7e8 !important;
    color: #8f0b13 !important;
    border-color: #c30f18 !important;
    border-width: 3px !important;
    box-shadow: none !important;
}

body.light-mode .answers-checked .tf-question.incorrect .tf-btn.selected {
    background-color: #fde7e8 !important;
    color: #8f0b13 !important;
    border-color: #c30f18 !important;
    border-width: 3px !important;
    box-shadow: none !important;
}

body.light-mode .answers-checked .tf-question.correct .tf-btn.selected {
    background-color: #eef9f1 !important;
    color: #185b2a !important;
    border-color: #2f9246 !important;
    border-width: 3px !important;
    box-shadow: none !important;
}

.answers-checked .options li,
.answers-checked .tf-btn {
    pointer-events: none;
}

/* --- BUTTONS --- */
.answers-actions { text-align: center; margin-top: 40px; }
[hidden] { display: none !important; }
.action-btn {
    background-color: var(--primary-color); color: #fff; border: none; padding: 14px 35px;
    font-size: 1.2em; font-weight: bold; border-radius: 50px; cursor: pointer;
    transition: all 0.3s var(--bounce); box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-transform: uppercase; letter-spacing: 1px; position: relative; overflow: hidden;
}
.action-btn:hover { background-color: var(--primary-hover); transform: translateY(-3px) scale(1.05); box-shadow: 0 10px 20px rgba(229, 9, 20, 0.4); }
.action-btn:active { transform: translateY(1px) scale(0.98); }
.action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.18);
}
.action-btn:disabled:hover {
    background-color: var(--primary-color);
    transform: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.18);
}
.reset-btn { background-color: #555; display: none; }
.reset-btn:hover { background-color: #666; box-shadow: 0 10px 20px rgba(0,0,0,0.3); }

.score-display {
    text-align: center;
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--text-color-dark);
    padding: 10px;
    border-radius: 5px;
    background-color: rgba(0,0,0,0.2);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out;
}

body.light-mode .score-display {
    color: var(--text-color-light);
    background-color: rgba(255,255,255,0.5);
}

/* --- FLASHCARDS & MATCHING GAME --- */
.flashcard-instructions { text-align: center; margin: -10px 0 30px 0; color: #aaa; font-style: italic; }

.flashcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 30px; padding: 10px; }
.flashcard { background-color: transparent; height: 220px; perspective: 1000px; cursor: pointer; position: relative; display: flex; flex-direction: column; }
.flashcard:hover .flashcard-inner { transform: translateY(-10px) rotateX(5deg); box-shadow: 0 15px 35px rgba(0,0,0,0.4); }

.flashcard-inner {
    position: relative; width: 100%; height: 100%;
    transition: transform 0.6s var(--bounce), box-shadow 0.3s;
    transform-style: preserve-3d; box-shadow: var(--shadow-dark); border-radius: 15px;
}
body.light-mode .flashcard-inner { box-shadow: var(--shadow-light); }
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-front, .flashcard-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; display: flex;
    align-items: center; justify-content: center;
    padding: 30px; box-sizing: border-box;
    border-radius: 15px; color: #fff;
    text-align: center; flex-direction: column;
    transform-style: preserve-3d;
}

.flashcard-front p {
    margin-bottom: 20px;
}

.audio-button-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    backface-visibility: hidden;
}

.audio-button {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
    position: relative;
}

.audio-button::after {
    content: '';
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    border-radius: 50%;
    z-index: 1;
}

.audio-button:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.audio-button img {
    width: 24px;
    height: 24px;
    filter: invert(1);
}

.audio-button.loading img {
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}
.flashcard-front { background: linear-gradient(135deg, var(--primary-color), #b2070f); font-weight: 800; font-size: 1.8em; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.flashcard-back { background: linear-gradient(135deg, var(--light-red-color), #d32f2f); transform: rotateY(180deg); font-size: 1.1em; line-height: 1.5; font-weight: 500; box-shadow: inset 0 0 20px rgba(0,0,0,0.1); }

/* MATCHING GAME STYLES */
.matching-wrapper { display: none; width: 100%; }
.matching-grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.match-item {
    background-color: #2a2a2a; border: 2px solid #444; border-radius: 8px;
    padding: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    text-align: center; font-weight: 500; transition: transform 0.4s var(--smooth), background-color 0.3s; min-height: 60px;
    position: relative; z-index: 1;
}

.defs-col .match-item {
    font-size: 0.9em;
}
body.light-mode .match-item { background-color: #fff; border-color: #ddd; }
.match-item:hover { transform: scale(1.02); border-color: #888; z-index: 2; }

.match-item.selected { border-color: var(--primary-color); background-color: rgba(229, 9, 20, 0.1); transform: scale(1.05); box-shadow: 0 5px 15px rgba(229,9,20,0.2); z-index: 3; }
.match-item.matched { 
    background-color: rgba(46, 204, 113, 0.2) !important; 
    border-color: #2f9246 !important; 
    opacity: 0.8; pointer-events: none; 
    z-index: 1;
}
.match-item.match-error { animation: shake 0.4s; background-color: rgba(229, 9, 20, 0.2); border-color: var(--primary-color); }

.match-group {
    display: grid;
    gap: 15px;
}

.group-separator {
    grid-column: 1 / -1;
    border: none;
    height: 2px;
    background-color: var(--primary-color);
    margin: 20px 0;
}

/* --- PARTICLES --- */
.particle { position: absolute; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; animation: particle-burst 1s ease-out forwards; }
@keyframes particle-burst { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; } }

/* --- MEDIA QUERIES --- */
@media (max-width: 1100px) {
    .main-wrapper { max-width: 100%; }
    .header, .tabs-container, .content-container { padding-left: 20px; padding-right: 20px; margin-left: 0; margin-right: 0; }
    .logo { font-size: 2em; }
    .tabs-container { overflow-x: auto; -ms-overflow-style: none; scrollbar-width: none; padding-bottom: 5px; scroll-behavior: smooth; }
    .tabs-container::-webkit-scrollbar { display: none; }
    .tabs { justify-content: flex-start; min-width: max-content; }
}

@media (max-width: 700px) {
    .matching-grid-layout { grid-template-columns: 1fr 1fr; gap: 10px; }
    .match-item { font-size: 0.9em; padding: 10px; min-height: 100px; }
    .tf-question { flex-direction: column; align-items: stretch; text-align: center; }
    .tf-options { justify-content: center; margin-top: 10px; }
}

/* --- AI DEFINITION TOOLTIP --- */
.clickable-word {
    cursor: pointer;
    transition: background-color 0.3s;
}

.user-clicked-highlight {
    background-color: rgba(229, 9, 20, 0.5); /* Darker red highlight */
    color: #ffffff !important;
    font-weight: inherit;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.5);
    text-shadow:
        0 0 0 currentColor,
        0.35px 0 0 currentColor,
        -0.35px 0 0 currentColor,
        0 0.35px 0 currentColor,
        0 1px 3px rgba(0,0,0,0.3);
    border-radius: 3px;
    padding: 0;
}

.esl-ai-tooltip {
    position: absolute;
    background-color: #1c1c1c;
    color: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10001;
    max-width: 350px;
    font-size: 1em;
    line-height: 1.6;
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: break-word;
    --tooltip-arrow-offset: 50%;
}

.esl-ai-tooltip::after {
    content: '';
    position: absolute;
    left: var(--tooltip-arrow-offset);
    width: 14px;
    height: 14px;
    background-color: inherit;
    border-right: 2px solid var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    transform: translateX(-50%) rotate(45deg);
    pointer-events: none;
}

.esl-ai-tooltip[data-placement="above"]::after {
    bottom: -9px;
}

.esl-ai-tooltip[data-placement="below"]::after {
    top: -9px;
    transform: translateX(-50%) rotate(225deg);
}

@media (max-width: 768px) {
    .esl-ai-tooltip {
        max-width: calc(100dvw - 20px);
        width: auto;
    }

    .esl-ai-tooltip.is-loading-state {
        width: auto;
        max-width: calc(100dvw - 20px);
    }
}

.esl-ai-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.esl-ai-tooltip strong {
    color: var(--primary-color);
}

.esl-ai-tooltip em {
    font-style: italic;
    color: #aaa;
}

.esl-ai-tooltip-entry + .esl-ai-tooltip-entry {
    margin-top: 12px;
}

.esl-ai-tooltip-divider {
    height: 1px;
    margin: 12px 0;
    background: rgba(255, 255, 255, 0.12);
}

.esl-ai-tooltip-entry-body {
    display: flex;
    align-items: flex-start;
}

.esl-ai-tooltip-audio-slot {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 42px;
    flex: 0 0 42px;
}

.esl-ai-tooltip-control-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.esl-ai-tooltip-text {
    min-width: 0;
    flex: 1 1 auto;
}

.esl-ai-tooltip-translation {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.3);
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.9);
}

.esl-ai-tooltip-translation-loader {
    display: inline-block;
    position: relative;
    overflow: hidden;
    width: 96px;
    max-width: 100%;
    height: 0.85em;
    border-radius: 999px;
    vertical-align: middle;
    background: rgba(255, 255, 255, 0.16);
}

.esl-ai-tooltip-translation-loader::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.58) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: esl-tooltip-translation-shimmer 0.9s ease-in-out infinite;
}

@keyframes esl-tooltip-translation-shimmer {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(100%);
    }
}

.esl-ai-tooltip-translation-value.is-typing::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: -0.12em;
    border-radius: 1px;
    background: currentColor;
    animation: esl-tooltip-translation-caret 0.7s step-end infinite;
}

.esl-ai-tooltip-translation-value.is-complete {
    animation: esl-tooltip-translation-reveal 0.18s ease-out both;
}

@keyframes esl-tooltip-translation-caret {
    0%, 45% {
        opacity: 1;
    }

    46%, 100% {
        opacity: 0;
    }
}

@keyframes esl-tooltip-translation-reveal {
    from {
        opacity: 0.72;
    }

    to {
        opacity: 1;
    }
}

.esl-audio-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(229, 9, 20, 0.1);
    border: 2px solid var(--primary-color);
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 0;
    margin-right: 10px;
    vertical-align: middle;
    border-radius: 999px;
    flex-shrink: 0;
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}

.esl-audio-control {
    position: relative;
    box-sizing: border-box;
    flex: 0 0 32px;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.esl-audio-control.is-entering {
    opacity: 0;
    transform: scale(0.82);
}

.esl-audio-control.is-exiting {
    opacity: 0;
    transform: scale(0.92);
    pointer-events: none;
}

.esl-audio-control.is-morphing {
    overflow: hidden;
}

.esl-audio-button svg {
    fill: var(--primary-color);
    transition: transform 0.2s;
    width: 16px;
    height: 16px;
    margin-left: 1px;
}

.esl-audio-button:hover svg {
    transform: scale(1.1);
}

.esl-audio-button:hover {
    background: rgba(229, 9, 20, 0.18);
}

.esl-audio-loader {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 10px;
    vertical-align: middle;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    flex-shrink: 0;
    transition: opacity 0.35s ease, transform 0.35s ease, border-color 0.35s ease, background-color 0.35s ease;
    cursor: default;
}

.esl-audio-loader-shimmer {
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.18) 45%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0.18) 55%, transparent 100%);
    animation: esl-audio-shimmer 1.1s linear infinite;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

@keyframes esl-audio-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.esl-audio-loader.is-timeout {
    opacity: 0.5;
    transform: scale(0.92);
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.esl-audio-loader.is-timeout .esl-audio-loader-shimmer {
    opacity: 0;
    animation: none;
}

.esl-wordlist-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    margin-right: 10px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    cursor: pointer;
    box-sizing: border-box;
    transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.25s ease, background-color 0.25s ease, color 0.25s ease;
}

.esl-wordlist-button:hover:not(:disabled) {
    transform: scale(1.06);
    border-color: var(--primary-color);
    background: rgba(229, 9, 20, 0.14);
}

.esl-wordlist-button:disabled {
    cursor: default;
}

.esl-wordlist-icon {
    position: absolute;
    width: 16px;
    height: 16px;
    opacity: 0;
    transform: scale(0.82);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.esl-wordlist-button.state-plus .plus-icon,
.esl-wordlist-button.state-loading .loading-icon,
.esl-wordlist-button.state-added .tick-icon,
.esl-wordlist-button.state-error .error-icon {
    opacity: 1;
    transform: scale(1);
}

.esl-wordlist-button.state-loading {
    border-color: rgba(255, 255, 255, 0.32);
    background: rgba(255, 255, 255, 0.08);
}

.esl-wordlist-button.state-loading .loading-icon {
    animation: esl-wordlist-spin 1s linear infinite;
}

.esl-wordlist-button.state-added {
    border-color: var(--primary-color);
    background: rgba(229, 9, 20, 0.16);
    color: #fff;
}

.esl-wordlist-button.state-error {
    border-color: #ff8f8f;
    background: rgba(255, 80, 80, 0.18);
    color: #fff;
}

@keyframes esl-wordlist-spin {
    from {
        transform: scale(1) rotate(0deg);
    }

    to {
        transform: scale(1) rotate(360deg);
    }
}

body.light-mode .user-clicked-highlight {
    background-color: rgba(229, 9, 20, 0.2);
    color: #000000 !important;
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.2);
}

body.light-mode .esl-ai-tooltip {
    background-color: #ffffff;
    color: #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

body.light-mode .esl-ai-tooltip em {
    color: #777;
}

body.light-mode .esl-ai-tooltip-divider {
    background: rgba(0, 0, 0, 0.08);
}

body.light-mode .esl-ai-tooltip-translation {
    border-top-color: rgba(0, 0, 0, 0.18);
    color: rgba(0, 0, 0, 0.72);
}

body.light-mode .esl-ai-tooltip-translation-loader {
    background: rgba(0, 0, 0, 0.1);
}

body.light-mode .esl-ai-tooltip-translation-loader::after {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.8) 50%,
        transparent 100%
    );
}

body.light-mode .esl-audio-button {
    background: rgba(229, 9, 20, 0.06);
}

body.light-mode .esl-audio-loader {
    border-color: rgba(0, 0, 0, 0.12);
    background: rgba(0, 0, 0, 0.04);
}

body.light-mode .esl-audio-loader.is-timeout {
    border-color: rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.02);
}

body.light-mode .esl-audio-loader-shimmer {
    background: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.08) 45%, rgba(0, 0, 0, 0.18) 50%, rgba(0, 0, 0, 0.08) 55%, transparent 100%);
}

body.light-mode .esl-wordlist-button {
    border-color: rgba(0, 0, 0, 0.14);
    background: rgba(0, 0, 0, 0.03);
    color: var(--primary-color);
}

body.light-mode .esl-wordlist-button:hover:not(:disabled) {
    background: rgba(229, 9, 20, 0.08);
}

body.light-mode .esl-wordlist-button.state-loading {
    border-color: rgba(0, 0, 0, 0.18);
    background: rgba(0, 0, 0, 0.06);
}

body.light-mode .esl-wordlist-button.state-added {
    border-color: var(--primary-color);
    background: rgba(229, 9, 20, 0.12);
    color: var(--primary-color);
}

body.light-mode .esl-wordlist-button.state-error {
    border-color: #cf3c4f;
    background: rgba(207, 60, 79, 0.12);
    color: #cf3c4f;
}

/* --- PARAGRAPH IMAGES --- */
.paragraph-image {
    width: 250px;
    height: 180px;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    margin-bottom: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.paragraph-image.deferred-bg-image {
    background-color: rgba(255, 255, 255, 0.06);
}

body.light-mode .paragraph-image.deferred-bg-image {
    background-color: #ececec;
}

.paragraph-image.align-right {
    float: right;
    margin-left: 20px;
}

.paragraph-image.align-left {
    float: left;
    margin-right: 20px;
}

@media (max-width: 600px) {
    .paragraph-image.align-right,
    .paragraph-image.align-left {
        float: none;
        margin: 0 auto 15px auto;
        width: 100%;
        height: 200px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .deferred-bg-image {
        transition: none;
        transform: none;
        filter: none;
    }
}
