.insight-editor {
    --ie-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.96));
    --ie-border: rgba(203, 213, 225, 0.9);
    --ie-strong: #0f172a;
    --ie-muted: #64748b;
    --ie-accent: #4f46e5;
    --ie-accent-soft: rgba(79, 70, 229, 0.12);
    --ie-panel: rgba(248, 250, 252, 0.92);
    border: 1px solid var(--ie-border);
    border-radius: 0.4rem;
    overflow: hidden;
    background: var(--ie-bg);
    box-shadow:
        0 26px 70px -46px rgba(15, 23, 42, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.insight-editor__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.92);
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.10), transparent 28%),
        linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(255, 255, 255, 0.92));
}

.insight-editor__group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding-right: 0.8rem;
    margin-right: 0.15rem;
    border-right: 1px solid rgba(226, 232, 240, 0.92);
}

.insight-editor__group:last-child {
    border-right: none;
    padding-right: 0;
    margin-right: 0;
}

.insight-editor__button,
.insight-editor__select,
.insight-editor__upload {
    position: relative;
    height: 2.2rem;
    min-width: 2.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 0.3rem;
    border-radius: 0;
    border: 0;
    background: transparent;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    transition:
        color 0.18s ease,
        opacity 0.18s ease;
}

.insight-editor__button::after,
.insight-editor__upload::after {
    content: attr(data-label);
    display: none;
}

.insight-editor__button:hover,
.insight-editor__select:hover,
.insight-editor__upload:hover {
    color: #3730a3;
    opacity: 1;
}

.insight-editor__button.is-active {
    color: #312e81;
    opacity: 1;
}

.insight-editor__button i,
.insight-editor__upload i {
    pointer-events: none;
    width: 1rem;
    text-align: center;
}

.insight-editor__button--accent,
.insight-editor__upload--accent {
    color: #4338ca;
}

.insight-editor__select {
    appearance: none;
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 0.8rem;
}

.insight-editor__upload input {
    display: none;
}

.insight-editor__surface {
    min-height: 520px;
    padding: 2rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.98)),
        linear-gradient(180deg, rgba(248, 250, 252, 0.3), rgba(255, 255, 255, 0));
    color: var(--ie-strong);
    font-size: 1.02rem;
    line-height: 1.9;
    outline: none;
    word-break: break-word;
}

.insight-editor__surface.is-empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

.insight-editor__surface > *:first-child {
    margin-top: 0;
}

.insight-editor__surface > *:last-child {
    margin-bottom: 0;
}

.insight-editor__surface h2,
.insight-editor__surface h3,
.insight-editor__surface h4 {
    color: #0f172a;
    letter-spacing: -0.04em;
    line-height: 1.15;
}

.insight-editor__surface h2 {
    margin: 2rem 0 1rem;
    font-size: clamp(1.7rem, 2.8vw, 2.3rem);
    font-weight: 900;
}

.insight-editor__surface h3 {
    margin: 1.75rem 0 0.9rem;
    font-size: clamp(1.25rem, 2.4vw, 1.7rem);
    font-weight: 850;
}

.insight-editor__surface h4 {
    margin: 1.35rem 0 0.8rem;
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.insight-editor__surface p,
.insight-editor__surface ul,
.insight-editor__surface ol,
.insight-editor__surface pre,
.insight-editor__surface blockquote {
    margin: 1.1rem 0;
}

.insight-editor__surface img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 0.3rem;
    margin: 1.5rem 0;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 18px 40px -28px rgba(15, 23, 42, 0.34);
}

.insight-editor__surface blockquote {
    padding: 1rem 1.1rem 1rem 1.25rem;
    border-left: 4px solid #818cf8;
    background: linear-gradient(135deg, rgba(238, 242, 255, 0.92), rgba(248, 250, 252, 0.96));
    color: var(--ie-muted);
    border-radius: 0;
}

.insight-editor__surface pre {
    padding: 1rem 1.2rem;
    border-radius: 0.3rem;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #e2e8f0;
    overflow-x: auto;
    border: 1px solid rgba(51, 65, 85, 0.88);
}

.insight-editor__surface ul,
.insight-editor__surface ol {
    padding-left: 1.55rem;
}

.insight-editor__surface a {
    color: #4338ca;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.18em;
    font-weight: 800;
}

.insight-editor__surface hr {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.8), transparent);
    margin: 2rem 0;
}

.insight-editor__surface .insight-editor__callout,
.insight-editor__surface blockquote.insight-editor__callout {
    border-left-color: #0ea5e9;
    background: linear-gradient(135deg, rgba(224, 242, 254, 0.92), rgba(239, 246, 255, 0.98));
    color: #0f172a;
}

.insight-editor__embed {
    position: relative;
}

.insight-editor__hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem 1rem;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 800;
    background: rgba(248, 250, 252, 0.72);
}

.insight-editor__hint span {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.insight-editor__hint span::before {
    content: '';
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.insight-editor__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.9rem 1rem 1rem;
    border-top: 1px solid rgba(226, 232, 240, 0.88);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.92));
}

.insight-editor__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
}

.insight-editor__stats span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.48rem 0.7rem;
    border-radius: 0.25rem;
    background: rgba(241, 245, 249, 0.96);
    border: 1px solid rgba(226, 232, 240, 0.95);
    color: #475569;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.insight-editor__shortcuts {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 800;
}

.editor-status {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 1.05rem;
    border-radius: 0.3rem;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.92));
    color: #475569;
    font-size: 0.82rem;
    font-weight: 800;
}

.editor-status::before {
    content: '';
    width: 0.72rem;
    height: 0.72rem;
    border-radius: 999px;
    background: #94a3b8;
    box-shadow: 0 0 0 6px rgba(148, 163, 184, 0.12);
    flex-shrink: 0;
}

.editor-status[data-state="pending"]::before {
    background: #f59e0b;
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.15);
}

.editor-status[data-state="success"]::before {
    background: #10b981;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.14);
}

.editor-status[data-state="error"] {
    border-color: rgba(244, 63, 94, 0.24);
    color: #be123c;
    background: rgba(255, 241, 242, 0.96);
}

.editor-status[data-state="error"]::before {
    background: #f43f5e;
    box-shadow: 0 0 0 6px rgba(244, 63, 94, 0.14);
}

.editor-status[data-state="idle"]::before {
    background: linear-gradient(135deg, #6366f1, #0ea5e9);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.13);
}

.editor-orb {
    width: 3.25rem;
    height: 3.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.3rem;
    background: linear-gradient(135deg, #111827, #4338ca);
    color: #fff;
    box-shadow: 0 18px 40px -24px rgba(67, 56, 202, 0.55);
}

.editor-orb--soft {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(14, 165, 233, 0.16));
    color: #3730a3;
    box-shadow: none;
}

.editor-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.72rem 0.95rem;
    border-radius: 0.25rem;
    border: 1px solid rgba(226, 232, 240, 0.92);
    background: rgba(255, 255, 255, 0.92);
    color: #334155;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .insight-editor {
        border-radius: 0.35rem;
    }

    .insight-editor__toolbar {
        padding: 0.8rem;
        gap: 0.65rem;
    }

    .insight-editor__group {
        gap: 0.45rem;
        padding-right: 0.65rem;
    }

    .insight-editor__button,
    .insight-editor__select,
    .insight-editor__upload {
        min-width: 2rem;
        height: 2rem;
        border-radius: 0;
        padding: 0 0.2rem;
    }

    .insight-editor__surface {
        min-height: 320px;
        padding: 1rem;
    }

    .insight-editor__hint {
        padding: 0.85rem 1rem 1rem;
    }

    .insight-editor__meta {
        padding: 0.85rem 1rem 1rem;
    }

    .insight-editor__shortcuts {
        width: 100%;
    }

    .editor-orb {
        width: 2.9rem;
        height: 2.9rem;
        border-radius: 0.25rem;
    }
}
