/* 
 * Paperwork Factory Specialized Styles
 * Focuses on the split-view layout and the high-fidelity document preview.
 */

.paperwork-viewport {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Split View Layout */
.paperwork-split-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
    background: hsl(var(--background));
}

/* Left Sidebar - Editor */
.paperwork-editor-sidebar {
    width: 420px;
    background: hsla(var(--h), 25%, 8%, 0.8);
    backdrop-filter: blur(20px);
    border-right: 1px solid hsl(var(--border-light));
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 20px 0 50px rgba(0,0,0,0.3);
    animation: sidebarSlideLeft 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sidebarSlideLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes sidebarSlideRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.editor-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.editor-scrollbox {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.editor-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    background: rgba(0,0,0,0.2);
    display: flex;
    gap: 1rem;
}

/* Right Content - Preview */
.paperwork-preview-area {
    flex: 1;
    background: #05070a;
    background-image: 
        radial-gradient(circle at 50% 50%, hsla(var(--h), var(--s), 60%, 0.03) 0%, transparent 70%),
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 100% 100%, 40px 40px, 40px 40px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 2rem;
    overflow-y: auto;
    position: relative;
}

/* Virtual Paper Sheet */
.paper-sheet {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.1);
    padding: 2.5rem;
    color: #1a1a1a;
    position: relative;
    transform-origin: top center;
    animation: paperSlideIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes paperSlideIn {
    from { opacity: 0; transform: translateY(40px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.paper-sheet::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(0,0,0,0.02) 0%, transparent 50%);
    pointer-events: none;
}

/* Sheet Internal Content Styles */
.paper-sheet-content {
    font-family: 'Helvetica', Arial, sans-serif;
    line-height: 1.5;
    font-size: 11pt;
}

.paper-sheet-content h1, 
.paper-sheet-content h2, 
.paper-sheet-content h3 {
    color: #000;
    margin-bottom: 0.5rem;
}

/* Form Decorations */
.doc-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.hud-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hud-form-sub-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-top: 0.5rem;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}

/* Formatting Help Panel */
.editor-help-panel {
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    animation: slideDown 0.3s ease-out;
    max-height: 400px;
    overflow-y: auto;
}

.sub-help-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.help-section:first-child .sub-help-title {
    margin-top: 0;
}

.tool-btn.color-warning:hover { background: #f59e0b; }
.tool-btn.color-note:hover { background: #64748b; }
.tool-btn.color-info:hover { background: #3b82f6; }
.tool-btn.color-important:hover { background: #ef4444; }
.tool-btn.color-legal:hover { background: #8b5cf6; }

@keyframes slideDown {
    from { max-height: 0; opacity: 0; }
    to { max-height: 400px; opacity: 1; }
}

.help-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.formatting-toolbar {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tool-btn {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: white;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: hsl(var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.help-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.help-grid div {
    display: flex;
    justify-content: space-between;
    background: rgba(0,0,0,0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.help-grid code {
    color: hsl(var(--primary));
}

.form-section-divider {
    height: 1px;
    background: linear-gradient(90deg, hsl(var(--primary)) 0%, transparent 100%);
    margin: 2rem 0 1rem 0;
    opacity: 0.3;
}

.form-section-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: hsl(var(--primary));
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1rem;
}

/* Template Browser Grid Overlay */
.template-browser-overlay {
    position: absolute;
    inset: 0;
    background: hsl(var(--background));
    z-index: 20;
    padding: 3rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.browser-header {
    margin-bottom: 3rem;
    max-width: 1200px;
    width: 100%;
    margin-inline: auto;
}

.browser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    width: 100%;
    margin-inline: auto;
}

/* Loader in Preview */
.preview-loader-overlay {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    padding: 0.75rem;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    display: none;
}

/* Right Sidebar Animation */
.paperwork-right-sidebar {
    animation: sidebarSlideRight 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Global Transition Utility */
.transition-premium {
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Hover Effects for items */
.hud-input-ctrl {
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hud-input-ctrl:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background: rgba(59, 130, 246, 0.02);
}

/* Button Micro-interactions */
button {
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

button:active {
    transform: scale(0.96);
}

/* Form Group staggered entrance */
.form-group-animate {
    animation: fadeInUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes fadeInUp {
    from { transform: translateY(15px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.preview-loader-overlay.active {
    display: block;
}

/* Template Card Animations */
.template-card-animate {
    animation: cardEntrance 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes cardEntrance {
    from { 
        opacity: 0; 
        transform: translateY(30px) scale(0.95);
        filter: blur(10px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.template-card-animate:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
}

.template-card-animate:hover .fa-plus {
    transform: rotate(90deg);
}

.fa-plus {
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Custom Scrollbar Utility */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.3s;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Dropdown Animation and Refinement */
@keyframes dropdownSlide {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-menu-active {
    animation: dropdownSlide 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 99999 !important;
}

.dropdown-wrapper .hud-input-ctrl:hover {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(255, 255, 255, 0.03);
}

/* Premium Animations */
.animate-fadeIn {
    animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Fluid entry animation for template selector cards and rows */
.template-card-animate {
    animation: templateCardEntry 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes templateCardEntry {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Premium Glassmorphic Cards following Caselaws */
.paperwork-card {
    background: rgba(30, 41, 59, 0.2) !important;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(59, 130, 246, 0.12) !important;
    border-radius: 24px !important;
    transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
    position: relative;
    overflow: hidden;
}

.paperwork-card:hover {
    transform: scale(1.015) translateY(-5px) !important;
    background: rgba(30, 41, 59, 0.4) !important;
    border-color: rgba(59, 130, 246, 0.35) !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.45), 0 0 25px rgba(59, 130, 246, 0.12) !important;
}

.paperwork-card::before {
    content: '';
    position: absolute;
    top: 2rem;
    left: 0;
    width: 4px;
    height: calc(100% - 4rem);
    background: #3b82f6;
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    transition: all 0.3s;
    opacity: 0.8;
}

.paperwork-card.is-favorite::before {
    background: #eab308;
    box-shadow: 0 0 20px rgba(234, 179, 8, 0.6);
}

.paperwork-card:hover::before {
    height: calc(100% - 2.5rem);
    top: 1.25rem;
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   ══ RP SCREENSHOT EDITOR - FIGMA MASTER THEME ══
   ═══════════════════════════════════════════════════════════════════ */

.rpse-editor-window {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 25px 60px rgba(0, 0, 0, 0.5);
    background-color: #080b12;
}

/* 1. Toolbar */
.rpse-toolbar {
    background-color: #0b0f19;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    height: 52px;
}

/* Floating tooltips (poza overflow edytora) */
#view-screenshot-editor [data-tooltip]::before,
#view-screenshot-editor [data-tooltip]::after {
    display: none !important;
    content: none !important;
}

.rpse-floating-tooltip {
    position: fixed;
    z-index: 100050;
    max-width: min(320px, calc(100vw - 16px));
    padding: 8px 14px;
    border-radius: 8px;
    background: #1c2533;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: normal;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

.rpse-floating-tooltip.hidden {
    display: none;
}

.rpse-tool-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.rpse-tool-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.rpse-tool-btn.active {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.rpse-mini-icon-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 9px;
    transition: all 0.2s;
}

.rpse-mini-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.15);
}

.rpse-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 14px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
}

.rpse-action-btn.primary {
    background: #2563eb;
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.rpse-action-btn.primary:hover {
    background: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.rpse-action-btn.primary:active {
    transform: translateY(0);
}

.rpse-action-btn.secondary {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
}

.rpse-action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.15);
}

/* Button aliases used in markup */
.rpse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    white-space: nowrap;
}

.rpse-btn-primary {
    background: #2563eb;
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.rpse-btn-primary:hover {
    background: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.rpse-btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
}

.rpse-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.15);
}

.rpse-btn-secondary.active {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
}

/* Icon-only button for properties panel (32×32, Figma-style) */
.rpse-icon-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.07);
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}
.rpse-icon-btn:hover {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.rpse-icon-btn:active,
.rpse-icon-btn.active {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
}

.rpse-context-menu {
    position: fixed;
    z-index: 99999;
    min-width: 220px;
    padding: 6px;
    border-radius: 10px;
    background: #121722;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
}

.rpse-context-menu kbd,
.rpse-context-menu .rpse-ctx-shortcut {
    margin-left: auto;
    font-size: 9px;
    font-family: ui-monospace, monospace;
    color: #6b7280;
    font-weight: 600;
}

.rpse-context-menu button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #d1d5db;
    font-size: 11px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.rpse-context-menu button:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.12);
    color: #fff;
}

.rpse-context-menu button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.rpse-context-menu hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin: 4px 0;
}

.rpse-range-bidirectional {
    accent-color: #3b82f6;
}

.rpse-field label[data-rpse-scrub] {
    cursor: ew-resize;
    user-select: none;
}

.rpse-field label[data-rpse-scrub]:hover {
    color: #93c5fd;
}

.rpse-mini-icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* 2. Workspace & Drop Zone */
#rpse-drop-zone {
    background: #111520;
    transition: background-color 0.2s, box-shadow 0.2s;
    background-image: 
        radial-gradient(rgba(255,255,255,0.015) 1px, transparent 0),
        radial-gradient(rgba(255,255,255,0.015) 1px, transparent 0);
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
}

#rpse-drop-zone.is-dragging,
#view-screenshot-editor.is-file-drag #rpse-drop-zone {
    background-color: rgba(59, 130, 246, 0.1);
    box-shadow: inset 0 0 0 3px rgba(59, 130, 246, 0.55);
}

#rpse-drop-zone.is-dragging .rpse-canvas-frame,
#view-screenshot-editor.is-file-drag .rpse-canvas-frame {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.85), 0 30px 80px rgba(59, 130, 246, 0.2);
}

.rpse-file-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 10, 18, 0.72);
    backdrop-filter: blur(4px);
    pointer-events: none;
    border-radius: inherit;
}

.rpse-file-drop-overlay.hidden {
    display: none;
}

.rpse-file-drop-overlay-inner {
    text-align: center;
    padding: 2rem 2.5rem;
    border-radius: 1rem;
    border: 2px dashed rgba(59, 130, 246, 0.65);
    background: rgba(15, 23, 42, 0.85);
    box-shadow: 0 0 40px rgba(59, 130, 246, 0.15);
}

.rpse-canvas-frame {
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    background-color: #000;
}

#rpse-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: auto;
}

/* 3. Left Sidebar Layers */
.rpse-layer-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #9ca3af;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.rpse-layer-row.rpse-child-layer {
    cursor: grab;
}

.rpse-layer-row.rpse-frame-header {
    cursor: pointer;
    border-left: 2px solid transparent;
}

.rpse-layer-row.rpse-frame-header.active {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    color: #60a5fa;
}

.rpse-layer-row.rpse-frame-header:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #e5e7eb;
}

.rpse-layer-row:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #e5e7eb;
}

.rpse-layer-row.active {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.2);
}

.rpse-layer-row.dragging {
    opacity: 0.4;
    transform: scale(0.98);
}

.rpse-layer-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    opacity: 1;
}

.rpse-layer-action.locked {
    color: #3b82f6;
}

.rpse-layer-action {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #6b7280;
    transition: all 0.15s;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 9px;
}

.rpse-layer-action:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.rpse-layer-action.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* 4. Right Sidebar Properties — Figma-style */

/* ── Section container ── */
.rpse-prop-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}

.rpse-prop-section:last-child {
    border-bottom: none;
}

/* ── Section header (clickable title row) ── */
.rpse-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    cursor: default;
    user-select: none;
    position: relative;
}

.rpse-section-header-left {
    display: flex;
    align-items: center;
    gap: 7px;
}

.rpse-section-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    font-size: 9px;
    flex-shrink: 0;
}

.rpse-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9ca3af;
}

.rpse-section-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Section body ── */
.rpse-section-body {
    padding: 4px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Inline number input row (label + input in same line, Figma-style) ── */
.rpse-num-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.rpse-num-row.cols-1 {
    grid-template-columns: 1fr;
}

.rpse-num-row.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.rpse-num-row.cols-4 {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.rpse-num-input-wrap {
    display: flex;
    align-items: center;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.3);
    transition: border-color 0.15s, background 0.15s;
    overflow: hidden;
}

.rpse-num-input-wrap:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.4);
}

.rpse-num-input-wrap:focus-within {
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.04);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.rpse-num-label {
    font-size: 9px;
    font-weight: 700;
    color: #4b5563;
    padding: 0 5px 0 7px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1;
}

.rpse-num-input-wrap input[type="number"],
.rpse-field input[type="number"],
.rpse-preset-card input[type="number"] {
    -moz-appearance: textfield;
}
.rpse-num-input-wrap input[type="number"]::-webkit-outer-spin-button,
.rpse-num-input-wrap input[type="number"]::-webkit-inner-spin-button,
.rpse-field input[type="number"]::-webkit-outer-spin-button,
.rpse-field input[type="number"]::-webkit-inner-spin-button,
.rpse-preset-card input[type="number"]::-webkit-outer-spin-button,
.rpse-preset-card input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.rpse-num-input-wrap input[type="number"] {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    text-align: right;
    padding: 0 6px 0 2px;
    font-family: 'SF Mono', 'Roboto Mono', ui-monospace, monospace;
    min-width: 0;
}

.rpse-num-unit {
    font-size: 9px;
    color: #374151;
    padding-right: 6px;
    flex-shrink: 0;
    font-weight: 600;
}

/* ── Alignment grid ── */
.rpse-align-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
}

.rpse-align-grid .rpse-icon-btn {
    width: 100%;
    height: 26px;
    border-radius: 5px;
    font-size: 10px;
}

/* ── Color swatch field ── */
.rpse-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.3);
    padding: 0 8px;
    transition: border-color 0.15s;
}

.rpse-color-row:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.rpse-color-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    flex-shrink: 0;
    overflow: hidden;
}

.rpse-color-swatch input[type="color"] {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    opacity: 0;
    position: absolute;
    transform: translateX(-4px) translateY(-4px);
}

.rpse-color-label {
    font-size: 10px;
    color: #9ca3af;
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Field (legacy, used for dropdowns/color inputs in sub-blocks) ── */
.rpse-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.rpse-field label {
    color: #4b5563;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rpse-field input[type="text"],
.rpse-field input[type="number"] {
    width: 100%;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.3);
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 9px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.rpse-field input[type="text"]:focus,
.rpse-field input[type="number"]:focus {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.rpse-field input[type="color"] {
    width: 100%;
    height: 28px;
    padding: 2px 3px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: border-color 0.15s;
}

.rpse-field input[type="color"]:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

/* ── Sub-section header (small uppercase label with line) ── */
.rpse-subsection-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 2px;
}

.rpse-subsection-label span {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #374151;
    white-space: nowrap;
}

.rpse-subsection-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.04);
}

/* ── Property panel header ── */
.rpse-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055);
    background: rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.rpse-panel-header-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    font-size: 9px;
    flex-shrink: 0;
}

.rpse-panel-header-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7280;
}

/* ── Blend mode row (compact inside section) ── */
.rpse-blend-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rpse-blend-row .rpse-dropdown {
    flex: 1;
}

/* ── Toggle row (visibility, lock etc.) ── */
.rpse-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.rpse-toggle-label {
    font-size: 10px;
    color: #6b7280;
    font-weight: 500;
}

/* ── Checkbox row ── */
.rpse-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
}

.rpse-checkbox-row input[type="checkbox"] {
    position: relative;
    width: 13px;
    height: 13px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.4);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, background-color 0.15s;
}

.rpse-checkbox-row input[type="checkbox"]:checked {
    border-color: #3b82f6;
    background: #3b82f6;
}

.rpse-checkbox-row input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.rpse-checkbox-row input[type="checkbox"]:hover {
    border-color: #3b82f6;
}

.rpse-checkbox-row input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.rpse-checkbox-row span {
    font-size: 10px;
    color: #9ca3af;
    font-weight: 500;
    line-height: 1.3;
}

/* Custom Dropdowns */
.rpse-dropdown {
    position: relative;
    width: 100%;
}

.rpse-dropdown-trigger {
    width: 100%;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.25);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    padding: 0 9px;
    cursor: pointer;
    transition: all 0.2s;
}

.rpse-dropdown-trigger:hover,
.rpse-dropdown.open .rpse-dropdown-trigger {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(0, 0, 0, 0.4);
}

.rpse-dropdown-trigger i {
    color: #6b7280;
    font-size: 8px;
    transition: transform 0.2s;
}

.rpse-dropdown.open .rpse-dropdown-trigger i {
    transform: rotate(180deg);
}

.rpse-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    display: grid;
    gap: 2px;
    max-height: 160px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #0f131c;
    padding: 4px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
    pointer-events: none;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

.rpse-dropdown.open .rpse-dropdown-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.rpse-dropdown-menu button {
    width: 100%;
    border-radius: 4px;
    color: #9ca3af;
    font-size: 11px;
    font-weight: 650;
    padding: 6px 8px;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.rpse-dropdown-menu button:hover,
.rpse-dropdown-menu button.active {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

/* Premium Range Sliders */
.rpse-range-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rpse-range-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #1c212e;
    border-radius: 4px;
    outline: none;
    transition: background 0.15s;
}

.rpse-range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
    transition: all 0.15s ease;
}

.rpse-range-row input[type="range"]::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

.rpse-range-row input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
    transition: all 0.15s ease;
}

.rpse-range-row input[type="range"]::-moz-range-thumb:hover {
    background: #2563eb;
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

/* 5. RP Chat Lines List */
.rpse-chat-line {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
    padding: 4px 6px;
}

.rpse-chat-line input[type="color"] {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.rpse-chat-line span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #9ca3af;
    font-size: 10px;
    font-weight: 600;
}

.rpse-chat-line button {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    color: #6b7280;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.rpse-chat-line button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.rpse-line-context-menu,
#rpse-line-context-menu {
    position: fixed;
    z-index: 500;
    width: min(260px, calc(100vw - 24px));
    max-height: min(65vh, calc(100vh - 24px));
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.65);
    background-color: #0f131c;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px;
}

.rpse-line-menu-title {
    margin-bottom: 8px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #9ca3af;
}

.rpse-line-menu-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rpse-line-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #d1d5db;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}

.rpse-line-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.rpse-line-menu-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

/* RP Screenshot Editor — admin presets dock (below editor) */
.rpse-admin-dock {
    margin-top: 4px;
    padding: 24px 28px 28px;
    border-radius: 16px;
    border: 1px solid rgba(245, 158, 11, 0.22);
    background: linear-gradient(180deg, rgba(20, 16, 8, 0.95) 0%, rgba(10, 12, 18, 0.98) 100%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.rpse-admin-dock-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rpse-admin-dock-title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rpse-admin-dock-desc {
    margin-top: 6px;
    font-size: 12px;
    color: #9ca3af;
    max-width: 52rem;
    line-height: 1.5;
}

.rpse-admin-dock-help {
    display: grid;
    gap: 6px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 11px;
    color: #9ca3af;
    line-height: 1.55;
}

.rpse-admin-dock-help code {
    font-size: 10px;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.12);
    padding: 1px 5px;
    border-radius: 4px;
}

.rpse-presets-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}

.rpse-preset-card {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rpse-preset-card-head {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.rpse-preset-color-wrap input[type="color"] {
    width: 44px;
    height: 44px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
}

.rpse-preset-field-grow {
    flex: 1;
    min-width: 0;
}

.rpse-preset-card .rpse-field label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 4px;
    display: block;
}

.rpse-preset-card .rpse-field input[type="text"],
.rpse-preset-card .rpse-field input[type="number"],
.rpse-preset-card .rpse-field select {
    width: 100%;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.45);
    color: #e5e7eb;
}

.rpse-preset-card-meta {
    display: grid;
    grid-template-columns: 1fr 88px 1fr;
    gap: 10px;
    align-items: end;
}

.rpse-preset-enabled {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    padding-bottom: 8px;
    cursor: pointer;
    user-select: none;
}

.rpse-preset-delete {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.rpse-preset-delete:hover {
    background: rgba(239, 68, 68, 0.22);
}

.rpse-admin-dock-footer {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.rpse-admin-dock-footer .rpse-btn-primary {
    min-width: 220px;
}

.rpse-admin-save-status {
    font-size: 11px;
    color: #6b7280;
}

.rpse-admin-save-status.text-green-400 {
    color: #4ade80;
}

.rpse-admin-save-status.text-red-400 {
    color: #f87171;
}

@media (max-width: 720px) {
    .rpse-preset-card-meta {
        grid-template-columns: 1fr 1fr;
    }
    .rpse-preset-enabled {
        grid-column: 1 / -1;
    }
}

/* Onboarding / poradnik */
.rpse-onboarding {
    position: fixed;
    inset: 0;
    z-index: 100000;
    pointer-events: auto;
}

.rpse-onboarding.hidden {
    display: none;
}

.rpse-onboarding-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.rpse-onboarding-highlight {
    position: fixed;
    border: 2px solid rgba(59, 130, 246, 0.9);
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55), 0 0 24px rgba(59, 130, 246, 0.35);
    pointer-events: none;
    z-index: 100001;
    transition: all 0.2s ease;
}

.rpse-onboarding-highlight.hidden {
    display: none;
}

.rpse-onboarding-card {
    position: fixed;
    z-index: 100002;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    width: min(440px, calc(100vw - 32px));
    padding: 1.25rem 1.35rem;
    border-radius: 14px;
    background: #121722;
    border: 1px solid rgba(59, 130, 246, 0.35);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}

.rpse-onboarding-progress {
    font-size: 10px;
    font-weight: 700;
    color: #3b82f6;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.rpse-chat-line input[type="color"] {
    cursor: pointer;
}

.rpse-field input[type="color"]:focus,
.rpse-chat-line input[type="color"]:focus {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* 6. Animations */
@keyframes rpseFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
    animation: rpseFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@media (max-width: 1024px) {
    .rpse-editor-window {
        height: auto;
    }
    .rpse-editor-window > div {
        flex-direction: column;
    }
    .rpse-editor-window aside {
        width: 100% !important;
        height: auto !important;
    }
}

/* Prevent scroll chaining from the editor panels to the main page */
.rpse-editor-window aside,
.rpse-editor-window #rpse-layer-list,
.rpse-editor-window #rpse-chat-lines,
.rpse-editor-window #rpse-drop-zone {
    overscroll-behavior: contain;
}

