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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    padding: 8px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
    overflow: hidden;
}

h1 {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 2.2em;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo {
    height: 80px;
    width: auto;
    margin-right: 12px;
    vertical-align: middle;
}

.category-tabs {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.category-btn {
    padding: 16px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    color: #64748b;
}

.category-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.category-btn.active {
    background: #ffffff;
    color: #667eea;
    border-bottom-color: #667eea;
}

.tool-tabs {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tool-tabs::-webkit-scrollbar {
    display: none;
}

.tool-btn {
    flex: 0 0 auto;
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    color: #64748b;
    border-radius: 8px 8px 0 0;
    margin: 4px 2px 0;
}

.tool-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.tool-btn.active {
    background: #ffffff;
    color: #667eea;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.category-content, .tool-content {
    display: none;
    padding: 24px;
}

.category-content.active, .tool-content.active {
    display: block;
}

input[type="file"] {
    margin: 16px 0;
    padding: 12px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    width: 100%;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="file"]:hover {
    border-color: #667eea;
    background: #f1f5f9;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0;
    align-items: center;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.controls input, .controls select, .controls button {
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.controls input:focus, .controls select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.controls input[type="range"] {
    width: 140px;
    accent-color: #667eea;
}

.controls input[type="number"] {
    width: 90px;
}

.controls input[type="text"] {
    width: 160px;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
    min-height: 44px;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

canvas {
    max-width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin: 20px 0;
    display: block;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

textarea {
    width: 100%;
    min-height: 140px;
    padding: 16px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    resize: vertical;
    margin: 16px 0;
    background: #f8fafc;
    transition: all 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: #ffffff;
}

.preview-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 24px 0;
}

.preview-area > div {
    text-align: center;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.preview-area img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 8px;
    margin: 12px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin: 20px 0;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.stats span {
    font-weight: 600;
    color: #374151;
}

.color-info {
    margin: 20px 0;
    font-family: 'JetBrains Mono', monospace;
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.color-info div {
    margin: 8px 0;
    font-size: 14px;
}

#gradient-preview {
    width: 100%;
    height: 120px;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#drawing-canvas {
    border: 2px solid #667eea;
    cursor: crosshair;
    background: #ffffff;
}

#ascii-output {
    background: #1e293b;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    line-height: 1.1;
    white-space: pre;
    overflow: auto;
    max-height: 400px;
    border-radius: 12px;
    padding: 16px;
}

#qr-output {
    text-align: center;
    margin: 24px 0;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

#json-error {
    color: #dc2626;
    margin: 12px 0;
    font-weight: 600;
    padding: 12px;
    background: #fef2f2;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

#regex-results {
    margin: 20px 0;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    white-space: pre-wrap;
    border: 1px solid #e2e8f0;
    font-size: 13px;
}

.controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.mobile-nav-toggle {
    display: none;
}

.mobile-nav {
    display: none;
}

.mobile-overlay {
    display: none;
}

/* Mobile Styles */
@media (max-width: 768px) {
    body {
        padding: 0;
        background: #667eea;
    }
    
    .container {
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        position: relative;
    }
    
    h1 {
        padding: 20px 16px;
        font-size: 1.6em;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .logo {
        height: 60px;
        margin-right: 12px;
    }
    
    .category-tabs {
        display: none;
    }
    
    .mobile-nav-toggle {
        display: block;
        position: fixed;
        top: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.9);
        color: #667eea;
        font-size: 20px;
        font-weight: bold;
        z-index: 1001;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        backdrop-filter: blur(10px);
    }
    
    .mobile-nav {
        display: block;
        position: fixed;
        top: 0;
        right: -300px;
        width: 280px;
        height: 100vh;
        background: #ffffff;
        z-index: 1000;
        transition: right 0.3s ease;
        box-shadow: -4px 0 12px rgba(0,0,0,0.1);
        padding: 20px;
    }
    
    .mobile-nav.open {
        right: 0;
    }
    
    .mobile-nav-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 30px;
        padding-bottom: 20px;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .mobile-nav-header span {
        font-size: 18px;
        font-weight: 600;
        color: #374151;
    }
    
    .mobile-nav-header button {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: #f3f4f6;
        color: #6b7280;
        font-size: 18px;
        min-height: auto;
    }
    
    .mobile-category-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .mobile-category-btn {
        padding: 16px 20px;
        border: none;
        background: #f8fafc;
        border-radius: 12px;
        cursor: pointer;
        font-size: 16px;
        font-weight: 600;
        color: #64748b;
        transition: all 0.2s ease;
        text-align: left;
        min-height: 60px;
        display: flex;
        align-items: center;
        gap: 12px;
        border: 2px solid transparent;
    }
    
    .mobile-category-btn.active {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border-color: #667eea;
        transform: scale(1.02);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }
    
    .mobile-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .mobile-overlay.open {
        opacity: 1;
        visibility: visible;
    }
    
    .category-content {
        flex: 1;
        padding: 16px 16px 40px;
        overflow-y: auto;
    }
    
    .tool-tabs {
        position: sticky;
        top: 0;
        z-index: 50;
        background: #ffffff;
        margin: -16px -16px 20px;
        padding: 12px 16px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border-radius: 0;
    }
    
    .tool-btn {
        font-size: 13px;
        padding: 12px 16px;
        margin: 2px 4px 0;
        min-height: 44px;
        border-radius: 8px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 20px;
        margin: 20px 0;
    }
    
    .controls input, .controls select, .controls button {
        width: 100%;
        padding: 16px;
        font-size: 16px;
        min-height: 52px;
        border-radius: 12px;
    }
    
    .controls input[type="range"] {
        width: 100%;
        height: 44px;
        padding: 0;
    }
    
    .controls label {
        width: 100%;
        padding: 12px 0;
        font-size: 16px;
    }
    
    .controls label input[type="checkbox"] {
        width: auto;
        min-height: auto;
        margin-right: 12px;
        transform: scale(1.3);
    }
    
    button {
        min-height: 52px;
        font-size: 16px;
        font-weight: 600;
        padding: 16px 24px;
        border-radius: 12px;
    }
    
    input[type="file"] {
        padding: 20px;
        font-size: 16px;
        border-radius: 12px;
        margin: 20px 0;
    }
    
    textarea {
        min-height: 120px;
        font-size: 16px;
        padding: 20px;
        border-radius: 12px;
    }
    
    .preview-area {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .preview-area > div {
        padding: 20px;
    }
    
    .stats {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 20px;
    }
    
    .stats span {
        font-size: 16px;
        padding: 8px 0;
    }
    
    canvas {
        margin: 20px 0;
        border-radius: 12px;
    }
    
    #drawing-canvas {
        width: 100%;
        height: 300px;
        touch-action: none;
    }
    
    .color-info {
        padding: 20px;
        font-size: 16px;
    }
    
    .color-info div {
        margin: 12px 0;
        font-size: 16px;
    }
    
    #gradient-preview {
        height: 100px;
        margin: 20px 0;
    }
    
    #ascii-output {
        font-size: 10px;
        padding: 20px;
        max-height: 300px;
    }
    
    #qr-output {
        padding: 20px;
        margin: 20px 0;
    }
    
    #json-error, #regex-results {
        padding: 20px;
        font-size: 16px;
        margin: 20px 0;
    }
    
    audio {
        width: 100%;
        height: 54px;
        margin: 16px 0;
    }
    
    input[type="color"] {
        width: 100%;
        height: 60px;
        border: none;
        border-radius: 12px;
        cursor: pointer;
    }
    
    select {
        appearance: none;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 12px center;
        background-repeat: no-repeat;
        background-size: 16px;
        padding-right: 40px;
    }
}

@media (max-width: 480px) {
    .mobile-nav {
        width: 100%;
        right: -100%;
    }
    
    .mobile-nav-toggle {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .tool-tabs {
        padding: 8px 12px;
    }
    
    .tool-btn {
        font-size: 12px;
        padding: 10px 12px;
        min-height: 40px;
    }
    
    .category-content {
        padding: 12px 12px 40px;
    }
    
    .controls {
        padding: 16px;
        gap: 12px;
    }
    
    .controls input, .controls select, .controls button {
        min-height: 48px;
        padding: 14px;
    }
    
    button {
        min-height: 48px;
        padding: 14px 20px;
    }
    
    h1 {
        font-size: 1.4em;
        padding: 16px 12px;
    }
}