.lm-tool-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: #12142380;
    display: grid;
    place-items: center;
    padding: max(16px, env(safe-area-inset-top)) 16px
        max(16px, env(safe-area-inset-bottom));
    backdrop-filter: blur(3px);
}
.lm-tool-panel {
    width: min(620px, 100%);
    max-height: 90dvh;
    overflow: auto;
    overscroll-behavior: contain;
    background: var(--page-card, var(--bg-card, #fff));
    color: var(--page-text, var(--text-main, #252637));
    border: 1px solid var(--page-line, var(--border-light, #ddd));
    border-radius: 22px;
    box-shadow: 0 20px 80px #0003;
    padding: 22px;
    box-sizing: border-box;
    animation: lm-tool-in 0.18s ease-out;
}
.lm-tool-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.lm-tool-heading h2 {
    font-size: 18px;
    margin: 0;
}
.lm-tool-heading button {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 25px;
    width: 36px;
    height: 36px;
    cursor: pointer;
}
.lm-tool-field {
    display: grid;
    gap: 8px;
    margin: 14px 0;
    font-size: 14px;
}
.lm-tool-field input:not([type='checkbox']),
.lm-tool-field select,
.lm-tool-field textarea,
.lm-tool-text {
    box-sizing: border-box;
    width: 100%;
    border: 1px solid var(--page-line, var(--border-light, #dadde7));
    border-radius: 12px;
    background: var(--page-bg, var(--bg-body, #f7f8fc));
    color: inherit;
    padding: 11px 12px;
    font: inherit;
    font-size: 16px;
    min-width: 0;
}
.lm-tool-field textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.7;
}
.lm-tool-text {
    min-height: 42dvh;
    resize: vertical;
    line-height: 1.8;
    white-space: pre-wrap;
}
.lm-tool-note {
    color: var(--page-muted, var(--text-sub, #747584));
    font-size: 12px;
    line-height: 1.8;
    margin: 8px 0;
}
.lm-tool-error {
    font-size: 13px;
    line-height: 1.6;
    color: var(--danger, #c44455);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.lm-tool-actions,
.lm-tool-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.lm-tool-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 0 10px;
    scrollbar-width: thin;
}
.lm-tool-tabs button {
    white-space: nowrap;
}
.lm-tool-button {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--page-line, var(--border-light, #ddd));
    border-radius: 12px;
    background: var(--page-bg, var(--bg-body, #f5f6fb));
    color: inherit;
    padding: 9px 14px;
    min-height: 38px;
}
.lm-tool-button.primary,
.lm-tool-tabs button[aria-selected='true'] {
    background: var(--page-accent, var(--primary, #6c63df));
    color: #fff;
    border-color: transparent;
}
.lm-tool-button:disabled {
    opacity: 0.55;
    cursor: default;
}
.lm-tool-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
}
.lm-tool-row + .lm-tool-row {
    border-top: 1px solid var(--page-line, var(--border-light, #eee));
}
.lm-tool-row strong {
    font-size: 14px;
}
.lm-tool-row p {
    margin: 5px 0 0;
}
.lm-tool-row input[type='checkbox'] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    accent-color: var(--page-accent, var(--primary, #6c63df));
}
.lm-writing-options {
    padding: 2px 16px;
    margin: 16px 0;
    border: 1px solid var(--page-line, var(--border-light, #ddd));
    border-radius: 16px;
}
.lm-tool-field-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.lm-ai-field {
    font-size: 12px;
    padding: 5px 10px;
    min-height: 30px;
    border-radius: 9px;
    white-space: nowrap;
}
.lm-generation-preview {
    margin: 12px 16px 16px 48px;
    padding: 14px 17px;
    border-radius: 18px;
    background: var(--bg-card, var(--page-card, #fff));
    color: var(--text-main, var(--page-text, #252637));
    max-width: 88%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 15px;
    line-height: 1.8;
    box-sizing: border-box;
}
.lm-generation-preview small {
    display: block;
    opacity: 0.6;
    font-size: 11px;
    margin-bottom: 8px;
}
.lm-step-badge {
    display: block;
    width: max-content;
    font: inherit;
    font-size: 11px;
    padding: 3px 8px;
    margin: 0 0 6px;
    border: 1px solid var(--border-light, #ddd);
    background: var(--bg-body, #f5f5fb);
    color: var(--text-sub, #777);
    border-radius: 8px;
    cursor: pointer;
}
@keyframes lm-tool-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
@media (prefers-reduced-motion: reduce) {
    .lm-tool-panel {
        animation: none;
    }
}
@media (max-width: 520px) {
    .lm-tool-panel {
        padding: 18px;
        border-radius: 18px;
        max-height: 88dvh;
    }
    .lm-tool-overlay {
        padding: 12px;
    }
    .lm-tool-actions button {
        flex: 1;
    }
    .lm-tool-row {
        align-items: flex-start;
    }
    .lm-tool-row input {
        margin-top: 3px;
    }
}
.lm-generation-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    box-sizing: border-box;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: lm-generation-spin 0.8s linear infinite;
    vertical-align: middle;
    flex: none;
    margin-right: 6px;
}
.lm-generation-activity {
    flex: none;
    display: grid;
    gap: 3px;
    padding: 9px 12px;
    margin: 4px 0 8px;
    border: 1px solid var(--page-line, #ddd);
    border-radius: 12px;
    color: var(--page-text, inherit);
    background: var(--page-card, transparent);
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.lm-generation-activity[hidden],
.lm-generation-track[hidden] {
    display: none !important;
}
.lm-generation-detail {
    color: var(--page-sub, #777);
    font-size: 11px;
}
.lm-generation-track {
    height: 3px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--page-line, #ddd);
    margin-top: 3px;
}
.lm-generation-track > span {
    display: block;
    height: 100%;
    width: 35%;
    border-radius: 4px;
    background: var(--page-accent, #8b6ad9);
    animation: lm-generation-flow 1.4s ease-in-out infinite;
}
@keyframes lm-generation-spin {
    to {
        transform: rotate(360deg);
    }
}
@keyframes lm-generation-flow {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(390%);
    }
}
@media (prefers-reduced-motion: reduce) {
    .lm-generation-spinner,
    .lm-generation-track > span {
        animation: none;
    }
    .lm-generation-track > span {
        width: 100%;
        opacity: 0.6;
    }
}
