:root {
    --bg-main: #f8f9fa;
    --bg-surface: #ffffff;
    --text-main: #183153;
    --text-muted: #5c6d7e;
    --border-color: #e5e7eb;
    --primary: #ffd43b;
    --primary-text: #183153;
    --accent: #183153;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --preview-bg-light: #ffffff;
    --preview-bg-dark: #183153;
    
    --icon-color: #000000;
    --icon-scale: 1;
    --icon-rotate: 0deg;
    --icon-scale-x: 1;
    --icon-scale-y: 1;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    width: 100%;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.25rem 1.5rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.title-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.title-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.badge {
    background-color: var(--primary);
    color: var(--primary-text);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.icon-link-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    background-color: #005cfa;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.icon-link-container .icon-link {
    color: white;
    font-size: 1rem;
    cursor: pointer;
}

.icon-link-container:hover {
    background-color: #0046c4;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--border-color);
}

/* Main Content */
.main-content {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
}

.preview-panel {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-canvas {
    flex: 1;
    min-height: 220px;
    background-color: var(--preview-bg-light);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s;
    overflow: hidden;
}

.preview-canvas.dark {
    background-color: var(--preview-bg-dark);
}

.preview-canvas.dark .icon-path {
    fill: #ffffff; /* Default fallback, will be overridden by --icon-color if set */
}

#previewIcon {
    width: 150px;
    height: 150px;
    fill: var(--icon-color);
    color: var(--icon-color);
    transform: scale(var(--icon-scale)) rotate(var(--icon-rotate)) scaleX(var(--icon-scale-x)) scaleY(var(--icon-scale-y));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), fill 0.3s ease, color 0.3s ease;
}

.preview-toolbar {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.left-tools, .right-tools {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.tool-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.tool-btn:hover {
    color: var(--text-main);
    background: var(--bg-main);
}

.reset-btn {
    font-size: 0.875rem;
    font-weight: 400;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    margin-left: 0.25rem;
}

.reset-btn:hover {
    background: #dbeafe !important;
    color: #1e3a8a !important;
}

.tool-btn i {
    font-size: 1.3rem;
}

/* Code Panel */
.code-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.style-selector {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.kind-selector-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 180px;
    min-width: 160px;
}

.kind-select {
    width: 100%;
    height: 100%;
    padding: 0.8rem 2rem 0.8rem 2.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.2s;
}

.kind-select:hover {
    border-color: #93c5fd;
    background: #f8fafc;
}

.kind-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.kind-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
}

.kind-arrow {
    position: absolute;
    right: 0.75rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.style-options {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    width: 100%;
}

.style-icon-btn {
    flex: 1;
    background: white;
    border: none;
    border-right: 1px solid var(--border-color);
    padding: 0.8rem 0;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.style-icon-btn:last-child {
    border-right: none;
}

.style-icon-btn:hover:not(.active) {
    background: #f8f9fa;
    color: var(--text-main);
}

.style-icon-btn i {
    font-size: 1.5rem;
}

.style-icon-btn.active {
    background: #005cfa;
    color: white;
}

.code-box {
    background: var(--accent);
    border-radius: var(--radius-md);
    overflow: hidden;
    color: white;
}

.code-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.tab-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.tab-btn.active {
    color: white;
    border-bottom: 2px solid white;
}
.tab-btn:hover:not(.active) {
    color: white;
}

.code-content {
    padding: 1rem;
    position: relative;
    font-family: monospace;
    font-size: 0.875rem;
    background: rgba(0,0,0,0.2);
    min-height: 80px;
}

.code-content code {
    display: block;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 90px;
    white-space: pre-wrap;
    word-break: break-all;
    padding-right: 2rem;
    color: #e2e8f0;
}

/* Custom scrollbar for code snippet */
.code-content code::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.code-content code::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

.code-content code::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.code-content code::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

.copy-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: rgba(255,255,255,0.2);
}

.code-footer {
    padding: 1rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
}

.code-footer a {
    color: #74c0fc;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.code-footer a:hover {
    text-decoration: underline;
}

.creative-svg-box {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
    overflow: hidden;
}

.creative-svg-header {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.svg-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.creative-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.copy-action {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}
.copy-action:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.download-action {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.download-action:hover {
    background: #dbeafe;
    color: #1e3a8a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(29, 78, 216, 0.15);
}

.svg-action {
    background: #fdf4ff;
    color: #a21caf;
    border: 1px solid #f5d0fe;
}
.svg-action:hover {
    background: #fae8ff;
    color: #86198f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(162, 28, 175, 0.15);
}


/* Customization Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .tools-grid {
        grid-template-columns: 1fr;
    }
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tool-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #1e40af;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.color-palette {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.color-swatch {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.no-color {
    background: white;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
}

.color-bar-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.color-bar-btn {
    width: 100%;
    height: 2.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    /* Premium checkerboard pattern for transparency */
    background-image: linear-gradient(45deg, #cbd5e1 25%, transparent 25%), 
                      linear-gradient(-45deg, #cbd5e1 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #cbd5e1 75%), 
                      linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    background-color: #ffffff;
}

.color-bar-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: inherit;
    pointer-events: none;
}

.color-bar-btn:hover {
    transform: translateY(-1px);
    border-color: #93c5fd;
}

.color-bar-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 0.25rem;
    letter-spacing: 0.05em;
}

.gradient-btn {
    background: linear-gradient(to right, #fb923c, #facc15, #4ade80, #22d3ee, #a78bfa);
    border: 2px solid transparent;
}

/* Make Pickr button fit our swatch perfectly */
.custom-color-picker .pcr-button {
    width: 100%;
    height: 2.5rem;
    border-radius: var(--radius-md);
    background: linear-gradient(to right, #fb923c, #facc15, #4ade80, #22d3ee, #a78bfa);
    border: 2px solid transparent;
    transition: transform 0.1s;
}

.custom-color-picker .pcr-button:hover {
    transform: scale(1.1);
}

.custom-color-picker.active .pcr-button,
.gradient-btn.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #3b82f6;
}

.size-options, .rotate-options, .flip-options {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.size-btn, .rotate-btn, .flip-btn {
    flex: 1;
    background: white;
    border: none;
    border-right: 1px solid var(--border-color);
    padding: 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s;
}
.size-btn:last-child, .rotate-btn:last-child, .flip-btn:last-child {
    border-right: none;
}

.size-btn:hover:not(.active), .rotate-btn:hover:not(.active), .flip-btn:hover:not(.active) {
    background: #f8f9fa;
}

.size-btn.active, .rotate-btn.active, .flip-btn.active {
    background: #005cfa;
    color: white;
}

.custom-input {
    width: 110px;
    border: none;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    text-align: center;
    outline: none;
    color: var(--text-main);
    font-weight: 400;
}

.custom-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.tags-area {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.tool-btn.active {
    color: #005cfa;
    background: #e6efff;
}

.animate-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.animate-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.animate-btn i {
    font-size: 1.1rem;
}

.animate-btn:hover {
    background: #f8f9fa;
    color: var(--text-main);
}

.animate-btn.active {
    background: #f8f9fa;
    border-color: #005cfa;
    color: #1e293b;
    box-shadow: 0 0 0 1px #005cfa;
}

@media (max-width: 768px) {
    .animate-options {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Fix border-right artifacts when buttons wrap on mobile */
    .size-btn,
    .rotate-btn,
    .flip-btn {
        border-right: none;
    }
}


.tag {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.tag-yellow { background: #fef08a; color: #854d0e; }
.tag-blue { background: #bfdbfe; color: #1e40af; }
.tag-gray { background: var(--bg-main); color: var(--text-muted); }
