/**
 * Claw TipTap Editor — IPS 5-inspired responsive editor shell.
 */
.claw-tiptap-shell {
    --claw-editor-border: color-mix(in srgb, currentColor 16%, transparent);
    --claw-editor-border-strong: color-mix(in srgb, currentColor 24%, transparent);
    --claw-editor-surface: var(--windowbg, #fff);
    --claw-editor-toolbar: color-mix(in srgb, var(--windowbg, #fff) 92%, #6f7d8c 8%);
    --claw-editor-control: color-mix(in srgb, var(--windowbg, #fff) 97%, currentColor 3%);
    --claw-editor-hover: color-mix(in srgb, var(--primary-color, #2f7db5) 10%, var(--windowbg, #fff));
    --claw-editor-active: color-mix(in srgb, var(--primary-color, #2f7db5) 17%, var(--windowbg, #fff));
    --claw-editor-accent: var(--primary-color, #2f7db5);
    --claw-editor-muted: color-mix(in srgb, currentColor 62%, transparent);
    position: relative;
    border: 1px solid var(--claw-editor-border-strong);
    border-radius: 10px;
    background: var(--claw-editor-surface);
    overflow: visible;
    box-shadow: 0 1px 2px color-mix(in srgb, #000 8%, transparent), 0 8px 24px color-mix(in srgb, #000 4%, transparent);
}

.claw-tiptap-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    min-height: 56px;
    padding: 9px;
    border-bottom: 1px solid var(--claw-editor-border);
    border-radius: 9px 9px 0 0;
    background: var(--claw-editor-toolbar);
}

.claw-tiptap-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-height: 38px;
    padding: 2px;
    border: 0;
    border-radius: 8px;
    background: transparent;
}

.claw-tiptap-toolbar-group--tools[data-group="cleanup"] {
    margin-inline-start: auto;
}

.claw-tiptap-button,
.claw-tiptap-select {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: color-mix(in srgb, var(--claw-editor-control) 72%, transparent);
    color: color-mix(in srgb, currentColor 84%, transparent);
    font: inherit;
    cursor: pointer;
    transition: background-color .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}

.claw-tiptap-button {
    display: inline-grid;
    place-items: center;
    width: 36px;
    min-width: 36px;
    padding: 0;
    line-height: 1;
}

.claw-tiptap-icon {
    display: inline-grid;
    place-items: center;
    width: 19px;
    height: 19px;
    pointer-events: none;
}

.claw-tiptap-icon svg {
    display: block;
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.claw-tiptap-icon svg circle,
.claw-tiptap-icon svg rect,
.claw-tiptap-icon svg path {
    vector-effect: non-scaling-stroke;
}

.claw-tiptap-icon svg circle {
    fill: none;
}

.claw-tiptap-letter-icon {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    min-height: 20px;
    font: 700 17px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.claw-tiptap-button:hover,
.claw-tiptap-button:focus-visible,
.claw-tiptap-select:hover,
.claw-tiptap-select:focus-visible {
    border-color: var(--claw-editor-border-strong);
    background: var(--claw-editor-hover);
    color: var(--claw-editor-accent);
    box-shadow: 0 1px 2px color-mix(in srgb, #000 9%, transparent);
    outline: none;
}

.claw-tiptap-button:focus-visible,
.claw-tiptap-select:focus-visible {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--claw-editor-accent) 30%, transparent);
}

.claw-tiptap-button.is-active,
.claw-tiptap-button[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--claw-editor-accent) 42%, transparent);
    background: var(--claw-editor-active);
    color: var(--claw-editor-accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--claw-editor-accent) 12%, transparent);
}

.claw-tiptap-button:disabled,
.claw-tiptap-select:disabled {
    opacity: .38;
    cursor: not-allowed;
    box-shadow: none;
}

.claw-tiptap-select-wrap {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 2px;
    border: 1px solid var(--claw-editor-border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--claw-editor-control) 88%, transparent);
}

.claw-tiptap-select {
    max-width: 144px;
    padding: 0 30px 0 10px;
    background-color: transparent;
    font-size: .93rem;
    font-weight: 600;
}

.claw-tiptap-content {
    min-height: inherit;
    padding: 18px 20px;
    border-radius: 0 0 9px 9px;
    background: var(--claw-editor-surface);
}

.claw-tiptap-content .ProseMirror,
.claw-tiptap-content .claw-tiptap-prosemirror {
    min-height: inherit;
    outline: none;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-size: 1rem;
    line-height: 1.65;
}

.claw-tiptap-content p:first-child,
.claw-tiptap-content h2:first-child,
.claw-tiptap-content h3:first-child,
.claw-tiptap-content h4:first-child {
    margin-top: 0;
}

.claw-tiptap-content blockquote {
    margin-inline: 0;
    padding: 11px 15px;
    border-inline-start: 4px solid var(--claw-editor-accent);
    border-radius: 0 7px 7px 0;
    background: var(--claw-editor-toolbar);
}

.claw-tiptap-content pre {
    overflow: auto;
    padding: 13px;
    border-radius: 8px;
    background: color-mix(in srgb, currentColor 9%, transparent);
}

.claw-tiptap-content code:not(pre code) {
    padding: 1px 5px;
    border-radius: 4px;
    background: color-mix(in srgb, currentColor 8%, transparent);
}

.claw-bbc-token {
    display: inline-block;
    padding: 1px 5px;
    border: 1px dashed var(--claw-editor-border);
    border-radius: 4px;
    color: var(--claw-editor-muted);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .86em;
}

.claw-tiptap-shell[data-profile="full"] {
    --claw-editor-min-height: 300px;
}

.claw-tiptap-shell[data-profile="quick"] {
    --claw-editor-min-height: 160px;
}

.claw-tiptap-shell[data-profile="minimal"] {
    --claw-editor-min-height: 110px;
}

.claw-tiptap-shell .claw-tiptap-content,
.claw-tiptap-shell .claw-tiptap-source-editor {
    min-height: var(--claw-editor-min-height, 180px);
}

#quickreply .claw-tiptap-shell[data-editor-context="quick-reply"] {
    width: 100%;
    max-width: none;
    margin: 0;
}

#quickreply .claw-tiptap-shell[data-editor-context="quick-reply"][data-profile="full"] {
    --claw-editor-min-height: 280px;
}

.sceditor-container[data-claw-tiptap-retired="1"] {
    display: none !important;
}

.claw-tiptap-source-editor {
    display: block;
    box-sizing: border-box;
    width: 100%;
    padding: 18px 20px;
    border: 0;
    border-radius: 0 0 9px 9px;
    outline: 0;
    resize: vertical;
    background: var(--claw-editor-surface);
    color: inherit;
    font: 14px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.claw-tiptap-source-editor:focus-visible,
.claw-tiptap-content .ProseMirror:focus-visible {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--claw-editor-accent) 58%, transparent);
}

.claw-tiptap-source-editor[hidden],
.claw-tiptap-shell.is-source-mode .claw-tiptap-content {
    display: none !important;
}

.claw-tiptap-source-textarea {
    position: absolute !important;
    inline-size: 1px !important;
    block-size: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
}

.claw-tiptap-visually-hidden {
    position: absolute !important;
    inline-size: 1px !important;
    block-size: 1px !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

@media (max-width: 860px) {
    .claw-tiptap-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
    }

    .claw-tiptap-toolbar-group,
    .claw-tiptap-button,
    .claw-tiptap-select-wrap {
        flex: 0 0 auto;
    }

    .claw-tiptap-toolbar-group--tools[data-group="cleanup"] {
        margin-inline-start: 0;
    }

    .claw-tiptap-content,
    .claw-tiptap-source-editor {
        padding: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .claw-tiptap-shell *,
    .claw-tiptap-shell *::before,
    .claw-tiptap-shell *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

/* Unified content picker. */
.claw-content-picker {
    position: absolute;
    z-index: 10050;
    inset-inline-end: 8px;
    inset-block-start: 48px;
    box-sizing: border-box;
    width: min(520px, calc(100% - 16px));
    max-height: min(520px, 72vh);
    padding: 0;
    border: 1px solid var(--claw-editor-border);
    border-radius: 10px;
    background: var(--claw-editor-surface);
    color: inherit;
    box-shadow: 0 16px 38px color-mix(in srgb, #000 25%, transparent);
    overflow: hidden;
}

.claw-tiptap-shell {
    position: relative;
}

.claw-content-picker[hidden] {
    display: none !important;
}

.claw-picker-header {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--claw-editor-border);
}

.claw-picker-search {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--claw-editor-border);
    border-radius: 7px;
    background: var(--claw-editor-surface);
    color: inherit;
    font: inherit;
}

.claw-picker-search:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--primary-color, #3b82f6) 65%, transparent);
    outline-offset: 1px;
}

.claw-picker-close {
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    font: 700 24px/1 system-ui, sans-serif;
    cursor: pointer;
}

.claw-picker-close:hover,
.claw-picker-close:focus-visible {
    background: var(--claw-editor-hover);
}

.claw-picker-tabs {
    display: flex;
    overflow-x: auto;
    padding: 0 8px;
    border-bottom: 1px solid var(--claw-editor-border);
    scrollbar-width: thin;
}

.claw-picker-tab {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 11px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.claw-picker-tab:hover,
.claw-picker-tab:focus-visible {
    background: var(--claw-editor-hover);
}

.claw-picker-tab.is-active {
    border-bottom-color: var(--primary-color, #3b82f6);
    font-weight: 700;
}

.claw-picker-tones {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px 4px;
}

.claw-picker-tone {
    display: grid;
    place-items: center;
    width: 36px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
}

.claw-picker-tone:hover,
.claw-picker-tone:focus-visible {
    background: var(--claw-editor-hover);
}

.claw-picker-tone.is-selected {
    border-color: color-mix(in srgb, var(--primary-color, #3b82f6) 65%, transparent);
    background: var(--claw-editor-active);
}

.claw-picker-notice {
    margin: 8px 10px 0;
    padding: 8px 10px;
    border-radius: 7px;
    background: color-mix(in srgb, var(--primary-color, #3b82f6) 10%, var(--claw-editor-surface));
    color: var(--claw-editor-muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

.claw-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 4px;
    max-height: 330px;
    padding: 10px;
    overflow: auto;
    overscroll-behavior: contain;
}

.claw-picker-item {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 42px;
    padding: 4px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.claw-picker-item:hover,
.claw-picker-item:focus-visible {
    background: var(--claw-editor-hover);
    outline: 2px solid transparent;
}

.claw-picker-item-emoji {
    font-size: 25px;
    line-height: 1;
}

.claw-picker-item-smiley img {
    display: block;
    max-width: 30px;
    max-height: 30px;
}

.claw-picker-item-fontawesome {
    grid-column: span 2;
    grid-template-columns: 30px minmax(0, 1fr);
    justify-items: start;
    gap: 6px;
    min-height: 48px;
    padding: 5px 8px;
    text-align: start;
}

.claw-fa-picker-preview {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--claw-editor-toolbar);
    color: var(--primary-color, currentColor);
    font-size: 12px;
    font-weight: 800;
}

.claw-picker-item-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.86rem;
}

.claw-picker-empty {
    margin: 0;
    padding: 22px 14px;
    color: var(--claw-editor-muted);
    text-align: center;
}

.claw-fa-token {
    max-width: 100%;
    vertical-align: baseline;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .claw-content-picker {
        position: fixed;
        inset: auto 8px 8px;
        width: auto;
        max-height: min(640px, calc(100vh - 16px));
    }

    .claw-picker-grid {
        max-height: min(390px, 52vh);
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }

    .claw-picker-item-fontawesome {
        grid-column: span 3;
    }
}

.claw-fa-picker-preview img,
.claw-fa-rendered {
    display: inline-block;
    width: 1em;
    height: 1em;
    object-fit: contain;
    vertical-align: -0.125em;
}

.claw-fa-picker-preview img {
    width: 17px;
    height: 17px;
}

/* Phase 5: native SMF attachment bridge. */
.claw-upload-input {
    position: fixed !important;
    inline-size: 1px !important;
    block-size: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.claw-tiptap-shell.is-file-dragging {
    outline: 2px dashed var(--primary-color, #3b82f6);
    outline-offset: 3px;
}

.claw-tiptap-shell.is-file-dragging .claw-tiptap-content::after {
    content: "Drop files to upload with SMF";
    position: absolute;
    inset: 8px;
    z-index: 5;
    display: grid;
    place-items: center;
    border: 2px dashed var(--primary-color, #3b82f6);
    border-radius: 8px;
    background: color-mix(in srgb, var(--claw-editor-surface) 88%, transparent);
    color: inherit;
    font-weight: 700;
    pointer-events: none;
}

.claw-tiptap-content {
    position: relative;
}

.claw-upload-panel {
    display: grid;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--claw-editor-border);
    background: color-mix(in srgb, var(--claw-editor-surface) 97%, var(--primary-color, #3b82f6));
}

.claw-upload-panel[hidden] {
    display: none !important;
}

.claw-upload-item {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    padding: 9px;
    border: 1px solid var(--claw-editor-border);
    border-radius: 8px;
    background: var(--claw-editor-surface);
}

.claw-upload-item.is-complete {
    border-color: color-mix(in srgb, #15803d 45%, var(--claw-editor-border));
}

.claw-upload-item.has-error {
    border-color: color-mix(in srgb, #b91c1c 55%, var(--claw-editor-border));
}

.claw-upload-preview {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    overflow: hidden;
    border-radius: 7px;
    background: var(--claw-editor-hover);
    font-size: 24px;
}

.claw-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.claw-upload-details {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.claw-upload-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.claw-upload-meta,
.claw-upload-message {
    color: var(--claw-editor-muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.claw-upload-item.has-error .claw-upload-message {
    color: #b91c1c;
}

.claw-upload-alt-wrap {
    display: grid;
    gap: 3px;
    margin-top: 3px;
    color: var(--claw-editor-muted);
    font-size: 0.82rem;
}

.claw-upload-alt {
    width: 100%;
    min-height: 34px;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid var(--claw-editor-border);
    border-radius: 6px;
    background: var(--claw-editor-surface);
    color: inherit;
    font: inherit;
}

.claw-upload-progress {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--claw-editor-hover);
}

.claw-upload-progress > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--primary-color, #3b82f6);
    transition: width 120ms linear;
}

.claw-upload-actions {
    display: grid;
    gap: 6px;
}

.claw-upload-insert,
.claw-upload-remove {
    min-height: 34px;
    padding: 5px 9px;
    border: 1px solid var(--claw-editor-border);
    border-radius: 6px;
    background: var(--claw-editor-surface);
    color: inherit;
    cursor: pointer;
    font: inherit;
    white-space: nowrap;
}

.claw-upload-insert:hover:not(:disabled),
.claw-upload-remove:hover:not(:disabled),
.claw-upload-insert:focus-visible,
.claw-upload-remove:focus-visible {
    background: var(--claw-editor-hover);
}

.claw-upload-insert:disabled,
.claw-upload-remove:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.claw-attachment-node {
    display: inline-flex;
    max-width: min(100%, 520px);
    align-items: center;
    gap: 7px;
    margin: 2px 3px;
    padding: 5px 8px;
    border: 1px solid var(--claw-editor-border);
    border-radius: 7px;
    background: var(--claw-editor-hover);
    vertical-align: middle;
    user-select: all;
}

.claw-attachment-node.ProseMirror-selectednode {
    outline: 2px solid var(--primary-color, #3b82f6);
    outline-offset: 2px;
}

.claw-attachment-image {
    display: block;
    width: auto;
    max-width: 160px;
    height: auto;
    max-height: 110px;
    border-radius: 5px;
    object-fit: contain;
}

.claw-attachment-icon {
    font-size: 1.1rem;
}

.claw-attachment-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 600;
}

@media (max-width: 720px) {
    .claw-upload-item {
        grid-template-columns: 46px minmax(0, 1fr);
    }

    .claw-upload-preview {
        width: 46px;
        height: 46px;
    }

    .claw-upload-actions {
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .claw-attachment-image {
        max-width: 110px;
        max-height: 82px;
    }
}

/* Phase 6: advanced quick reply, local drafts and AJAX status. */
.claw-quick-draft-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 11px;
    border-top: 1px solid var(--claw-editor-border);
    background: color-mix(in srgb, var(--claw-editor-surface) 88%, #f59e0b);
    color: inherit;
    font-size: 0.9rem;
}

.claw-quick-draft-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.claw-quick-draft-actions .button {
    min-height: 32px;
    margin: 0;
    padding: 4px 9px;
}

.claw-quick-submit-status {
    min-height: 1.35em;
    margin-top: 7px;
    color: var(--claw-editor-muted);
    font-size: 0.88rem;
}

button.is-submitting,
input.is-submitting {
    cursor: progress !important;
    opacity: 0.68;
}

@media (max-width: 600px) {
    .claw-quick-draft-notice {
        align-items: stretch;
        flex-direction: column;
    }

    .claw-quick-draft-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Phase 7: privacy-aware social embeds. */
.claw-social-editor-node {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
    align-items: center;
    margin: 0.75rem 0;
    padding: 0.85rem 1rem;
    border: 1px solid var(--claw-editor-border, rgba(0, 0, 0, 0.18));
    border-radius: 0.65rem;
    background: var(--claw-editor-panel, rgba(127, 127, 127, 0.08));
    cursor: default;
}
.claw-social-editor-node__provider {
    grid-row: 1 / span 2;
    min-width: 4.5rem;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    text-align: center;
    font-weight: 700;
    background: rgba(30, 115, 190, 0.12);
}
.claw-social-editor-node__url {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.72;
    font-size: 0.9em;
}
.claw-social-embed {
    margin: 1rem auto;
    max-width: 680px;
    padding: 1rem;
    border: 1px solid rgba(127, 127, 127, 0.28);
    border-radius: 0.8rem;
    background: rgba(127, 127, 127, 0.06);
}
.claw-social-embed__header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}
.claw-social-embed__provider {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.82em;
    font-weight: 700;
    background: rgba(30, 115, 190, 0.14);
}
.claw-social-embed__privacy {
    margin: 0.65rem 0;
    opacity: 0.78;
}
.claw-social-embed__actions,
.claw-social-composer__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.claw-social-embed__target:not([hidden]) {
    margin-top: 0.9rem;
}
.claw-social-embed__iframe {
    display: block;
    width: 100%;
    min-height: 270px;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 0.55rem;
    background: #000;
}
.claw-social-embed__error {
    margin: 0.75rem 0 0;
    color: var(--error, #b42318);
}
.claw-social-composer {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.58);
}
.claw-social-composer[hidden] { display: none; }
.claw-social-composer__panel {
    width: min(34rem, 100%);
    padding: 1.15rem;
    border-radius: 0.85rem;
    background: var(--background-color, #fff);
    color: var(--body-text-color, #222);
    box-shadow: 0 1.25rem 4rem rgba(0, 0, 0, 0.28);
}
.claw-social-composer__panel h3 { margin-top: 0; }
.claw-social-composer__panel label { display: grid; gap: 0.35rem; }
.claw-social-composer__input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.7rem 0.8rem;
}
.claw-social-composer__status {
    min-height: 1.35em;
    color: var(--error, #b42318);
}
.claw-social-composer__actions { justify-content: flex-end; }
@media (max-width: 600px) {
    .claw-social-editor-node { grid-template-columns: 1fr; }
    .claw-social-editor-node__provider { grid-row: auto; justify-self: start; }
    .claw-social-embed { padding: 0.8rem; }
    .claw-social-embed__actions .button { flex: 1 1 100%; text-align: center; }
    .claw-social-embed__iframe { min-height: 220px; }
}


/* 0.9.8 single-instance recovery and editor takeover hardening. */
.claw-tiptap-shell,
.claw-tiptap-shell * {
    box-sizing: border-box;
}

html body .claw-tiptap-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    padding: 0 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

html body .claw-tiptap-shell .claw-tiptap-toolbar {
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    height: auto !important;
    min-height: 54px !important;
    padding: 8px !important;
    gap: 6px !important;
}

html body .claw-tiptap-shell .claw-tiptap-toolbar-group {
    display: inline-flex !important;
    align-items: center !important;
    width: auto !important;
    height: auto !important;
    min-height: 38px !important;
    padding: 2px !important;
    gap: 2px !important;
}

html body .claw-tiptap-shell button.claw-tiptap-button {
    display: inline-grid !important;
    place-items: center !important;
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    font-size: 14px !important;
}

html body .claw-tiptap-shell select.claw-tiptap-select {
    width: auto !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding-block: 0 !important;
    line-height: 1.2 !important;
    font-size: 14px !important;
}

html body .claw-tiptap-shell .claw-tiptap-icon,
html body .claw-tiptap-shell .claw-tiptap-icon svg {
    display: block !important;
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
}

html body .claw-tiptap-shell .claw-tiptap-content {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: var(--claw-editor-min-height, 180px) !important;
    padding: 18px 20px !important;
}


/* 0.9.7 emergency isolation for themes that apply broad form-control rules. */
html.claw-tiptap-emergency-isolation body .claw-tiptap-shell {
    contain: layout style !important;
}
html.claw-tiptap-emergency-isolation body .claw-tiptap-shell button.claw-tiptap-button {
    appearance: none !important;
    -webkit-appearance: none !important;
    float: none !important;
    position: relative !important;
    inset: auto !important;
    overflow: visible !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    text-indent: 0 !important;
}
html.claw-tiptap-emergency-isolation body .claw-tiptap-shell .claw-tiptap-icon svg {
    fill: currentColor !important;
}

/* SMF member mention autocomplete. */
.claw-tiptap-mention-menu{position:fixed;z-index:10050;min-width:220px;max-width:min(360px,calc(100vw - 16px));max-height:260px;overflow:auto;padding:6px;background:var(--window_bg,#fff);border:1px solid var(--bordercolor,#cfd6dd);border-radius:6px;box-shadow:0 8px 24px rgba(0,0,0,.18)}
.claw-tiptap-mention-menu[hidden]{display:none!important}.claw-tiptap-mention-option{display:block!important;width:100%!important;height:auto!important;min-height:34px!important;padding:7px 10px!important;text-align:left!important;border:0!important;border-radius:4px!important;background:transparent!important;color:inherit!important;cursor:pointer!important}.claw-tiptap-mention-option:hover,.claw-tiptap-mention-option.is-active{background:var(--button_active,#e7f2ff)!important;color:inherit!important}
.claw-tiptap-content .claw-member-mention,.claw-tiptap-content a[href$="#claw-mention"]{display:inline;font-weight:600;text-decoration:none;background:transparent;padding:0;border-radius:0;color:inherit}


/* TipTap editor follow-up refinement hotfix */
.claw-tiptap-shell:focus-within {
	border-color: color-mix(in srgb, var(--claw-editor-accent, #2f7db5) 44%, var(--claw-editor-border-strong));
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--claw-editor-accent, #2f7db5) 18%, transparent), 0 16px 38px color-mix(in srgb, #000 14%, transparent);
}

.claw-tiptap-content:focus-within,
.claw-tiptap-source-editor:focus-visible {
	box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--claw-editor-accent, #2f7db5) 34%, transparent);
	border-radius: 0 0 9px 9px;
}

.claw-tiptap-source-editor:focus-visible,
.claw-tiptap-content .ProseMirror:focus-visible {
	box-shadow: none;
}

.claw-tiptap-content .claw-member-mention,
.claw-tiptap-content a[href$="#claw-mention"],
.post .claw-member-mention,
.post a[href$="#claw-mention"],
.inner .claw-member-mention,
.inner a[href$="#claw-mention"] {
	display: inline-flex;
	align-items: center;
	padding: 0.1rem 0.48rem;
	border: 1px solid color-mix(in srgb, var(--claw-editor-accent, #2f7db5) 18%, transparent);
	border-radius: 999px;
	background: color-mix(in srgb, var(--claw-editor-accent, #2f7db5) 12%, transparent);
	color: inherit;
	font-weight: 700;
	line-height: 1.35;
	text-decoration: none;
	vertical-align: baseline;
	box-decoration-break: clone;
	-webkit-box-decoration-break: clone;
	white-space: nowrap;
}

.claw-tiptap-content .claw-member-mention:hover,
.claw-tiptap-content .claw-member-mention:focus-visible,
.claw-tiptap-content a[href$="#claw-mention"]:hover,
.claw-tiptap-content a[href$="#claw-mention"]:focus-visible,
.post .claw-member-mention:hover,
.post .claw-member-mention:focus-visible,
.post a[href$="#claw-mention"]:hover,
.post a[href$="#claw-mention"]:focus-visible,
.inner .claw-member-mention:hover,
.inner .claw-member-mention:focus-visible,
.inner a[href$="#claw-mention"]:hover,
.inner a[href$="#claw-mention"]:focus-visible {
	background: color-mix(in srgb, var(--claw-editor-accent, #2f7db5) 18%, transparent);
	border-color: color-mix(in srgb, var(--claw-editor-accent, #2f7db5) 32%, transparent);
	text-decoration: none;
}

@media (max-width: 600px) {
	.claw-tiptap-content .claw-member-mention,
	.claw-tiptap-content a[href$="#claw-mention"],
	.post .claw-member-mention,
	.post a[href$="#claw-mention"],
	.inner .claw-member-mention,
	.inner a[href$="#claw-mention"] {
		max-width: 100%;
		white-space: normal;
	}
}

/* -------------------------------------------------------------------------
   Phase 12 - full post composer polish.
   The rules are intentionally scoped to SMF's full post form and leave quick
   reply, PMs, signatures and TinyPortal editors untouched.
   ------------------------------------------------------------------------- */
html body form#postmodify #post_area > .roundframe {
    padding: 18px 20px;
}

html body form#postmodify #post_header {
    display: grid;
    grid-template-columns: minmax(120px, 155px) minmax(0, 1fr);
    column-gap: 18px;
    row-gap: 12px;
    align-items: center;
    margin: 0 0 18px;
    padding: 16px 18px;
    border: 1px solid rgba(127, 127, 127, .22);
    border-radius: 10px;
    background: rgba(127, 127, 127, .045);
    box-sizing: border-box;
}

html body form#postmodify #post_header > dt,
html body form#postmodify #post_header > dd {
    float: none;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html body form#postmodify #post_header > dt {
    font-weight: 650;
    line-height: 1.35;
}

html body form#postmodify #post_header > dd input[type="text"],
html body form#postmodify #post_header > dd input[type="search"],
html body form#postmodify #post_header > dd select {
    max-width: 100%;
    box-sizing: border-box;
}

html body form#postmodify #post_header #subject {
    width: 100%;
    min-height: 38px;
}

html body form#postmodify #post_header .pf_icon select,
html body form#postmodify #post_header dd.pf_topicclassification_prefix select {
    width: min(100%, 260px);
    min-height: 36px;
}

html body form#postmodify .claw-tiptap-shell {
    margin: 4px 0 16px;
    border-radius: 10px;
}

html body form#postmodify #post_attachments_area {
    margin-top: 14px;
}

html body form#postmodify #post_confirm_buttons,
html body form#postmodify .post_button_container {
    margin-top: 14px;
}

@media (max-width: 720px) {
    html body form#postmodify #post_area > .roundframe {
        padding: 14px;
    }

    html body form#postmodify #post_header {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
        padding: 14px;
    }

    html body form#postmodify #post_header > dt:not(:first-child) {
        margin-top: 5px;
    }

    html body form#postmodify #post_header .pf_icon select,
    html body form#postmodify #post_header dd.pf_topicclassification_prefix select {
        width: 100%;
    }
}
/* 0.9.18 fail-open + mounted-DOM self-heal ownership.
   Never hide the canonical source textarea before TipTap has mounted successfully.
   If the local runtime, recovery chain or native SCEditor fallback fails, members
   must still have a visible, usable posting field instead of a blank editor gap. */
textarea[data-claw-tiptap-server-owned="1"]:not([data-claw-tiptap-mounted="1"]),
textarea[data-claw-tiptap-native-fallback="1"] {
    position: static !important;
    inline-size: 100% !important;
    block-size: auto !important;
    min-block-size: 180px !important;
    overflow: auto !important;
    clip: auto !important;
    white-space: pre-wrap !important;
    visibility: visible !important;
    opacity: 1 !important;
}
textarea.claw-tiptap-source-textarea + .richedit_resize,
textarea[data-claw-tiptap-mounted="1"] + .richedit_resize { display: none !important; }

/* Phase 50: responsive toolbar ownership.
   The toolbar wraps into compact logical rows instead of becoming a wide
   horizontally-scrollable landscape strip. Controls remain reachable without
   sideways scrolling at Quick Reply, topic, tablet and phone widths. */
html body .claw-tiptap-shell .claw-tiptap-toolbar {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    align-content: flex-start !important;
    gap: 5px !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    overscroll-behavior-inline: auto;
    scrollbar-width: auto;
}

html body .claw-tiptap-shell .claw-tiptap-toolbar-group {
    display: inline-flex !important;
    flex: 0 1 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    gap: 3px !important;
}

html body .claw-tiptap-shell .claw-tiptap-button {
    flex: 0 0 auto !important;
    min-width: 36px !important;
    min-height: 36px !important;
}

html body .claw-tiptap-shell .claw-tiptap-select-wrap {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    max-width: min(100%, 14rem) !important;
}

html body .claw-tiptap-shell .claw-tiptap-select {
    max-width: 100% !important;
}

html body .claw-tiptap-shell .claw-tiptap-toolbar-group--tools[data-group="cleanup"],
html body .claw-tiptap-shell .claw-tiptap-toolbar-group[data-group="source"] {
    margin-inline-start: 0 !important;
}

@media (max-width: 860px) {
    html body .claw-tiptap-shell .claw-tiptap-toolbar {
        padding: 6px !important;
        gap: 4px !important;
    }

    html body .claw-tiptap-shell .claw-tiptap-select-wrap {
        flex: 1 1 10.5rem !important;
        max-width: 14rem !important;
    }

    html body .claw-tiptap-shell .claw-tiptap-select {
        width: 100% !important;
        min-width: 0 !important;
    }
}

@media (max-width: 520px) {
    html body .claw-tiptap-shell .claw-tiptap-toolbar {
        gap: 3px !important;
    }

    html body .claw-tiptap-shell .claw-tiptap-toolbar-group {
        gap: 2px !important;
    }

    html body .claw-tiptap-shell .claw-tiptap-select-wrap[data-command="blockStyle"],
    html body .claw-tiptap-shell .claw-tiptap-select-wrap[data-command="alignment"] {
        flex: 1 1 calc(50% - 4px) !important;
        max-width: none !important;
    }
}
