#wling-switcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}

#wling-switcher .wling-flag {
    display: inline-flex;
    width: 40px;
    height: 40px;
    padding: 0;
    box-sizing: border-box;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    border: 2px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

#wling-switcher .wling-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

#wling-switcher .wling-flag:hover {
    transform: translateY(-2px);
}

#wling-switcher .wling-flag.wling-active {
    border-color: #111;
}

#wling-switcher .wling-flag-more {
    align-items: center;
    justify-content: center;
    color: #111;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    border: 2px solid transparent;
    cursor: pointer;
}

#wling-switcher .wling-flag-more[aria-expanded="true"] {
    border-color: #111;
}

#wling-switcher .wling-switcher-extra {
    position: absolute;
    right: 48px;
    bottom: 0;
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(4, 40px);
    gap: 8px;
}

#wling-switcher .wling-switcher-extra[hidden] {
    display: none !important;
}

#wling-translate-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: 360px;
    height: 100vh;
    max-height: none;
    overflow-y: auto;
    background: #111;
    color: #fff;
    border-radius: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 2147483647;
    padding: 18px 16px 20px;
    isolation: isolate;
}

body.admin-bar #wling-translate-panel {
    top: 32px;
    height: calc(100vh - 32px);
}

.wling-panel-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wling-panel-title {
    font-size: 18px;
    font-weight: 600;
}

.wling-panel-hint {
    font-size: 13px;
    opacity: 0.8;
}

.wling-panel-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wling-panel-meta-toggle {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
}

.wling-panel-meta-toggle::after {
    content: "+";
    float: right;
}

.wling-panel-meta-toggle.is-open::after {
    content: "-";
}

.wling-panel-meta-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wling-panel-meta-list[hidden] {
    display: none !important;
}

.wling-meta-item {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 8px;
    font-size: 11px;
    padding: 5px 8px;
    cursor: pointer;
}

.wling-meta-item.is-active {
    border-color: #00c853;
    background: rgba(0, 200, 83, 0.2);
}

.wling-meta-item.is-translated {
    border-color: rgba(0, 200, 83, 0.65);
}

.wling-panel-meta-empty {
    font-size: 12px;
    opacity: 0.7;
}

.wling-panel-original {
    background: rgba(255, 255, 255, 0.08);
    padding: 10px;
    border-radius: 10px;
}

.wling-panel-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.6;
    margin-bottom: 6px;
}

.wling-panel-text {
    font-size: 14px;
    line-height: 1.4;
}

.wling-panel-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wling-panel-field + .wling-panel-field {
    margin-top: 8px;
}

.wling-panel-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.wling-panel-field-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wling-panel-field label {
    font-size: 12px;
    opacity: 0.8;
}

.wling-panel-lang-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.wling-panel-lang-flag {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
    flex: 0 0 14px;
}

.wling-deepl-button {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}

.wling-deepl-button:disabled {
    opacity: 0.6;
    cursor: default;
}

.wling-delete-button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 8px;
    width: 28px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.wling-delete-button svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.wling-delete-button:disabled {
    opacity: 0.5;
    cursor: default;
}

.wling-panel-field textarea {
    width: 100%;
    background: #fff;
    color: #111;
    border-radius: 8px;
    border: none;
    padding: 8px;
    font-size: 13px;
    resize: vertical;
}

.wling-panel-field textarea[readonly] {
    background: rgba(255, 255, 255, 0.7);
    color: #333;
}

.wling-save {
    background: #00c853;
    color: #111;
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: visible;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.wling-save:disabled {
    opacity: 0.55;
    cursor: default;
}

.wling-save.is-saving:disabled,
.wling-save.is-success:disabled,
.wling-save.is-error:disabled {
    opacity: 1;
}

.wling-save.is-dirty::before {
    content: "";
    position: absolute;
    inset: -3px;
    padding: 2px;
    border-radius: 12px;
    background: #f0c551;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    animation: wling-save-dirty-fade 1.6s ease-in-out infinite;
}

.wling-save.is-saving,
.wling-save.is-success,
.wling-save.is-error {
    color: transparent;
}

.wling-save.is-saving::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
    border-radius: 50%;
    border: 2px solid rgba(17, 17, 17, 0.25);
    border-top-color: #111;
    animation: wling-save-spin 0.8s linear infinite;
}

.wling-save.is-success::after,
.wling-save.is-error::after {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -52%);
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.wling-save.is-success::after {
    content: "\2713";
    color: #111;
}

.wling-save.is-error {
    background: #ffb7b7;
}

.wling-save.is-error::after {
    content: "\00d7";
    color: #7b1414;
}

@supports not ((-webkit-mask-composite: xor) or (mask-composite: exclude)) {
    .wling-save.is-dirty {
        outline: 2px solid #f0c551;
        outline-offset: 2px;
        animation: wling-save-dirty-outline-fade 1.6s ease-in-out infinite;
    }

    .wling-save.is-dirty::before {
        display: none;
    }
}

@keyframes wling-save-dirty-fade {
    from {
        background: #f0c551;
    }
    50% {
        background: #fff;
    }
    to {
        background: #f0c551;
    }
}

@keyframes wling-save-dirty-outline-fade {
    from {
        outline-color: #f0c551;
    }
    50% {
        outline-color: #fff;
    }
    to {
        outline-color: #f0c551;
    }
}

@keyframes wling-save-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.wling-panel-actions {
    display: flex;
    gap: 8px;
}

.wling-mode-toggle {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wling-mode-toggle.is-active {
    border-color: #00c853;
    background: rgba(0, 200, 83, 0.18);
}

.wling-mode-toggle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.wling-preview {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 600;
    cursor: pointer;
}

.wling-preview:disabled {
    opacity: 0.55;
    cursor: default;
}

.wling-panel-status {
    font-size: 12px;
    min-height: 16px;
}

.wling-highlight {
    outline: 1px solid #00c853;
    outline-offset: 2px;
}

.wling-translate-mode {
    box-sizing: border-box;
    padding-left: 360px;
}

.wling-translate-mode.wling-selection-active {
    cursor: pointer;
}

.wling-translate-mode::before {
    content: "";
    position: fixed;
    left: 0;
    top: 0;
    width: 360px;
    height: 100vh;
    background: #111;
    z-index: 2147483646;
    pointer-events: auto;
}

body.admin-bar.wling-translate-mode::before {
    top: 32px;
    height: calc(100vh - 32px);
}

.wling-translate-mode #wling-translate-panel,
.wling-translate-mode #wling-switcher,
.wling-translate-mode #wpadminbar,
.wling-translate-mode #wpadminbar * {
    cursor: default;
}

.wling-translate-mode.wling-selection-active .wling-hover {
    cursor: pointer;
}

#wling-text-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2147483646;
}

.wling-text-marker {
    position: fixed;
    box-sizing: border-box;
    border-radius: 2px;
    pointer-events: none;
}

.wling-text-marker-hover {
    border: 1px dashed #00c853;
    background: rgba(0, 200, 83, 0.08);
}

.wling-text-marker-selected {
    border: 1px solid #00c853;
    background: rgba(0, 200, 83, 0.16);
}

@media (max-width: 1024px) {
    .wling-translate-mode {
        padding-left: 0;
    }

    .wling-translate-mode::before {
        display: none;
    }

    #wling-translate-panel {
        width: 90vw;
        left: 5vw;
        top: 80px;
        height: auto;
        max-height: calc(100vh - 120px);
        border-radius: 16px;
    }

    body.admin-bar #wling-translate-panel {
        top: 96px;
        height: auto;
        max-height: calc(100vh - 136px);
    }
}

@media (max-width: 782px) {
    body.admin-bar #wling-translate-panel {
        top: 110px;
        max-height: calc(100vh - 150px);
    }
}
