:root {
    --bg-color: #121212;
    --panel-bg: #1e1e1e;
    --border-color: #333;
    --text-color: #ffffff;
    --danger-bg: #f44336;
    --label-width: 108px;

    --gap-size: 3px;
    --img-h: 135px;
    --vert-w: 89px;
    --square-w: 135px;
    --horizontal-w: calc(var(--vert-w) * 2 + var(--gap-size));
    --column-min-w: var(--vert-w);
}

:root.column-auto-rectangles {
    --column-min-w: var(--horizontal-w);
}

body {
    font-family: sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 18px 72px 18px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    font-size: 14.4px;
}

.tier-name,
#tierlist-title,
input,
textarea,
.instruction,
select {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

h1 {
    margin-top: 0;
    text-align: center;
    color: #eee;
}

.side-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 18px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
    padding: 0;
}

@media (hover: hover) {
    .side-btn:hover {
        background: rgba(50, 50, 50, 0.9);
        transform: scale(1.05);
        border-color: rgba(255, 255, 255, 0.3);
    }
    .add-row-btn:hover,
    .control-btn:hover {
        background: rgba(0, 0, 0, 0.9);
    }
    .btn-delete:hover {
        background-color: #d32f2f;
    }
    .toolbar button:hover,
    .toolbar .file-upload-label:hover {
        transform: translateY(-3px);
        filter: brightness(1.1);
    }
}

.side-btn.active {
    background: rgba(33, 150, 243, 0.8);
    border-color: #64b5f6;
}

#hamburger-btn {
    top: 18px;
    z-index: 1003;
}
#settings-btn {
    top: 68px;
}
#global-format-btn {
    top: 118px;
}
#lang-btn {
    top: 168px !important;
}

body.menu-open #settings-btn,
body.menu-open #global-format-btn,
body.menu-open #add-text-btn,
body.menu-open #lang-btn,
body.menu-open #language-menu {
    opacity: 0;
    pointer-events: none;
}

#global-format-menu {
    position: fixed;
    z-index: 10005;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s;
    right: 68px;
    top: 118px;
    width: 220px;
    max-height: calc(100dvh - 150px);
    overflow-y: auto;
    box-sizing: border-box;
    overflow-x: hidden;
    overscroll-behavior: contain;
}
#global-format-menu.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
    display: flex !important;
}
#language-menu {
    position: fixed;
    z-index: 10005;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s;
    right: 68px;
    top: 168px;
    min-width: 170px;
    max-height: calc(100dvh - 190px);
    overflow-y: auto;
    box-sizing: border-box;
}
#language-menu.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
    display: flex !important;
}

.lang-option-btn {
    background: #333;
    color: white;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    transition: 0.2s;
    font-size: 14px;
    text-align: left;
}
.lang-option-btn:hover {
    background: #444;
    border-color: #64b5f6;
}
.lang-option-btn.active {
    background: rgba(33, 150, 243, 0.15);
    border-color: #64b5f6;
    font-weight: bold;
}

.toolbar {
    position: fixed;
    top: 0;
    right: -340px;
    width: 320px;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(15px);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: right 0.4s;
    padding: 100px 24px 80px 24px;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    gap: 16px;
}
.toolbar.active {
    right: 0;
}

button,
.file-upload-label {
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-block;
}
.toolbar button,
.toolbar .file-upload-label {
    width: 100%;
    min-height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin: 0;
    text-align: center;
    box-sizing: border-box;
    max-width: 100%;
    flex-shrink: 0;
}
button:active,
.file-upload-label:active {
    transform: scale(0.96) translateY(0) !important;
}

.btn-grad-orange {
    background: linear-gradient(135deg, #f39c12, #d35400);
}
.btn-grad-blue {
    background: linear-gradient(135deg, #3498db, #2980b9);
}
.btn-grad-purple {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}
.btn-grad-green {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}
input[type='file'] {
    display: none;
}
.btn-danger {
    background-color: var(--danger-bg) !important;
    color: white !important;
}

input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type='number'] {
    -moz-appearance: textfield;
}

#mobile-overlay {
    visibility: hidden;
    opacity: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    transition: 0.3s ease;
}
#mobile-overlay.active {
    visibility: visible;
    opacity: 1;
}

@media (max-width: 768px) {
    :root {
        --label-width: 50px;
        --gap-size: 2px;
        --img-h: 85px;
        --vert-w: 56px;
        --square-w: 85px;
    }
    body {
        padding: 5px;
    }
    .tier-label {
        font-size: 14px;
        max-width: 170px;
    }
    .tier-img {
        border-width: 2px;
    }
    .tier-row,
    .tier-items {
        min-height: 104px;
    }
    #tierlist-title {
        font-size: 20px;
        padding: 12px 10px;
        min-height: 30px;
    }
    .tier-name {
        padding: 0 4px;
    }
    .pool-header {
        flex-direction: column;
        align-items: stretch;
    }
    .pool-header h3 {
        margin-bottom: 12px !important;
        text-align: center;
    }
    .pool-header-actions {
        gap: 5px;
        flex-wrap: nowrap;
    }
    .modal-content {
        padding: 15px;
        width: 95%;
        max-height: 85vh !important;
    }
    .modal-close {
        top: 5px;
        right: 10px;
        font-size: 24px;
    }
    #select-mode-btn,
    #select-all-btn {
        padding: 0 4px !important;
        flex-grow: 1;
        white-space: nowrap;
    }
    .project-save-section {
        flex-direction: column;
        gap: 8px;
    }
    .project-save-section button {
        width: 100%;
    }
    #image-pool {
        margin: 0 8px 0 0;
    }
}

@media (max-height: 500px) {
    .toolbar {
        padding-top: 50px !important;
        padding-bottom: 120px !important;
    }
    .modal-content {
        padding: 12px !important;
        max-height: 95vh !important;
    }
    .modal-content h2 {
        font-size: 18px !important;
        margin-bottom: 5px !important;
    }
}

#tierlist-wrapper {
    width: 98%;
    max-width: none;
    background-color: var(--bg-color);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

#title-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}
#tierlist-title {
    text-align: center;
    font-size: 36px;
    font-weight: bold;
    padding: 20px;
    outline: none;
    background-color: #121212;
    color: #fff;
    border-bottom: 2px solid var(--border-color);
    word-wrap: break-word;
    min-height: 45px;
    transition: background-color 0.2s;
    box-sizing: border-box;
    width: 100%;
    line-height: 1.2;
    overflow: hidden;
}
#tierlist-title:empty::before {
    content: attr(data-placeholder);
    color: #666;
    font-weight: normal;
}

.tier-row {
    display: flex;
    position: relative;
    border-bottom: 2px solid var(--border-color);
    background-color: #1a1a1a;
    min-height: calc(var(--img-h) + 8px);
    transition: background-color 0.2s;
    contain: layout;
}
.tier-row:last-child {
    border-bottom: none;
}

.tier-label {
    width: var(--label-width);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #000;
    font-weight: bold;
    font-size: 18px;
    position: relative;
    flex-shrink: 0;
    border-right: 2px solid var(--border-color);
    padding: 5px;
    box-sizing: border-box;
    transition: background-color 0.2s;
}
.tier-name {
    outline: none;
    width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    position: relative;
    z-index: 2;
    padding: 0 10px;
    box-sizing: border-box;
    text-align: center;
    line-height: 1.2;
}
#tierlist-title,
.tier-name,
.header-cell-text,
.text-block-content {
    transition:
        color 0.2s ease,
        -webkit-text-stroke-color 0.2s ease,
        text-decoration-color 0.2s ease,
        text-shadow 0.2s ease,
        background-color 0.2s ease,
        border-color 0.2s ease;
}
.resizer {
    position: absolute;
    right: -3px;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}

.add-row-btn,
.control-btn,
.color-picker-container {
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    position: absolute;
    z-index: 100;
    touch-action: none;
}
body.show-settings .add-row-btn,
body.show-settings .control-btn,
body.show-settings .color-picker-container {
    opacity: 1;
    pointer-events: auto;
}

.add-row-btn {
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
}
.add-row-above {
    top: 4px;
}
.add-row-below {
    bottom: 4px;
}
.control-btn {
    background-color: rgba(0, 0, 0, 0.7);
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-size: 12px;
}
.btn-up {
    top: 4px;
    right: 4px;
}
.btn-down {
    bottom: 4px;
    right: 4px;
}
.btn-delete {
    top: 50%;
    left: 4px;
    transform: translateY(-50%);
    background-color: rgba(244, 67, 54, 0.9);
}
.color-picker-container {
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.color-picker-container::after {
    content: '🎨';
    font-size: 13px;
    pointer-events: none;
}

#color-preset-menu {
    position: fixed;
    z-index: 10005;
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: 0.2s;
    border: 1px solid #444;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
    min-width: 220px;
}
#color-preset-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.color-target-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 2px;
}
.color-target-toggle button {
    flex: 1;
    padding: 8px 4px;
    border-radius: 4px;
    background: #333;
    border: 1px solid #555;
    color: #fff;
    cursor: pointer;
}
.color-target-toggle button.active {
    background: rgba(33, 150, 243, 0.2);
    border-color: #64b5f6;
    color: #64b5f6;
    font-weight: bold;
}

.tier-items {
    flex-grow: 1;
    display: flex;
    flex-wrap: wrap;
    padding: 4px;
    min-height: calc(var(--img-h) + 8px);
    align-items: center;
    align-content: center;
    gap: var(--gap-size);
    justify-content: flex-start;
}
.tier-items::after {
    content: '';
    flex-grow: 9999;
    height: 0;
    min-width: 0;
}
.tier-items,
.tier-column,
.header-column-cell {
    transition: background-color 0.2s;
}

.pool-container {
    width: 98%;
    max-width: 1400px;
    margin-top: 30px;
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    contain: layout;
}
.pool-header {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 10px;
    align-items: center;
}
.pool-header h3 {
    margin: 0;
    color: #ccc;
    font-size: 16px;
}
.pool-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.pool-icon-btn {
    background-color: #2196f3;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    color: white;
    margin: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: 0.2s;
}
.pool-icon-btn:active {
    transform: scale(0.95);
}

#select-mode-btn {
    background-color: #444;
    border-radius: 6px;
    padding: 0 15px;
    font-size: 12px;
    height: 32px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
#image-pool {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: var(--gap-size);
    min-height: 140px;
    padding: 6px;
    background-color: #141414;
    border-radius: 5px;
    border: 2px dashed #444;
}

.tier-img {
    flex-shrink: 0;
    height: var(--img-h);
    border-radius: 4px;
    cursor: grab;
    border: 4px solid transparent;
    background-color: #1a1a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition:
        border-color 0.2s ease,
        border-width 0.2s ease,
        background-color 0.2s ease,
        opacity 0.15s ease;
    box-sizing: border-box;
    -webkit-user-drag: none !important;
    user-drag: none !important;
    -webkit-touch-callout: none !important;
    touch-action: none;
}
.tier-img:active {
    cursor: grabbing;
    transform: scale(1.05);
}
body.is-uploading-images .tier-img {
    pointer-events: none;
}
.tier-img.text-block {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.text-block-content {
    width: 100%;
    max-height: 100%;
    padding: 6px;
    box-sizing: border-box;
    text-align: center;
    outline: none;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    line-height: 1.2;
    user-select: text;
    -webkit-user-select: text;
    overflow: hidden;
}
.text-block-content:empty::before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.4);
}

.tier-img.ratio-vertical {
    width: var(--vert-w) !important;
    max-width: none;
}
.tier-img.ratio-square {
    width: var(--square-w) !important;
    max-width: none;
}
.tier-img.ratio-horizontal {
    width: calc(var(--vert-w) * 2 + var(--gap-size)) !important;
    max-width: none;
}
.tier-img.ratio-circle {
    width: var(--square-w) !important;
    border-radius: 50% !important;
}
/* Для круга contain физически не имеет смысла (даёт «деформированный» вид),
           поэтому круг всегда заливается как cover. */
.tier-img.ratio-circle.fit-contain img {
    object-fit: contain;
    transform: scale(0.7071);
}

.tier-img img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none !important;
    user-drag: none !important;
}
.tier-img.fit-cover img {
    object-fit: cover;
}
.tier-img.fit-contain img {
    object-fit: contain;
}
.tier-img.selected {
    border: 4px solid var(--danger-bg) !important;
    transform: scale(0.9);
    opacity: 0.8;
    border-radius: 8px;
}

.wm-logo-container {
    border-radius: 4px;
    border: 0px solid transparent;
    background-color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    flex-shrink: 0;
}
.wm-logo-container img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}
.wm-logo-container.fit-cover img {
    object-fit: cover;
}
.wm-logo-container.fit-contain img {
    object-fit: contain;
}
.wm-logo-container.ratio-circle {
    border-radius: 50%;
}

.instruction {
    font-size: 12px;
    color: #888;
    text-align: center;
    margin-top: 10px;
}

#tier-popup-menu {
    position: fixed;
    z-index: 9999;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(5px);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 5px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
    width: max-content;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 45vh;
    overflow-y: auto;
    overflow-x: hidden;
}
#tier-popup-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.popup-btn {
    padding: 5px 8px;
    border-radius: 4px;
    color: #000;
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    border: none;
    cursor: pointer;
    text-shadow: 0px 1px 2px rgba(255, 255, 255, 0.4);
    word-wrap: break-word;
    max-width: 200px;
    width: 100%;
    box-sizing: border-box;
}
.popup-btn:hover {
    filter: brightness(1.15);
}
.popup-btn:active {
    transform: scale(0.95);
}
.popup-btn.btn-action {
    background-color: #444;
    color: #fff;
    text-shadow: none;
    margin-top: 3px;
    border-top: 1px solid #555;
}

.format-menu-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 2px;
    box-sizing: border-box;
}
.format-row {
    display: flex;
    gap: 6px;
    justify-content: space-between;
}
.format-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}
.format-btn {
    background: #333;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex: 1;
    cursor: pointer;
    color: white;
    transition: 0.2s;
    min-height: 60px;
    text-align: center;
}
.format-btn.flat {
    min-height: 28px;
    flex-direction: row;
    gap: 5px;
    padding: 4px;
}
.format-btn:hover {
    background: #444;
}
.format-btn.active {
    border-color: #64b5f6;
    background: rgba(33, 150, 243, 0.15);
}

.icon-box {
    border: 2px solid #ccc;
    border-radius: 2px;
    margin-bottom: 5px;
    transition: border-color 0.2s;
}
.format-btn.active .icon-box {
    border-color: #64b5f6;
}
.icon-vertical {
    width: 12px;
    height: 18px;
}
.icon-square {
    width: 18px;
    height: 18px;
}
.icon-horizontal {
    width: 26px;
    height: 18px;
}
.icon-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

#floating-action-btn {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: max-content;
    transform: translateY(100px);
    z-index: 2000;
    background-color: #2196f3;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: bold;
    display: none;
    opacity: 0;
    transition:
        transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        opacity 0.3s;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}
#floating-action-btn.visible {
    transform: translateY(0);
    opacity: 1;
}

body.exporting .tier-img.selected {
    border: 4px solid transparent !important;
    transform: none !important;
    opacity: 1 !important;
    border-radius: 0px !important;
}
body.exporting .add-row-btn,
body.exporting .control-btn,
body.exporting .color-picker-container,
body.exporting .resizer,
body.exporting .col-resizer {
    display: none !important;
}
body.exporting #col-settings-menu,
body.exporting #row-settings-menu,
body.exporting #mass-menu,
body.exporting #floating-action-btn,
body.exporting .side-btn,
body.exporting #quick-color-popup {
    display: none !important;
}
body.exporting .tier-items {
    padding-right: 4px !important;
}
body.exporting #tierlist-wrapper {
    border-radius: 0;
    box-shadow: none;
    position: absolute;
    top: 0;
    left: 0;
}
body.exporting #tier-popup-menu,
body.exporting #color-preset-menu {
    display: none !important;
}
body.exporting .title-controls {
    display: none !important;
}

.sortable-ghost {
    opacity: 0.3 !important;
    transform: scale(0.9);
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.sortable-drag {
    cursor: grabbing !important;
    z-index: 9999 !important;
    pointer-events: none !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
.tier-img.sortable-drag,
.tier-img.sortable-ghost {
    transition: none !important;
}
.sortable-drag img {
    transform: scale(0.65) translateY(-35px) !important;
    opacity: 0.95 !important;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.9) !important;
    border-radius: 6px !important;
    transition: none !important;
}

.modal-overlay {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}
.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--panel-bg);
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 550px;
    position: relative;
    color: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.modal-overlay.minimized {
    background: transparent !important;
    pointer-events: none !important;
    align-items: flex-end !important;
    justify-content: flex-end !important;
}
.modal-overlay.minimized .modal-content {
    pointer-events: auto;
    width: 340px !important;
    max-width: 340px !important;
    max-height: 45vh !important;
    overflow-y: auto;
    margin: 0 12px 12px 0 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    border-color: #64b5f6;
}
.modal-minimize-btn {
    position: absolute;
    top: 10px;
    right: 42px;
    font-size: 20px;
    cursor: pointer;
    color: #aaa;
    transition: 0.2s;
    z-index: 5;
}
.modal-minimize-btn:hover {
    color: white;
}
/* Менеджер сейвов: контент растёт вверх/вниз при поиске, и flex-центрирование
           заставляло окно «прыгать». Прижимаем к верху и даём автоскролл — стабильнее. */
#saves-modal {
    align-items: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
}
#saves-modal .modal-content {
    margin: 40px auto;
    max-height: none;
    overflow: visible;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    cursor: pointer;
    color: #aaa;
    transition: 0.2s;
}
.modal-close:hover {
    color: white;
}

.project-save-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.project-save-section input {
    flex-grow: 1;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: #121212;
    color: white;
    outline: none;
    font-size: 14px;
    box-sizing: border-box;
    min-width: 0;
}
.project-save-section button {
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 14px;
    background-color: #8e44ad;
    box-sizing: border-box;
    flex-shrink: 0;
}
#saves-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.project-item {
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.project-item.expanded {
    border-color: #64b5f6;
    background: #222;
}
.project-item-header {
    display: flex;
    align-items: center;
    width: 100%;
    overflow: hidden;
}
.drag-handle {
    cursor: grab;
    padding-right: 10px;
    color: #888;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    -webkit-touch-callout: none;
    outline: none;
}
.project-item-name {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.expand-icon {
    color: #888;
    font-size: 12px;
    transition: transform 0.2s;
    padding-left: 10px;
}
.project-item.expanded .expand-icon {
    transform: rotate(180deg);
    color: #fff;
}
.project-actions {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #333;
    cursor: default;
}
.project-item.expanded .project-actions {
    display: flex;
}
.project-actions button {
    padding: 10px 4px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    box-sizing: border-box;
    border: none;
    color: white;
    transition: filter 0.2s;
    font-weight: bold;
}
.project-actions button:hover {
    filter: brightness(1.15);
}
.project-actions button:active {
    transform: scale(0.97);
}
.action-btn-main {
    width: 100%;
}
.action-btn-row {
    display: flex;
    gap: 6px;
    width: 100%;
}
.action-btn-row button {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.title-controls {
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 6px;
    align-items: center;
    z-index: 100;
}
body.show-settings .title-controls {
    opacity: 1;
    pointer-events: auto;
}

#global-columns-menu {
    position: fixed;
    z-index: 10005;
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s ease;
    border: 1px solid #444;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
    min-width: 180px;
}
#global-columns-menu.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
}
.tier-name,
#tierlist-title,
.header-cell-text,
.text-block-content {
    paint-order: stroke fill;
    -webkit-paint-order: stroke fill;
    stroke-linejoin: round;
    letter-spacing: 0;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    backface-visibility: hidden;
    transform: translateZ(0);
}
.tier-name *,
#tierlist-title *,
.header-cell-text *,
.text-block-content * {
    text-shadow: none !important;
    -webkit-text-stroke: inherit !important;
    color: inherit !important;
    font-size: inherit !important;
    font-family: inherit !important;
    background-color: transparent !important;
}
.save-drag-item {
    transition: none !important;
    background: #222 !important;
    border: 1px solid #64b5f6 !important;
    opacity: 0.9 !important;
    pointer-events: none !important;
    margin: 0 !important;
    list-style: none !important;
    z-index: 9999 !important;
}

#global-dropzone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    border: 6px dashed #64b5f6;
    box-sizing: border-box;
    pointer-events: none;
}
#global-dropzone.active {
    display: flex;
}

.cropper-point {
    width: 25px !important;
    height: 25px !important;
    background-color: #2196f3 !important;
    opacity: 0.9 !important;
    border-radius: 50% !important;
}
.cropper-point.point-e {
    right: -12.5px !important;
    margin-top: -12.5px !important;
}
.cropper-point.point-n {
    top: -12.5px !important;
    margin-left: -12.5px !important;
}
.cropper-point.point-w {
    left: -12.5px !important;
    margin-top: -12.5px !important;
}
.cropper-point.point-s {
    bottom: -12.5px !important;
    margin-left: -12.5px !important;
}
.cropper-point.point-ne {
    top: -12.5px !important;
    right: -12.5px !important;
}
.cropper-point.point-nw {
    top: -12.5px !important;
    left: -12.5px !important;
}
.cropper-point.point-sw {
    bottom: -12.5px !important;
    left: -12.5px !important;
}
.cropper-point.point-se {
    bottom: -12.5px !important;
    right: -12.5px !important;
}
/* Фикс: чтобы элементы не обрезались внутри меню (кнопки и ползунки) */
#global-format-menu input[type='range'],
#tier-popup-menu input[type='range'],
.modal-content input[type='range'] {
    min-width: 0; /* Разрешаем ползунку сжиматься, если не х  атает места */
}

#global-format-menu button {
    box-sizing: border-box; /* Кнопки перестанут вылезать за края из-за внутренних отступов */
}

/* Фикс: чтобы само окошко меню не улетало за левый край на смартфонах */
#global-format-menu,
#color-preset-menu {
    max-width: calc(100vw - 90px);
}
/* Активное состояние кнопок стиля шрифта B/I/U/S */
#font-bold-btn.active,
#font-italic-btn.active,
#font-underline-btn.active,
#font-strike-btn.active,
.font-style-btn.active {
    background: #2196f3 !important;
    border-color: #2196f3 !important;
} /* --- СТИЛИ ДЛЯ КРАСИВОГО МЕНЮ ШРИФТОВ --- */
#color-preset-menu {
    min-width: 280px !important;
    box-sizing: border-box;
}

/* Сетка для выравнивания */
.font-settings-grid {
    display: grid;
    grid-template-columns: 1fr 170px;
    row-gap: 10px;
    column-gap: 10px;
    align-items: center;
    color: #eee;
    font-size: 13px;
    box-sizing: border-box;
    text-align: left;
}

.font-settings-label {
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.font-settings-control {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    width: 170px;
    box-sizing: border-box;
}

.font-select-input {
    flex: 1;
    min-width: 0;
    height: 30px;
    background: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 0 8px !important; /* Внутренний отступ слева для текста */
    text-align: left !important; /* Принудительное выравнивание влево */
    text-align-last: left !important; /* Поддержка в Safari/Chrome */
    outline: none;
    font-size: 11px;
    box-sizing: border-box;
}
/* Кнопка "+ Свой" */
.font-btn-custom {
    height: 30px;
    font-size: 10px;
    padding: 0 8px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 !important;
    box-sizing: border-box;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 0;
}
.font-btn-custom:hover {
    filter: brightness(1.1);
}

/* Кнопка удаления (урна) в виде ровного квадрата */
.font-btn-delete {
    width: 30px;
    height: 30px;
    background: #e74c3c;
    border: none;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
    flex-shrink: 0;
}
.font-btn-delete:hover {
    background: #c0392b;
}

/* Ползунки */
.font-range-slider {
    flex: 1;
    min-width: 0;
    height: 30px;
    margin: 0;
}

/* Квадратные блоки для цифр */
.font-number-input {
    width: 30px;
    height: 30px;
    text-align: center;
    background: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    outline: none;
    box-sizing: border-box;
    font-size: 12px;
    padding: 0;
    -moz-appearance: textfield;
    flex-shrink: 0;
}
.font-number-input::-webkit-inner-spin-button,
.font-number-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Выравнивание сетки кружков по центру колонок */
.color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    justify-items: center;
    align-items: center;
}
.color-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: 0.1s;
    position: relative;
    box-sizing: border-box;
}
.color-circle:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.8);
}
.color-circle.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px #64b5f6;
}
.saved-color-circle.selected-slot {
    outline: 2px solid rgba(100, 181, 246, 0.8);
    outline-offset: 2px;
}
.saved-color-circle.is-empty {
    background: rgba(255, 255, 255, 0.06) !important;
}
/* Bug 7: keep the Cropper preview inside the modal instead of overflowing off-screen */
#magic-canvas-container .cropper-container {
    max-height: calc(50vh - 20px) !important;
    margin: auto;
}
#magic-crop-target {
    max-height: calc(50vh - 20px) !important;
}

/* Выравнивание строки выбора своего цвета */
.custom-color-wrapper {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    align-items: center;
    border-top: 1px solid #555;
    padding-top: 12px;
    font-size: 14px;
    font-weight: bold;
    color: #eee;
    padding-left: 6px;
    padding-right: 6px;
}
.custom-color-wrapper {
    padding-left: 0;
    padding-right: 0;
}
.custom-color-wrapper > span {
    grid-column: 1 / 4;
    padding-left: 6px;
}
.custom-color-wrapper > div,
.custom-color-wrapper > label,
.custom-color-wrapper > input[type='color'] {
    grid-column: 4;
    justify-self: center;
}

/* Переносим точку привязки системного окна в правый верхний угол меню */
.hidden-color-picker {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important; /* Ровно по верхней границе меню */
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

/* Квадратные кнопки стилей (B, I, U, S) */
.font-style-btn {
    width: 30px;
    height: 30px;
    background: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    margin: 0;
}
.font-style-btn[data-style='underline'] {
    text-decoration: underline;
    text-underline-offset: 0.12em;
}
.font-style-btn[data-style='strike'] {
    text-decoration: line-through;
}
/* ===== Редактор фото: кнопки инструментов ===== */
.ed-tool-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 52px;
    padding: 6px 8px;
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1.1;
    transition: all 0.15s ease;
    box-sizing: border-box;
}
.ed-tool-btn span {
    font-size: 10px;
    opacity: 0.9;
}
@media (hover: hover) {
    .ed-tool-btn:hover {
        background: #383838;
        border-color: #64b5f6;
        transform: translateY(-1px);
    }
}
.ed-tool-btn.active {
    background: linear-gradient(135deg, #2196f3, #1976d2);
    border-color: #64b5f6;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.4);
}
.ed-tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Подпанели (яркость/контраст, текст, рисование) ===== */
.ed-subpanel {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

/* ===== Палитра цветов кисти ===== */
.ed-draw-colors {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}
.ed-color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    padding: 0;
    transition:
        transform 0.12s ease,
        border-color 0.12s ease;
}
@media (hover: hover) {
    .ed-color-swatch:hover {
        transform: scale(1.15);
    }
}
.ed-color-swatch.active {
    border-color: #64b5f6;
    transform: scale(1.15);
    box-shadow: 0 0 0 2px rgba(100, 181, 246, 0.35);
}

/* ===== Инпуты внутри модала-редактора ===== */
#crop-modal input[type='range'] {
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: #555;
    border-radius: 3px;
    outline: none;
}
#crop-modal input[type='range']::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196f3;
    cursor: pointer;
    border: 2px solid #fff;
}
#crop-modal input[type='range']::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196f3;
    cursor: pointer;
    border: 2px solid #fff;
}
#crop-modal input[type='color'] {
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
}
#crop-modal input[type='color']::-webkit-color-swatch-wrapper {
    padding: 0;
}
#crop-modal input[type='color']::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

/* ===== Мобильная адаптация редактора ===== */
@media (max-width: 768px) {
    .ed-tool-btn {
        min-width: 44px;
        padding: 5px 6px;
        font-size: 15px;
    }
    .ed-tool-btn span {
        font-size: 9px;
    }
    .ed-color-swatch {
        width: 28px;
        height: 28px;
    }
}
/* ===== Photo editor redesign override ===== */
#crop-modal .modal-content.editor-shell {
    width: min(1180px, 96vw);
    max-width: none;
    height: min(760px, 94dvh);
    max-height: 94dvh !important;
    padding: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    background: #171717;
    border: 1px solid #343434;
}
.ed-stage {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #0b0b0b;
}
.ed-stage-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid #2b2b2b;
    background: #141414;
}
.ed-stage-head h2 {
    margin: 0 0 4px;
    color: #fff;
    font-size: 18px;
    line-height: 1.2;
}
.ed-stage-head p {
    margin: 0;
    color: #aaa;
    font-size: 12px;
    line-height: 1.35;
    max-width: 640px;
}
.ed-viewport {
    flex: 1;
    min-height: 260px;
    margin: 14px;
    background: #000;
    border: 1px solid #2b2b2b;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
#ed-crop-area {
    display: flex;
}
#ed-preview-area {
    display: none;
}
#ed-canvas-wrap {
    position: relative;
    line-height: 0;
    transform-origin: center center;
    will-change: transform;
}
#ed-preview-canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none !important;
    max-height: none !important;
}
#ed-draw-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}
.ed-zoom-bar {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 5;
    display: none;
    gap: 6px;
    padding: 6px;
    background: rgba(18, 18, 18, 0.88);
    border: 1px solid #383838;
    border-radius: 8px;
    backdrop-filter: blur(8px);
}
.ed-icon-btn,
.ed-tool-btn {
    min-height: 34px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #282828;
    color: #fff;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}
.ed-icon-btn {
    width: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.ed-tool-btn {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.1;
}
.ed-tool-btn span {
    font-size: 12px;
    opacity: 1;
}
@media (hover: hover) {
    .ed-icon-btn:hover,
    .ed-tool-btn:hover {
        background: #333;
        border-color: #64b5f6;
        transform: none;
    }
}
.ed-tool-btn.active,
.ed-icon-btn.active {
    background: rgba(33, 150, 243, 0.18);
    border-color: #64b5f6;
    color: #90caf9;
    box-shadow: none;
}
.ed-sidebar {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border-left: 1px solid #343434;
}
.ed-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-bottom: 1px solid #343434;
}
.ed-tab {
    height: 54px;
    border: 0;
    border-right: 1px solid #343434;
    border-bottom: 2px solid transparent;
    background: #202020;
    color: #cfcfcf;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
}
.ed-tab:last-child {
    border-right: 0;
}
.ed-tab.active {
    color: #90caf9;
    background: #252525;
    border-bottom-color: #64b5f6;
}
.ed-sidebar-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
}
.ed-subpanel {
    display: none;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}
.ed-subpanel.active {
    display: flex;
}
.ed-group {
    padding: 12px;
    background: #242424;
    border: 1px solid #373737;
    border-radius: 8px;
}
.ed-group-title {
    margin: 0 0 10px;
    color: #e8e8e8;
    font-size: 12px;
    font-weight: 800;
}
.ed-control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: #d7d7d7;
    font-size: 12px;
}
.ed-control-row:first-child {
    margin-top: 0;
}
.ed-control-row label {
    min-width: 72px;
    color: #bdbdbd;
}
.ed-control-row input[type='text'],
.ed-control-row input[type='number'],
.ed-control-row select {
    min-width: 0;
    height: 32px;
    background: #161616;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 0 8px;
    box-sizing: border-box;
}
.ed-control-row input[type='text'],
.ed-control-row select {
    flex: 1;
}
.ed-control-row input[type='number'] {
    width: 66px;
    text-align: center;
}
.ed-control-row textarea {
    flex: 1;
    min-width: 0;
    min-height: 56px;
    background: #161616;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 6px 8px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.35;
    resize: vertical;
}
.ed-segment {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    flex: 1;
}
.ed-segment.two {
    grid-template-columns: repeat(2, 1fr);
}
.ed-segment button,
.ed-toggle-btn {
    height: 32px;
    min-width: 32px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #161616;
    color: #ddd;
    cursor: pointer;
    font-weight: 700;
}
.ed-segment button.active,
.ed-toggle-btn.active {
    background: rgba(33, 150, 243, 0.18);
    border-color: #64b5f6;
    color: #90caf9;
}
.ed-palette .color-target-toggle {
    margin-bottom: 10px;
}
.ed-saved-colors-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    border-top: 1px solid #555;
    padding-top: 10px;
}
.ed-saved-colors-wrapper > span {
    color: #999;
    font-size: 12px;
    font-weight: 700;
}
.ed-palette .custom-color-wrapper {
    margin-top: 10px;
}
.ed-palette .color-circle.active {
    border-color: #64b5f6;
    box-shadow: 0 0 0 2px rgba(100, 181, 246, 0.35);
    transform: scale(1.12);
}
.ed-footer {
    display: flex;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid #343434;
    background: #1b1b1b;
}
.ed-footer button {
    flex: 1;
    min-height: 40px;
    border-radius: 8px;
    font-weight: 800;
    border: 0;
    cursor: pointer;
}
.ed-secondary-btn {
    background: #4a4a4a;
    color: #fff;
}
.ed-danger-btn {
    background: #9f2d27;
    color: #fff;
}
#crop-modal input[type='range'] {
    flex: 1;
}
@media (max-width: 768px) {
    #crop-modal .modal-content.editor-shell {
        width: 96vw;
        height: 96dvh;
        grid-template-columns: 1fr;
        grid-template-rows: minmax(260px, 42dvh) minmax(0, 1fr);
    }
    .ed-sidebar {
        border-left: 0;
        border-top: 1px solid #343434;
    }
    .ed-stage-head {
        padding: 12px 14px;
    }
    .ed-stage-head p {
        display: none;
    }
    .ed-viewport {
        margin: 10px;
        min-height: 190px;
    }
    .ed-sidebar-body {
        padding: 10px;
    }
    .ed-tab {
        height: 48px;
    }
}
/* Глобальный фикс для ВСЕХ выпадающих списков */
select,
.font-select-input,
.ed-control-row select,
#watermark-font,
#watermark-position {
    /* Отключаем системную кривую отрисовку списка */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;

    /* Добавляем свою собственную аккуратную белую стрелочку */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 4px center !important;
    background-size: 18px !important;

    /* Делаем отступ и корректно обрезаем текст троеточием */
    padding-right: 22px !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    overflow: hidden !important;
}
/* Делаем меню чуть шире, чтобы влезли длинные названия */
#color-preset-menu {
    width: 310px !important;
    max-width: 90vw !important; /* Защита, чтобы не вылезало за экран на мобилках */
}

/* Делаем колонки гибкими: левая по ширине текста, правая занимает всё остальное */
.font-settings-grid {
    grid-template-columns: max-content 1fr !important;
}

/* Убираем жесткое ограничение правой колонки в 170px */
.font-settings-control {
    width: 100% !important;
}
/* Делае   родителя относительным (нужно для позиционирования контролов) */
#tierlist-title {
    position: relative;
}

/* Зачеркивание теперь рисуется стандартным text-decoration: line-through —
           оно корректно переносится на несколько строк. Старую абсолютную линию
           .custom-strike::after убрали: она ломалась при многострочном тексте. */
#tierlist-title,
.tier-name,
.header-cell-text,
.text-block-content {
    text-underline-offset: 0.15em; /* Опускает линию подчеркивания чуть ниже */
    text-decoration-thickness: max(1px, 0.055em);
    text-decoration-skip-ink: auto; /* Делает аккуратные разрывы там, где линия пересекает хвостики букв (например у "ф" или "р") */
}

/* Новые стили для колоночной структуры */
.tier-columns-wrapper {
    display: flex;
    flex-grow: 1;
    gap: 8px;
    padding: 4px;
    overflow-x: auto;
}
.tier-column {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    min-width: 150px;
    flex-grow: 1;
    box-sizing: border-box;
}
.column-header {
    text-align: center;
    font-size: 11px;
    color: #888;
    padding: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    outline: none;
}
.column-items {
    flex-grow: 1;
    min-height: 100px;
}
/* =========================================================================
   НОВЫЕ СТИЛИ ДЛЯ ШАПКИ КОЛОНОК, КОЛОНОК И РЕСАЙЗА (Genshin-style)
   ========================================================================= */
.columns-header-bar {
    display: flex;
    width: 100%;
    background-color: #1a1a1a;
    border-bottom: 2px solid var(--border-color);
    box-sizing: border-box;
}

.header-label-spacer {
    width: var(--label-width);
    flex-shrink: 0;
    border-right: 2px solid var(--border-color);
    box-sizing: border-box;
}
.header-column-cell {
    flex: 1 1 150px;
    width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: none; /* Убираем тонкую рамку */
    border-right: 2px solid var(--border-color); /* Стиль границы как у блоков тиров */
    border-radius: 0;
    padding: 6px;
    min-height: 44px;
    box-sizing: border-box;
    overflow: hidden;
    min-width: 0;
}
.header-column-cell:last-child {
    border-right: none; /* У крайней правой колонки у  ираем правую границу */
}
/* Обертка для ячеек шапки */
.header-columns-wrapper {
    display: flex;
    flex-grow: 1;
    gap: 0; /* Делаем ячейки сплошными без черных зазоров */
    padding: 0; /* Убираем внешние отступы по краям */
    box-sizing: border-box;
    overflow-x: auto;
}
.header-columns-wrapper::-webkit-scrollbar {
    display: none; /* Скрываем   олосу прокрутки для бесшовного вида */
}

.tier-row.has-columns .tier-column {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.02);
    border: none; /* Убираем рамку */
    border-right: 2px solid var(--border-color); /* Граница в стиле блоков тиров */
    border-radius: 0;
    flex: 1 1 150px;
    width: 150px;
    box-sizing: border-box;
    position: relative;
    min-width: 0;
}
.tier-row.has-columns .tier-column:last-child {
    border-right: none;
}
.tier-row.has-columns .tier-column {
    border-right: none !important;
    position: relative;
}
.tier-row.has-columns .tier-column:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    bottom: 0;
    background: var(--border-color);
    z-index: 1;
    pointer-events: none;
}
.tier-row:last-child .tier-column:not(:last-child)::after {
    bottom: 0;
}

.header-cell-text {
    width: 100%;
    text-align: center;
    font-weight: bold;
    font-size: 13px;
    color: #eee;
    outline: none;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.2;
}

.header-cell-text:empty::before {
    content: attr(data-placeholder);
    color: currentColor;
}

.header-cell-image-container {
    width: 100%;
    height: 100%;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    border-radius: 4px;
}

.header-cell-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-placeholder-icon {
    font-size: 16px;
    color: #888;
}

/* Маленькая контекстная кнопка настроек ячейки */
.header-cell-settings-btn {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 15;
}

.header-column-cell .color-picker-container {
    opacity: 0 !important;
    pointer-events: none !important;
}

body.show-settings .header-column-cell .color-picker-container {
    opacity: 1 !important;
    pointer-events: auto !important;
}
.col-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}
.col-resizer.right-edge {
    right: -4px;
}
.col-resizer.left-edge {
    left: -4px;
}
.col-resizer:hover {
    background: rgba(100, 181, 246, 0.4);
}

.tier-row.has-columns .tier-columns-wrapper {
    display: flex;
    flex-grow: 1;
    gap: 0; /* Убираем зазоры между колонками */
    padding: 0; /* Убираем отступы сверху/снизу и по бокам */
    overflow-x: auto;
    box-sizing: border-box;
}
.tier-row.has-columns .tier-column .column-header {
    display: none;
}

.tier-row.has-columns .tier-column .column-items {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: flex-start;
    padding: 4px; /* Изменяем на 4px, чтобы убрать лишний пустой зазор сверху */
    gap: var(--gap-size);
    min-height: 120px;
    box-sizing: border-box;
    flex-grow: 1;
}
.tier-row.has-columns .tier-column .column-items::after {
    display: none !important;
}

.tier-row.has-columns .tier-column .column-items .tier-img {
    max-width: 100% !important;
    height: var(--img-h) !important;
    box-sizing: border-box;
}
:root.column-auto-rectangles
    .tier-row.has-columns:not([data-max-per-row])
    .tier-column
    .column-items
    .tier-img {
    max-width: none !important;
}
.tier-row.has-columns .tier-column .column-items .tier-img img {
    width: 100% !important;
    height: 100% !important;
}
.tier-row.has-columns .tier-column .column-items .tier-img.fit-cover img {
    object-fit: cover !important;
}
.tier-row.has-columns .tier-column .column-items .tier-img.fit-contain img {
    object-fit: contain !important;
}

.header-cell-image-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.control-btn.btn-row-settings {
    bottom: 4px;
    left: 4px;
    background-color: rgba(0, 0, 0, 0.7);
}

.control-btn.btn-row-settings:hover {
    background-color: rgba(50, 50, 50, 0.9);
}

#row-settings-menu select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 4px center !important;
    background-size: 18px !important;
    padding-right: 22px !important;
}
/* === Панель свойств (И  спектор) и теги === */
.inspector-panel {
    position: fixed;
    z-index: 1002; /* Увеличено, чтобы перекрывать 4 правые кнопки */
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(15px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transition:
        transform 0.3s ease,
        bottom 0.3s ease,
        width 0.3s ease,
        height 0.3s ease;
    box-sizing: border-box;
    color: #fff;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
}
@media (min-width: 769px) {
    .inspector-panel {
        top: 0;
        right: 0;
        width: 380px;
        height: 100vh;
        height: 100dvh;
        transform: translateX(380px);
        padding: 28px 15px 20px 15px;
    }
    .inspector-panel.active {
        transform: translateX(0);
    }
    .inspector-panel.collapsed {
        width: 50px;
        padding: 20px 5px 20px 5px;
    }
    .inspector-panel.collapsed .inspector-body {
        display: none;
    }
    .inspector-panel.collapsed .inspector-header h3 {
        display: none;
    }
    .inspector-header {
        min-height: 45px;
        padding-right: 45px !important;
    }
    .inspector-close-btn {
        display: none !important;
    }
}
@media (max-width: 768px) {
    .inspector-panel {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 380px;
        max-height: 80vh;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        transform: translateY(380px);
        padding: 15px;
        border-radius: 16px 16px 0 0;
    }
    .inspector-panel.active {
        transform: translateY(0);
    }
    .inspector-panel.collapsed {
        height: 50px;
    }
    .inspector-panel.collapsed .inspector-body {
        display: none;
    }
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    gap: 5px;
    background: #2196f3;
    color: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: 0.15s;
}
.tag-chip:hover {
    filter: brightness(1.15);
}
.tag-chip-del {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.7;
}
.tag-chip-del:hover {
    opacity: 1;
    color: #ff3b30;
}
#inspector-comment {
    width: 100%;
    height: 80px;
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px;
    resize: none;
    box-sizing: border-box;
    outline: none;
    font-size: 13px;
}
#inspector-comment:disabled {
    background: #121212;
    color: #aaa;
    border-color: #333;
}

@media (min-width: 769px) {
    body.inspector-open {
        padding-right: 380px;
    }
}
@media (max-width: 768px) {
    body.inspector-open {
        padding-bottom: 390px;
    }
}
#row-settings-menu {
    position: fixed;
    z-index: 10005;
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s ease;
    border: 1px solid #444;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
    min-width: 220px;
}
#row-settings-menu.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
}

/* Исправление контекстного меню колонок */
#col-settings-menu {
    position: fixed;
    z-index: 10005;
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s ease;
    border: 1px solid #444;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
    min-width: 180px;
}
#col-settings-menu.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
}
.tier-columns-wrapper,
.header-columns-wrapper {
    scrollbar-width: none !important;
    overflow-y: hidden !important;
}
.tier-columns-wrapper::-webkit-scrollbar,
.header-columns-wrapper::-webkit-scrollbar {
    display: none !important;
}
.header-column-cell,
.tier-row.has-columns .tier-column {
    min-width: var(--column-min-w) !important;
}

body.hide-column-tier-labels .columns-header-bar .header-label-spacer,
body.hide-column-tier-labels .tier-row.has-columns > .tier-label {
    display: none !important;
}

/* ===== Ограничение картинок в ряду (maxItemsPerRow) ===== */
.tier-items.max-cols {
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
}
.tier-items.max-cols::after {
    display: none !important;
}
.max-row-break {
    flex-basis: 100%;
    width: 100%;
    height: 0;
    min-height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ===== Сетка 3×3 выравнивания текста в редакторе ===== */
.ed-align-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.ed-align-grid button {
    height: 36px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #161616;
    color: #ddd;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
}
.ed-align-grid button.active {
    background: rgba(33, 150, 243, 0.18);
    border-color: #64b5f6;
    color: #90caf9;
}

/* ===== Канвас рамки «Кадр в блоке» в редакторе ===== */
#ed-frame-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    touch-action: none;
    cursor: grab;
}
#ed-frame-canvas.dragging {
    cursor: grabbing;
}

/* ===== Чипы фильтра по тегам ===== */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #333;
    color: #ddd;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid #555;
    transition: 0.15s;
    user-select: none;
    -webkit-user-select: none;
}
.filter-chip:hover {
    filter: brightness(1.2);
}
.filter-chip.active {
    background: #2196f3;
    border-color: #64b5f6;
    color: #fff;
}
.filter-chip.chip-mode {
    background: #444;
}
.filter-chip.chip-mode.active {
    background: #e67e22;
    border-color: #f39c12;
}
.filter-chip.chip-mode.mode-show-active {
    background: #4fc3f7;
    border-color: #81d4fa;
    color: #002b40;
}
.filter-chip.chip-reset {
    background: #555;
}

/* ===== Единое окно импорта ===== */
#import-modal .modal-content {
    transition:
        border-color 0.15s,
        background 0.15s;
    border: 2px solid transparent;
}
#import-modal .modal-content.drop-hover {
    border-color: #64b5f6;
    background: #1d232b;
}
#import-modal .modal-content.drop-hover #import-drop-hint {
    border-color: #64b5f6;
    color: #90caf9;
}

/* ===== Строка тира в окне настройки экспорта ===== */
.export-setup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px 12px;
}
.export-setup-row .es-name {
    width: 90px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
    padding: 4px 6px;
    text-align: center;
    color: #000;
}
.export-setup-row input[type='range'] {
    flex: 1;
    min-width: 0;
}
.export-setup-row .es-val {
    width: 52px;
    flex-shrink: 0;
    text-align: center;
    font-size: 12px;
    color: #ddd;
    background: #262626;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 0;
}

/* ===== Быстрая палитра цветов ===== */
#quick-color-popup {
    position: fixed;
    z-index: 10010;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
    display: none;
    flex-direction: column;
    gap: 10px;
    width: 230px;
    box-sizing: border-box;
}
#quick-color-popup.active {
    display: flex;
}
.quick-saved-colors-wrapper {
    display: none;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid #555;
    padding-top: 10px;
}
.quick-saved-colors-wrapper > span {
    color: #999;
    font-size: 12px;
}

/* ===== Общая полировка интерфейса (без изменения функционала) ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: #161616;
}
::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 5px;
    border: 2px solid #161616;
}
::-webkit-scrollbar-thumb:hover {
    background: #4f4f4f;
}
* {
    scrollbar-width: thin;
    scrollbar-color: #3a3a3a #161616;
}
button {
    -webkit-tap-highlight-color: transparent;
}
input[type='text']:focus,
input[type='number']:focus,
textarea:focus,
select:focus {
    border-color: #64b5f6 !important;
    box-shadow: 0 0 0 2px rgba(100, 181, 246, 0.15);
}
.modal-content {
    border: 1px solid rgba(255, 255, 255, 0.07);
}
.pool-container,
#tierlist-wrapper {
    border: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Unified export menu ===== */
#export-setup-modal.active {
    display: flex;
    padding: 18px;
    box-sizing: border-box;
    background: rgba(6, 8, 12, 0.78);
    backdrop-filter: blur(18px);
}

#export-setup-modal .export-menu-shell {
    width: min(1120px, 96vw) !important;
    max-width: min(1120px, 96vw) !important;
    height: min(860px, 92dvh);
    max-height: 92dvh !important;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(145deg, rgba(31, 34, 42, 0.96), rgba(16, 18, 24, 0.97));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.62);
}

.export-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.export-title-group h2 {
    margin: 0;
    font-size: 19px;
    line-height: 1.2;
}

.export-title-group p {
    margin: 5px 0 0;
    color: #9aa3af;
    font-size: 13px;
    line-height: 1.35;
}

.modal-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.modal-controls .modal-control-btn,
.modal-controls .modal-minimize-btn,
.modal-controls .modal-close {
    position: static;
    inset: auto;
    width: 34px;
    height: 34px;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: #aaa;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 0;
    transition:
        color 0.16s ease,
        background 0.16s ease,
        border-color 0.16s ease;
    z-index: 5;
}

.modal-controls .modal-control-btn:hover,
.modal-controls .modal-minimize-btn:hover,
.modal-controls .modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.18);
}

.modal-control-minimize,
.modal-control-close,
.modal-control-expand {
    position: relative;
    width: 16px;
    height: 16px;
    display: block;
    color: currentColor;
}

.modal-control-minimize::before {
    content: '';
    position: absolute;
    left: 2px;
    right: 2px;
    top: 7px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.modal-control-close::before,
.modal-control-close::after {
    content: '';
    position: absolute;
    left: 2px;
    right: 2px;
    top: 7px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.modal-control-close::before {
    transform: rotate(45deg);
}
.modal-control-close::after {
    transform: rotate(-45deg);
}

.modal-control-expand::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 2px solid currentColor;
    border-radius: 3px;
}

.modal-control-expand::after {
    content: '';
    position: absolute;
    right: 1px;
    top: 1px;
    width: 5px;
    height: 5px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
}

.export-menu-body {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 0;
}

.export-settings-rail {
    min-width: 0;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-card {
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
    padding: 12px;
    box-sizing: border-box;
}

.export-card-title {
    color: #e5e7eb;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 10px;
}

.export-setup-rows,
.export-column-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
}

.export-setup-row,
.export-column-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) 50px;
    align-items: center;
    gap: 9px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 7px;
    padding: 8px;
}

.export-setup-row .es-name {
    min-width: 0;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 5px;
    padding: 5px 6px;
    text-align: center;
    color: #000;
}

.export-setup-row input[type='range'],
.export-column-row input[type='range'],
.export-slider-row input[type='range'] {
    width: 100%;
    min-width: 0;
}

.export-setup-row .es-val,
.export-column-row output,
.export-slider-row output {
    width: 50px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    text-align: center;
    font-size: 12px;
    color: #d8dee9;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 0 4px;
}

.export-input,
.export-select {
    width: 100%;
    min-height: 38px;
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    padding: 0 10px;
    box-sizing: border-box;
    outline: none;
}

.export-control-row,
.export-font-row,
.export-slider-row,
.export-select-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.export-font-row {
    grid-template-columns: minmax(0, 1fr) auto auto 36px;
    margin-top: 8px;
}

.export-slider-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.export-slider-row {
    grid-template-columns: 72px minmax(0, 1fr) 50px;
}

.export-select-row {
    grid-template-columns: 72px minmax(0, 1fr);
}

.export-slider-row span,
.export-select-row span,
.export-column-row span {
    color: #aab2bf;
    font-size: 12px;
}

.export-small-btn,
.export-logo-upload,
.export-logo-actions button,
.export-secondary-btn,
.export-download-btn,
.export-quality-btn {
    min-height: 38px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    box-sizing: border-box;
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
}

.export-small-btn.danger,
.export-logo-actions button.danger {
    background: rgba(231, 76, 60, 0.7);
}

.export-small-btn.file {
    white-space: nowrap;
}

.export-color-swatch {
    width: 36px;
    min-width: 36px;
    height: 36px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0;
    background: rgba(255, 255, 255, 0.95);
}

.export-logo-upload {
    width: 100%;
    margin: 0 0 8px;
    background: rgba(100, 181, 246, 0.14);
    border-color: rgba(100, 181, 246, 0.28);
}

.export-logo-actions {
    gap: 6px;
    width: 100%;
    margin-bottom: 8px;
}

.export-logo-actions button {
    flex: 1;
}

.export-submenu {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.export-segment-row {
    display: flex;
    gap: 6px;
}

.export-watermark-mini-preview {
    margin-top: 10px;
    min-height: 84px;
    padding: 10px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: repeating-conic-gradient(#333 0% 25%, #222 0% 50%, #333 50% 75%, #222 75% 100%)
        50% / 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.export-watermark-mini-preview #watermark-preview-box {
    display: flex;
    align-items: center;
    gap: 10px;
    transform-origin: center;
}

.export-note {
    margin-top: 7px;
    color: #8c94a1;
    font-size: 11px;
    line-height: 1.35;
    text-align: center;
}

.export-quality-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.export-quality-btn {
    min-width: 0;
    flex-direction: column;
    gap: 2px;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.06);
}

.export-quality-btn span {
    color: #9aa3af;
    font-size: 10px;
}

.export-quality-btn.active {
    color: #06111f;
    background: #8bd3ff;
    border-color: #b6e6ff;
}

.export-quality-btn.active span {
    color: #17344d;
}

.export-secondary-btn {
    width: 100%;
    margin-top: 10px;
    background: rgba(127, 140, 141, 0.24);
}

.export-download-btn {
    width: 100%;
    min-height: 44px;
    font-size: 14px;
    font-weight: 800;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border-color: rgba(255, 255, 255, 0.14);
}

.export-preview-panel {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 50% 0%, rgba(100, 181, 246, 0.1), transparent 36%), #0d0f14;
}

.export-preview-head {
    min-height: 48px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.export-preview-head h3 {
    margin: 0 0 3px;
    font-size: 15px;
}

#export-preview-status {
    color: #9aa3af;
    font-size: 12px;
}

#export-preview-status.error {
    color: #ff8f8f;
}

.export-preview-stage {
    min-height: 0;
    flex: 1;
    padding: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#export-preview-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
    background: #121212;
}

#export-setup-modal.minimized {
    background: transparent !important;
    backdrop-filter: none;
    align-items: flex-end !important;
    justify-content: flex-end !important;
    pointer-events: none !important;
    padding: 12px !important;
}

#export-setup-modal.minimized .export-menu-shell {
    pointer-events: auto;
    width: 320px !important;
    max-width: calc(100vw - 24px) !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
}

#export-setup-modal.minimized .export-menu-body {
    display: none !important;
}

#export-setup-modal.minimized .export-menu-header {
    border-bottom: 0;
}

.export-settings-rail {
    order: 2;
}
.export-preview-panel {
    order: 1;
}

@media (max-width: 768px) {
    #export-setup-modal.active {
        align-items: stretch;
        padding: 0;
    }

    #export-setup-modal .export-menu-shell,
    #export-setup-modal.minimized .export-menu-shell {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .export-menu-header {
        padding: 12px 12px 10px;
    }

    .export-title-group h2 {
        font-size: 18px;
    }

    .export-title-group p {
        font-size: 12px;
    }

    .export-menu-body,
    #export-setup-modal.minimized .export-menu-body {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 56dvh) minmax(0, 1fr);
    }

    .export-preview-panel {
        order: 1;
        min-height: 0;
    }

    .export-settings-rail,
    #export-setup-modal.minimized .export-settings-rail {
        order: 2;
        border-left: none;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding: 10px;
    }

    .export-preview-stage {
        padding: 10px;
    }

    .export-setup-row,
    .export-column-row {
        grid-template-columns: 78px minmax(0, 1fr) 46px;
        gap: 6px;
        padding: 7px;
    }

    .export-font-row {
        grid-template-columns: minmax(0, 1fr) 46px 66px 36px;
    }

    .export-quality-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Export refinements ===== */
.export-textarea {
    min-height: 76px;
    padding: 9px 10px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.35;
    white-space: pre-wrap;
}

.export-bulk-wrap-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #aab2bf;
    font-size: 12px;
}

.export-bulk-wrap-row input {
    min-height: 34px;
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    text-align: center;
    box-sizing: border-box;
}

.export-secondary-btn.compact {
    min-height: 34px;
    margin-top: 0;
    width: auto;
    padding: 0 12px;
}

.export-column-list {
    max-height: none;
    overflow: visible;
}

.export-column-rail {
    position: relative;
    height: 58px;
    padding: 18px 0 8px;
    touch-action: none;
}

.export-column-track {
    height: 30px;
    display: flex;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.28);
}

.export-column-segment {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(100, 181, 246, 0.12);
    border-right: 1px solid rgba(255, 255, 255, 0.13);
    color: #d8eeff;
    font-size: 11px;
    box-sizing: border-box;
}

.export-column-segment:nth-child(even) {
    background: rgba(139, 211, 255, 0.18);
}

.export-column-segment:last-child {
    border-right: 0;
}

.export-column-segment output {
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 11px;
}

.export-column-handle {
    position: absolute;
    top: 10px;
    width: 18px;
    height: 46px;
    transform: translateX(-50%);
    border: 0;
    border-radius: 9px;
    background: #8bd3ff;
    box-shadow:
        0 0 0 3px rgba(139, 211, 255, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.45);
    cursor: col-resize;
    z-index: 2;
    padding: 0;
    touch-action: none;
}

.export-column-handle::before {
    content: '';
    position: absolute;
    top: 11px;
    bottom: 11px;
    left: 8px;
    width: 2px;
    border-radius: 2px;
    background: rgba(6, 17, 31, 0.75);
}

.export-column-rail.dragging .export-column-handle {
    cursor: grabbing;
}

.export-column-hint {
    color: #8c94a1;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
}

.export-preview-tools {
    display: flex;
    gap: 6px;
}

.export-preview-tools button {
    min-width: 34px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    padding: 0 8px;
}

.export-preview-stage {
    cursor: grab;
}

.export-preview-stage.panning {
    cursor: grabbing;
}

#export-preview-canvas {
    transform-origin: center center;
    will-change: transform;
    touch-action: none;
}

#preview-text {
    white-space: pre-line;
    line-height: 1.2;
}
