@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#game {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #832EC5 0%, #B900FF 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: #fff;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #FFC700;
    border-right-color: #FFC700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #FFC700;
}

.loading-progress {
    width: 300px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 10px;
}

.loading-progress-bar {
    width: 0%;
    height: 100%;
    background: #FFC700;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.loading-percent {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

/* Template Loading Popup */
.template-loading-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #FFFFFF;
    border-radius: 20px;
    padding: 32px 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s ease;
    min-width: 240px;
}

.template-loading-popup.visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.template-loading-popup .popup-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #F0F0F0;
    border-top-color: #832EC5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.template-loading-popup .popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.template-loading-popup .popup-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    letter-spacing: -0.2px;
}

.template-loading-popup .popup-progress {
    font-size: 13px;
    color: #888;
    font-weight: 500;
}

.template-loading-popup .popup-bar-container {
    width: 100%;
    height: 6px;
    background: #F0F0F0;
    border-radius: 3px;
    overflow: hidden;
}

.template-loading-popup .popup-bar {
    height: 100%;
    background: linear-gradient(90deg, #832EC5, #B900FF);
    border-radius: 3px;
    transition: width 0.15s ease;
    width: 0%;
}

/* Sidebar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: #FFFFFF;
    border-right: 1px solid #E0E0E0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    transition: width 0.3s ease, padding 0.3s ease;
}

/* ================================
   TOOLS GRID STYLES (now uses shared component)
   ================================ */
/* We still need this for the container that the JS injects into */
.tools-grid {
    width: 100%;
}


.sidebar-toggle-btn {
    position: fixed;
    top: 16px;
    left: 280px;
    width: 20px;
    height: 56px;
    border-radius: 0 10px 10px 0;
    border: none;
    background: linear-gradient(135deg, #832EC5 0%, #a855f7 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 8px rgba(131, 46, 197, 0.25);
    transition: all 0.25s ease, left 0.3s ease;
    z-index: 101;
    opacity: 0.7;
}

.sidebar-toggle-btn:hover {
    opacity: 1;
    width: 24px;
    box-shadow: 3px 3px 12px rgba(131, 46, 197, 0.35);
}

.sidebar-toggle-btn .toggle-icon {
    transition: transform 0.3s ease;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.sidebar-toggle-btn.collapsed .toggle-icon {
    transform: rotate(180deg);
}

#sidebar.collapsed {
    width: 0px;
    padding: 0;
    border-right: 0;
    box-shadow: none;
    overflow: visible;
    min-width: 0;
}

#sidebar.collapsed > *:not(.sidebar-toggle-btn) {
    display: none;
}

/* ==================== AI PROMPT DOCK ==================== */
.ai-prompt-dock {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #E0E0E0;
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 120;
    min-width: 320px;
    max-width: 720px;
    width: min(80vw, 720px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-prompt-dock.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(10px);
}

.ai-prompt-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-prompt-input {
    flex: 5 1 0;
    padding: 10px 12px;
    border: 2px solid #E0E0E0;
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    color: #333;
    background: #FAFAFA;
    transition: all 0.2s ease;
}

.ai-prompt-input:focus {
    outline: none;
    border-color: #832EC5;
    background: #FFF;
    box-shadow: 0 0 0 3px rgba(131, 46, 197, 0.1);
}

.ai-generate-btn {
    flex: 1 1 0;
    padding: 10px 12px;
    background: linear-gradient(135deg, #B900FF 0%, #832EC5 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(131, 46, 197, 0.25);
}

.ai-generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(131, 46, 197, 0.35);
    filter: brightness(1.05);
}

.ai-generate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

.ai-generate-btn.loading .btn-text {
    display: none;
}

.ai-generate-btn.loading .spinner {
    display: block;
}

.ai-error-msg {
    color: #EF4444;
    font-size: 0.75rem;
    font-weight: 500;
}

.ai-hint {
    font-size: 0.7rem;
    color: #999999;
}

.ai-prompt-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    min-height: 0;
}

.ai-error-msg:empty {
    display: none;
}

.ai-toggle-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #B900FF 0%, #832EC5 100%);
    color: #fff;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(131, 46, 197, 0.35);
    transition: all 0.2s ease;
    z-index: 130;
}

.ai-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 26px rgba(131, 46, 197, 0.4);
}

.ai-toggle-btn.active {
    background: #E8E8E8;
    color: #333333;
    border: 1px solid #E0E0E0;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

#sidebar-world {
    display: none;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

#sidebar-world.active {
    display: flex;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-header {
    font-size: 0.66rem;
    font-weight: 600;
    color: #666666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tools Grid - Now using shared/tools-card.css */


/* Color Picker */
#world-color-selector {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.hue-ring-container {
    position: relative;
    width: 110px;
    height: 110px;
}

.hue-ring {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.hue-ring-inner {
    position: absolute;
    top: 18px;
    left: 18px;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.1);
}

.hue-marker {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.shade-square {
    width: 110px;
    height: 110px;
    position: relative;
    border-radius: 8px;
    cursor: crosshair;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.shade-marker {
    position: absolute;
    width: 14px;
    height: 14px;
    background: transparent;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #333, 0 1px 4px rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Style Selector */
.style-dropdown {
    position: relative;
}

.style-trigger {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #E0E0E0;
    border-radius: 12px;
    background: #FFFFFF;
    color: #333333;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.style-trigger-content {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.style-trigger-arrow {
    width: 10px;
    height: 10px;
    border-right: 2px solid #832EC5;
    border-bottom: 2px solid #832EC5;
    transform: rotate(45deg);
    margin-top: -2px;
    transition: transform 0.15s ease;
}

.style-dropdown.is-open .style-trigger-arrow {
    transform: rotate(-135deg);
    margin-top: 2px;
}

.style-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.style-trigger:focus-visible {
    outline: none;
    border-color: #832EC5;
    box-shadow: 0 0 0 3px rgba(131, 46, 197, 0.2);
}

.style-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #FFFFFF;
    border: 2px solid #E0E0E0;
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 60;
}

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

.style-option {
    border: 1px solid transparent;
    border-radius: 10px;
    background: #FFFFFF;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.style-option:hover {
    background: #F5F5F5;
    transform: translateY(-1px);
}

.style-option.is-selected {
    border-color: #832EC5;
    box-shadow: 0 0 0 2px rgba(131, 46, 197, 0.18);
}

.style-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #D5D5D5;
    overflow: hidden;
    position: relative;
    background-size: 16px 16px;
    image-rendering: pixelated;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.style-swatch-standard {
    background: linear-gradient(135deg, #f5f5f5, #dcdcdc);
}

.material-brick {
    background-image:
        linear-gradient(90deg, #d3d3d3 0 2px, transparent 2px 16px),
        linear-gradient(#d3d3d3 0 2px, transparent 2px 16px),
        linear-gradient(90deg, transparent 0 8px, #d3d3d3 8px 10px, transparent 10px 16px),
        linear-gradient(#963428, #812b21);
    background-size: 16px 12px, 16px 12px, 16px 12px, 16px 16px;
    background-position: 0 0, 0 6px, 8px 3px, 0 0;
}

.material-grass {
    background-color: #2d4a1c;
    background-image:
        /* Light green patches */
        radial-gradient(ellipse 5px 4px at 2px 2px, #c8e6b0 0%, transparent 80%),
        radial-gradient(ellipse 4px 5px at 12px 4px, #b5d99a 0%, transparent 80%),
        radial-gradient(ellipse 6px 4px at 7px 10px, #e0f0d0 0%, transparent 80%),
        radial-gradient(ellipse 4px 4px at 14px 12px, #a3cc85 0%, transparent 80%),
        radial-gradient(ellipse 3px 4px at 4px 14px, #c8e6b0 0%, transparent 80%),
        radial-gradient(ellipse 5px 3px at 10px 1px, #b5d99a 0%, transparent 80%),
        radial-gradient(ellipse 4px 5px at 1px 8px, #e0f0d0 0%, transparent 80%);
    background-size: 16px 16px;
    border-color: rgba(90, 138, 53, 0.8);
}

.material-stone {
    background-image:
        radial-gradient(circle at 3px 4px, rgba(255, 255, 255, 0.35) 0 1px, transparent 1px),
        radial-gradient(circle at 11px 5px, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px),
        radial-gradient(circle at 8px 12px, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px),
        radial-gradient(circle at 2px 13px, rgba(255, 255, 255, 0.3) 0 1px, transparent 1px),
        radial-gradient(circle at 13px 13px, rgba(255, 255, 255, 0.2) 0 1px, transparent 1px),
        linear-gradient(#8a8a8a, #737373);
    background-size: 16px 16px;
}

.material-water {
    background-image:
        repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.4) 0 2px, transparent 2px 6px),
        repeating-linear-gradient(60deg, rgba(20, 70, 160, 0.45) 0 3px, transparent 3px 7px),
        linear-gradient(180deg, rgba(63, 118, 228, 0.55), rgba(31, 85, 182, 0.55));
    background-size: 16px 16px, 16px 16px, 100% 100%;
}

.material-glass {
    background-color: rgba(255, 255, 255, 0.2);
    background-image:
        linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0 2px, transparent 2px 10px, rgba(255, 255, 255, 0.7) 10px 12px, transparent 12px 16px),
        linear-gradient(45deg, transparent 0 8px, rgba(255, 255, 255, 0.8) 8px 10px, transparent 10px 16px),
        linear-gradient(160deg, transparent 0 12px, rgba(255, 255, 255, 0.6) 12px 14px, transparent 14px 16px);
    background-size: 16px 16px;
    border-color: rgba(160, 190, 220, 0.8);
}

.material-lava {
    background-image:
        radial-gradient(circle at 4px 4px, rgba(255, 255, 255, 0.55) 0 2px, transparent 2px),
        radial-gradient(circle at 12px 10px, rgba(255, 120, 0, 0.75) 0 3px, transparent 3px),
        radial-gradient(circle at 8px 14px, rgba(255, 210, 80, 0.85) 0 3px, transparent 3px),
        radial-gradient(circle at 2px 12px, rgba(255, 120, 0, 0.7) 0 2px, transparent 2px),
        linear-gradient(135deg, #ffd700, #ff8a00 55%, #ff4500);
    background-size: 16px 16px, 16px 16px, 16px 16px, 16px 16px, 100% 100%;
}

.style-option-label,
.style-trigger-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333333;
}

/* Zoom Control */
.zoom-control {
    position: fixed;
    bottom: 5px;
    right: 10px;
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #E0E0E0;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    height: 32px;
    width: 180px;
    overflow: hidden;
}

.zoom-control-inner {
    display: flex;
    align-items: center;
    background: #FAFAFA;
    height: 100%;
    width: 100%;
    border-radius: 6px;
}

.zoom-control-section {
    display: flex;
    align-items: center;
    height: 100%;
}

.zoom-info-section {
    padding: 0 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.zoom-control .zoom-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    color: #000;
}

.zoom-control .zoom-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.zoom-percentage {
    font-size: 12px;
    font-weight: 500;
    color: #000;
    min-width: 34px;
    text-align: left;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.zoom-divider {
    width: 2px;
    height: 100%;
    background: #E0E0E0;
}

.zoom-button-wrapper {
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.zoom-button-wrapper:hover:not(.disabled) {
    background: rgba(0, 0, 0, 0.05);
}

.zoom-button-wrapper.disabled {
    cursor: default;
}

.zoom-control button {
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    color: #3379FF;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
    pointer-events: none;
}

.zoom-button-wrapper.disabled button {
    color: #E0E0E0;
}

.zoom-slider-container {
    position: relative;
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0 8px;
}

.zoom-slider-track {
    position: absolute;
    left: 8px;
    right: 8px;
    height: 1px;
    background: #E0E0E0;
    border-radius: 0.5px;
}

.zoom-slider-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #000;
    border-radius: 50%;
    z-index: 1;
    transition: all 0.1s ease;
    left: 50%;
    transform: translateX(-50%);
    cursor: grab;
}

.zoom-slider-dot:active {
    cursor: grabbing;
    transform: translateX(-50%) scale(1.1);
}

/* Cursor styles for tools */
.cursor-add { cursor: crosshair; }
.cursor-hammer { cursor: pointer; }

.cursor-dropper { cursor: copy; }
.cursor-rotate { cursor: grab; }
.cursor-rotate:active { cursor: grabbing; }

/* Controls List */
.controls-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #F5F5F5;
    border-radius: 6px;
}

.control-keys {
    display: flex;
    gap: 4px;
    align-items: center;
}

.control-desc {
    font-size: 0.75rem;
    color: #666666;
    font-weight: 500;
}

kbd {
    display: inline-block;
    padding: 4px 8px;
    background: linear-gradient(180deg, #832EC5 0%, #6b24a0 100%);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 2px 0 #4a1a70;
    min-width: 24px;
    text-align: center;
}

.control-keys kbd {
    padding: 3px 6px;
    font-size: 10px;
    min-width: 20px;
}

/* Embedded mode - hide sidebar when loaded in iframe */
body.embedded #sidebar {
    display: none;
}

body.embedded #ai-prompt-dock,
body.embedded #ai-toggle-btn {
    display: none;
}

body.embedded #game {
    width: 100vw;
}

body.embedded #stats-display {
    left: 50%;
    transform: translateX(-50%);
}

/* Stats Display */
#stats-display {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 12px;
    z-index: 100;
    pointer-events: none;
}

.stat-item {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 8px;
    padding: 8px 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(131, 46, 197, 0.15);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: auto;
}

.stat-label {
    font-size: 10px;
    font-weight: 600;
    color: #832EC5;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #333333;
    line-height: 1;
}

.stat-unit {
    font-size: 10px;
    font-weight: 500;
    color: #888888;
}

/* Help Icon */
.help-icon {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    color: #832EC5;
    transition: all 0.2s ease;
}

.help-icon:hover {
    background: #832EC5;
    color: white;
    transform: scale(1.05);
}

.help-tooltip {
    position: absolute;
    top: 60px;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 101;
}

.help-tooltip div {
    line-height: 1.6;
}

.help-icon:hover .help-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Status Card */
.status-card {
    background: #F5F5F5;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-label {
    font-size: 0.875rem;
    color: #666666;
    font-weight: 500;
}

.status-value {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #333333;
}

.block-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* ==================== SAVED SESSIONS ==================== */
.saves-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.sessions-list::-webkit-scrollbar {
    width: 6px;
}

.sessions-list::-webkit-scrollbar-track {
    background: #F0F0F0;
    border-radius: 3px;
}

.sessions-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #832EC5, #B900FF);
    border-radius: 3px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    color: #999;
    font-size: 0.8rem;
    gap: 8px;
    flex: 1;
}

/* Session Tile */
.session-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.session-tile:hover {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
}

.session-tile.active {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.1);
}

.session-tile.pending-delete {
    border-color: #EF4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2), 0 2px 8px rgba(239, 68, 68, 0.15);
}

.session-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #eee;
}

.session-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.session-info {
    flex: 1;
    min-width: 0;
}

.session-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.session-meta {
    font-size: 0.75rem;
    color: rgba(51, 51, 51, 0.5);
    display: flex;
    gap: 8px;
}

.session-time {
    font-size: 0.75rem;
    color: rgba(51, 51, 51, 0.5);
}

.session-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
    position: relative;
}

.session-tile:hover .session-actions {
    opacity: 1;
}

.session-action-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 4px;
    color: rgba(51, 51, 51, 0.7);
    cursor: pointer;
    transition: all 0.2s;
}

.session-action-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #000;
}

.session-action-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.session-menu-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 4px;
    color: rgba(51, 51, 51, 0.6);
    cursor: pointer;
    transition: all 0.2s;
}

.session-menu-btn:hover {
    background: rgba(0, 0, 0, 0.14);
    color: #111111;
}

.session-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    display: none;
    flex-direction: column;
    gap: 2px;
    min-width: 150px;
    padding: 6px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    z-index: 5;
}

.session-menu.open {
    display: flex;
}

.session-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #333333;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease;
}

.session-menu-item:hover {
    background: rgba(0, 0, 0, 0.06);
}

.session-menu-item.remove {
    color: #ef4444;
}

.session-menu-item.remove:hover {
    background: rgba(239, 68, 68, 0.12);
}

.session-tile.is-hidden {
    opacity: 0.5;
}

.session-tile.is-hidden .session-thumbnail {
    filter: grayscale(0.4);
}

/* Save Button */
.save-button {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #832EC5 0%, #B900FF 100%);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(131, 46, 197, 0.3);
    flex-shrink: 0;
    margin-top: auto;
}

.save-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(131, 46, 197, 0.4);
}

.save-button:active {
    transform: translateY(0);
}

.save-button.hidden {
    display: none;
}

.save-icon {
    font-size: 1rem;
}

/* Sidebar spacer removed - save button now at bottom via flex */

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Modal Dialog */
.modal-dialog {
    width: 90%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.2s ease;
    overflow: hidden;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-overlay.visible .modal-dialog {
    transform: scale(1) translateY(0);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #333333;
    margin: 0;
}

.modal-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #E0E0E0;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    color: #333333;
    background: #FFFFFF;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-input:focus {
    outline: none;
    border-color: #832EC5;
    box-shadow: 0 0 0 3px rgba(131, 46, 197, 0.15);
}

.modal-input::placeholder {
    color: #999999;
}

.modal-input.hidden {
    display: none;
}

.modal-message {
    font-size: 14px;
    color: #666666;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 4px;
}

/* Modal Buttons */
.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-btn-cancel {
    background: #F5F5F5;
    color: #666666;
}

.modal-btn-cancel:hover {
    background: #E8E8E8;
}

.modal-btn-confirm {
    background: linear-gradient(135deg, #B900FF 0%, #832EC5 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(131, 46, 197, 0.3);
}

.modal-btn-confirm:hover {
    box-shadow: 0 4px 12px rgba(185, 0, 255, 0.4);
    transform: translateY(-1px);
}

.modal-btn-danger {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.modal-btn-danger:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

/* ================================
   TEMPLATE POPUP STYLES
   ================================ */

.template-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.template-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.template-popup {
    width: 90%;
    max-width: 520px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.2s ease;
    overflow: hidden;
}

.template-overlay.visible .template-popup {
    transform: scale(1) translateY(0);
}

.template-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #E0E0E0;
}

.template-popup-title {
    font-size: 18px;
    font-weight: 600;
    color: #333333;
    margin: 0;
}

.template-popup-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: #F5F5F5;
    color: #666666;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.template-popup-close:hover {
    background: #E8E8E8;
    color: #333333;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    padding: 16px 20px 20px;
    max-height: 400px;
    overflow-y: auto;
}

.template-card {
    background: #FFFFFF;
    border: 1px solid #E8E8E8;
    border-radius: 10px;
    padding: 16px 12px 14px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.template-card:hover {
    border-color: #D0D0D0;
    background: #FAFAFA;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.template-card-icon {
    font-size: 32px;
    line-height: 1;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-card-icon-image {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.template-card-name {
    font-size: 13px;
    font-weight: 600;
    color: #333333;
    margin-bottom: 2px;
}

.template-card-desc {
    font-size: 11px;
    color: #888888;
}

.template-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 12px;
}

.template-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(131, 46, 197, 0.2);
    border-top-color: #832EC5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.template-loading-text {
    font-size: 14px;
    color: #666666;
}

/* Section Header Row */
.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.section-header-row .section-header {
    margin-bottom: 0;
    flex: 1;
}

/* Load Template Button */
.load-template-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    background: none;
    border: 1px solid rgba(131, 46, 197, 0.3);
    border-radius: 5px;
    color: #832EC5;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.load-template-btn:hover {
    background: rgba(131, 46, 197, 0.08);
    border-color: rgba(131, 46, 197, 0.5);
}

.load-template-btn svg {
    width: 12px;
    height: 12px;
}

/* Template Placement Mode */
.template-ghost {
    opacity: 0.6;
    pointer-events: none;
}

.placement-hint {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(131, 46, 197, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(131, 46, 197, 0.4);
    z-index: 200;
    display: none;
}

.placement-hint.visible {
    display: block;
}
