.font-size-small .custom .text {
    font-size: 18px !important;
}

.font-size-normal .custom .text {
    font-size: 25px !important;
}

.font-size-large .custom .text {
    font-size: 35px !important;
}

.font-size-small .custom .char {
    height: 34px;
}

.font-size-normal .custom .char {
    height: 44px;
}

.font-size-large .custom .char {
    height: 54px;
}

/* 隱藏原生輸入容器 */
.input-container {
    /* opacity: 0 !important; */
}

/* 基礎容器 */
.custom {
    line-height: 1.8;
    padding: 24px;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    color: #e2e8f0;
}

/* 字組容器 - 採用微玻璃擬態與平滑過渡 */
.custom .word {
    background-color: transparent;
    border: none;
    ;
    border-radius: 12px;
    /* margin: 4px; */
    /* min-width: 50px; */
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 字組文字顯示 */
.custom .word .display {
    font-size: 38px;
    font-weight: 600;
    color: #94a3b8;
    line-height: 1.2;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    border-bottom: 4px solid transparent;
}

/* 字組文字容器 */
.custom .word-char-text-container {
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

/* 當前字組高亮 - 發光玻璃效果 */
.custom .word.current {
    transform: translateY(-2px);
}

.custom .word.current .word-char-text-container {
    background: rgba(255, 255, 255, 0.05);
    /* 支援深色模式的玻璃背景 */
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}

.custom .word .display.current {
    color: #ffffff;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
    border-bottom: 4px solid #6366f1;
}

/* 字符編碼顯示 */
.custom .chars {
    position: relative;
    gap: 4px;
    display: flex;
}

.custom .char {
    contain: layout style;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 2px;
    border: 1px solid transparent;
}

.custom .char .text {
    padding: 0 4px;
    font-size: 15px;
    font-weight: 500;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    color: #64748b;
}

.custom .char .code {
    padding: 0 4px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    color: #94a3b8;
}

.custom .word .display.current,
.char.current {
    border-bottom: none;
}



.custom .char.current {
    background: linear-gradient(135deg, #414141, #232323);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
    /* zoom: 1.1; */
    transform: scale(1.1);
}

.custom .char.current .code,
.custom .char.current .text {
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 正確輸入樣式 */
.custom .char.correct:not(.wrong):not(.once-wronged) {
    background: rgba(34, 197, 94, 0.1) !important;
    border: 1px solid rgba(34, 197, 94, 0.2);
    animation: success-pulse 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.custom .word .display.typed.correct,
.custom .char.typed.correct .code,
.custom .char.typed.correct .text,
.custom .display.correct {
    color: #22c55e !important;
    text-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
}

/* 曾經錯誤的提示 (Once Wronged) */
.custom .word .char.typed.correct.once-wronged,
.custom .char.typed.correct.once-wronged {
    background: rgba(234, 179, 8, 0.1) !important;
    border: 1px solid rgba(234, 179, 8, 0.2);
    animation: warning-pulse 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.custom .word .display.typed.correct.once-wronged {
    color: #eab308;
    background: transparent !important;
}

.custom .char.once-wronged.correct .code,
.custom .char.once-wronged.correct .text {
    color: #eab308 !important;
}

/* 錯誤輸入樣式 */
.custom .word .char.typed.wrong {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    animation: error-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

.custom .word .char.typed.wrong .code,
.custom .word .char.typed.wrong .text {
    color: #ef4444;
}

.custom .word .display.typed.wrong {
    color: #ef4444;
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    animation: error-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

.custom .char.typed.wrong {
    color: #ef4444;
}

/* 動畫定義 */
@keyframes success-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 10px 2px rgba(34, 197, 94, 0.2);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

@keyframes warning-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 10px 2px rgba(234, 179, 8, 0.2);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(234, 179, 8, 0);
    }
}

@keyframes error-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-4px);
    }

    40%,
    80% {
        transform: translateX(4px);
    }
}

/* 特殊處理 */
.custom .word .display.space::after {
    content: "⎵";
    color: #475569;
    font-size: 22px;
    opacity: 0.6;
}

.custom .char.code-space {
    display: block;
    position: absolute;
    bottom: -24px;
    width: 100%;
    text-align: center;
}

.custom .char.code-space .text::after {
    content: "\2423";
    color: #64748b;
}

/* 字體大小處理 */
.font-size-small .custom .char.code-space {
    bottom: -16px;
}

.font-size-normal .custom .char.code-space {
    bottom: -20px;
}

.font-size-large .custom .char.code-space {
    bottom: -28px;
}

.font-size-small .custom .chars {
    /* margin-bottom: 24px; */
}

.font-size-normal .custom .chars {
    /* margin-bottom: 28px; */
}

.font-size-large .custom .chars {
    /* margin-bottom: 36px; */
}

/* 提示框 */
.custom .word-img-container {
    display: none;
}

/* ── Compositor cursor (desktop: below IME textarea z-index 10001; iOS: textarea is z-index 0) ── */
.custom .article.compositor-cursor-active .word.current {
    transform: none;
}

.custom .article.compositor-cursor-active .typing-cursor-overlay {
    z-index: 0;
}

.custom .article.compositor-cursor-active .char .text {
    position: relative;
    z-index: 1;
}

.custom .article.compositor-cursor-active .char.cursor-target {
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
    font-weight: 600;
    color: white;
    z-index: 1;
}

.custom .article.compositor-cursor-active .char.cursor-target .text {
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.custom .article.compositor-cursor-active .typing-cursor-shell {
    background: linear-gradient(135deg, #414141, #232323);
    border: none;
    border-radius: 4px;
    outline: none;
    box-shadow: none;
}

.custom .article.compositor-cursor-active:not(.burst-typing) .typing-cursor-shell {
    animation: blinking-cursor 1s ease-in-out infinite;
    will-change: opacity;
}

.custom .article.burst-typing.compositor-cursor-active .typing-cursor-shell {
    animation: none;
    opacity: 1;
    will-change: auto;
}

/* ── Burst typing: suppress heavy transitions/animations ── */
.custom .article.burst-typing .word {
    transition: none;
}

.custom .article.burst-typing .word.current {
    transform: none;
}

.custom .article.burst-typing .word.current .word-char-text-container {
    backdrop-filter: none;
    transition: none;
}

.custom .article.burst-typing .char {
    transition: none;
}

.custom .article.burst-typing .char.correct,
.custom .article.burst-typing .char.wrong,
.custom .article.burst-typing .char.once-wronged,
.custom .article.burst-typing .char.typed.correct,
.custom .article.burst-typing .char.typed.wrong,
.custom .article.burst-typing .char.typed.correct.once-wronged,
.custom .article.burst-typing .word .display.typed.wrong {
    animation: none !important;
    transform: none !important;
}

.custom .article.burst-typing .char.typed.correct:not(.wrong):not(.once-wronged) {
    background: rgba(34, 197, 94, 0.1) !important;
}

/* ── Replay seek/stop bulk apply ── */
.custom .article.replay-bulk-apply .word {
    transition: none;
}

.custom .article.replay-bulk-apply .word.current {
    transform: none;
}

.custom .article.replay-bulk-apply .char.correct,
.custom .article.replay-bulk-apply .char.wrong,
.custom .article.replay-bulk-apply .char.once-wronged,
.custom .article.replay-bulk-apply .char.typed.correct,
.custom .article.replay-bulk-apply .char.typed.wrong {
    animation: none !important;
    transform: none !important;
}

.embedded-ime-candidates {
    position: fixed;
    z-index: 10003;
    width: max-content;
    max-width: min(560px, calc(100vw - 16px));
    padding: 4px;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #c5d0dc;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.embedded-ime-candidates[hidden] {
    display: none;
}

.embedded-ime-candidates-scroll {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    max-width: min(520px, calc(100vw - 24px));
    overflow-x: auto;
    overflow-y: hidden;
}

.embedded-ime-candidates--overlay-scroll:not(.embedded-ime-candidates--vertical) .embedded-ime-candidates-scroll {
    padding-bottom: 16px;
}

.embedded-ime-candidates--vertical .embedded-ime-candidates-scroll {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: max-content;
    min-width: 120px;
    max-width: none;
    max-height: calc(26px * 9);
    overflow-x: hidden;
    overflow-y: auto;
}

.embedded-ime-candidate {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    border: 1px solid transparent;
    background: #fff;
    border-radius: 4px;
    padding: 1px 8px 1px 4px;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

.embedded-ime-candidates--vertical .embedded-ime-candidate {
    height: 26px;
    justify-content: flex-start;
}

.embedded-ime-candidate i {
    flex: none;
    width: 1em;
    font-style: normal;
    font-size: 12px;
    color: #6b7785;
    font-family: sans-serif;
}

.embedded-ime-candidate:hover,
.embedded-ime-candidate.is-selected {
    border-color: #1976d2;
}

.embedded-ime-candidate.is-selected {
    background: #e7eef8;
}

.embedded-ime-candidates-empty {
    font-size: 14px;
    color: #5c6b7a;
    padding: 2px 4px;
}