.embedded-ime-engine {
    position: relative;
    display: flex;
    align-items: center;
}

/* 輸入法 group in the header: one white pill, [⌨ name ▾ | 💡], sized like the round icons. */
.ime-group {
    display: inline-flex;
    align-items: stretch;
    height: 46px;
    margin: 0 8px;
    border: 2px solid transparent;
    border-radius: 23px;
    background: #fff;
}

.ime-group .header-toggle-wrapper {
    display: flex;
    align-items: stretch;
}

.ime-group .ime-hint-anchor {
    border-left: 1px solid #e3e7ee;
}

.embedded-ime-engine-trigger,
.ime-hint-icon {
    display: inline-flex;
    align-items: center;
    border: 0;
    background: transparent;
    color: #5D84C1;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.embedded-ime-engine-trigger {
    gap: 8px;
    padding: 0 12px 0 16px;
    border-radius: 23px 0 0 23px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

/* One control alone in the group (x-show hid the other): round both ends. */
.ime-group:has(> .ime-hint-anchor[style*="display: none"]) .embedded-ime-engine-trigger,
.ime-group:has(> .embedded-ime-engine[style*="display: none"]) .ime-hint-icon {
    border-radius: 23px;
}

.ime-group:has(> .embedded-ime-engine[style*="display: none"]) .ime-hint-anchor {
    border-left: 0;
}

.embedded-ime-engine-trigger > .fa-keyboard {
    font-size: 18px;
}

.embedded-ime-engine-chevron {
    font-size: 11px;
    opacity: 0.7;
}

.ime-hint-icon {
    justify-content: center;
    width: 46px;
    border-radius: 0 23px 23px 0;
    font-size: 19px;
}

.embedded-ime-engine-trigger:hover,
.embedded-ime-engine-trigger.is-open,
.ime-hint-icon:hover {
    background: #f0f6ff;
    color: #365A92;
}

.ime-hint-icon.is-on {
    background: var(--theme-accent, #5D84C1);
    color: #fff;
}

.ime-hint-icon.is-on:hover {
    background: var(--theme-accent-strong, #365A92);
    color: #fff;
}

@media (max-width: 1180px) {
    .ime-group {
        height: 40px;
        margin: 0 4px;
    }

    .embedded-ime-engine-trigger {
        padding: 0 10px 0 12px;
        font-size: 13px;
    }

    .ime-hint-icon {
        width: 40px;
        font-size: 17px;
    }
}

@media (max-width: 600px) {
    .ime-group {
        height: 36px;
    }

    .ime-hint-icon {
        width: 36px;
    }
}

#embedded-ime-dialog {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 10000;
    width: 280px;
}

.embedded-ime-dialog-content {
    background: #f6f6f6;
    border: 2px solid #fff;
    border-radius: 18px;
    padding: 14px 14px 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    position: relative;
}

.embedded-ime-dialog-tip {
    position: absolute;
    top: -11px;
    right: 18px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #fff;
}

.embedded-ime-field + .embedded-ime-field {
    margin-top: 12px;
}

.embedded-ime-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #333;
}

/* One list for one choice: 電腦輸入法 or a platform scheme. */
.embedded-ime-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.embedded-ime-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font: inherit;
    text-align: left;
    color: #333;
    cursor: pointer;
}

.embedded-ime-option:hover:not(.is-on):not(.is-fixed) {
    background: #eef3fb;
}

.embedded-ime-option.is-on {
    background: #e3ecf8;
}

.embedded-ime-option.is-fixed {
    cursor: default;
}

.embedded-ime-dot {
    /* border-box: the thicker 「selected」 border must not grow the dot and push the text. */
    box-sizing: border-box;
    flex: none;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    border: 2px solid #9aa3b2;
    border-radius: 50%;
    background: #fff;
}

.embedded-ime-option.is-on .embedded-ime-dot {
    border: 5px solid #365A92;
}

.embedded-ime-lock {
    flex: none;
    width: 16px;
    margin-top: 3px;
    font-size: 13px;
    text-align: center;
    color: #365A92;
}

.embedded-ime-option-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.embedded-ime-option-name {
    font-size: 14px;
    line-height: 1.4;
}

.embedded-ime-option.is-on .embedded-ime-option-name {
    font-weight: 600;
    color: #24456f;
}

.embedded-ime-option-desc {
    font-size: 12px;
    line-height: 1.4;
    color: #777;
}

.embedded-ime-options + .embedded-ime-field,
.embedded-ime-option.is-fixed + .embedded-ime-field {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e3e3e3;
}

/* 選字列: a small picture of each candidate layout. */
.embedded-ime-layouts {
    display: flex;
    gap: 6px;
}

.embedded-ime-layout {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 0;
    border: 1px solid #d5d5d5;
    border-radius: 10px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    color: #333;
    cursor: pointer;
}

.embedded-ime-layout.is-on {
    background: #eef3fb;
    border-color: #9eb6de;
    color: #24456f;
}

.embedded-ime-layout-pic {
    display: inline-flex;
    gap: 2px;
}

.embedded-ime-layout-pic.is-vertical {
    flex-direction: column;
}

.embedded-ime-layout-pic i {
    display: block;
    border-radius: 2px;
    background: currentColor;
    opacity: 0.5;
}

.embedded-ime-layout-pic.is-horizontal i {
    width: 8px;
    height: 6px;
}

.embedded-ime-layout-pic.is-vertical i {
    width: 16px;
    height: 3px;
}
