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

:root {
    --primary: #667eea;
    --primary-dark: #764ba2;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary: #6B7280;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    
    --bg-page: #F9FAFB;
    --bg-gradient: linear-gradient(to bottom right, #EFF6FF, #E0E7FF);
    --bg-card: #FFFFFF;
    --bg-hover: rgba(102, 126, 234, 0.05);
    
    --text-dark: #111827;
    --text-medium: #374151;
    --text-light: #6B7280;
    
    --border-light: #E5E7EB;
    --border-medium: #D1D5DB;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.15);
    --shadow-focus: 0 0 0 4px rgba(102, 126, 234, 0.1);
    
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --radius-full: 9999px;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    padding: 1rem;
    color: var(--text-dark);
    line-height: 1.5;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.content {
    padding: 1.5rem;
}

.page-title {
    text-align: center;
    margin-bottom: 1.5rem;
}

.page-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    line-height: 1.25;
    color: var(--text-dark);
}

.page-title p {
    font-size: 0.75rem;
    color: var(--text-light);
}

.controls {
    margin-bottom: 1rem;
}

.add-element-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.select-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-medium);
}

select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--primary);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-card);
    color: var(--text-dark);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    background-size: 1rem;
    padding-right: 2.25rem;
}

select:hover {
    background: var(--bg-hover);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

select:focus {
    outline: none;
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-focus);
    transform: translateY(-1px);
}

select:active {
    transform: translateY(0);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    border: 2px solid;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

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

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

.btn-primary:hover {
    background: var(--bg-hover);
    border-color: var(--primary-dark);
    color: var(--primary-dark);
}

.btn-primary:focus {
    outline: none;
    background: rgba(102, 126, 234, 0.08);
}

.btn-secondary {
    border-color: var(--secondary);
    color: var(--text-medium);
}

.btn-secondary:hover {
    background: rgba(107, 114, 128, 0.05);
    border-color: var(--text-medium);
}

.btn-success {
    border-color: var(--success);
    color: var(--success);
}

.btn-success:hover {
    background: rgba(16, 185, 129, 0.08);
}

.icon {
    font-size: 1rem;
    line-height: 1;
}

.elements-container {
    min-height: 8rem;
    margin-bottom: 1rem;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
    background: rgba(102, 126, 234, 0.03);
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-lg);
}

.empty-icon {
    font-size: 2rem;
    margin-bottom: 0.375rem;
}

.empty-state p {
    font-size: 0.75rem;
}

.element-item {
    background: var(--bg-card);
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 0.625rem;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.6s ease-out;
    position: relative;
    cursor: grab;
    transition: all 0.3s ease;
}

.element-item:last-child {
    margin-bottom: 0;
}

.element-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.element-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.element-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.element-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.drag-handle {
    cursor: grab;
    color: var(--text-light);
    margin-right: 0.25rem;
    font-size: 0.875rem;
    user-select: none;
}

.btn-remove {
    background: transparent;
    color: var(--danger);
    border: 2px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 0.1875rem 0.625rem;
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.08);
    transform: translateY(-2px);
}

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

.element-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-medium);
}

input[type="text"],
textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-family: inherit;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
    transform: translateY(-1px);
}

textarea {
    min-height: 4rem;
    resize: vertical;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.checkbox-group label {
    font-size: 0.75rem;
    color: var(--text-dark);
    cursor: pointer;
}

input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    accent-color: var(--primary);
}

input[type="file"] {
    display: none;
}

.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.file-upload-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

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

.file-name {
    font-size: 0.6875rem;
    color: var(--text-light);
    margin-top: 0.1875rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 0.5rem;
}

@media (max-width: 400px) {
    body {
        padding: 0.75rem;
    }

    .container {
        border-radius: var(--radius-lg);
    }

    .content {
        padding: 1.25rem;
    }

    .page-title h1 {
        font-size: 1.375rem;
    }

    .page-title p {
        font-size: 0.8125rem;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: 0.75rem 1.25rem;
    }
}

@media (max-width: 320px) {
    .page-title h1 {
        font-size: 1.25rem;
    }

    .btn {
        font-size: 0.8125rem;
        padding: 0.625rem 1rem;
    }
}

@media (hover: none) {
    .btn:hover,
    .element-item:hover,
    .select:hover,
    .file-upload-btn:hover,
    .btn-remove:hover {
        transform: none;
    }
}

.notification {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
    color: white;
}

.notification-success {
    background: var(--success);
}

.notification-error {
    background: var(--danger);
}

.notification-warning {
    background: var(--warning);
}

.notification-info {
    background: var(--info);
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 0);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}
