.studio-subbar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    padding: 8px 18px;
    background: #fafafa;
    border-bottom: 1px solid #e5e5e5;
}

.studio-subbar .control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.subbar-divider {
    width: 1px;
    height: 22px;
    background: #d0d0d0;
    flex-shrink: 0;
}

.resource-thumb-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid #dddddd;
    border-radius: 6px;
    overflow: hidden;
    background: #f9f9f9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resource-thumb-wrapper img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.delete-resource-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(17, 17, 17, 0.85);
    color: #ffffff;
    border: none;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.resource-thumb-wrapper:hover .delete-resource-btn {
    display: flex;
}

.empty-resources {
    grid-column: 1 / -1;
    font-size: 0.78rem;
    color: #888888;
    font-style: italic;
}

@media (max-width: 768px) {
    .studio-subbar {
        padding: 8px 10px;
        gap: 8px;
    }
}

.text-align-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.text-align-group .align-btn {
    padding: 4px 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 28px;
}

.text-advanced-panel {
    margin-top: 10px;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #dcdcdc;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.text-advanced-panel.hidden {
    display: none;
}

.text-adv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.92rem;
    color: #111111;
    border-bottom: 1px solid #efefef;
    padding-bottom: 6px;
}

.text-adv-close {
    background: none;
    border: none;
    font-size: 1.15rem;
    line-height: 1;
    color: #555555;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
}

.text-adv-close:hover {
    background: #f2f2f2;
    color: #111111;
}

.text-adv-section-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #222222;
}

.text-adv-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.text-adv-control label {
    font-size: 0.82rem;
    color: #333333;
}

.text-adv-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.text-adv-slider-row input[type="range"] {
    flex: 1;
    accent-color: #111111;
    cursor: pointer;
}

.text-adv-num-input {
    width: 54px;
    height: 30px;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    text-align: center;
    font-size: 0.84rem;
    color: #111111;
    background: #ffffff;
    padding: 0 4px;
}

.text-anchor-segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #f1f2f4;
    padding: 3px;
    border-radius: 10px;
    gap: 3px;
}

.anchor-seg-btn {
    border: none;
    background: transparent;
    border-radius: 8px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #222222;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.anchor-seg-btn:hover {
    background: rgba(255, 255, 255, 0.65);
}

.anchor-seg-btn.active {
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    color: #111111;
}

.creative-dock {
    width: calc(100% - 40px);
    max-width: 1120px;
    margin: 0 auto 48px auto;
    padding: 24px 28px;
    background: #ffffff;
    border: 1px solid #e2e2e2;
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.dock-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px solid #efefef;
    padding-bottom: 12px;
}

.dock-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #111111;
}

.dock-subtitle {
    font-size: 0.88rem;
    color: #666666;
    font-style: italic;
}

.dock-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.dock-card {
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dock-card.dock-card-focused {
    border-color: #111111;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.dock-card.wide-card {
    grid-column: 1 / -1;
}

.dock-card h4 {
    margin: 0 0 2px 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: #1a1a1a;
}

.dock-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.9rem;
    color: #222222;
}

.upload-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.dock-hint {
    font-size: 0.82rem;
    color: #666666;
    line-height: 1.45;
    display: block;
}

.creative-dock .modal-input {
    border: 1px solid #d4d4d4;
    border-radius: 999px;
    background: #ffffff;
    color: #111111;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.creative-dock .modal-input:focus {
    border-color: #111111;
}

.recent-resources {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    min-height: 68px;
    padding: 12px;
    background: #ffffff;
    border: 1px dashed #d4d4d4;
    border-radius: 12px;
    box-sizing: border-box;
}

.recent-resources .resource-thumb-wrapper {
    width: 62px;
    height: 62px;
    flex: 0 0 auto;
}

@media (max-width: 860px) {
    .creative-dock {
        width: calc(100% - 24px);
        padding: 16px;
        margin-bottom: 32px;
    }

    .dock-grid {
        grid-template-columns: 1fr;
    }
}

.layers-floating-panel {
    position: fixed;
    right: 18px;
    top: 126px;
    width: 256px;
    max-height: calc(100vh - 150px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    border: 1px solid #dcdcdc;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.09);
    z-index: 950;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #111111;
    transition: width 0.18s ease;
}

.layers-floating-panel.collapsed {
    width: 156px;
}

.layers-floating-panel.collapsed .layers-panel-body {
    display: none;
}

.layers-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #fafafa;
    border-bottom: 1px solid #ececec;
    font-size: 0.86rem;
    font-weight: 700;
    user-select: none;
}

.layers-panel-toggle {
    border: 1px solid #d4d4d4;
    background: #ffffff;
    color: #111111;
    border-radius: 6px;
    width: 24px;
    height: 24px;
    font-size: 0.82rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.layers-panel-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.layers-blend-box {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-bottom: 8px;
    border-bottom: 1px solid #efefef;
}

.layers-blend-box label {
    font-size: 0.76rem;
    font-weight: 600;
    color: #555555;
}

.layers-blend-select {
    width: 100%;
    height: 30px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid #d4d4d4;
    background: #ffffff;
    color: #111111;
    font-size: 0.8rem;
    cursor: pointer;
}

.layers-blend-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.layers-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 44px;
}

.layers-empty-msg {
    font-size: 0.78rem;
    color: #888888;
    font-style: italic;
    text-align: center;
    padding: 14px 6px;
}

.layer-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    background: #f9f9f9;
    border: 1px solid #e4e4e4;
    border-radius: 9px;
    cursor: pointer;
    user-select: none;
    transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.layer-row:hover {
    background: #f2f2f2;
}

.layer-row.selected {
    background: #111111;
    border-color: #111111;
    color: #ffffff;
}

.layer-row.dragging {
    opacity: 0.45;
}

.layer-row.drag-over-top {
    border-top: 2px solid #111111;
}

.layer-row.drag-over-bottom {
    border-bottom: 2px solid #111111;
}

.layer-drag-handle {
    cursor: grab;
    font-size: 0.9rem;
    opacity: 0.65;
    padding: 0 2px;
    flex-shrink: 0;
}

.layer-thumb {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    background: #ffffff;
    border: 1px solid #dcdcdc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 700;
    color: #111111;
}

.layer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.layer-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.layer-title {
    font-size: 0.79rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-meta {
    font-size: 0.68rem;
    opacity: 0.72;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-delete-btn {
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.7;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
}

.layer-delete-btn:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.2);
}

@media (max-width: 1180px) {
    .layers-floating-panel {
        position: static;
        width: calc(100% - 24px);
        max-width: 1120px;
        max-height: 320px;
        margin: 12px auto;
    }
}

.page,
.stickers-layer,
.textboxes-layer {
    isolation: auto;
}

.page {
    isolation: isolate;
}

.sticker-item,
.textbox-item,
.reader-textbox-item {
    isolation: auto;
}

body[data-page="studio"] .stickers-layer .sticker-item,
body[data-page="studio"] .textboxes-layer .textbox-item,
body[data-page="studio"] #stickers-cover .sticker-item,
body[data-page="studio"] #stickers-cover .textbox-item {
  pointer-events: none !important;
}

body[data-page="studio"] .stickers-layer .sticker-item.active-transform,
body[data-page="studio"] .stickers-layer .sticker-item.active-transform *,
body[data-page="studio"] .textboxes-layer .textbox-item.active-transform,
body[data-page="studio"] .textboxes-layer .textbox-item.active-transform *,
body[data-page="studio"] #stickers-cover .sticker-item.active-transform,
body[data-page="studio"] #stickers-cover .sticker-item.active-transform *,
body[data-page="studio"] #stickers-cover .textbox-item.active-transform,
body[data-page="studio"] #stickers-cover .textbox-item.active-transform * {
  pointer-events: auto !important;
}

body[data-page="studio"] .stickers-layer .sticker-item.active-transform img,
body[data-page="studio"] #stickers-cover .sticker-item.active-transform img {
  pointer-events: none !important;
}