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

body {
    font-family: 'Cal Sans', sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

.editor-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 320px;
    background: linear-gradient(180deg, #1a1a1a, #111);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #333;
    background: #1a1a1a;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-align: center;
}

.controls-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.controls-wrapper::-webkit-scrollbar {
    width: 8px;
}

.controls-wrapper::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.controls-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #555, #333);
    border-radius: 4px;
    border: 1px solid #222;
}

.controls-wrapper::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #666, #444);
}

.control-group {
    margin-bottom: 24px;
    background: #1a1a1a;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #2a2a2a;
}

.control-group h4 {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    min-height: 32px;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-row label {
    font-size: 12px;
    color: #ccc;
    min-width: 70px;
    font-weight: 600;
}

.control-row select,
.control-row input[type="range"],
.control-row input[type="color"],
.control-row input[type="file"],
.control-row input[type="number"] {
    border: 1px solid #333;
    border-radius: 6px;
    background: #0f0f0f;
    color: #e0e0e0;
    font-size: 12px;
    transition: all 0.2s ease;
}

.control-row select {
    padding: 6px 8px;
    cursor: pointer;
    width: 110px;
}

.control-row select:hover,
.control-row input[type="file"]:hover {
    border-color: #555;
    background: #1a1a1a;
}

.control-row input[type="range"] {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    background: #333;
    outline: none;
    cursor: grab;
}

.control-row input[type="range"]:active {
    cursor: grabbing;
}

.control-row input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 0;
    border: 2px solid #333;
    cursor: pointer;
}

.control-row span {
    font-size: 11px;
    color: #888;
    font-family: 'Space Mono', monospace;
    min-width: 40px;
    text-align: right;
}

.control-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #fff;
}

.control-row input[type="file"] {
    font-size: 10px;
    padding: 4px 6px;
    cursor: pointer;
    width: 80px;
}

.control-row .text-input {
    width: 50px;
    padding: 4px 6px;
    text-align: center;
    font-family: 'Space Mono', monospace;
}

.control-row .text-input:hover,
.control-row .text-input:focus {
    border-color: #555;
    background: #1a1a1a;
    outline: none;
}

.control-row select:focus,
.control-row input:focus {
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
    outline: none;
}

.btn-small {
    background: #333;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: #555;
}

.ai-prompt-row {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 12px;
}

.ai-prompt-row textarea {
    width: 100%;
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    color: #e0e0e0;
    font-size: 12px;
    font-family: 'Cal Sans', sans-serif;
    resize: vertical;
    min-height: 60px;
    transition: all 0.2s ease;
}

.ai-prompt-row textarea:hover,
.ai-prompt-row textarea:focus {
    border-color: #555;
    background: #1a1a1a;
    outline: none;
}

.ai-prompt-row textarea::placeholder {
    color: #666;
    font-style: italic;
}

.btn-ai {
    background: linear-gradient(135deg, #4a9eff, #0078d4);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #5ba3ff, #106ebe);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.btn-ai:active {
    transform: translateY(0);
}

.btn-ai:disabled {
    background: #333;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-status {
    font-size: 10px;
    color: #888;
    font-family: 'Space Mono', monospace;
    margin-left: 12px;
    display: flex;
    align-items: center;
}

.ai-status.loading {
    color: #4a9eff;
}

.ai-status.success {
    color: #4ade80;
}

.ai-status.error {
    color: #ef4444;
}

.canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    background: #0a0a0a;
    position: relative;
}

.text-canvas {
    background: #0f0f0f;
    border-radius: 16px;
    padding: 80px;
    min-width: 600px;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    border: 1px solid #222;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.text-canvas::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--bg-image, none);
    background-size: var(--bg-size, cover);
    background-position: var(--bg-position, center);
    background-repeat: no-repeat;
    opacity: var(--bg-opacity, 0.7);
    z-index: 0;
    pointer-events: none;
    filter: var(--bg-blur, blur(0px));
    transition: all 0.3s ease;
}

.text-element {
    font-size: 48px;
    font-family: 'Cal Sans', sans-serif;
    color: #fff;
    text-align: center;
    outline: none;
    border: 2px dashed transparent;
    padding: 24px;
    border-radius: 12px;
    transition: all 0.3s ease;
    white-space: nowrap;
    user-select: text;
    cursor: text;
    transform-origin: center;
    font-weight: 600;
    letter-spacing: -2px;
    position: relative;
    z-index: 2;
    line-height: 1.2;
    mix-blend-mode: normal;
    will-change: transform, filter, opacity;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    font-smooth: always;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
    font-variant-ligatures: common-ligatures;
}

.text-element.has-gradient {
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.text-element:not(.has-gradient) {
    -webkit-text-fill-color: initial;
    background: none;
}

.text-element:focus {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.02);
}

.text-element:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.text-element[contenteditable="true"]:empty:before {
    content: "Type your text here";
    color: #666;
    font-style: italic;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(calc(1 + var(--anim-intensity, 1) * 0.1)); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(calc(-10px * var(--anim-intensity, 1))); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(calc(-5px * var(--anim-intensity, 1))); }
    75% { transform: translateX(calc(5px * var(--anim-intensity, 1))); }
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(calc(-5px * var(--anim-intensity, 1))); }
}

@keyframes glow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(calc(1 + var(--anim-intensity, 1) * 0.5)); }
}

@keyframes fade {
    0%, 100% { opacity: 1; }
    50% { opacity: calc(1 - var(--anim-intensity, 1) * 0.3); }
}

@keyframes typewriter {
    0% { width: 0; }
    100% { width: 100%; }
}

.anim-pulse { animation: pulse var(--anim-speed, 2s) ease-in-out infinite; }
.anim-bounce { animation: bounce var(--anim-speed, 2s) ease-in-out infinite; }
.anim-shake { animation: shake var(--anim-speed, 2s) ease-in-out infinite; }
.anim-rotate { animation: rotate var(--anim-speed, 2s) linear infinite; }
.anim-float { animation: float var(--anim-speed, 2s) ease-in-out infinite; }
.anim-glow { animation: glow var(--anim-speed, 2s) ease-in-out infinite; }
.anim-fade { animation: fade var(--anim-speed, 2s) ease-in-out infinite; }
.anim-typewriter { 
    animation: typewriter var(--anim-speed, 2s) steps(40, end) infinite;
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid;
}

@keyframes wave {
    0%, 100% { 
        clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
        transform: translateY(0);
    }
    50% { 
        clip-path: polygon(0% 20%, 100% 0%, 100% 80%, 0% 100%);
        transform: translateY(calc(-5px * var(--morph-intensity, 1)));
    }
}

@keyframes ripple {
    0%, 100% { 
        transform: scale(1) rotateZ(0deg);
    }
    25% { 
        transform: scale(calc(1 + var(--morph-intensity, 0.2) * 0.01)) rotateZ(1deg);
    }
    75% { 
        transform: scale(calc(1 - var(--morph-intensity, 0.2) * 0.01)) rotateZ(-1deg);
    }
}

@keyframes twist {
    0%, 100% { 
        transform: rotateZ(0deg) skewX(0deg);
    }
    50% { 
        transform: rotateZ(calc(var(--morph-intensity, 20) * 0.1deg)) skewX(calc(var(--morph-intensity, 20) * 0.2deg));
    }
}

@keyframes bulge {
    0%, 100% { 
        transform: scaleX(1) scaleY(1);
    }
    50% { 
        transform: scaleX(calc(1 + var(--morph-intensity, 20) * 0.01)) scaleY(calc(1 - var(--morph-intensity, 20) * 0.005));
    }
}

.morph-wave { animation: wave var(--morph-speed, 1s) ease-in-out infinite; }
.morph-ripple { animation: ripple var(--morph-speed, 1s) ease-in-out infinite; }
.morph-twist { animation: twist var(--morph-speed, 1s) ease-in-out infinite; }
.morph-bulge { animation: bulge var(--morph-speed, 1s) ease-in-out infinite; }

.text-element.path-arc {
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center bottom;
    border-radius: 50%;
    clip-path: ellipse(100% 50% at 50% 100%);
}

.text-element.path-circle {
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1;
    writing-mode: vertical-lr;
}

.text-element.path-wave {
    position: relative;
}

.text-element.path-wave::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, currentColor 50%, transparent 100%);
    clip-path: polygon(0% 50%, 25% 0%, 50% 50%, 75% 100%, 100% 50%, 100% 100%, 0% 100%);
    z-index: -1;
}

.text-element.path-zigzag {
    background: linear-gradient(45deg, transparent 40%, currentColor 40%, currentColor 60%, transparent 60%);
    background-size: 20px 20px;
    -webkit-background-clip: text;
    background-clip: text;
}

.text-element.path-spiral {
    transform-origin: center;
    animation: spiral 10s linear infinite;
}

@keyframes spiral {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}

.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-10vh) rotate(360deg);
        opacity: 0;
    }
}

.particle.sparks {
    background: radial-gradient(circle, currentColor, transparent);
    animation: sparkle 0.5s ease-in-out infinite alternate;
}

@keyframes sparkle {
    0% { transform: scale(1) rotate(0deg); opacity: 1; }
    100% { transform: scale(1.5) rotate(90deg); opacity: 0.5; }
}

.particle.fireflies {
    background: radial-gradient(circle, #ffff80, #80ff80);
    box-shadow: 0 0 10px currentColor;
    animation: firefly 3s ease-in-out infinite;
}

@keyframes firefly {
    0%, 100% { 
        transform: translateX(0) translateY(0) scale(1);
        opacity: 0.8;
    }
    25% { 
        transform: translateX(20px) translateY(-10px) scale(1.2);
        opacity: 1;
    }
    50% { 
        transform: translateX(-15px) translateY(15px) scale(0.8);
        opacity: 0.6;
    }
    75% { 
        transform: translateX(10px) translateY(-20px) scale(1.1);
        opacity: 0.9;
    }
}

.gradient-spin {
    animation: gradientSpin 4s linear infinite;
}

@keyframes gradientSpin {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.gradient-shift {
    background-size: 200% 200%;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 0%; }
    50% { background-position: 100% 100%; }
    100% { background-position: 0% 0%; }
}

.gradient-pulse {
    animation: gradientPulse 2s ease-in-out infinite;
}

@keyframes gradientPulse {
    0%, 100% { filter: brightness(1) saturate(1); }
    50% { filter: brightness(1.3) saturate(1.5); }
}

.gradient-wave {
    background-size: 400% 400%;
    animation: gradientWave 5s ease-in-out infinite;
}

@keyframes gradientWave {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 0%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 100%; }
    100% { background-position: 0% 50%; }
}

.text-element.mask-circle {
    clip-path: circle(var(--mask-size, 100%) at var(--mask-position, 50%) 50%);
}

.text-element.mask-polygon {
    clip-path: polygon(20% 0%, 80% 0%, 100% 20%, 100% 80%, 80% 100%, 20% 100%, 0% 80%, 0% 20%);
}

.text-element.hover-scale:hover {
    transform: scale(1.1);
    transition: transform 0.3s ease;
}

.text-element.hover-glow:hover {
    filter: drop-shadow(0 0 20px currentColor);
    transition: filter 0.3s ease;
}

.text-element.hover-rotate:hover {
    transform: rotate(5deg);
    transition: transform 0.3s ease;
}

.text-element.hover-color:hover {
    color: #ff6b6b !important;
    transition: color 0.3s ease;
}

.text-element.hover-shadow:hover {
    text-shadow: 0 0 30px currentColor;
    transition: text-shadow 0.3s ease;
}

@keyframes clickBounce {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes clickFlash {
    0% { filter: brightness(1); }
    50% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

@keyframes clickRipple {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 20px rgba(255, 255, 255, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

@keyframes clickShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.click-bounce {
    animation: clickBounce 0.3s ease;
}

.click-flash {
    animation: clickFlash 0.3s ease;
}

.click-ripple {
    animation: clickRipple 0.6s ease;
}

.click-shake {
    animation: clickShake 0.3s ease;
}

.auto-rotate {
    animation: autoRotate linear infinite;
}

@keyframes autoRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.backdrop-filter {
    backdrop-filter: blur(var(--backdrop-blur, 10px)) hue-rotate(var(--backdrop-hue, 0deg));
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.isolation {
    isolation: isolate;
}

.variable-font {
    font-variation-settings: 
        'wdth' var(--font-width, 100),
        'slnt' var(--font-slant, 0),
        'opsz' var(--optical-size, 16);
}

.btn-action {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s ease;
    margin: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-action:hover {
    background: linear-gradient(135deg, #7c8df0, #8a5db8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid #333;
    }
    
    .controls-wrapper {
        padding: 12px;
    }
    
    .control-group {
        margin-bottom: 16px;
        padding: 12px;
        background: #161616;
    }
    
    .control-row {
        margin-bottom: 8px;
        min-height: 28px;
        flex-wrap: wrap;
        gap: 8px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .control-row label {
        font-size: 11px;
        min-width: 60px;
        flex-basis: auto;
        margin-bottom: 4px;
    }
    
    .control-row select {
        width: 90px;
        font-size: 11px;
        padding: 4px 6px;
    }
    
    .text-element {
        font-size: 24px;
        padding: 12px;
    }
    
    .btn-action {
        width: 100%;
        margin: 4px 0;
    }
    
    .particles-container {
        display: none; /* Disable particles on mobile for performance */
    }
}

@media (prefers-reduced-motion: reduce) {
    .text-element,
    .text-element::before,
    .text-element::after {
        animation: none !important;
        transition: none !important;
    }
}

@media (prefers-contrast: high) {
    .control-group {
        border: 2px solid #fff;
        background: #000;
    }
    
    .text-element {
        filter: contrast(2);
    }
}

.text-element {
    will-change: transform, filter, opacity;
    contain: layout style paint;
}

.particles-container {
    will-change: transform;
    contain: layout style;
}