:root {
    --onedark-bg: #282c34;
    --onedark-gutter: #282c34;
    --onedark-guide: #4b5263;
    --onedark-line-active: #2c313c;
    --onedark-fg: #abb2bf;
    --onedark-comment: #5c6370;
    --onedark-keyword: #c678dd;
    --onedark-function: #61afef;
    --onedark-string: #98c379;
    --onedark-tag: #e06c75;
    --onedark-attr: #d19a66;
    --onedark-operator: #56b6c2;
    --onedark-class: #e5c07b;
}

/* Grid Pattern Background - Checkered Style */
.bg-grid-pattern {
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f8fafc;
}

/* Sidebar & Grid */
#svg-list-container::-webkit-scrollbar {
    width: 6px;
}

#svg-list-container::-webkit-scrollbar-track {
    background: transparent;
}

#svg-list-container::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

.icon-grid-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    color: #64748b;
}

.icon-grid-item:hover {
    border-color: #3b82f6;
    background-color: #eff6ff;
    color: #3b82f6;
}

/* EDITOR OVERLAY SYSTEM - Critical for Sync */
.editor-wrapper {
    position: relative;
    background-color: var(--onedark-bg);
    height: 100%;
    display: flex;
    overflow: hidden;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 21px;
    /* Explicit line height for sync */
}

.line-numbers {
    width: 45px;
    background-color: var(--onedark-bg);
    color: #4b5263;
    text-align: right;
    padding-right: 12px;
    padding-top: 10px;
    border-right: 1px solid #3e4451;
    user-select: none;
    font-family: inherit;
    font-size: inherit;
    line-height: 21px;
    flex-shrink: 0;
    overflow: hidden;
    pointer-events: none;
}

.line-numbers>div {
    height: 21px;
    line-height: 21px;
}

.code-container {
    position: relative;
    flex-grow: 1;
    height: 100%;
    overflow: hidden;
    /* Only textarea scrolls, container just holds the layers */
}

/* Common styles for both layers */
.editor-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 10px;
    border: none;
    font-family: inherit;
    font-size: inherit;
    line-height: 21px;
    white-space: pre;
    /* No word wrap - horizontal scroll instead */
    overflow: hidden;
    box-sizing: border-box;
    tab-size: 2;
}

/* Bottom Layer: Coloring */
.editor-pre {
    z-index: 1;
    pointer-events: none;
    /* Let clicks pass through */
    color: var(--onedark-fg);
    background: transparent;
}

/* Top Layer: Input & Cursor */
.editor-textarea {
    z-index: 2;
    overflow: auto;
    /* Scroll both directions */
    color: transparent !important;
    /* Hide text but keep cursor */
    background: transparent;
    caret-color: #528bff;
    /* Blue cursor */
    resize: none;
    outline: none;
    white-space: pre;
    /* No word wrap - matches line numbers */
}

/* Beautiful Scrollbar for Editor */
.editor-textarea::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.editor-textarea::-webkit-scrollbar-track {
    background: #21252b;
    border-radius: 0;
}

.editor-textarea::-webkit-scrollbar-thumb {
    background: #4b5263;
    border-radius: 5px;
    border: 2px solid #21252b;
}

.editor-textarea::-webkit-scrollbar-thumb:hover {
    background: #636d83;
}

.editor-textarea::-webkit-scrollbar-corner {
    background: #21252b;
}

/* Firefox scrollbar */
.editor-textarea {
    scrollbar-width: thin;
    scrollbar-color: #4b5263 #21252b;
}

/* Selection Color - visible through transparent text */
.editor-textarea::selection {
    background-color: rgba(62, 68, 81, 0.5);
}

/* Syntax Highlighting Classes */
.token.tag {
    color: var(--onedark-tag);
}

.token.attr-name {
    color: var(--onedark-attr);
}

.token.attr-value {
    color: var(--onedark-string);
}

.token.punctuation {
    color: var(--onedark-fg);
}

.token.comment {
    color: var(--onedark-comment);
    font-style: italic;
}

.token.string {
    color: var(--onedark-string);
}

/* Status Bar */
.status-bar {
    height: 24px;
    background-color: #21252b;
    color: #9da5b4;
    font-size: 12px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    justify-content: flex-end;
    border-top: 1px solid #181a1f;
    font-family: monospace;
}

/* PREVIEW SECTION */
#preview-container {
    background-image:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Animation control - only for smooth UI without performance issues */
/* Removed global disable to allow Monaco editor and smooth transitions */

/* SVG Resize Wrapper - Fixes handle jumping */
.svg-resize-container {
    position: relative;
    display: inline-flex;
    /* Shrink wrap content */
    align-items: center;
    justify-content: center;
    width: max-content;
    /* Ensure container fits SVG EXACTLY */
    height: max-content;
    border: 1px solid transparent;
    /* Reserve border space */
}

/* Hover Effect on SVG (Orange Dashed) */
.preview-content svg {
    display: block;
    /* Remove bottom alignment gap */
    outline: none;
    /* Reset default highlight */
}

/* Show border only when SVG is selected (clicked) */
.preview-content svg.selected,
#preview-content svg.selected,
.svg-wrapper.selected,
.svg-wrapper.selected svg {
    outline: 2px dashed #f97316 !important;
    outline-offset: 4px;
    /* Orange-500 */
}

/* SVG styling in preview - NO margin for accurate display */
#preview-content svg {
    display: block;
    cursor: pointer;
}

/* SVG wrapper styling */
.svg-wrapper {
    display: inline-block;
    position: relative;
    padding: 4px;
}

/* Resize Handle */
.resize-handle {
    position: absolute;
    bottom: -6px;
    /* Offset to sit nicely on corner */
    right: -6px;
    width: 12px;
    height: 12px;
    background-color: #f97316;
    /* Orange */
    border: 2px solid white;
    border-radius: 50%;
    cursor: se-resize;
    z-index: 10;
    opacity: 0;
    /* Hidden by default */
    pointer-events: auto;
    /* Ensure clickable */
}

/* Show handle when hovering container OR when resizing */
.svg-resize-container:hover .resize-handle,
.preview-container.is-resizing .resize-handle {
    opacity: 1;
}

/* Highlight Overlay */
.svg-element-highlight {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    background-color: rgba(167, 139, 250, 0.25);
    /* Light purple */
    border: 1px solid rgba(139, 92, 246, 0.5);
}

/* Reverse Highlight */
.code-highlight-mark {
    background-color: rgba(62, 68, 81, 0.6);
    /* Subtle highlight in editor */
    border-radius: 2px;
    outline: 1px solid #4b5263;
}

/* Purple overlay for Preview (from code) */
#highlight-overlay {
    background: rgba(139, 92, 246, 0.25);
    border: 2px solid rgba(139, 92, 246, 0.6);
    pointer-events: none;
    position: absolute;
    z-index: 100;
}

/* Load More */
.load-more-btn {
    width: 100%;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    color: #374151;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.load-more-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Error Bar */
.error-bar {
    background: #ef4444;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transform: translateY(-100%);
    transition: all 0.3s;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

.error-bar.visible {
    opacity: 1;
    transform: translateY(0);
}