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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #1e1e1e;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #1e1e1e;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
    height: 48px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo h1 {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.version {
    font-size: 11px;
    color: #888;
    background: #404040;
    padding: 2px 6px;
    border-radius: 3px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#svgFile {
    display: none;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
}

.upload-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.upload-btn-left {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    width: 100%;
    justify-content: center;
    margin-bottom: 16px;
}

.upload-btn-left:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
}

.file-upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(0, 120, 212, 0.1);
    transform: scale(1.02);
}

.drag-drop-text {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.8;
}

.drag-drop-text span {
    font-style: italic;
}

/* Main Layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Panel */
.left-panel {
    width: 280px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.panel-section {
    padding: 16px;
    border-bottom: 1px solid #404040;
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: #cccccc;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-section h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.visitor-section {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.visitor-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    justify-content: center;
}

.tool-group {
    display: flex;
    gap: 4px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    background: #3c3c3c;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cccccc;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: #464647;
    border-color: #666;
}

.tool-btn.active {
    background: #0078d4;
    border-color: #0078d4;
    color: white;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    font-size: 12px;
    color: #cccccc;
    margin-bottom: 4px;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 6px 8px;
    background: #3c3c3c;
    border: 1px solid #555;
    border-radius: 3px;
    color: #e0e0e0;
    font-size: 13px;
}

.input-group input:focus {
    outline: none;
    border-color: #0078d4;
    box-shadow: 0 0 0 1px #0078d4;
}

.primary-btn {
    width: 100%;
    padding: 8px 12px;
    background: #16825d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s ease;
}

.primary-btn:hover:not(:disabled) {
    background: #1a9870;
}

.primary-btn:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

.zoom-controls-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.control-btn {
    padding: 6px 8px;
    background: #3c3c3c;
    border: 1px solid #555;
    border-radius: 3px;
    color: #cccccc;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.control-btn:hover:not(:disabled) {
    background: #464647;
    border-color: #666;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn.full-width {
    width: 100%;
    margin-bottom: 4px;
    gap: 6px;
    padding: 8px 12px;
}

#zoomLevel {
    font-size: 11px;
    color: #cccccc;
    min-width: 35px;
    text-align: center;
}

/* Center Panel */
.center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    overflow: hidden;
}

.canvas-header {
    height: 32px;
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
    display: flex;
    align-items: center;
    padding: 0 12px;
    flex-shrink: 0;
}

.canvas-info {
    font-size: 12px;
    color: #888;
}

.canvas-container {
    flex: 1;
    position: relative;
    background: #000000;
    overflow: hidden;
}

#svgContainer {
    width: 100%;
    height: 100%;
    overflow: auto;
    position: relative;
    cursor: crosshair;
}

#svgContainer svg {
    display: block;
    max-width: none;
    transition: transform 0.3s ease;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    text-align: center;
    gap: 16px;
}

.placeholder p {
    font-size: 14px;
    max-width: 300px;
    line-height: 1.4;
}

#selectionOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.selection-box {
    position: absolute;
    border: 2px dashed #0078d4;
    background: rgba(0, 120, 212, 0.1);
    pointer-events: none;
}

.canvas-container .zoom-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 15;
    pointer-events: auto;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(45, 45, 46, 0.9);
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    color: #cccccc;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: rgba(70, 70, 71, 0.9);
    border-color: #666;
}

/* Right Panel */
.right-panel {
    width: 320px;
    background: #252526;
    border-left: 1px solid #404040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.panel-header {
    padding: 12px 16px;
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #cccccc;
    margin: 0;
}

.download-all-btn {
    background: #0078d4;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s ease;
}

.download-all-btn:hover:not(:disabled) {
    background: #106ebe;
}

.download-all-btn:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

.icons-grid {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    overflow-y: auto;
    flex: 1;
}

.cropped-icon {
    background: #3c3c3c;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
}

.cropped-icon:hover {
    border-color: #666;
    background: #464647;
}

.cropped-icon svg {
    max-width: 100%;
    max-height: 80px;
    margin-bottom: 8px;
    background: #2d2d2d;
    border-radius: 4px;
    padding: 8px;
}

.cropped-icon .filename {
    font-size: 11px;
    color: #cccccc;
    margin-bottom: 8px;
    word-break: break-word;
}

.cropped-icon .download-btn {
    background: #0078d4;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 500;
    transition: background 0.2s ease;
    width: 100%;
}

.cropped-icon .download-btn:hover {
    background: #106ebe;
}

/* Footer */
.footer {
    background: #2d2d2d;
    border-top: 1px solid #404040;
    padding: 24px 16px;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-main {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 32px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #404040;
}

.footer-section h3 {
    color: #ffffff;
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 600;
}

.footer-section h4 {
    color: #e0e0e0;
    font-size: 14px;
    margin: 16px 0 8px 0;
    font-weight: 500;
}

#visitorCount {
    font-weight: bold;
    color: #0078d4;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .left-panel {
        width: 240px;
    }
    
    .right-panel {
        width: 280px;
    }
    
    .icons-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }
    
    .left-panel {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #404040;
        overflow-x: auto;
    }
    
    .panel-section {
        padding: 12px;
    }
    
    .tool-group {
        justify-content: center;
    }
    
    .right-panel {
        width: 100%;
        height: 300px;
        border-left: none;
        border-top: 1px solid #404040;
    }
    
    .center-panel {
        min-height: 400px;
    }
    
    .icons-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
        padding: 12px;
    }
    
    .cropped-icon {
        padding: 8px;
    }
    
    .cropped-icon svg {
        max-height: 60px;
    }
    
    .app-header {
        padding: 6px 12px;
    }
    
    .logo h1 {
        font-size: 14px;
    }
    
    .upload-btn {
        padding: 4px 8px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .app-header {
        flex-direction: column;
        height: auto;
        gap: 8px;
        padding: 8px;
    }
    
    .left-panel {
        max-height: 150px;
    }
    
    .panel-section {
        padding: 8px;
    }
    
    .panel-section h3 {
        font-size: 11px;
    }
    
    .right-panel {
        height: 250px;
    }
    
    .icons-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}
