.posts-editor {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    box-shadow: 0 18px 40px rgba(6, 8, 20, 0.35);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.posts-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    position: relative;
}

.posts-editor-popover {
    position: absolute;
    z-index: 30;
    min-width: 260px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(4, 8, 18, 0.96);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.posts-editor-popover-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.posts-editor-popover-label {
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.posts-editor-popover-field input {
    width: 100%;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.posts-editor-popover-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.posts-editor-popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

.posts-editor-popover-cancel {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 6px;
}

.posts-editor-popover-cancel:hover,
.posts-editor-popover-cancel:focus-visible {
    color: var(--text-primary);
    outline: none;
}

.posts-editor-button {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    font-size: x-small;
}

.posts-editor-button:hover,
.posts-editor-button.is-active {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    color: var(--accent-strong);
}

.posts-editor-input {
    min-height: 180px;
    padding: 18px;
    font-size: 1rem;
    line-height: 1.6;
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
}

.posts-editor-input .posts-editor-mention {
    display: inline-flex;
    align-items: center;
    padding: 0 6px;
    margin: 0 1px;
    border-radius: var(--radius-sm);
    background: rgba(88, 212, 255, 0.18);
    color: var(--accent-strong);
    font-weight: 600;
    white-space: nowrap;
}

.posts-editor-input .posts-editor-mention[contenteditable="false"] {
    cursor: default;
}

.posts-editor-input[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
}

.posts-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.posts-editor-footer .posts-editor-counter {
    font-variant-numeric: tabular-nums;
}

.posts-editor-footer .posts-editor-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.posts-editor-footer button {
    text-transform: none;
    letter-spacing: 0.05em;
}

.posts-editor-empty .posts-editor-input {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.posts-tenor {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.posts-tenor-inline {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.posts-tenor-inline .posts-tenor-trigger-row {
    justify-content: flex-start;
}

.posts-tenor-inline .posts-tenor-hint {
    display: none;
}

.posts-tenor-inline .posts-tenor-trigger {
    flex: 0 0 auto;
}

.posts-tenor-trigger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.posts-tenor-trigger {
    flex: 1 0 auto;
}

.posts-tenor-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    display:none; /* looks ugly, and only needed for commercial use */
}

.posts-tenor-panel {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md);
    background: rgba(6, 10, 22, 0.92);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.posts-tenor-panel[hidden] {
    display: none;
}

.posts-tenor-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.posts-tenor-title {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
}

.posts-tenor-subtitle {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.posts-tenor-search {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.posts-tenor-search input {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.posts-tenor-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.posts-tenor-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.posts-tenor-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.posts-tenor-popup {
    position: absolute;
    z-index: 2600;
    width: 420px;
    max-width: min(92vw, 460px);
    left: 0;
    top: 0;
    box-shadow: 0 18px 28px rgba(0, 0, 0, 0.45);
}

.posts-tenor-popup[hidden] {
    display: none;
}

.posts-tenor-result {
    border: none;
    padding: 0;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    isolation: isolate;
}

.posts-tenor-result img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

.posts-tenor-result:hover::after,
.posts-tenor-result:focus-visible::after {
    content: 'Insert GIF';
    position: absolute;
    inset: 0;
    background: rgba(6, 9, 18, 0.55);
    color: var(--accent-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-radius: inherit;
}

.posts-tenor-result:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.posts-tenor-close {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .posts-editor-toolbar {
        padding: 10px;
    }

    .posts-editor-input {
        padding: 14px;
        min-height: 150px;
    }

    .posts-editor-footer {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .posts-tenor-trigger-row {
        flex-direction: column;
        align-items: stretch;
    }

    .posts-tenor-hint {
        width: 100%;
        text-align: left;
    }

    .posts-tenor-results {
        max-height: 200px;
    }
}
