@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

.bridge-editor-host {
    min-height: 260px;
}

.bridge-editor-host[aria-busy="true"] {
    display: grid;
    place-items: center;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    color: #64748b;
    background: linear-gradient(110deg, #f8fafc 25%, #f1f5f9 40%, #f8fafc 55%);
    background-size: 240% 100%;
    animation: pe-loading 1.5s ease-in-out infinite;
}

.bridge-editor-host[aria-busy="true"]::before {
    content: "در حال آماده‌سازی ویرایشگر…";
    font-size: 13px;
}

.pe-root {
    --pe-primary: #4f46e5;
    --pe-primary-strong: #4338ca;
    --pe-primary-soft: #eef2ff;
    --pe-border: #d9e0ea;
    --pe-border-soft: #e9edf3;
    --pe-canvas: #f4f6fa;
    --pe-surface: #fff;
    --pe-surface-soft: #f8fafc;
    --pe-text: #172033;
    --pe-muted: #64748b;
    --pe-danger: #dc2626;
    --pe-success: #059669;
    position: relative;
    isolation: isolate;
    color: var(--pe-text);
    background: var(--pe-surface);
    border: 1px solid var(--pe-border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px rgba(15, 23, 42, .05);
    font-family: inherit;
    text-align: right;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.pe-root [hidden] {
    display: none !important;
}

.pe-root[data-readonly="true"] .pe-editable {
    background-image: linear-gradient(135deg, rgba(148, 163, 184, .05) 25%, transparent 25%, transparent 50%, rgba(148, 163, 184, .05) 50%, rgba(148, 163, 184, .05) 75%, transparent 75%, transparent);
    background-size: 12px 12px;
}

.pe-root[data-disabled="true"] {
    opacity: .68;
}

.pe-root[data-disabled="true"] .pe-workspace {
    pointer-events: none;
}

.pe-root:focus-within {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .08), 0 16px 38px rgba(15, 23, 42, .07);
}

.pe-header {
    min-height: 68px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--pe-border-soft);
    background: linear-gradient(180deg, #fff, #fbfcff);
    border-radius: 15px 15px 0 0;
}

.pe-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.pe-brand__icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(145deg, #6366f1, #4338ca);
    box-shadow: 0 7px 18px rgba(79, 70, 229, .22);
    font-size: 17px;
}

.pe-brand strong,
.pe-brand small {
    display: block;
}

.pe-brand strong {
    margin-bottom: 3px;
    font-size: 14px;
    font-weight: 750;
    color: var(--pe-text);
}

.pe-brand small {
    overflow: hidden;
    color: var(--pe-muted);
    font-size: 11.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.pe-header-state,
.pe-sync-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--pe-muted);
    white-space: nowrap;
}

.pe-header-state {
    padding: 7px 10px;
    border: 1px solid var(--pe-border-soft);
    border-radius: 999px;
    background: var(--pe-surface-soft);
    font-size: 11px;
}

.pe-header-state i,
.pe-sync-status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
}

.pe-header-state[data-state="synced"] i,
.pe-sync-status[data-state="synced"] i {
    background: var(--pe-success);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, .12);
}

.pe-header-state[data-state="dirty"] i,
.pe-sync-status[data-state="dirty"] i {
    background: #f59e0b;
}

.pe-header-state[data-state="syncing"] i,
.pe-sync-status[data-state="syncing"] i {
    background: var(--pe-primary);
    animation: pe-pulse .9s ease-in-out infinite;
}

.pe-header-state[data-state="error"] i,
.pe-sync-status[data-state="error"] i {
    background: var(--pe-danger);
}

.pe-realtime-presence-stack {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    direction: ltr;
}

.pe-realtime-avatar {
    --pe-peer-color: #5b63d3;
    width: 28px;
    height: 28px;
    margin-inline-start: -7px;
    display: inline-grid;
    place-items: center;
    color: #fff;
    border: 2px solid var(--pe-surface);
    border-radius: 50%;
    background: var(--pe-peer-color);
    box-shadow: 0 2px 7px rgba(15, 23, 42, .16);
    font-size: 10px;
    font-weight: 800;
}

.pe-realtime-avatar[data-status="idle"] { opacity: .58; }

.pe-toolbar {
    position: sticky;
    top: var(--pe-sticky-offset, 0px);
    z-index: 15;
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    padding: 9px 11px;
    border-bottom: 1px solid var(--pe-border);
    background: rgba(248, 250, 252, .96);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
}

.pe-toolbar-group {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding-inline-end: 7px;
    border-inline-end: 1px solid var(--pe-border);
}

.pe-toolbar-group:last-child {
    padding-inline-end: 0;
    border-inline-end: 0;
}

.pe-btn,
.pe-btn-sm,
.pe-select,
.pe-size {
    font: inherit;
    transition: color .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease, transform .14s ease;
}

.pe-btn {
    position: relative;
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #475569;
    background: transparent;
    cursor: pointer;
}

.pe-btn svg {
    width: 17px;
    height: 17px;
    display: block;
    pointer-events: none;
}

.pe-btn:hover:not(:disabled) {
    color: var(--pe-primary-strong);
    border-color: #d8dcff;
    background: #fff;
    box-shadow: 0 2px 7px rgba(15, 23, 42, .07);
    transform: translateY(-1px);
}

.pe-btn:focus-visible,
.pe-btn-sm:focus-visible,
.pe-select:focus-visible,
.pe-size:focus-visible,
.pe-color:focus-visible,
.pe-grid-cell:focus-visible {
    outline: 2px solid rgba(79, 70, 229, .42);
    outline-offset: 2px;
}

.pe-btn.active {
    color: var(--pe-primary-strong);
    border-color: #c7d2fe;
    background: var(--pe-primary-soft);
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .04);
}

.pe-btn:disabled,
.pe-select:disabled,
.pe-size:disabled,
.pe-color:disabled {
    opacity: .38;
    cursor: not-allowed;
    transform: none;
}

.pe-btn-text {
    width: auto;
    min-width: 34px;
    padding: 0 9px;
    font-size: 11.5px;
    font-weight: 650;
}

.pe-btn-wide {
    min-width: 50px;
}

.pe-btn-fullscreen {
    font-size: 19px;
    font-weight: 400;
}

.pe-select {
    height: 34px;
    max-width: 126px;
    padding: 0 9px 0 26px;
    border: 1px solid var(--pe-border);
    border-radius: 8px;
    color: #334155;
    background-color: #fff;
    font-size: 11.5px;
    cursor: pointer;
}

.pe-select:hover:not(:disabled) {
    border-color: #aeb9ca;
}

.pe-size-control {
    direction: ltr;
    height: 34px;
    display: inline-flex;
    border: 1px solid var(--pe-border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.pe-size {
    width: 48px;
    height: 32px;
    padding: 0 5px;
    border: 0;
    outline: 0;
    color: #334155;
    background: transparent;
    font-size: 11.5px;
    text-align: center;
}

.pe-size-apply {
    height: 32px;
    min-width: 31px;
    padding: 0 6px;
    border: 0;
    border-inline-start: 1px solid var(--pe-border);
    border-radius: 0;
    color: var(--pe-muted);
    font-size: 10px;
}

.pe-color-control {
    position: relative;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.pe-color-control:hover {
    border-color: var(--pe-border);
    background: #fff;
}

.pe-color-control::before {
    color: #334155;
    font-family: Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    pointer-events: none;
}

.pe-color-control--text::before { content: "A"; }
.pe-color-control--fill::before { content: "▰"; color: #f59e0b; }

.pe-color {
    position: absolute;
    inset: 3px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}

.pe-workspace {
    position: relative;
    padding: 18px;
    background: var(--pe-canvas);
}

.pe-realtime-presence-layer {
    position: absolute;
    inset: 0;
    z-index: 8;
    overflow: hidden;
    pointer-events: none;
}

.pe-realtime-selection,
.pe-realtime-caret {
    --pe-peer-color: #5b63d3;
    position: absolute;
    pointer-events: none;
}

.pe-realtime-selection {
    border-radius: 2px;
    background: color-mix(in srgb, var(--pe-peer-color) 22%, transparent);
}

.pe-realtime-caret {
    width: 2px;
    min-height: 16px;
    border-radius: 2px;
    background: var(--pe-peer-color);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--pe-peer-color) 18%, transparent);
}

.pe-realtime-caret > span {
    position: absolute;
    inset-inline-start: 0;
    bottom: 100%;
    max-width: 150px;
    padding: 2px 6px;
    overflow: hidden;
    color: #fff;
    border-radius: 5px 5px 5px 0;
    background: var(--pe-peer-color);
    font-size: 9px;
    font-weight: 700;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pe-editable,
.pe-source {
    width: 100%;
    min-height: var(--pe-min-height, 320px);
    max-height: min(68vh, 720px);
    overflow: auto;
    border: 1px solid var(--pe-border);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .035);
}

.pe-editable {
    padding: 28px clamp(20px, 4vw, 52px);
    color: #20293a;
    outline: none;
    font-size: 15px;
    line-height: 2;
    overflow-wrap: anywhere;
    caret-color: var(--pe-primary);
}

.pe-editable:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .07), 0 4px 14px rgba(15, 23, 42, .04);
}

.pe-editable:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

.pe-editable p { margin: 0 0 1em; }
.pe-editable h1,
.pe-editable h2,
.pe-editable h3 { margin: 1.35em 0 .6em; color: #111827; line-height: 1.55; }
.pe-editable h1 { font-size: 2em; }
.pe-editable h2 { font-size: 1.55em; }
.pe-editable h3 { font-size: 1.25em; }
.pe-editable ul,
.pe-editable ol { padding-inline-start: 1.8rem; margin: 0 0 1rem; }
.pe-editable li > ul,
.pe-editable li > ol { margin: .35rem 0; }
.pe-editable a { color: #4338ca; text-decoration: underline; text-decoration-color: #a5b4fc; text-underline-offset: 3px; }
.pe-editable blockquote {
    margin: 1.25rem 0;
    padding: 13px 17px;
    border-inline-start: 4px solid #818cf8;
    border-radius: 8px;
    color: #475569;
    background: #f5f7ff;
}
.pe-editable pre {
    direction: ltr;
    padding: 15px 17px;
    overflow: auto;
    border-radius: 9px;
    color: #e2e8f0;
    background: #172033;
    font: 13px/1.75 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    text-align: left;
}
.pe-editable hr { margin: 1.7rem 0; border: 0; border-top: 2px solid #e2e8f0; opacity: 1; }

.pe-source {
    resize: vertical;
    padding: 22px;
    color: #dbeafe;
    outline: none;
    background: #111827;
    font: 13px/1.75 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    text-align: left;
    tab-size: 2;
}

.pe-root[data-mode="source"] .pe-workspace {
    background: #0b1220;
}

.pe-root[data-mode="source"] .pe-tablebar {
    display: none;
}

.pe-status {
    min-height: 40px;
    padding: 8px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-top: 1px solid var(--pe-border-soft);
    border-radius: 0 0 15px 15px;
    color: var(--pe-muted);
    background: var(--pe-surface-soft);
    font-size: 10.5px;
}

.pe-status__context,
.pe-status__meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pe-status__context span + span,
.pe-status__meta > span + span {
    position: relative;
    padding-inline-start: 12px;
}

.pe-status__context span + span::before,
.pe-status__meta > span + span::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #cbd5e1;
}

.pe-status strong {
    color: #334155;
    font-weight: 700;
}

.pe-realtime-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.pe-realtime-status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
}

.pe-realtime-status[data-state="connected"] i {
    background: var(--pe-success);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, .12);
}

.pe-realtime-status[data-state="connecting"] i,
.pe-realtime-status[data-state="reconnecting"] i {
    background: var(--pe-primary);
    animation: pe-pulse .9s ease-in-out infinite;
}

.pe-realtime-status[data-state="offline"] i { background: #f59e0b; }
.pe-realtime-status[data-state="error"] i { background: var(--pe-danger); }

.pe-tablebar {
    position: sticky;
    top: calc(var(--pe-sticky-offset, 0px) + var(--pe-toolbar-height, 0px));
    z-index: 14;
    display: none;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-bottom: 1px solid #dbe3ef;
    background: #eef2ff;
}

.pe-root[data-in-table="1"] .pe-tablebar { display: flex; }
.pe-tablebar__label { margin-inline-end: 5px; color: #4338ca; font-size: 11px; font-weight: 750; }
.pe-tablebar__spacer { flex: 1; }

.pe-btn-sm {
    height: 29px;
    padding: 0 9px;
    border: 1px solid #d5dcff;
    border-radius: 7px;
    color: #4338ca;
    background: rgba(255, 255, 255, .82);
    cursor: pointer;
    font-size: 10.5px;
}

.pe-btn-sm:hover { border-color: #a5b4fc; background: #fff; }
.pe-btn-sm--danger { color: #b91c1c; border-color: #fecaca; }

.pe-editable table.pe-table {
    width: 100%;
    margin: 18px 0;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 9px;
    table-layout: fixed;
    transition: box-shadow .15s ease, opacity .15s ease;
}

.pe-editable table.pe-table--selected {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pe-primary) 14%, transparent);
}

.pe-editable table.pe-table--dragging { opacity: .58; }

.pe-editable > .pe-table-drop-before { box-shadow: 0 -3px 0 var(--pe-primary); }
.pe-editable > .pe-table-drop-after { box-shadow: 0 3px 0 var(--pe-primary); }

.pe-editable table.pe-table td,
.pe-editable table.pe-table th {
    position: relative;
    min-width: 60px;
    padding: 10px 12px;
    border-inline-end: 1px solid #dbe2ea;
    border-bottom: 1px solid #dbe2ea;
    vertical-align: top;
    word-break: break-word;
}

.pe-editable table.pe-table tr:last-child > * { border-bottom: 0; }
.pe-editable table.pe-table tr > *:last-child { border-inline-end: 0; }
.pe-editable table.pe-table tr:nth-child(even) { background: #f8fafc; }
.pe-editable table.pe-table thead th { color: #283548; background: #eef2f7; font-weight: 750; }
.pe-editable table.pe-table caption {
    padding: 8px 12px;
    color: #475569;
    caption-side: top;
    font-size: 11px;
    font-weight: 700;
    text-align: start;
}

.pe-editable .pe-col-resizer {
    position: absolute;
    top: 0;
    inset-inline-end: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    z-index: 2;
}

.pe-editable .pe-col-resizer::after {
    content: "";
    position: absolute;
    top: 0;
    inset-inline-end: 3px;
    width: 1px;
    height: 100%;
    background: transparent;
}

.pe-editable .pe-col-resizer:hover::after { background: var(--pe-primary); }
.pe-editable .pe-col-resizer:focus-visible { outline: 2px solid var(--pe-primary); outline-offset: -2px; }

.pe-editable .pe-row-resizer {
    position: absolute;
    inset-inline-end: 18px;
    bottom: -5px;
    z-index: 3;
    width: 34px;
    height: 11px;
    cursor: row-resize;
    opacity: 0;
    user-select: none;
    touch-action: none;
    transition: opacity .12s ease;
}

.pe-editable .pe-row-resizer::after {
    content: "";
    position: absolute;
    inset-inline: 4px;
    top: 4px;
    height: 3px;
    border-radius: 999px;
    background: var(--pe-primary);
    box-shadow: 0 0 0 2px #fff;
}

.pe-editable table.pe-table:hover .pe-row-resizer { opacity: .45; }
.pe-editable table.pe-table--selected .pe-row-resizer,
.pe-editable table.pe-document-block--selected .pe-row-resizer,
.pe-editable table.pe-table tr:hover .pe-row-resizer,
.pe-editable .pe-row-resizer:hover,
.pe-editable .pe-row-resizer:focus-visible { opacity: 1; }

.pe-editable .pe-row-resizer:focus-visible {
    outline: 2px solid var(--pe-primary);
    outline-offset: 1px;
    border-radius: 5px;
}

.pe-editable .pe-table-move-handle,
.pe-editable .pe-table-resizer {
    position: absolute;
    z-index: 4;
    display: none;
    place-items: center;
    color: #fff;
    background: var(--pe-primary);
    box-shadow: 0 3px 10px rgba(79, 70, 229, .25);
    user-select: none;
    touch-action: none;
}

.pe-editable table.pe-table--selected .pe-table-move-handle,
.pe-editable table.pe-table--selected .pe-table-resizer,
.pe-editable table.pe-document-block--selected .pe-table-move-handle,
.pe-editable table.pe-document-block--selected .pe-table-resizer,
.pe-editable table.pe-table:focus-within .pe-table-move-handle,
.pe-editable table.pe-table:focus-within .pe-table-resizer,
.pe-editable table.pe-table:hover .pe-table-move-handle,
.pe-editable table.pe-table:hover .pe-table-resizer { display: grid; }

.pe-editable .pe-table-move-handle {
    top: -13px;
    inset-inline-start: -13px;
    width: 26px;
    height: 26px;
    border: 2px solid #fff;
    border-radius: 8px;
    cursor: grab;
    font-size: 17px;
    line-height: 1;
}

.pe-editable .pe-table-move-handle:active { cursor: grabbing; }

.pe-editable .pe-table-resizer {
    inset-inline-end: -7px;
    bottom: -7px;
    width: 15px;
    height: 15px;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: nwse-resize;
}

.pe-editable[dir="rtl"] .pe-table-resizer { cursor: nesw-resize; }
.pe-editable .pe-table-resizer:focus-visible,
.pe-editable .pe-table-move-handle:focus-visible {
    display: grid;
    outline: 2px solid var(--pe-primary);
    outline-offset: 2px;
}
.pe-root.pe-is-resizing,
.pe-root.pe-is-resizing * {
    cursor: var(--pe-active-resize-cursor, col-resize) !important;
    user-select: none;
}
.pe-root.pe-is-moving-table,
.pe-root.pe-is-moving-table * { cursor: grabbing !important; }

@media (pointer: coarse) {
    .pe-editable .pe-col-resizer { inset-inline-end: -7px; width: 15px; }
    .pe-editable .pe-row-resizer {
        inset-inline-end: 24px;
        bottom: -12px;
        width: 48px;
        height: 24px;
    }
    .pe-editable .pe-row-resizer::after { top: 10px; }
    .pe-editable .pe-table-resizer {
        inset-inline-end: -11px;
        bottom: -11px;
        width: 24px;
        height: 24px;
    }
}

.pe-popover {
    position: absolute;
    z-index: 70;
    min-width: 244px;
    padding: 12px;
    border: 1px solid var(--pe-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(15, 23, 42, .17);
}

.pe-popover__title { display: block; margin-bottom: 10px; color: #334155; font-size: 11.5px; }

.pe-grid {
    direction: ltr;
    display: grid;
    grid-template-columns: repeat(10, 17px);
    grid-auto-rows: 17px;
    gap: 4px;
    padding: 9px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #f8fafc;
}

.pe-grid-cell {
    width: 17px;
    height: 17px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
}

.pe-grid-cell.active { border-color: #4f46e5; background: #818cf8; }
.pe-grid-label { margin-top: 9px; color: #475569; font-size: 11px; text-align: center; }

.pe-media {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 12px 0;
    border-radius: 10px;
}

.pe-media img,
.pe-media video,
.pe-media iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.pe-media iframe {
    aspect-ratio: 16 / 9;
    border: 0;
}

.pe-media-caption {
    display: block;
    padding: 8px 10px 2px;
    color: #64748b;
    font-size: 11px;
    line-height: 1.7;
    text-align: center;
}

.pe-media-handle {
    position: absolute;
    inset-inline-end: -6px;
    bottom: -6px;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--pe-primary);
    box-shadow: 0 3px 10px rgba(15, 23, 42, .2);
    cursor: nwse-resize;
}

.pe-media.pe-selected::after {
    content: "";
    position: absolute;
    inset: -4px;
    border: 2px solid #6366f1;
    border-radius: 13px;
    pointer-events: none;
}

.pe-media-toolbar {
    position: absolute;
    z-index: 75;
    display: none;
    align-items: center;
    gap: 5px;
    max-width: calc(100% - 16px);
    padding: 6px;
    overflow-x: auto;
    border: 1px solid #dbe2ea;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
    white-space: nowrap;
}

.pe-media-toolbar__label { padding: 0 5px; color: var(--pe-muted); font-size: 10px; }
.pe-media-width { height: 29px; display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; border: 1px solid #dbe2ea; border-radius: 7px; color: var(--pe-muted); font-size: 10px; }
.pe-media-width input { width: 42px; padding: 0; border: 0; outline: 0; color: #334155; background: transparent; text-align: center; }

.pe-mbtn {
    height: 29px;
    padding: 0 8px;
    border: 1px solid #dbe2ea;
    border-radius: 7px;
    color: #475569;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
}

.pe-mbtn:hover { background: #f8fafc; }
.pe-mbtn--primary { color: #fff; border-color: var(--pe-primary); background: var(--pe-primary); }
.pe-mbtn--primary:hover { background: var(--pe-primary-strong); }
.pe-mbtn--danger { color: #b91c1c; border-color: #fecaca; background: #fff7f7; }

.pe-upload {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    background: rgba(248, 250, 252, .84);
    backdrop-filter: blur(5px);
}

.pe-upload-box {
    width: min(380px, calc(100% - 32px));
    padding: 20px;
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 22px 58px rgba(15, 23, 42, .16);
    text-align: center;
}

.pe-upload-icon { width: 42px; height: 42px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: var(--pe-primary); font-size: 20px; }
.pe-upload-text { margin-bottom: 13px; color: #334155; font-size: 12px; font-weight: 650; }
.pe-upload-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e2e8f0; }
.pe-upload-bar-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width .15s linear; }
.pe-upload-percent { margin-top: 7px; color: var(--pe-muted); font-size: 10px; }

.pe-drop-hint {
    position: absolute;
    inset: 18px;
    z-index: 25;
    display: none;
    place-items: center;
    align-content: center;
    gap: 7px;
    border: 2px dashed #818cf8;
    border-radius: 11px;
    color: #4338ca;
    background: rgba(238, 242, 255, .94);
    pointer-events: none;
}

.pe-drop-hint > span { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: #6366f1; font-size: 24px; }
.pe-drop-hint strong { margin-top: 4px; font-size: 13px; }
.pe-drop-hint small { color: #636c88; font-size: 10.5px; }
.pe-workspace--dragging .pe-drop-hint { display: grid; }

.pe-toast {
    position: absolute;
    inset-inline-start: 16px;
    bottom: 50px;
    z-index: 130;
    max-width: min(360px, calc(100% - 32px));
    padding: 10px 13px;
    border: 1px solid #dbe2ea;
    border-radius: 10px;
    color: #334155;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .15);
    font-size: 11px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
}

.pe-toast--show { opacity: 1; transform: translateY(0); }
.pe-toast--success { color: #065f46; border-color: #a7f3d0; background: #ecfdf5; }
.pe-toast--error { color: #991b1b; border-color: #fecaca; background: #fff7f7; }

.pe-dialog-backdrop {
    position: absolute;
    inset: 0;
    z-index: 150;
    display: grid;
    place-items: center;
    padding: 20px;
    border-radius: inherit;
    background: rgba(15, 23, 42, .52);
    backdrop-filter: blur(3px);
}

.pe-dialog {
    width: min(480px, 100%);
    max-height: calc(100% - 16px);
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 26px 70px rgba(15, 23, 42, .25);
}

.pe-dialog__header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid #edf0f4;
}

.pe-dialog__icon { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 10px; color: #4338ca; background: #eef2ff; font-size: 18px; }
.pe-dialog__header > div { min-width: 0; flex: 1; }
.pe-dialog__header strong,
.pe-dialog__header small { display: block; }
.pe-dialog__header strong { margin-bottom: 3px; color: #172033; font-size: 13px; }
.pe-dialog__header small { color: #64748b; font-size: 10.5px; }
.pe-dialog__close { width: 31px; height: 31px; padding: 0; border: 0; border-radius: 8px; color: #64748b; background: #f1f5f9; cursor: pointer; font-size: 20px; line-height: 1; }
.pe-dialog__body { padding: 16px; }

.pe-field { display: block; margin-bottom: 13px; }
.pe-field > span { display: block; margin-bottom: 6px; color: #475569; font-size: 11px; font-weight: 650; }
.pe-field input { width: 100%; height: 39px; padding: 0 11px; border: 1px solid #cbd5e1; border-radius: 9px; color: #172033; outline: 0; background: #fff; font-family: inherit; font-size: 12px; }
.pe-field input:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(99, 102, 241, .1); }
.pe-check { display: inline-flex; align-items: center; gap: 8px; color: #475569; cursor: pointer; font-size: 11px; }
.pe-check input { accent-color: var(--pe-primary); }

.pe-dialog__actions { padding: 14px 16px; display: flex; align-items: center; justify-content: flex-end; gap: 7px; border-top: 1px solid #edf0f4; }
.pe-dialog__body .pe-dialog__actions { margin: 16px -16px -16px; }
.pe-dialog__actions--wrap { flex-wrap: wrap; }
.pe-find-status { min-height: 20px; margin: 12px 0 0; color: #64748b; font-size: 11px; }
.pe-dialog-btn { height: 36px; padding: 0 13px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 11px; font-weight: 650; }
.pe-dialog-btn--primary { color: #fff; border-color: var(--pe-primary); background: var(--pe-primary); }
.pe-dialog-btn--primary:hover { background: var(--pe-primary-strong); }
.pe-dialog-btn--ghost { color: #475569; border-color: #dbe2ea; background: #fff; }
.pe-dialog-btn--danger { margin-inline-end: auto; color: #b91c1c; border-color: #fecaca; background: #fff7f7; }

.pe-shortcuts {
    padding: 16px;
    display: grid;
    grid-template-columns: minmax(110px, 1fr) auto auto auto;
    align-items: center;
    gap: 9px 6px;
    color: #475569;
    font-size: 11px;
}

.pe-shortcuts kbd { min-width: 31px; padding: 5px 7px; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 6px; color: #334155; background: #f8fafc; font: 10px ui-monospace, monospace; text-align: center; }
.pe-shortcuts b { color: #94a3b8; font-weight: 400; }

.pe-about {
    margin: 0 16px 16px;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px 12px;
    border: 1px solid #e0e7ff;
    border-radius: 11px;
    color: #475569;
    background: #f8faff;
    font-size: 11px;
}

.pe-about__product {
    margin-inline-end: auto;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.pe-about__product strong { color: #312e81; font-size: 12px; }
.pe-about__product small { color: #64748b; font-size: 10px; }
.pe-about a { color: #4338ca; font-weight: 700; text-decoration: none; }
.pe-about a:hover { text-decoration: underline; }
.pe-about a:focus-visible { outline: 2px solid #818cf8; outline-offset: 3px; border-radius: 3px; }

.pe-fullscreen {
    position: fixed;
    inset: 10px;
    z-index: 99999;
    height: calc(100dvh - 20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, .3);
}

.pe-editor-fullscreen-open { overflow: hidden !important; }
.pe-fullscreen .pe-header { flex: 0 0 auto; }
.pe-fullscreen .pe-toolbar { flex: 0 0 auto; max-height: min(34dvh, 220px); overflow-y: auto; }
.pe-fullscreen .pe-tablebar { flex: 0 0 auto; }
.pe-fullscreen .pe-workspace { box-sizing: border-box; flex: 1 1 0; min-height: 0; display: flex; overflow: hidden; }
.pe-fullscreen .pe-editable,
.pe-fullscreen .pe-source {
    box-sizing: border-box;
    height: 100%;
    min-height: 0;
    max-height: none;
    flex: 1 1 0;
    overflow: auto;
    overscroll-behavior: contain;
}
.pe-fullscreen .pe-status { flex: 0 0 auto; }
.pe-fullscreen .pe-dialog-backdrop { position: fixed; inset: 10px; }

[data-bs-theme="dark"] .pe-root,
body[data-bs-theme="dark"] .pe-root {
    --pe-border: #344258;
    --pe-border-soft: #28364a;
    --pe-canvas: #0e1726;
    --pe-surface: #172235;
    --pe-surface-soft: #121c2c;
    --pe-text: #e5eaf2;
    --pe-muted: #9aa8bd;
}

[data-bs-theme="dark"] .pe-header,
[data-bs-theme="dark"] .pe-toolbar,
[data-bs-theme="dark"] .pe-dialog,
[data-bs-theme="dark"] .pe-popover,
[data-bs-theme="dark"] .pe-media-toolbar,
[data-bs-theme="dark"] .pe-upload-box { background: #172235; }
[data-bs-theme="dark"] .pe-editable { color: #dbe3ee; border-color: #344258; background: #101a2a; }
[data-bs-theme="dark"] .pe-editable h1,
[data-bs-theme="dark"] .pe-editable h2,
[data-bs-theme="dark"] .pe-editable h3 { color: #f1f5f9; }
[data-bs-theme="dark"] .pe-btn,
[data-bs-theme="dark"] .pe-select { color: #cbd5e1; }

@media (max-width: 780px) {
    .pe-header { min-height: 58px; padding: 10px 12px; }
    .pe-brand__icon { width: 34px; height: 34px; flex-basis: 34px; }
    .pe-brand small,
    .pe-header-state { display: none; }
    .pe-toolbar { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; }
    .pe-toolbar-group { flex: 0 0 auto; }
    .pe-workspace { padding: 8px; }
    .pe-editable { padding: 20px 16px; font-size: 14px; }
    .pe-drop-hint { inset: 8px; }
    .pe-status__context { display: none; }
    .pe-status { justify-content: flex-end; }
    .pe-status__meta { width: 100%; justify-content: space-between; gap: 7px; }
    .pe-tablebar { flex-wrap: nowrap; overflow-x: auto; }
    .pe-tablebar__spacer { display: none; }
    .pe-dialog-backdrop { padding: 10px; }
    .pe-dialog__actions { flex-wrap: wrap; }
    .pe-dialog-btn--danger { order: 3; width: 100%; margin-inline-end: 0; }
    .pe-fullscreen { inset: 0; height: 100dvh; border: 0; border-radius: 0; }
    .pe-fullscreen .pe-header { border-radius: 0; }
    .pe-fullscreen .pe-dialog-backdrop { inset: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .pe-root *,
    .pe-root *::before,
    .pe-root *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@keyframes pe-loading {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

@keyframes pe-pulse {
    0%, 100% { opacity: .45; transform: scale(.88); }
    50% { opacity: 1; transform: scale(1); }
}

.pe-btn-custom {
    min-width: max-content;
    padding-inline: 10px;
    color: var(--pe-primary-strong);
    border-color: color-mix(in srgb, var(--pe-primary) 22%, var(--pe-border));
    background: color-mix(in srgb, var(--pe-primary) 6%, var(--pe-surface));
}

.pe-count--over { color: #b91c1c; font-weight: 700; }
.pe-invalid .pe-status { box-shadow: inset 0 2px 0 #ef4444; }

.pe-root[data-ui-culture="en"] { text-align: left; }
.pe-root[data-ui-culture="en"] .pe-toolbar,
.pe-root[data-ui-culture="en"] .pe-dialog,
.pe-root[data-ui-culture="en"] .pe-status { direction: ltr; }

.pe-dialog--wide { width: min(900px, 96vw); max-width: 900px; }

.pe-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.pe-template-card {
    min-height: 118px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    text-align: start;
    color: var(--pe-text);
    border: 1px solid var(--pe-border-soft);
    border-radius: 12px;
    background: var(--pe-surface-soft);
    cursor: pointer;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.pe-template-card:hover,
.pe-template-card:focus-visible {
    border-color: #818cf8;
    box-shadow: 0 8px 22px rgba(79, 70, 229, .12);
    transform: translateY(-1px);
    outline: none;
}

.pe-template-card__category {
    padding: 3px 7px;
    color: var(--pe-primary-strong);
    border-radius: 999px;
    background: var(--pe-primary-soft);
    font-size: 10px;
}

.pe-template-card strong { font-size: 13px; }
.pe-template-card small { color: var(--pe-muted); line-height: 1.7; }
.pe-template-empty,
.pe-media-library-empty { margin: 12px 0 0; color: var(--pe-muted); text-align: center; }

.pe-editable .pe-callout {
    margin: 1em 0;
    padding: 14px 16px;
    display: block;
    border: 1px solid #bfdbfe;
    border-inline-start: 4px solid #3b82f6;
    border-radius: 10px;
    background: #eff6ff;
}

.pe-editable .pe-callout--warning { border-color: #fde68a; border-inline-start-color: #f59e0b; background: #fffbeb; }
.pe-editable .pe-callout--success { border-color: #a7f3d0; border-inline-start-color: #10b981; background: #ecfdf5; }
.pe-editable .pe-callout > strong { display: block; margin-bottom: 5px; }
.pe-editable .pe-callout > p { margin: 0; }

.pe-editable .pe-content-button {
    padding: 9px 16px;
    display: inline-block;
    color: #fff;
    border-radius: 8px;
    background: var(--pe-primary);
    font-weight: 700;
    text-decoration: none;
}

.pe-media-library {
    max-height: min(56vh, 540px);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    overflow: auto;
}

.pe-media-library-card {
    padding: 0;
    overflow: hidden;
    color: var(--pe-text);
    text-align: start;
    border: 1px solid var(--pe-border-soft);
    border-radius: 12px;
    background: var(--pe-surface);
    cursor: pointer;
}

.pe-media-library-card:hover,
.pe-media-library-card:focus-visible { border-color: #818cf8; outline: 2px solid rgba(99, 102, 241, .18); }
.pe-media-library-card > img,
.pe-media-library__video { width: 100%; height: 112px; display: grid; place-items: center; object-fit: cover; background: var(--pe-canvas); }
.pe-media-library__video { color: var(--pe-primary); font-size: 30px; }
.pe-media-library-card > span { padding: 9px 10px; display: flex; flex-direction: column; gap: 3px; }
.pe-media-library-card strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.pe-media-library-card small { color: var(--pe-muted); font-size: 10px; }

.pe-image-preview {
    min-height: 150px;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--pe-muted);
    border: 1px dashed var(--pe-border);
    border-radius: 11px;
    background: var(--pe-canvas);
}

.pe-image-preview img { width: 100%; max-height: 260px; object-fit: contain; }
.pe-dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pe-image-quality-field { display: grid; grid-template-columns: 1fr auto; }
.pe-image-quality-field > span { grid-column: 1 / -1; }
.pe-image-quality-field input { width: 100%; }
.pe-image-quality-field output { min-width: 42px; text-align: end; }

.pe-revisions {
    min-height: 360px;
    display: grid;
    grid-template-columns: minmax(210px, .75fr) minmax(0, 1.7fr);
    gap: 12px;
}

.pe-revision-list {
    max-height: 52vh;
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow: auto;
}

.pe-revision-item {
    padding: 10px 11px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    color: var(--pe-text);
    text-align: start;
    border: 1px solid var(--pe-border-soft);
    border-radius: 9px;
    background: var(--pe-surface);
    cursor: pointer;
}

.pe-revision-item time { grid-column: 1 / -1; color: var(--pe-muted); font-size: 10px; }
.pe-revision-item.active { border-color: var(--pe-primary); background: var(--pe-primary-soft); }
.pe-revision-preview {
    padding: 16px;
    overflow: auto;
    color: var(--pe-text);
    border: 1px solid var(--pe-border-soft);
    border-radius: 10px;
    background: var(--pe-surface-soft);
}

/* BridgeEditor 3 structured document workspace */
.pe-document-layout {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 310px);
    align-items: stretch;
    background: var(--pe-canvas);
}

.pe-document-layout--html { display: block; }
.pe-document-layout > .pe-workspace { min-width: 0; }
.pe-root[data-mode="source"] .pe-document-layout { grid-template-columns: minmax(0, 1fr); }
.pe-root[data-mode="source"] .pe-inspector,
.pe-root[data-mode="source"] .pe-block-toolbar { display: none !important; }
.pe-fullscreen .pe-document-layout { flex: 1 1 0; min-height: 0; overflow: hidden; }
.pe-fullscreen .pe-document-layout > .pe-workspace { height: 100%; min-height: 0; display: flex; overflow: hidden; }
.pe-fullscreen .pe-document-layout > .pe-inspector { min-height: 0; overflow: auto; }

.pe-editable > .pe-document-block {
    position: relative;
    border-radius: 7px;
    outline: 1px solid transparent;
    outline-offset: 7px;
    transition: outline-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}

.pe-editable > .pe-document-block:hover { outline-color: color-mix(in srgb, var(--pe-primary) 25%, transparent); }
.pe-editable > .pe-document-block--selected {
    outline: 2px solid color-mix(in srgb, var(--pe-primary) 74%, white);
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--pe-primary) 7%, transparent);
}
.pe-editable > .pe-document-block--drop-before::before,
.pe-editable > .pe-document-block--drop-after::after {
    content: "";
    position: absolute;
    z-index: 4;
    inset-inline: -8px;
    height: 3px;
    border-radius: 99px;
    background: var(--pe-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pe-primary) 15%, transparent);
}
.pe-editable > .pe-document-block--drop-before::before { top: -12px; }
.pe-editable > .pe-document-block--drop-after::after { bottom: -12px; }

.pe-block-toolbar {
    position: absolute;
    z-index: 14;
    padding: 3px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    direction: ltr;
    border: 1px solid var(--pe-border);
    border-radius: 8px;
    background: var(--pe-surface);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .15);
    transform: translateY(-100%);
}
.pe-block-toolbar button {
    width: 27px;
    height: 27px;
    padding: 0;
    display: grid;
    place-items: center;
    color: var(--pe-muted);
    border: 0;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
}
.pe-block-toolbar button:hover,
.pe-block-toolbar button:focus-visible { color: var(--pe-primary-strong); background: var(--pe-primary-soft); outline: none; }
.pe-block-toolbar .pe-block-handle { cursor: grab; font-size: 17px; }
.pe-block-toolbar .pe-block-handle:active { cursor: grabbing; }
.pe-block-toolbar .pe-block-action--danger:hover { color: #b91c1c; background: #fef2f2; }

.pe-inspector {
    min-width: 0;
    border-inline-start: 1px solid var(--pe-border-soft);
    background: var(--pe-surface);
}
.pe-inspector__header {
    min-height: 64px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--pe-border-soft);
}
.pe-inspector__header strong,
.pe-inspector__header small { display: block; }
.pe-inspector__header strong { margin-bottom: 3px; font-size: 12px; }
.pe-inspector__header small { max-width: 170px; overflow: hidden; color: var(--pe-muted); font: 9px/1.5 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.pe-inspector__type {
    max-width: 112px;
    padding: 4px 7px;
    overflow: hidden;
    color: var(--pe-primary-strong);
    border-radius: 999px;
    background: var(--pe-primary-soft);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pe-inspector__body {
    max-height: min(68vh, 720px);
    padding: 13px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: auto;
}
.pe-inspector__empty {
    min-height: 190px;
    padding: 20px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 9px;
    color: var(--pe-muted);
    text-align: center;
    border: 1px dashed var(--pe-border);
    border-radius: 11px;
    background: var(--pe-surface-soft);
}
.pe-inspector__empty span { color: #818cf8; font-size: 24px; }
.pe-inspector__empty p { margin: 0; font-size: 11px; line-height: 1.8; }
.pe-inspector__empty--compact { min-height: 120px; }
.pe-inspector-field { display: flex; flex-direction: column; gap: 5px; }
.pe-inspector-field > span { color: var(--pe-muted); font-size: 10px; font-weight: 700; }
.pe-inspector-field input,
.pe-inspector-field select,
.pe-inspector-field textarea {
    width: 100%;
    min-height: 36px;
    padding: 7px 9px;
    color: var(--pe-text);
    border: 1px solid var(--pe-border);
    border-radius: 8px;
    background: var(--pe-surface);
    font: inherit;
    font-size: 11px;
}
.pe-inspector-field textarea { min-height: 78px; resize: vertical; }
.pe-inspector-field input:focus,
.pe-inspector-field select:focus,
.pe-inspector-field textarea:focus { border-color: #818cf8; outline: 3px solid rgba(99, 102, 241, .1); }
.pe-inspector-field input:invalid { border-color: #ef4444; }
.pe-inspector-actions { padding-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; border-top: 1px solid var(--pe-border-soft); }
.pe-inspector-actions button {
    min-height: 34px;
    color: var(--pe-text);
    border: 1px solid var(--pe-border);
    border-radius: 8px;
    background: var(--pe-surface-soft);
    cursor: pointer;
    font: inherit;
    font-size: 10px;
}
.pe-inspector-actions .pe-inspector-action--danger { color: #b91c1c; border-color: #fecaca; background: #fff7f7; }

.pe-document-dialog { display: grid; grid-template-columns: minmax(210px, .75fr) minmax(0, 1.55fr); gap: 14px; }
.pe-document-dialog section { min-width: 0; }
.pe-document-dialog h3 { margin: 0 0 8px; display: flex; justify-content: space-between; color: var(--pe-text); font-size: 12px; }
.pe-document-dialog .pe-dialog__actions { grid-column: 1 / -1; }
.pe-document-outline { max-height: min(48vh, 460px); display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.pe-document-outline__item {
    padding: 8px;
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 2px 7px;
    color: var(--pe-text);
    text-align: start;
    border: 1px solid var(--pe-border-soft);
    border-radius: 8px;
    background: var(--pe-surface-soft);
    cursor: pointer;
}
.pe-document-outline__item:hover,
.pe-document-outline__item:focus-visible { border-color: #818cf8; outline: 2px solid rgba(99, 102, 241, .12); }
.pe-document-outline__item > span { grid-row: 1 / 3; color: var(--pe-primary-strong); font-size: 10px; }
.pe-document-outline__item strong { font-size: 10px; }
.pe-document-outline__item small { overflow: hidden; color: var(--pe-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.pe-document-json {
    width: 100%;
    min-height: min(48vh, 460px);
    padding: 12px;
    resize: vertical;
    color: #dbeafe;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0f172a;
    font: 11px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-align: left;
}
.pe-document-json-error { margin: 7px 0 0; color: #b91c1c; font-size: 10px; }

/* Review collaboration (v3.1) */
.pe-collaboration-btn { gap: 6px; }
.pe-collaboration-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-grid;
    place-items: center;
    color: #fff;
    border-radius: 999px;
    background: var(--pe-primary);
    font-size: 9px;
    line-height: 1;
}
.pe-root[data-suggestion-mode="true"] .pe-collaboration-btn { color: var(--pe-primary-strong); background: var(--pe-primary-soft); }
.pe-root[data-suggestion-mode="true"] .pe-editable { box-shadow: inset 3px 0 0 #f59e0b; }
.pe-editable > .pe-document-block.pe-commented { box-shadow: inset 3px 0 0 #38bdf8; }
.pe-editable .pe-suggestion {
    padding: 1px 2px;
    border-radius: 3px;
    text-decoration-thickness: 1.5px;
}
.pe-editable ins.pe-suggestion { color: #166534; background: #dcfce7; text-decoration: none; }
.pe-editable del.pe-suggestion { color: #991b1b; background: #fee2e2; text-decoration-color: #dc2626; }

.pe-dialog--collaboration { width: min(940px, 100%); }
.pe-dialog--collaboration .pe-dialog__header { flex-wrap: wrap; }
.pe-collab-role {
    margin-inline-start: auto;
    padding: 5px 9px;
    color: var(--pe-primary-strong);
    border-radius: 999px;
    background: var(--pe-primary-soft);
    font-size: 10px;
    white-space: nowrap;
}
.pe-collab-tabs {
    padding: 0 18px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-bottom: 1px solid var(--pe-border-soft);
}
.pe-collab-tabs button {
    min-height: 42px;
    padding: 8px 11px;
    color: var(--pe-muted);
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    white-space: nowrap;
}
.pe-collab-tabs button:hover,
.pe-collab-tabs button:focus-visible,
.pe-collab-tabs button.active { color: var(--pe-primary-strong); border-bottom-color: var(--pe-primary); outline: none; }
.pe-collab-pane { min-height: 430px; max-height: min(66vh, 660px); overflow: auto; }
.pe-collab-loading,
.pe-collab-empty {
    min-height: 180px;
    display: grid;
    place-items: center;
    color: var(--pe-muted);
    text-align: center;
    border: 1px dashed var(--pe-border);
    border-radius: 11px;
    background: var(--pe-surface-soft);
}
.pe-collab-error { color: #b91c1c; border-color: #fecaca; background: #fff7f7; }
.pe-comment-composer,
.pe-version-composer {
    margin-bottom: 14px;
    padding: 13px;
    display: grid;
    gap: 8px;
    border: 1px solid color-mix(in srgb, var(--pe-primary) 28%, var(--pe-border));
    border-radius: 11px;
    background: color-mix(in srgb, var(--pe-primary-soft) 58%, var(--pe-surface));
}
.pe-comment-composer > strong,
.pe-comment-composer > small { display: block; }
.pe-comment-composer > small { color: var(--pe-muted); font-size: 10px; }
.pe-comment-composer textarea,
.pe-comment-reply textarea,
.pe-version-composer input {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    color: var(--pe-text);
    border: 1px solid var(--pe-border);
    border-radius: 8px;
    background: var(--pe-surface);
    font: inherit;
    font-size: 11px;
}
.pe-comment-composer textarea { min-height: 86px; resize: vertical; }
.pe-comment-composer .pe-dialog-btn,
.pe-version-composer .pe-dialog-btn { justify-self: end; }
.pe-collab-selection,
.pe-comment-thread blockquote {
    margin: 3px 0;
    padding: 7px 10px;
    overflow: hidden;
    color: var(--pe-muted);
    border-inline-start: 3px solid #38bdf8;
    border-radius: 6px;
    background: var(--pe-surface-soft);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pe-comment-list,
.pe-suggestion-list,
.pe-version-list,
.pe-activity-list { display: flex; flex-direction: column; gap: 9px; }
.pe-comment-thread,
.pe-suggestion-card,
.pe-version-card,
.pe-activity-list > article {
    padding: 12px;
    border: 1px solid var(--pe-border-soft);
    border-radius: 11px;
    background: var(--pe-surface);
}
.pe-comment-thread.is-resolved { opacity: .72; background: var(--pe-surface-soft); }
.pe-comment-thread > header,
.pe-version-card,
.pe-suggestion-card > header { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.pe-collab-status {
    padding: 3px 7px;
    color: #166534;
    border-radius: 999px;
    background: #dcfce7;
    font-size: 9px;
}
.pe-comment-thread.is-resolved .pe-collab-status { color: var(--pe-muted); background: var(--pe-surface-soft); }
.pe-link-action { padding: 3px; color: var(--pe-primary-strong); border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 10px; }
.pe-comment-message,
.pe-activity-list > article { margin-top: 10px; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 9px; }
.pe-collab-avatar {
    width: 28px;
    height: 28px;
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    color: #fff;
    border-radius: 50%;
    background: var(--pe-primary);
    font-size: 10px;
    font-weight: 800;
}
.pe-comment-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 9px; }
.pe-comment-meta strong,
.pe-suggestion-card strong,
.pe-version-card strong,
.pe-activity-list strong { font-size: 10px; }
.pe-comment-meta time,
.pe-suggestion-card small,
.pe-version-card small,
.pe-activity-list time { color: var(--pe-muted); font-size: 9px; }
.pe-comment-message p,
.pe-activity-list p { margin: 4px 0 0; color: var(--pe-text); font-size: 11px; line-height: 1.8; }
.pe-comment-reply { margin-top: 10px; padding-top: 10px; display: grid; grid-template-columns: 1fr auto; gap: 7px; border-top: 1px solid var(--pe-border-soft); }
.pe-comment-reply .pe-mention-picker { grid-column: 1 / -1; }
.pe-mention-picker {
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    border: 1px solid var(--pe-border);
    border-radius: 8px;
    background: var(--pe-surface);
    box-shadow: 0 8px 22px rgba(15, 23, 42, .12);
}
.pe-mention-picker[hidden] { display: none; }
.pe-mention-picker button { padding: 5px 7px; display: flex; align-items: center; gap: 7px; color: var(--pe-text); text-align: start; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font: inherit; font-size: 10px; }
.pe-mention-picker button:hover { background: var(--pe-primary-soft); }
.pe-mention-picker .pe-collab-avatar { width: 23px; height: 23px; font-size: 9px; }
.pe-suggestion-toggle { margin-bottom: 12px; padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; border: 1px solid #fde68a; border-radius: 9px; background: #fffbeb; }
.pe-suggestion-toggle input { grid-row: 1 / 3; align-self: center; }
.pe-suggestion-toggle span { color: #92400e; font-size: 11px; font-weight: 800; }
.pe-suggestion-toggle small { color: #a16207; font-size: 9px; }
.pe-suggestion-card > header { justify-content: flex-start; }
.pe-suggestion-card > header > div { display: flex; flex-direction: column; }
.pe-suggestion-diff { margin: 10px 0; padding: 9px; display: flex; flex-wrap: wrap; gap: 5px; border-radius: 8px; background: var(--pe-surface-soft); font-size: 11px; }
.pe-suggestion-diff ins { color: #166534; background: #dcfce7; text-decoration: none; }
.pe-suggestion-diff del { color: #991b1b; background: #fee2e2; }
.pe-suggestion-actions { display: flex; justify-content: flex-end; gap: 7px; }
.pe-version-composer { grid-template-columns: 1fr auto; align-items: end; }
.pe-version-composer label { display: flex; flex-direction: column; gap: 5px; color: var(--pe-muted); font-size: 10px; }
.pe-version-card > div { display: flex; flex-direction: column; gap: 3px; }
.pe-activity-list > article { margin-top: 0; }
.pe-activity-list span { display: block; color: var(--pe-text); font-size: 10px; }

[data-bs-theme="dark"] .pe-template-card,
[data-bs-theme="dark"] .pe-media-library-card,
[data-bs-theme="dark"] .pe-revision-item,
[data-bs-theme="dark"] .pe-revision-preview,
[data-bs-theme="dark"] .pe-inspector,
[data-bs-theme="dark"] .pe-block-toolbar,
[data-bs-theme="dark"] .pe-inspector-field input,
[data-bs-theme="dark"] .pe-inspector-field select,
[data-bs-theme="dark"] .pe-inspector-field textarea,
[data-bs-theme="dark"] .pe-comment-thread,
[data-bs-theme="dark"] .pe-suggestion-card,
[data-bs-theme="dark"] .pe-version-card,
[data-bs-theme="dark"] .pe-activity-list > article,
[data-bs-theme="dark"] .pe-comment-composer textarea,
[data-bs-theme="dark"] .pe-comment-reply textarea,
[data-bs-theme="dark"] .pe-version-composer input { background: #101a2a; }

@media (max-width: 640px) {
    .pe-template-grid,
    .pe-media-library { grid-template-columns: 1fr 1fr; }
    .pe-dialog-grid,
    .pe-revisions { grid-template-columns: 1fr; }
    .pe-revisions { min-height: 0; }
    .pe-revision-list { max-height: 190px; }
    .pe-revision-preview { max-height: 280px; }
    .pe-document-layout { grid-template-columns: 1fr; }
    .pe-inspector { border-inline-start: 0; border-top: 1px solid var(--pe-border-soft); }
    .pe-inspector__body { max-height: 320px; }
    .pe-document-dialog { grid-template-columns: 1fr; }
    .pe-document-dialog .pe-dialog__actions { grid-column: 1; }
    .pe-document-outline { max-height: 180px; }
    .pe-document-json { min-height: 250px; }
    .pe-block-toolbar { position: fixed; inset-inline: 12px; bottom: 12px; top: auto !important; right: auto !important; left: auto !important; justify-content: center; transform: none; }
    .pe-collab-pane { min-height: 360px; max-height: 68vh; }
    .pe-collab-role { width: 100%; margin-inline-start: 0; text-align: center; }
    .pe-comment-reply,
    .pe-version-composer { grid-template-columns: 1fr; }
    .pe-comment-composer .pe-dialog-btn,
    .pe-version-composer .pe-dialog-btn { width: 100%; justify-self: stretch; }
}
