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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-light: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #22d3ee;
    --success-color: #10b981;
    --border-radius: 12px;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background-color);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--background-color) 100%);
    border-bottom: 1px solid var(--surface-light);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.controls-panel h2 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

/* Shape Selector */
.shape-buttons {
    display: flex;
    gap: 0.5rem;
}

.shape-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--surface-color);
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.shape-btn:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.shape-btn.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.shape-btn span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Presets */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.preset-btn {
    aspect-ratio: 1;
    background: var(--surface-color);
    border: 2px solid var(--surface-light);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preset-btn:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.preset-btn svg {
    width: 100%;
    height: 100%;
}

.preset-btn .preset-shape {
    fill: var(--primary-color);
}

/* Action Buttons */
.points-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--surface-color);
    border: 1px solid var(--surface-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
}

/* Slider Controls */
.slider-group {
    margin-bottom: 1rem;
}

.slider-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.slider-group label span {
    color: var(--primary-color);
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--surface-light);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--primary-hover);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Code Output */
.code-output {
    margin-top: auto;
}

.code-container {
    position: relative;
    background: var(--surface-color);
    border: 1px solid var(--surface-light);
    border-radius: var(--border-radius);
    padding: 1rem;
}

#css-code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8125rem;
    color: var(--accent-color);
    word-break: break-all;
    white-space: pre-wrap;
    margin-bottom: 0.75rem;
}

.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--primary-hover);
}

.copy-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.copy-feedback.show {
    opacity: 1;
}

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

.editor-container {
    position: relative;
    aspect-ratio: 1;
    max-height: calc(100vh - 280px);
    background: var(--surface-color);
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.preview-element {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 50%, var(--accent-color) 100%);
}

.editor-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.control-point {
    fill: white;
    stroke: var(--primary-color);
    stroke-width: 3;
    cursor: grab;
    transition: r 0.15s ease;
}

.control-point:hover {
    r: 10;
}

.control-point.dragging {
    cursor: grabbing;
    r: 12;
    fill: var(--primary-color);
    stroke: white;
}

.control-line {
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 1;
    stroke-dasharray: 4 4;
    pointer-events: none;
}

.center-point {
    fill: var(--accent-color);
    stroke: white;
    stroke-width: 2;
    cursor: move;
}

.radius-handle {
    fill: white;
    stroke: var(--secondary-color);
    stroke-width: 3;
    cursor: ew-resize;
}

.radius-line {
    stroke: rgba(255, 255, 255, 0.5);
    stroke-width: 2;
    stroke-dasharray: 6 4;
    pointer-events: none;
}

.editor-info {
    text-align: center;
}

.editor-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    border-top: 1px solid var(--surface-light);
    background: var(--surface-color);
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .controls-panel {
        order: 2;
    }

    .editor-panel {
        order: 1;
    }

    .editor-container {
        max-height: 50vh;
        aspect-ratio: auto;
        min-height: 300px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .logo-img {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .shape-buttons {
        flex-wrap: wrap;
    }

    .shape-btn {
        flex: 1 1 calc(33% - 0.5rem);
        min-width: 80px;
    }

    .presets-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .points-actions {
        flex-direction: column;
    }

    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.875rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .control-point {
        r: 12;
    }

    .control-point:hover {
        r: 12;
    }

    .center-point {
        r: 14;
    }

    .radius-handle {
        r: 12;
    }
}
