/**
 * Toolora Advanced Design Studio — Shared Styling System
 * Sleek, high-performance UI matching Toolora's dark/light design tokens
 */

:root {
    --studio-bg: #090B10;
    --studio-sidebar-w: 72px;
    --studio-drawer-w: 340px;
    --studio-header-h: 56px;
    --studio-topbar-h: 46px;
    --studio-accent: #8B5CF6;
    --studio-accent-hover: #7C3AED;
    --studio-accent-soft: rgba(139, 92, 246, 0.12);
    --studio-line: rgba(255, 255, 255, 0.10);
    --studio-surface: #12151E;
    --studio-surface-alt: #181C28;
    --studio-card-bg: #1A1F2D;
    --studio-text: #F1F5F9;
    --studio-text-muted: #94A3B8;
    --studio-danger: #EF4444;
    --studio-success: #10B981;
}

/* Expand Studio Page Container for Immersive Canvas Workflow */
.tool-page:has(.toolora-studio-wrapper),
.container:has(.toolora-studio-wrapper),
.container:has(.youtube-studio-wrapper),
.container:has(.social-media-studio-wrapper),
.container:has(.invitation-card-studio-wrapper),
.container:has(.image-editor-studio-container) {
    max-width: 96vw !important;
    width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
}

/* Complete Image and Canvas Copy / Drag / Context Protection across all studio tools */
canvas,
.studio-canvas-area,
.canvas-container,
.ie-canvas-container,
.ie-workspace,
.toolora-studio-wrapper img,
.invitation-card-studio-wrapper img,
.youtube-studio-wrapper img,
.social-media-studio-wrapper img {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
    -khtml-user-drag: none !important;
    -moz-user-drag: none !important;
    -o-user-drag: none !important;
    user-drag: none !important;
    -webkit-touch-callout: none !important; /* Blocks mobile iOS long-press save menu */
}

/* Anti-Bypass: Prevent scraping via browser Print-to-PDF */
@media print {
    .ie-wrapper,
    .toolora-studio-wrapper,
    .canvas-container,
    .studio-canvas-area,
    .ie-workspace {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* Anti-Screenshot Shield on Window Blur (Lightshot / Snipping Tool / OS Capture Interception) */
.toolora-shield-active .ie-workspace canvas,
.toolora-shield-active .canvas-container canvas,
.toolora-shield-active .studio-canvas-area canvas,
.toolora-shield-active #ieCanvasContainer canvas,
.toolora-shield-active canvas {
    filter: blur(32px) grayscale(90%) !important;
    opacity: 0.12 !important;
    transition: filter 0.05s ease, opacity 0.05s ease !important;
    pointer-events: none !important;
}

/* Universal Live Preview Watermark Overlay for Screen & Lightshot Capture Protection */
.canvas-wrapper,
#frontCanvasWrapper,
#backCanvasWrapper,
.studio-canvas-holder,
#canvasHolder,
.ie-canvas-container,
#ieCanvasContainer,
.canvas-container {
    position: relative;
}

.canvas-wrapper::after,
#frontCanvasWrapper::after,
#backCanvasWrapper::after,
.studio-canvas-holder::after,
#canvasHolder::after,
.ie-canvas-container::after,
#ieCanvasContainer::after,
.canvas-container::after,
.toolora-live-watermark-layer {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none !important;
    z-index: 40;
    border-radius: inherit;
    background-repeat: repeat;
    background-size: 240px 140px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='140' viewBox='0 0 240 140'%3E%3Ctext x='120' y='70' fill='%23334155' fill-opacity='0.28' stroke='%23FFFFFF' stroke-width='0.75' stroke-opacity='0.6' font-family='Arial, sans-serif' font-size='16' font-weight='800' letter-spacing='1' text-anchor='middle' transform='rotate(-22 120 70)'%3ETOOLORA PREVIEW%3C/text%3E%3C/svg%3E");
}

/* Base Studio Container */
.toolora-studio-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 88vh;
    min-height: 700px;
    background: var(--studio-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    z-index: 1;
    isolation: isolate;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    color: var(--studio-text);
    font-family: var(--font-body, 'Inter', sans-serif);
    user-select: none;
}

/* Top Studio Navigation Bar */
.studio-top-nav {
    min-height: 52px;
    height: auto;
    background: var(--studio-surface);
    border-bottom: 1px solid var(--studio-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    gap: 12px;
    z-index: 40;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}
.studio-top-nav::-webkit-scrollbar { height: 4px; }
.studio-top-nav::-webkit-scrollbar-thumb { background: var(--studio-line); border-radius: 2px; }

.studio-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-shrink: 0;
}

.studio-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--studio-surface-alt);
    border: 1px solid var(--studio-line);
    color: var(--studio-text);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.studio-back-btn:hover {
    background: var(--studio-accent-soft);
    border-color: var(--studio-accent);
    color: var(--studio-accent);
}

.studio-title-input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--studio-text);
    font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
    font-size: 13px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 6px;
    max-width: 140px;
    min-width: 70px;
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.15s ease;
}
.studio-title-input:hover, .studio-title-input:focus {
    background: var(--studio-surface-alt);
    border-color: var(--studio-line);
    max-width: 180px;
}

.studio-preset-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--studio-surface-alt);
    border: 1px solid var(--studio-line);
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--studio-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.studio-save-status {
    font-size: 11px;
    font-weight: 600;
    color: var(--studio-text-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 3px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
}
.studio-save-status.saving { color: #F59E0B; background: rgba(245, 158, 11, 0.12); }
.studio-save-status.saved { color: var(--studio-success); background: rgba(16, 185, 129, 0.12); }

/* Center Action Controls (Undo, Redo, Zoom) */
.studio-center-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    background: var(--studio-surface-alt);
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    padding: 3px 5px;
    flex-shrink: 0;
}

.studio-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--studio-text);
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.studio-btn-icon:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: #FFF;
}
.studio-btn-icon:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.studio-zoom-val {
    font-size: 11px;
    font-weight: 700;
    min-width: 36px;
    text-align: center;
    color: var(--studio-text);
    white-space: nowrap;
    user-select: none;
}

/* Top Right Action Controls */
.studio-right-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.studio-right-actions select.context-input-select {
    max-width: 170px !important;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    font-size: 11px !important;
    padding: 4px 6px !important;
}

.studio-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--studio-accent);
    color: #FFFFFF;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(139, 92, 246, 0.35);
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.18s ease;
}
.studio-btn-primary:hover {
    background: var(--studio-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(139, 92, 246, 0.5);
}

.studio-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--studio-surface-alt);
    color: var(--studio-text);
    border: 1px solid var(--studio-line);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.studio-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Floating Contextual Properties Bar */
.studio-context-bar {
    min-height: 48px;
    height: auto;
    background: var(--studio-surface-alt);
    border-bottom: 1px solid var(--studio-line);
    display: flex;
    align-items: center;
    padding: 6px 14px;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    z-index: 30;
    flex-shrink: 0;
}
.studio-context-bar::-webkit-scrollbar { height: 4px; }
.studio-context-bar::-webkit-scrollbar-thumb { background: var(--studio-line); border-radius: 2px; }

.context-group {
    display: flex;
    align-items: center;
    gap: 6px;
    border-right: 1px solid var(--studio-line);
    padding-right: 10px;
    flex-shrink: 0;
    white-space: nowrap;
}
.context-group:last-child {
    border-right: none;
    padding-right: 0;
}

.context-group .studio-btn-secondary,
.context-group .studio-btn-primary {
    padding: 4px 8px !important;
    font-size: 11px !important;
    height: 28px !important;
    white-space: nowrap !important;
    line-height: 1 !important;
}

.context-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--studio-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.context-input-select {
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    color: var(--studio-text);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}
.context-input-number {
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    color: var(--studio-text);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 6px;
    border-radius: 6px;
    width: 54px;
    text-align: center;
    outline: none;
}
.context-color-picker {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--studio-line);
    padding: 0;
    background: none;
    cursor: pointer;
}

/* Studio Body Layout */
.studio-body {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* Left Icon Navigation Tabs */
.studio-left-nav {
    width: var(--studio-sidebar-w);
    background: var(--studio-surface);
    border-right: 1px solid var(--studio-line);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    z-index: 25;
    flex-shrink: 0;
}

.studio-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--studio-text-muted);
    font-size: 10px;
    font-weight: 700;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.studio-tab-btn span.tab-icon {
    font-size: 18px;
    line-height: 1;
}
.studio-tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--studio-text);
}
.studio-tab-btn.active {
    background: var(--studio-accent-soft);
    color: var(--studio-accent);
}

/* Left Sliding Drawer */
.studio-drawer {
    width: var(--studio-drawer-w);
    background: var(--studio-surface);
    border-right: 1px solid var(--studio-line);
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    z-index: 20;
    flex-shrink: 0;
    transition: width 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}
.studio-drawer.collapsed {
    width: 0;
    border-right: none;
}

.drawer-tab-pane {
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.drawer-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--studio-line);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
.drawer-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.drawer-title {
    font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
    font-size: 15px;
    font-weight: 800;
    color: var(--studio-text);
}
.drawer-search-box {
    position: relative;
    width: 100%;
}
.drawer-search-input {
    width: 100%;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    padding: 8px 12px 8px 32px;
    font-size: 13px;
    color: var(--studio-text);
    outline: none;
    box-sizing: border-box;
}
.drawer-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--studio-text-muted);
}

.drawer-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 16px 28px;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.7) rgba(255, 255, 255, 0.05);
    -webkit-overflow-scrolling: touch;
}
.drawer-content::-webkit-scrollbar {
    width: 6px;
}
.drawer-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
}
.drawer-content::-webkit-scrollbar-thumb {
    background: var(--studio-accent, #8B5CF6);
    border-radius: 4px;
}
.drawer-content::-webkit-scrollbar-thumb:hover {
    background: #A78BFA;
}

/* Category Pills in Drawer */
.drawer-category-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 4px;
    padding-bottom: 6px;
    margin-top: 4px;
    margin-bottom: 4px;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.6) rgba(255, 255, 255, 0.05);
    -webkit-overflow-scrolling: touch;
}
.drawer-category-pills::-webkit-scrollbar {
    height: 4px;
}
.drawer-category-pills::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
.drawer-category-pills::-webkit-scrollbar-thumb {
    background: var(--studio-accent, #8B5CF6);
    border-radius: 4px;
}
.drawer-category-pills::-webkit-scrollbar-thumb:hover {
    background: #A78BFA;
}

.cat-pill {
    padding: 5px 12px;
    border-radius: 14px;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    color: var(--studio-text-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
    user-select: none;
}
.cat-pill:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--studio-text);
    border-color: rgba(255, 255, 255, 0.2);
}
.cat-pill.active {
    background: var(--studio-accent);
    color: #FFFFFF;
    border-color: var(--studio-accent);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

/* Template Grid */
.templates-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.template-card {
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    flex-direction: column;
}
.template-card:hover {
    border-color: var(--studio-accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.template-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
}
.template-preview.portrait { aspect-ratio: 5 / 7; min-height: 110px; }
.template-preview.square { aspect-ratio: 1 / 1; min-height: 90px; }
.template-preview.story { aspect-ratio: 9 / 16; min-height: 130px; }
.template-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.template-info {
    padding: 8px 10px;
}
.template-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--studio-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.template-cat {
    font-size: 10px;
    color: var(--studio-text-muted);
}

/* Elements / Shapes Grid */
.shapes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.shape-btn {
    aspect-ratio: 1;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 20px;
    color: var(--studio-text);
    transition: all 0.15s ease;
}
.shape-btn:hover {
    background: var(--studio-accent-soft);
    border-color: var(--studio-accent);
    color: var(--studio-accent);
    transform: scale(1.06);
}

/* Text Presets */
.text-preset-btn {
    width: 100%;
    padding: 12px 14px;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    color: var(--studio-text);
    text-align: left;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.text-preset-btn:hover {
    border-color: var(--studio-accent);
    background: rgba(139, 92, 246, 0.05);
}

/* Uploads Dropzone */
.studio-upload-dropzone {
    border: 2px dashed var(--studio-accent);
    background: var(--studio-accent-soft);
    border-radius: 10px;
    padding: 20px 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 14px;
}
.studio-upload-dropzone:hover {
    background: rgba(139, 92, 246, 0.18);
    border-color: #A78BFA;
}
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.uploaded-asset-thumb {
    aspect-ratio: 1;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.18s ease;
}
.uploaded-asset-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.uploaded-asset-thumb:hover {
    border-color: var(--studio-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.uploaded-asset-thumb .asset-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 6px;
}
.uploaded-asset-thumb:hover .asset-overlay {
    opacity: 1;
}
.asset-overlay-btn {
    width: 100%;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}
.asset-overlay-btn.primary {
    background: var(--studio-accent);
    color: #FFF;
}
.asset-overlay-btn.primary:hover {
    background: var(--studio-accent-hover);
}
.asset-overlay-btn.secondary {
    background: var(--studio-surface-alt);
    color: var(--studio-text);
    border: 1px solid var(--studio-line);
}
.asset-overlay-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Background Image Control Card */
.bg-control-card {
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}
.bg-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.bg-control-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--studio-text-muted);
}
.bg-control-val {
    font-size: 11px;
    font-family: monospace;
    color: var(--studio-text);
}

/* Range sliders in Studio */
.studio-range-input {
    width: 100%;
    accent-color: var(--studio-accent);
    height: 4px;
    background: var(--studio-line);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

/* Center Infinite Workspace & Canvas Viewport */
.studio-canvas-viewport {
    flex: 1;
    background: #0B0D14;
    background-image: 
        radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: auto;
    padding: 30px;
}

.studio-canvas-holder {
    position: relative;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    background: #FFFFFF;
    transition: transform 0.05s ease-out;
}

/* Prevent Fabric.js hidden textarea from causing page scroll jump on double click */
.canvas-container {
    position: relative !important;
    overflow: visible !important;
}
.canvas-container textarea,
.canvas-container .fabric-canvas-hidden-textarea,
textarea.fabric-canvas-hidden-textarea,
.fabric-canvas-hidden-textarea {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    border: none !important;
    outline: none !important;
    resize: none !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: -9999 !important;
}

/* Right Layers Panel */
.studio-right-panel {
    width: 260px;
    background: var(--studio-surface);
    border-left: 1px solid var(--studio-line);
    display: flex;
    flex-direction: column;
    z-index: 20;
    flex-shrink: 0;
    transition: width 0.2s ease;
}
.studio-right-panel.collapsed { width: 0; border-left: none; }

.layers-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    overflow-y: auto;
}
.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--studio-text);
    cursor: pointer;
    transition: all 0.12s ease;
}
.layer-item:hover, .layer-item.active {
    border-color: var(--studio-accent);
    background: var(--studio-accent-soft);
}
.layer-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}
.layer-btn {
    background: none;
    border: none;
    color: var(--studio-text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 2px;
}
.layer-btn:hover { color: #FFF; }

/* Responsive & Mobile Dock */
.studio-mobile-dock {
    display: none;
    height: 56px;
    background: var(--studio-surface);
    border-top: 1px solid var(--studio-line);
    align-items: center;
    justify-content: space-around;
    z-index: 50;
    flex-shrink: 0;
}

@media (max-width: 1024px) {
    .toolora-studio-wrapper { height: 82vh; }
    .studio-drawer {
        position: absolute;
        left: var(--studio-sidebar-w);
        top: calc(var(--studio-header-h) + var(--studio-topbar-h));
        bottom: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }
    .studio-right-panel {
        position: absolute;
        right: 0;
        top: calc(var(--studio-header-h) + var(--studio-topbar-h));
        bottom: 0;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    }
}

@media (max-width: 768px) {
    .toolora-studio-wrapper { height: 88vh; min-height: 540px; }
    .studio-left-nav { display: none; }
    .studio-mobile-dock { display: flex; z-index: 100; }
    .studio-drawer {
        position: absolute;
        left: 0;
        right: 0;
        width: 100%;
        top: auto;
        bottom: 56px;
        height: 72%;
        max-height: 75%;
        border-radius: 16px 16px 0 0;
        border-top: 2px solid var(--studio-accent);
        z-index: 150 !important;
        background: var(--studio-surface) !important;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.95);
        display: flex;
        flex-direction: column;
    }
    .studio-drawer.collapsed {
        display: none !important;
    }
    .drawer-tab-pane {
        background: var(--studio-surface) !important;
        height: 100%;
    }
    .drawer-content {
        background: var(--studio-surface) !important;
        padding: 10px 12px 24px !important;
    }
    .studio-pages-bar {
        bottom: 64px !important;
        z-index: 10 !important;
        transform: translateX(-50%) scale(0.88);
    }
    .studio-body:has(.studio-drawer:not(.collapsed)) .studio-pages-bar {
        display: none !important;
    }
    .studio-title-input { max-width: 120px; font-size: 12px; }
    .studio-preset-badge { display: none; }
}

/* Floating WhatsApp button adjustment when on Studio page */
body:has(.toolora-studio-wrapper) #whatsappWidgetBtn,
.tool-page:has(.toolora-studio-wrapper) ~ #whatsappWidgetBtn {
    bottom: 84px !important;
    right: 16px !important;
    transform: scale(0.82) !important;
    z-index: 80 !important;
}
@media (max-width: 768px) {
    body:has(.toolora-studio-wrapper) #whatsappWidgetBtn {
        bottom: 68px !important;
        right: 12px !important;
        transform: scale(0.72) !important;
        z-index: 80 !important;
    }
}

/* Modals (Export, Preview) */
.studio-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    place-items: center;
    z-index: 1000;
}
.studio-modal-backdrop.show { display: grid; }
.studio-modal-box {
    background: var(--studio-surface);
    border: 1px solid var(--studio-line);
    border-radius: 14px;
    width: 90%;
    max-width: 540px;
    padding: 24px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
    color: var(--studio-text);
}

/* Live Preview Simulation Placements */
.preview-sim-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--studio-line);
    white-space: nowrap;
    scrollbar-width: thin;
}
.preview-sim-tab-btn {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    color: var(--studio-text-muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.preview-sim-tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--studio-text);
}
.preview-sim-tab-btn.active {
    background: var(--studio-accent);
    color: #FFFFFF;
    border-color: var(--studio-accent);
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.4);
}

.sim-pane {
    display: none;
    width: 100%;
}
.sim-pane.active {
    display: block;
}

/* YouTube Desktop Feed Card */
.yt-feed-mockup {
    max-width: 480px;
    margin: 0 auto;
    background: #0F0F0F;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #272727;
    font-family: 'Roboto', 'Inter', sans-serif;
    color: #F1F1F1;
}
.yt-thumb-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}
.yt-thumb-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.yt-duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #FFF;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.yt-details-row {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
}
.yt-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF0000, #8B5CF6);
    display: grid;
    place-items: center;
    font-size: 16px;
    flex-shrink: 0;
}
.yt-meta {
    flex: 1;
    min-width: 0;
}
.yt-video-title {
    font-size: 14px;
    font-weight: 700;
    color: #F1F1F1;
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.yt-channel-name {
    font-size: 12px;
    color: #AAAAAA;
    display: flex;
    align-items: center;
    gap: 4px;
}
.yt-stats {
    font-size: 12px;
    color: #AAAAAA;
}

/* YouTube Search / Sidebar Up Next Mockup */
.yt-sidebar-mockup {
    max-width: 520px;
    margin: 0 auto;
    background: #0F0F0F;
    border-radius: 12px;
    padding: 12px;
    border: 1px solid #272727;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.yt-sidebar-thumb {
    width: 170px;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    background: #000;
}
.yt-sidebar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Instagram Post Mockup */
.ig-post-mockup {
    max-width: 390px;
    margin: 0 auto;
    background: #000000;
    border: 1px solid #262626;
    border-radius: 12px;
    overflow: hidden;
    color: #FFF;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.ig-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
}
.ig-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ig-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(45deg, #F58529, #DD2A7B, #8134AF);
    padding: 2px;
}
.ig-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #1A1A1A;
    display: grid;
    place-items: center;
    font-size: 13px;
}
.ig-username {
    font-size: 13px;
    font-weight: 700;
}
.ig-image-box {
    width: 100%;
    background: #0a0a0a;
    display: grid;
    place-items: center;
    overflow: hidden;
}
.ig-image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.ig-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 6px;
    font-size: 18px;
}
.ig-caption-box {
    padding: 0 14px 12px;
    font-size: 12px;
    line-height: 1.4;
    color: #E0E0E0;
}

/* Story / Reel Mockup (9:16 vertical phone) */
.story-mockup-frame {
    width: 280px;
    height: 480px;
    margin: 0 auto;
    background: #000;
    border-radius: 28px;
    border: 4px solid #333;
    overflow: hidden;
    position: relative;
    box-shadow: 0 16px 36px rgba(0,0,0,0.8);
}
.story-image-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.story-top-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
    z-index: 5;
}
.story-progress-bar {
    height: 2px;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
    margin-bottom: 8px;
    overflow: hidden;
}
.story-progress-fill {
    width: 60%;
    height: 100%;
    background: #FFF;
}
.story-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #FFF;
    font-size: 12px;
    font-weight: 700;
}
.story-bottom-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 5;
}
.story-reply-pill {
    flex: 1;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 11px;
    color: rgba(255,255,255,0.8);
}

/* Facebook / LinkedIn Post Mockup */
.fb-post-mockup {
    max-width: 460px;
    margin: 0 auto;
    background: #242526;
    border: 1px solid #3A3B3C;
    border-radius: 10px;
    overflow: hidden;
    color: #E4E6EB;
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}
.fb-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 8px;
}
.fb-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1877F2;
    display: grid;
    place-items: center;
    font-size: 18px;
}
.fb-author-title {
    font-size: 13px;
    font-weight: 700;
    color: #E4E6EB;
}
.fb-author-sub {
    font-size: 11px;
    color: #B0B3B8;
}
.fb-text-content {
    padding: 0 14px 10px;
    font-size: 13px;
    line-height: 1.4;
}
.fb-image-holder {
    width: 100%;
    background: #000;
    overflow: hidden;
}
.fb-image-holder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.fb-footer-actions {
    display: flex;
    justify-content: space-around;
    padding: 8px 10px;
    border-top: 1px solid #3A3B3C;
    font-size: 12px;
    font-weight: 600;
    color: #B0B3B8;
}

/* ==========================================
   Multi-Page Bottom Bar
   ========================================== */
.studio-pages-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--studio-line);
    border-radius: 30px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 25;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}
.pages-tabs-list {
    display: flex;
    align-items: center;
    gap: 6px;
}
.page-chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.06);
    color: var(--studio-text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.page-chip-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--studio-text);
}
.page-chip-btn.active {
    background: var(--studio-accent);
    color: #FFFFFF;
    border-color: var(--studio-accent);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}
.page-delete-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    color: #FFF;
    font-size: 9px;
    margin-left: 2px;
}
.page-delete-x:hover {
    background: #EF4444;
}
.page-add-chip-btn {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px dashed var(--studio-line);
    background: transparent;
    color: var(--studio-text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.page-add-chip-btn:hover {
    border-color: var(--studio-accent);
    color: var(--studio-accent);
    background: var(--studio-accent-soft);
}

/* ==========================================
   Quick Create Modal & Forms
   ========================================== */
.qc-modal-box {
    max-width: 620px !important;
}
.qc-event-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.qc-event-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 8px;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    color: var(--studio-text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.qc-event-btn:hover {
    border-color: var(--studio-accent);
    background: var(--studio-accent-soft);
}
.qc-event-btn.active {
    border-color: var(--studio-accent);
    background: var(--studio-accent);
    color: #FFFFFF;
}
.qc-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.qc-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.qc-field-group.full-width {
    grid-column: span 2;
}
.qc-field-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--studio-text-muted);
}
.qc-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--studio-bg);
    border: 1px solid var(--studio-line);
    border-radius: 6px;
    color: var(--studio-text);
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}
.qc-input:focus {
    border-color: var(--studio-accent);
    box-shadow: 0 0 0 2px var(--studio-accent-soft);
}
