.friendspace-rich-editor {
    position: relative;
    overflow: visible;
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    transition: border-color .16s ease, box-shadow .16s ease;
}

.friendspace-rich-editor:focus-within {
    border-color: #fb923c;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .16);
}

.friendspace-rich-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    padding: .35rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(#fffdf9, #f8fafc);
    scrollbar-width: thin;
}

.friendspace-rich-editor-button {
    display: inline-grid;
    width: 32px;
    height: 30px;
    flex: 0 0 32px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #475569;
    font-size: .76rem;
    font-weight: 800;
}

.friendspace-rich-editor-button:hover,
.friendspace-rich-editor-button:focus-visible {
    border-color: #fdba74;
    color: #c2410c;
    background: #fff7ed;
    outline: none;
}

.friendspace-rich-editor-format-toggle { display: none; }
.friendspace-rich-editor-smiley { width: auto; min-width: 86px; padding: 0 .55rem; }
.friendspace-rich-editor-smiley span + span,
.friendspace-rich-editor-format-toggle span { margin-left: .25rem; }

.friendspace-composer-smiley-picker {
    position: absolute;
    top: 42px;
    right: 8px;
    z-index: 20;
    width: min(420px, calc(100% - 16px));
    max-height: 310px;
    overflow-y: auto;
    padding: .65rem;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    background: #fffaf5;
    box-shadow: 0 18px 48px rgba(15,23,42,.22);
}
.friendspace-composer-smiley-picker[hidden] { display: none; }
.friendspace-composer-smiley-head,
.friendspace-conversation-editor-tools { display: flex; align-items: center; justify-content: space-between; }
.friendspace-composer-smiley-head { margin-bottom: .55rem; color: #334155; }
.friendspace-composer-smiley-head button { padding: .15rem .45rem; color: #64748b; font-size: 1.35rem; }
.friendspace-composer-smiley-tabs { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: .55rem; }
.friendspace-composer-smiley-tabs button { padding: .38rem .6rem; border-radius: 999px; color: #64748b; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.friendspace-composer-smiley-tabs button.is-active { color: #c2410c; background: #ffedd5; }
.friendspace-composer-smiley-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .25rem; }
.friendspace-composer-smiley-icon { min-height: 38px; border: 1px solid transparent; border-radius: 8px; font-size: 1.35rem; }
.friendspace-composer-smiley-icon:hover,
.friendspace-composer-smiley-icon:focus-visible { border-color: #fdba74; background: #fff; outline: none; }

.friendspace-conversation-editor { position: relative; width: 100%; overflow: visible; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; }
.friendspace-comment-composer-row .friendspace-conversation-editor,
.business-comment-form__row .friendspace-conversation-editor,
.profile-comment-composer .friendspace-conversation-editor { flex: 1 1 auto; min-width: 0; }
.friendspace-conversation-editor:focus-within { border-color: #fb923c; box-shadow: 0 0 0 3px rgba(249,115,22,.13); }
.friendspace-conversation-editor > textarea { display: block; width: 100%; min-height: 70px; max-height: 190px; resize: none; padding: .72rem .8rem .35rem; border: 0 !important; border-radius: inherit; outline: 0 !important; box-shadow: none !important; line-height: 1.5; }
.friendspace-conversation-editor-tools { padding: .3rem .5rem; border-top: 1px solid #f1f5f9; }
.friendspace-conversation-editor-tools { justify-content: flex-end; }
.friendspace-conversation-count { color: #94a3b8; font-size: .65rem; }

body.friendspace-composer-dialog-open { overflow: hidden; }
.friendspace-composer-dialog-overlay { position: fixed; inset: 0; z-index: 10050; display: grid; place-items: center; padding: 1.25rem; background: rgba(15,23,42,.62); backdrop-filter: blur(3px); }
.friendspace-composer-dialog { display: flex; width: min(680px, 100%); max-height: min(88svh, 760px); flex-direction: column; overflow: hidden; border: 1px solid #fed7aa; border-radius: 18px; background: #fff; box-shadow: 0 28px 80px rgba(15,23,42,.3); }
.friendspace-composer-dialog > header { display: flex; flex: 0 0 auto; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.25rem .9rem; border-bottom: 1px solid #e2e8f0; background: linear-gradient(135deg,#fffaf5,#fff); }
.friendspace-composer-dialog-kicker { color: #ea580c; font-size: .68rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.friendspace-composer-dialog h2 { margin: .12rem 0 0; color: #1e293b; font-size: 1.35rem; }
.friendspace-composer-dialog header p { margin: .25rem 0 0; color: #64748b; font-size: .83rem; }
.friendspace-composer-dialog-close { width: 38px; height: 38px; flex: 0 0 38px; border: 1px solid #fed7aa; border-radius: 50%; color: #64748b; font-size: 1.45rem; }
.friendspace-composer-dialog-body { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 1rem 1.25rem; overscroll-behavior: contain; }
.friendspace-composer-dialog-category { display: grid; gap: .35rem; margin-top: .9rem; color: #475569; font-size: .75rem; font-weight: 800; }
.friendspace-composer-dialog-category select { width: 100%; padding: .65rem .75rem; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.friendspace-composer-media { margin-top: .9rem; padding: .85rem; border: 1px solid #fed7aa; border-radius: 12px; background: #fffaf5; }
.friendspace-composer-media-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .65rem; }
.friendspace-composer-media-heading > div { display: flex; align-items: center; gap: .45rem; color: #334155; }
.friendspace-composer-media-heading span { color: #94a3b8; font-size: .68rem; font-weight: 800; }
.friendspace-composer-media-heading a { color: #c2410c; font-size: .72rem; font-weight: 850; }
.friendspace-composer-media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
.friendspace-composer-media-item { position: relative; overflow: hidden; aspect-ratio: 1; border: 1px solid #e2e8f0; border-radius: 10px; background: #e2e8f0; }
.friendspace-composer-media-item img { width: 100%; height: 100%; object-fit: cover; }
.friendspace-composer-media-item > div { position: absolute; inset: auto .25rem .25rem; display: flex; justify-content: center; gap: .2rem; }
.friendspace-composer-media-item button { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: #fff; background: rgba(15,23,42,.82); font-size: .7rem; }
.friendspace-composer-media-item button:disabled { opacity: .35; }
.friendspace-composer-media-item [data-media-remove] { background: rgba(190,24,93,.88); }
.friendspace-composer-media-add { display: inline-flex; align-items: center; gap: .4rem; margin-top: .65rem; padding: .55rem .75rem; border: 1px solid #fdba74; border-radius: 9px; color: #c2410c; background: #fff; font-size: .75rem; font-weight: 850; cursor: pointer; }
.friendspace-composer-media-add input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.friendspace-composer-media-add:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.friendspace-composer-media > p { margin: .55rem 0 0; color: #64748b; font-size: .68rem; line-height: 1.45; }
.friendspace-composer-dialog > footer { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: .65rem; padding: .85rem 1.25rem; border-top: 1px solid #e2e8f0; background: #f8fafc; }
.friendspace-composer-dialog-cancel,
.friendspace-composer-dialog-save { min-height: 42px; padding: .65rem 1rem; border-radius: 9px; font-weight: 800; }
.friendspace-composer-dialog-cancel { color: #475569; }
.friendspace-composer-dialog-save { color: #fff; background: #f97316; box-shadow: 0 5px 14px rgba(249,115,22,.22); }

.friendspace-rich-editor-surface {
    min-height: 108px;
    padding: .78rem .85rem;
    color: #273449;
    font-size: .95rem;
    line-height: 1.65;
    outline: none;
    overflow-wrap: anywhere;
}

.friendspace-rich-editor-surface:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

.friendspace-rich-editor-surface p { margin: 0 0 .72rem; }
.friendspace-rich-editor-surface p:last-child { margin-bottom: 0; }
.friendspace-rich-editor-surface h2 { margin: .4rem 0 .55rem; font-size: 1.38rem; font-weight: 850; line-height: 1.25; }
.friendspace-rich-editor-surface h3 { margin: .35rem 0 .5rem; font-size: 1.1rem; font-weight: 820; line-height: 1.3; }
.friendspace-rich-editor-surface blockquote { margin: .55rem 0; padding: .25rem .8rem; border-left: 3px solid #fb923c; color: #64748b; }
.friendspace-rich-editor-surface ul,
.friendspace-rich-editor-surface ol { margin: .45rem 0 .65rem 1.35rem; }
.friendspace-rich-editor-surface ul { list-style: disc; }
.friendspace-rich-editor-surface ol { list-style: decimal; }

.friendspace-rich-editor-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .28rem .55rem;
    border-top: 1px solid #f1f5f9;
    color: #94a3b8;
    background: #fffdf9;
    font-size: .64rem;
}

.friendspace-rich-editor-footer .is-over { color: #be123c; font-weight: 800; }
.friendspace-rich-editor-source { display: none !important; }

.friendspace-rich-content { color: inherit; line-height: 1.7; }
.friendspace-rich-content p { margin: 0 0 .85rem; }
.friendspace-rich-content p:last-child { margin-bottom: 0; }
.friendspace-rich-content h2 { margin: .55rem 0 .7rem; color: inherit; font-size: 1.42rem; font-weight: 850; line-height: 1.25; }
.friendspace-rich-content h3 { margin: .5rem 0 .62rem; color: inherit; font-size: 1.12rem; font-weight: 820; line-height: 1.3; }
.friendspace-rich-content blockquote { margin: .65rem 0; padding: .35rem .9rem; border-left: 3px solid #fb923c; color: #64748b; background: #fffaf5; }
.friendspace-rich-content ul,
.friendspace-rich-content ol { margin: .55rem 0 .8rem 1.4rem; }
.friendspace-rich-content ul { list-style: disc; }
.friendspace-rich-content ol { list-style: decimal; }

@media (max-width: 640px) {
    .friendspace-rich-editor-toolbar { flex-wrap: wrap; overflow: visible; }
    .friendspace-rich-editor-format-toggle { display: inline-flex; width: auto; min-width: 82px; padding: 0 .55rem; }
    .friendspace-rich-editor-format { display: none; }
    .friendspace-rich-editor-toolbar.format-open .friendspace-rich-editor-format { display: inline-grid; }
    .friendspace-rich-editor-smiley,
    .friendspace-composer-smiley-picker { display: none !important; }
    .friendspace-rich-editor-format-toggle { margin-right: auto; }
    .friendspace-rich-editor-surface { min-height: 96px; padding: .7rem; }
    .friendspace-rich-editor-footer > span:first-child { display: none; }
    .friendspace-rich-editor-footer { justify-content: flex-end; }
    .friendspace-composer-dialog-overlay { align-items: center; padding: 8px 0; }
    .friendspace-composer-dialog { width: 100%; max-height: calc(100svh - 16px); border-radius: 20px 20px 14px 14px; }
    .friendspace-composer-dialog > header { padding: 1rem; }
    .friendspace-composer-dialog-body { padding: .85rem 1rem; }
    .friendspace-composer-dialog > footer { padding: .75rem 1rem max(.75rem, env(safe-area-inset-bottom)); }
    .friendspace-composer-dialog-cancel,
    .friendspace-composer-dialog-save { flex: 1; }
    .friendspace-composer-media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .friendspace-composer-media-heading { align-items: flex-start; }
}
