body {
    font-family: Arial, sans-serif;
}

[editor-instance] {
    position: relative;
    padding-block: 2rem;
}

.editor-ui-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 25;
}

.toolbar {
    --toolbar-fixed-right-width: 56px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    padding: 4px;
    padding-right: calc(4px + var(--toolbar-fixed-right-width));
    /* border-radius: 12px; */
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    position: sticky;
    top: 30px;
    z-index: 20;
}

.toolbar.toolbar--stacked {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 6px;
}

.toolbar.toolbar--stacked .toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

.toolbar-spacer {
    flex: 1 1 auto;
    min-width: 12px;
}

.toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 6px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 8px;
    background-color: #ffffff;
    color: #0f172a;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.toolbar button[data-tooltip] {
    position: relative;
    --tooltip-left: 50%;
    --tooltip-right: auto;
    --tooltip-translate-x: -50%;
}

.toolbar button[data-tooltip][data-tooltip-align="left"] {
    --tooltip-left: 0;
    --tooltip-right: auto;
    --tooltip-translate-x: 0;
}

.toolbar button[data-tooltip][data-tooltip-align="right"] {
    --tooltip-left: auto;
    --tooltip-right: 0;
    --tooltip-translate-x: 0;
}

.toolbar button[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: var(--tooltip-left);
    right: var(--tooltip-right);
    transform: translateX(var(--tooltip-translate-x)) translateY(6px);
    opacity: 0;
    pointer-events: none;
    padding: 6px 10px;
    border-radius: 10px;
    background: #0f172a;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.25);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 50;
}

.toolbar button[data-tooltip]:hover::after,
.toolbar button[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateX(var(--tooltip-translate-x)) translateY(0);
}

.editor-tooltip-measure {
    position: fixed;
    top: -9999px;
    left: -9999px;
    visibility: hidden;
    pointer-events: none;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    box-sizing: border-box;
}

.toolbar button:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
}

.toolbar button.is-active {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #ffffff;
}

.toolbar .toolbar-clean {
    background-color: #fde68a;
    border-color: #e2e8f0;
    color: #0f172a;
}

.toolbar .toolbar-clean:hover {
    background-color: #fcd34d;
    border-color: #f59e0b;
}

.toolbar button.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background-color: #f1f5f9;
    border-color: transparent;
    color: #94a3b8;
    pointer-events: none;
}

.toolbar .icon {
    width: 16px;
    height: 16px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toolbar .icon text {
    stroke: none;
    font-weight: 700;
}

.toolbar .toolbar-primary {
    background: #0ea5e9;
    color: #ffffff;
    border-color: #0ea5e9;
}

.toolbar .toolbar-primary:hover {
    background: #0284c7;
    border-color: #0284c7;
}

.toolbar .toolbar-label {
    font-weight: 700;
    font-size: 0.85rem;
}

.toolbar-fixed-right {
    position: absolute;
    top: 4px;
    right: 4px;
    bottom: 4px;
    padding: 0;
    border: 0;
    background: transparent;
    display: inline-flex;
    align-items: stretch;
}

.toolbar-fixed-right button {
    height: 100%;
    padding: 0 14px;
    border-radius: 10px;
}

.toolbar-dropdown {
    position: relative;
    display: inline-flex;
}

.toolbar-dropdown-trigger {
    gap: 6px;
}

.toolbar-caret {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toolbar-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    display: none;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.16);
    z-index: 30;
}

.toolbar-dropdown.is-open .toolbar-dropdown-menu {
    display: flex;
}

.toolbar-dropdown-menu button {
    justify-content: flex-start;
    width: 100%;
    background: #f8fafc;
    border-radius: 10px;
}

.toolbar-dropdown-menu button:hover {
    background: #e2e8f0;
}

.toolbar-table-menu {
    min-width: 200px;
}

.toolbar-table-inputs {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.toolbar-table-inputs input {
    width: 60px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
    text-align: center;
}

.toolbar-table-sep {
    font-weight: 700;
    color: #64748b;
}

.toolbar-table-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.toolbar-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #0f172a;
}

.toolbar-check input {
    width: 14px;
    height: 14px;
}


.editor {
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    min-height: 300px;
    padding: 10px;
    outline: none;
    overflow: visible;
    height: auto;
    position: relative;
    --editor-handle-gutter: 32px;
    background: #ffffff;
    cursor: text;
}

.editor-columns {
    display: flex;
    align-items: flex-start;
    gap: var(--column-gap, 16px);
    flex-wrap: nowrap;
}

.editor-columns .editor-column {
    min-width: 0;
    flex: 0 1 var(--column-left, 50%);
}

.editor-columns .editor-column[data-column="right"] {
    flex-basis: var(--column-right, 50%);
}

@media (max-width: 720px) {
    .editor-columns {
        flex-direction: column;
    }

    .editor-columns .editor-column {
        flex-basis: auto;
        width: 100%;
    }
}

[editor-instance].is-html-view .editor {
    background: #fef9c3;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: var(--editor-html-font-size, 0.85rem);
    white-space: pre-wrap;
    line-height: var(--editor-html-line-height, 1.45);
    tab-size: 4;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
    width: calc(100% - calc(var(--editor-html-gutter, 44px) / 2));
    min-width: 0;
}

.editor-html-view {
    display: block;
    position: relative;
}

[editor-instance].is-html-view .editor-html-view {
    display: grid;
    grid-template-columns: var(--editor-html-gutter, 44px) 1fr;
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

.editor-html-gutter {
    display: none;
}

[editor-instance].is-html-view .editor-html-gutter {
    display: block;
    position: relative;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    color: #94a3b8;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: var(--editor-html-font-size, 0.85rem);
    line-height: var(--editor-html-line-height, 1.45);
    padding: 10px 8px 10px 16px;
    text-align: right;
    user-select: none;
}

[editor-instance].is-html-view .editor-html-gutter::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: #e2e8f0;
}

[editor-instance].is-html-view .editor-html-template-box {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 6px 0;
    white-space: pre-wrap;
    color: #0f172a;
}

.editor-html-lines {
    white-space: pre;
    pointer-events: none;
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 35px;
    padding: 0 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    font-size: 0.85rem;
    position: sticky;
    bottom: 0;
    z-index: 20;
}

.editor-footer-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
}

.editor-footer-counts {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

.editor-footer-sep {
    width: 1px;
    height: 18px;
    background: #e2e8f0;
}

.editor-footer-tags {
    font-size: 0.75rem;
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50ch;
    flex: 1 1 auto;
    min-width: 0;
}

.editor-footer-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background-color: #fde68a;
    color: #0f172a;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.editor-footer-button .icon {
    width: 16px;
    height: 16px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.editor-footer-button:hover {
    background-color: #fcd34d;
    border-color: #f59e0b;
}

.editor-footer-button[editor-word-paste] {
    width: auto;
    padding: 0 10px;
    gap: 6px;
    background-color: #22c55e;
    border-color: #16a34a;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.editor-footer-button[editor-word-paste]:hover {
    background-color: #16a34a;
    border-color: #15803d;
}

.editor-footer-button[editor-select-all] {
    background-color: #0ea5e9;
    border-color: #0ea5e9;
    color: #ffffff;
}

.editor-footer-button[editor-select-all]:hover {
    background-color: #0284c7;
    border-color: #0284c7;
}

.editor-footer-button[editor-delete-selection] {
    background-color: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}

.editor-footer-button[editor-delete-selection]:hover {
    background-color: #dc2626;
    border-color: #dc2626;
}

.editor-footer-button:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: 2px;
}

.editor-footer button[data-tooltip] {
    position: relative;
    --tooltip-left: 50%;
    --tooltip-right: auto;
    --tooltip-translate-x: -50%;
}

.editor-footer button[data-tooltip][data-tooltip-align="left"] {
    --tooltip-left: 0;
    --tooltip-right: auto;
    --tooltip-translate-x: 0;
}

.editor-footer button[data-tooltip][data-tooltip-align="right"] {
    --tooltip-left: auto;
    --tooltip-right: 0;
    --tooltip-translate-x: 0;
}

.editor-footer button[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: var(--tooltip-left);
    right: var(--tooltip-right);
    transform: translateX(var(--tooltip-translate-x)) translateY(6px);
    opacity: 0;
    pointer-events: none;
    padding: 6px 10px;
    border-radius: 10px;
    background: #0f172a;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.25);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 50;
}

.editor-footer button[data-tooltip]:hover::after,
.editor-footer button[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateX(var(--tooltip-translate-x)) translateY(0);
}

.editor-footer-count {
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.editor p,
.editor h1,
.editor h2,
.editor h3,
.editor h4,
.editor blockquote,
.editor pre,
.editor ul,
.editor ol,
.editor table,
.editor [data-image-block] {
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
    padding: 6px 6px 6px calc(6px + var(--editor-handle-gutter));
    margin: 8px 0;
}
.editor pre,
.editor pre code,
.editor pre {
    max-width: 100%;
}

.editor ul,
.editor ol {
    padding-left: calc(26px + var(--editor-handle-gutter));
}

.editor [data-image-block] {
    display: block;
    padding: 10px 10px 10px calc(10px + var(--editor-handle-gutter));
    max-width: 100%;
}

.editor [data-columns-block] {
    padding-left: calc(6px + var(--editor-handle-gutter));
}

.editor hr {
    border: none;
    border-top: 1px solid #cbd5e1;
    margin: 14px 0;
}

.editor table {
    width: 100%;
    border-collapse: collapse;
    --editor-handle-gutter: 24px;
}

.editor table td,
.editor table th {
    border: 1px dashed #e2e8f0;
    padding: 8px;
    vertical-align: top;
}

.editor table thead th,
.editor table thead td,
.editor table tfoot td,
.editor table tfoot th {
    background: #f1f5f9;
}

.editor table td:focus-within,
.editor table th:focus-within {
    outline: 2px solid #38bdf8;
    outline-offset: 2px;
}

.editor [data-image-block],
.editor [data-image-block] * {
    box-sizing: border-box;
}

.editor [data-image-block] img {
    width: 100%;
    height: auto;
    display: block;
}

.editor [data-image-block] a.image-link {
    position: relative;
    display: inline-block;
}

.editor-image-block.image-layout-center > a.image-link {
    width: var(--image-size, 100%);
    margin: 0 auto;
    display: block;
}

.editor-image-block.image-layout-left > a.image-link {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    display: block;
}

.editor-image-block.image-layout-right > a.image-link {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    display: block;
}

.editor .image-link-trigger {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.95);
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
    user-select: none;
    pointer-events: auto;
}

.editor .image-link-trigger .icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.editor [data-image-block] figcaption {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #0f172a;
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
    padding: 8px 10px;
    border-radius: 8px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    min-height: 28px;
    position: relative;
}

.editor [data-image-block] figcaption.is-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.editor [data-image-block] figcaption.is-active,
.editor [data-image-block] figcaption:not(.is-empty) {
    padding-right: 32px;
}

.editor [data-image-block] figcaption.is-active [data-caption-add],
.editor [data-image-block] figcaption:not(.is-empty) [data-caption-add] {
    display: none;
}

.editor [data-image-block] .image-caption-add,
.editor [data-image-block] .gallery-caption-add,
.editor [data-image-block] .image-caption-remove,
.editor [data-image-block] .gallery-caption-remove {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px dashed #94a3b8;
    background: #ffffff;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0;
    line-height: 0;
}

.editor [data-image-block] .image-caption-trigger {
    margin: 8px auto 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px dashed #94a3b8;
    background: #ffffff;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0;
    line-height: 0;
}

.editor-image-block.image-layout-gallery .gallery-caption-trigger {
    align-self: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px dashed #94a3b8;
    background: #ffffff;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0;
    line-height: 0;
}

.editor [data-image-block] .image-caption-remove,
.editor [data-image-block] .gallery-caption-remove {
    position: absolute;
    top: 0;
    right: -10px;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: none;
    background: #ef4444;
    color: #ffffff;
}

.editor [data-image-block] figcaption.is-empty [data-caption-remove] {
    display: none;
}

.editor [data-image-block] .image-caption-add svg,
.editor [data-image-block] .gallery-caption-add svg,
.editor [data-image-block] .image-caption-remove svg,
.editor [data-image-block] .gallery-caption-remove svg,
.editor [data-image-block] .image-caption-trigger svg,
.editor [data-image-block] .gallery-caption-trigger svg,
.editor [data-image-block] .gallery-image-remove svg,
.editor [data-image-block] .gallery-add svg,
.editor [data-image-block] .gallery-group-add svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.editor-image-block.image-layout-center {
    text-align: center;
}

.editor-image-block.image-layout-center img {
    width: var(--image-size, 100%);
    margin: 0 auto;
}

.editor-image-block.image-layout-center figcaption {
    width: var(--image-size, 100%);
    margin: 0 auto;
}

.editor-image-block.image-layout-left,
.editor-image-block.image-layout-right {
    display: grid;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 0;
    align-items: start;
    width: 100%;
}

.editor-image-block.image-layout-left {
    grid-template-columns: minmax(0, var(--image-size, 50%)) minmax(0, calc(100% - var(--image-size, 50%)));
}

.editor-image-block.image-layout-right {
    grid-template-columns: minmax(0, calc(100% - var(--image-size, 50%))) minmax(0, var(--image-size, 50%));
}

.editor-image-block.image-layout-left > img {
    grid-column: 1;
    grid-row: 1;
}

.editor-image-block.image-layout-left > .image-caption-trigger {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
}

.editor-image-block.image-layout-left > figcaption {
    grid-column: 1;
    grid-row: 2;
}

.editor-image-block.image-layout-left > [data-image-text] {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.editor-image-block.image-layout-right > img {
    grid-column: 2;
    grid-row: 1;
}

.editor-image-block.image-layout-right > .image-caption-trigger {
    grid-column: 2;
    grid-row: 2;
    justify-self: center;
}

.editor-image-block.image-layout-right > figcaption {
    grid-column: 2;
    grid-row: 2;
}

.editor-image-block.image-layout-right > [data-image-text] {
    grid-column: 1;
    grid-row: 1 / span 2;
}

.editor-image-block .image-text {
    min-width: 0;
}

.editor-image-block.image-layout-left img,
.editor-image-block.image-layout-right img {
    width: 100%;
}

.editor-image-block.image-layout-left figcaption,
.editor-image-block.image-layout-right figcaption {
    width: 100%;
    margin-top: 0;
}

.editor-image-block.image-layout-gallery {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.editor-image-block.image-layout-gallery .gallery-group {
    display: grid;
    grid-template-columns: repeat(var(--gallery-cols, 3), minmax(0, 1fr));
    gap: 8px;
}

.editor-image-block.image-layout-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.editor-image-block.image-layout-gallery > figcaption {
    grid-column: 1 / -1;
}

.editor-image-block.image-layout-gallery .gallery-group-add {
    align-self: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px dashed #94a3b8;
    background: #ffffff;
    color: #0f172a;
    font-size: 0;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.editor [data-image-text] {
    padding-left: 0;
}

.editor-image-block.image-layout-gallery .gallery-item {
    border: 1px dashed #e2e8f0;
    border-radius: 10px;
    padding: 4px;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #f8fafc;
}

.editor-image-block.image-layout-gallery .gallery-item.is-empty {
    background: #f8fafc;
}

.editor-image-block.image-layout-gallery .gallery-add {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px dashed #94a3b8;
    background: #ffffff;
    color: #0f172a;
    font-size: 0;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.editor-image-block.image-layout-gallery .gallery-item:not(.is-empty) .gallery-add {
    display: none;
}

.editor-image-block.image-layout-gallery .gallery-figure {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.editor-image-block.image-layout-gallery .gallery-image {
    width: 100%;
    aspect-ratio: 3 / 4;
    min-height: 120px;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.editor-image-block.image-layout-gallery .gallery-image a.image-link {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

.editor-image-block.image-layout-gallery .gallery-caption {
    font-size: 0.85rem;
}

.editor-image-block.image-layout-gallery .gallery-image-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0;
    line-height: 0;
}

.editor-gallery-controls {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    z-index: 40;
    pointer-events: auto;
}

.editor-gallery-controls.is-visible {
    display: flex;
}

.editor-gallery-controls .gallery-delete {
    border: 1px solid #fecaca;
    background: #fee2e2;
    color: #b91c1c;
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.editor-gallery-controls .gallery-columns {
    display: flex;
    gap: 6px;
}

.editor-gallery-controls .gallery-columns button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    cursor: pointer;
    font-weight: 600;
}

.editor-gallery-controls .gallery-columns button.is-active {
    background: #0ea5e9;
    color: #ffffff;
    border-color: #0ea5e9;
}

.editor-block-handle {
    position: absolute;
    display: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
    transform: translateY(-50%);
    cursor: pointer;
    z-index: 30;
    pointer-events: auto;
}

.editor-block-handle.gallery-block-handle {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #ffffff;
}

.editor-block-handle.gallery-group-handle {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #ffffff;
}

.editor-block-handle.gallery-item-handle {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

.editor-item-handle {
    width: 24px;
    height: 24px;
    border-radius: 7px;
}

.editor-block-handle.is-visible {
    display: inline-flex;
}

.editor-block-handle-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.editor-block-menu {
    position: absolute;
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.16);
    z-index: 30;
    min-width: 140px;
    pointer-events: auto;
}

.editor-block-menu[data-open="true"] {
    display: flex;
}

.editor-block-menu button {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    font-weight: 600;
}

.editor-block-menu button:hover {
    background: #e2e8f0;
}

.editor-block-menu-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.editor-block-menu-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 0;
}

.editor-block-menu-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.editor-block-menu input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.editor-block-menu-size-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #94a3b8;
}

.editor-block-menu-table {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.editor-block-menu-table input {
    width: 64px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    text-align: center;
    font-size: 0.9rem;
}

.editor-block-menu-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.editor-block-menu-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #0f172a;
}

.editor-block-menu-check input {
    width: 14px;
    height: 14px;
}

.editor-block-menu-field input {
    width: 100%;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
}

.editor-block-menu-field.is-hidden {
    display: none;
}

.editor-block-menu-layout {
    display: flex;
    gap: 8px;
}

.editor-block-menu-layout button {
    width: 36px;
    height: 36px;
    justify-content: center;
    padding: 0;
}

.editor-block-menu-layout svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.editor-block-menu-layout button.is-active {
    background: #0ea5e9;
    color: #ffffff;
}

.editor-block-menu .gallery-columns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.editor-block-menu .gallery-columns button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    cursor: pointer;
    font-weight: 600;
}

.editor-block-menu .gallery-columns button.is-active {
    background: #0ea5e9;
    color: #ffffff;
    border-color: #0ea5e9;
}

.editor-block-menu .editor-block-delete {
    background: #fee2e2;
    color: #b91c1c;
}

.editor-block-menu .editor-block-delete:hover {
    background: #fecaca;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 4dvh 4dvw;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    z-index: 1000;
}

.modal[modal-hidden] {
    display: none;
}

.modal:not([modal-hidden]) {
    display: flex;
}

.modal-content {
    width: 80vw;
    height: 80vh;
    width: 80dvw;
    height: 80dvh;
    position: relative;
    background-color: #ffffff;
    color: #0f172a;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

.close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #0f172a;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    z-index: 2;
}

.modal .icon {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tabs {
    display: flex;
    gap: 10px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.tab-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: #0f172a;
}

.tab-link.active {
    background: #0ea5e9;
    color: #ffffff;
    border-color: #0ea5e9;
}

.tab-content {
    display: none;
    min-height: 0;
}

.tab-content.active {
    display: flex;
    gap: 12px;
    align-items: center;
}

.tab-content[modal-tab="url"].active {
    flex-direction: column;
    align-items: stretch;
}

.tab-content[modal-tab="server"].active {
    flex-direction: column;
    align-items: stretch;
}

.tab-content[modal-tab="server"] {
    width: 100%;
}

.tab-content[modal-tab="server"] input[type="text"] {
    width: 100%;
    flex: 0 0 auto;
    box-sizing: border-box;
}

.modal-image-search {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.modal-image-search-field {
    position: relative;
    flex: 1;
    display: flex;
    min-width: 0;
}

.modal-image-search-btn .icon {
    width: 18px;
    height: 18px;
}


.modal-image-url-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-image-url-header h3 {
    margin: 0;
    font-size: 1.05rem;
    color: #0f172a;
}

.modal-image-url-header p {
    margin: 0;
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.4;
}

.modal-image-url-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-content input[type="text"] {
    flex: 1;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #cbd5f5;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.modal-content [modal-image-filter] {
    width: 100%;
}

.modal-content input[type="text"]::placeholder {
    color: #94a3b8;
}

.tab-content button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #0ea5e9;
    background: #0ea5e9;
    color: #ffffff;
    cursor: pointer;
}

.tab-content button span {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.tab-content .modal-image-clear {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #e2e8f0;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.tab-content .modal-image-clear .icon {
    width: 12px;
    height: 12px;
}

.tab-content .modal-image-clear:hover {
    background: #cbd5e1;
}

.tab-content .modal-image-search-field input[type="text"] {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 0;
    padding-right: 38px;
}

.tab-content .modal-image-search-btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 0;
    margin-left: -1px;
    padding: 10px 16px;
}

.modal-code-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.modal-code-body h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
}

.modal-code-body p {
    margin: 0;
    color: #475569;
    line-height: 1.5;
}

.modal-code-body textarea {
    flex: 1;
    min-height: 220px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #cbd5f5;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.95rem;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    resize: vertical;
}

.modal-code-body button {
    align-self: flex-start;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #0ea5e9;
    background: #0ea5e9;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.modal-word-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.modal[modal-word] .modal-header h3,
.modal[modal-template] .modal-header h3 {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal[modal-word] .modal-header p,
.modal[modal-template] .modal-header p {
    color: #1f2937;
}

.modal-word-body h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
}

.modal-word-body p {
    margin: 0;
    color: #475569;
    line-height: 1.5;
}

.modal-word-body textarea {
    flex: 1;
    min-height: 320px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #cbd5f5;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.95rem;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    resize: vertical;
}

.modal-word-body button {
    align-self: flex-start;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #0ea5e9;
    background: #0ea5e9;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.modal[modal-word] .tab-content.active {
    align-items: stretch;
    flex-direction: column;
}

.modal-template-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.modal-template-body h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
}

.modal-template-body p {
    margin: 0;
    color: #475569;
    line-height: 1.5;
}

.template-table {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    overflow: auto;
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(220px, 2fr) minmax(120px, auto);
    min-height: 0;
}

.template-row {
    display: contents;
}

.template-row:first-child {
    border-top: 0;
}

.template-header {
    background: #f8fafc;
    font-weight: 700;
    color: #0f172a;
    align-items: center;
}

.template-header .template-cell {
    line-height: 1.2;
}

.template-cell {
    font-size: 0.9rem;
    color: inherit;
    line-height: 1.4;
    padding: 6px 12px;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
}

.template-row:nth-child(odd) .template-cell {
    background: #f9fafb;
}

.template-row.template-header .template-cell {
    background: #f1f5f9;
}

.template-row.template-header + .template-row .template-cell {
    border-top: 0;
}

.template-action button {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #0ea5e9;
    background: #0ea5e9;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.template-action button:hover {
    background: #0284c7;
    border-color: #0284c7;
}

.editor-template-code {
    display: block;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px dashed #e2e8f0;
    background: #f8fafc;
    color: #0f172a;
    white-space: pre-wrap;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.editor-template-block {
    display: block;
    margin: 14px 0;
    padding: 12px;
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
    background: #f1f5f9;
    color: #0f172a;
}

.template-block-header {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    margin-bottom: 10px;
}

.template-block-body,
.template-block-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.template-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    border: 1px dashed #d1d5db;
    background: #f8fafc;
}

.template-item-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.template-item-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.template-field-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #475569;
}

.template-field-value {
    min-height: 24px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
}

.template-field-value:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 0;
    border-color: #0ea5e9;
}

.template-field-value[data-template-value="title"] {
    font-weight: 600;
    white-space: pre-wrap;
}

.template-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.template-link-input {
    flex: 1 1 180px;
    min-width: 140px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.85rem;
}

.template-link-input:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 0;
    border-color: #0ea5e9;
}

.template-link-blank {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: #475569;
    user-select: none;
}

.template-link-blank input {
    width: 12px;
    height: 12px;
    margin: 0;
    cursor: pointer;
}

.modal-link-content {
    width: min(92vw, 520px);
    height: auto;
    max-height: 90dvh;
}

.modal-link-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-link-body h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
}

.modal-link-body p {
    margin: 0;
    color: #475569;
    line-height: 1.5;
}

.modal-link-types {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-link-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    font-weight: 600;
    color: #0f172a;
}

.modal-link-option input {
    accent-color: #0ea5e9;
}

.modal-link-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    color: #0f172a;
}

.modal-link-field span {
    font-size: 0.9rem;
    color: #475569;
}

.modal-link-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #0f172a;
    font-weight: 600;
}

.modal-link-check input {
    accent-color: #0ea5e9;
}

.modal-link-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-link-delete {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #fca5a5;
    background: #fee2e2;
    color: #b91c1c;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.modal-link-delete:hover {
    background: #fecaca;
}

.modal-link-submit {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #0ea5e9;
    background: #0ea5e9;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.modal-link-submit:hover {
    background: #0284c7;
    border-color: #0284c7;
}

.modal-link-cancel {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
}

.modal-link-cancel:hover {
    background: #e2e8f0;
}

.modal-color-content {
    width: min(92vw, 420px);
    height: auto;
    max-height: 90dvh;
}

.modal-color-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-color-body h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
}

.modal-color-body p {
    margin: 0;
    color: #475569;
    line-height: 1.5;
}

.modal-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-color-row input[type="color"] {
    width: 56px;
    height: 44px;
    padding: 0;
    border: 1px solid #cbd5f5;
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
}

.modal-color-row input[type="text"] {
    flex: 1;
}

.modal-color-apply {
    align-self: flex-start;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #0ea5e9;
    background: #0ea5e9;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.modal-color-apply:hover {
    background: #0284c7;
    border-color: #0284c7;
}

.image-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.image-grid-inner {
    display: block;
    column-count: 8;
    column-gap: 14px;
}

.tab-content [modal-image-list] .image-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    color: #0f172a;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin-bottom: 14px;
}

.tab-content [modal-image-list] .image-card img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.tab-content [modal-image-list] .image-card.selected img {
    border: 2px solid #cbd5e1;
}

.tab-content [modal-image-list] .image-card:hover img {
    transform: translateY(-2px);
    border-color: #cbd5e1;
}

.tab-content [modal-image-list] .image-card .image-name {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

@media (max-width: 1200px) {
    .image-grid-inner {
        column-count: 6;
    }
}

@media (max-width: 980px) {
    .image-grid-inner {
        column-count: 4;
    }
}

@media (max-width: 720px) {
    .image-grid-inner {
        column-count: 2;
    }
}

@media (max-width: 460px) {
    .image-grid-inner {
        column-count: 1;
    }
}
