* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 6px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(99, 102, 241, 0.15), 0 8px 24px rgba(99, 102, 241, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --text-tertiary: #64748b;
        --border: #334155;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.logo:hover {
    transform: scale(1.02);
}

.logo i {
    font-size: 26px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 14px;
    background: var(--bg-tertiary);
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    background: var(--bg-secondary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    transition: color 0.2s;
}

.search-box input:focus + i {
    color: var(--primary);
}

.main {
    padding: 40px 0;
}

.quick-tools {
    margin-bottom: 48px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-left: 16px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 18px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

.section-title i {
    color: var(--primary);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
}

.tool-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
}

.tool-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    color: white;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2);
    transition: transform 0.3s;
}

.tool-card:hover .tool-icon {
    transform: scale(1.1);
}

.tool-icon i {
    font-size: 24px;
}

.text-tools .tool-icon {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}

.dev-tools .tool-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
}

.image-tools .tool-icon {
    background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%);
}

.calc-tools .tool-icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
}

.tool-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.tool-card.popular::after {
    content: '🔥';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 12px;
}

.category {
    margin-bottom: 48px;
}

.category h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-left: 16px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.category h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 18px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

.category h2 i {
    color: var(--primary);
}

.footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    margin-top: 48px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.tool-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.toolbar {
    display: flex;
    gap: 10px;
    padding: 20px 24px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar button {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    background: var(--primary-gradient);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.toolbar button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.toolbar button:active {
    transform: scale(0.98);
}

.toolbar button.secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: none;
    border: 1px solid var(--border);
}

.toolbar button.secondary:hover {
    background: var(--bg-tertiary);
    box-shadow: none;
}

.panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.panels textarea {
    width: 100%;
    height: 420px;
    padding: 20px;
    border: none;
    border-right: 1px solid var(--border);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: background 0.3s;
}

.panels textarea:last-child {
    border-right: none;
    border-left: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.panels textarea:focus {
    outline: none;
    background: rgba(99, 102, 241, 0.05);
}

.error {
    padding: 14px 20px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    font-size: 14px;
    border-top: 1px solid var(--border);
}

.error.hidden {
    display: none;
}

.result {
    padding: 16px 20px;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 12px;
    margin-top: 16px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    word-break: break-all;
    border-left: 4px solid var(--primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-primary);
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--bg-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.description {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 15px;
}

.hint {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 14px;
    border-left: 4px solid var(--primary);
}

.tool-container .section {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.tool-container .section:last-child {
    border-bottom: none;
}

.tool-container .section h3 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.image-preview {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    text-align: center;
    border: 2px dashed var(--border);
}

.color-preview {
    margin-top: 20px;
    padding: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    text-align: center;
}

.color-box {
    width: 120px;
    height: 120px;
    border-radius: 16px;
    margin: 0 auto;
    box-shadow: var(--shadow-md);
    border: 4px solid var(--bg-secondary);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 16px 0;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 16px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.result-item .label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-item .value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', monospace;
    word-break: break-all;
}

.hash-value {
    font-size: 12px;
}

.stats {
    display: flex;
    gap: 32px;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
}

.stats span {
    font-size: 14px;
    color: var(--text-secondary);
}

.stats span span {
    font-weight: 700;
    color: var(--primary);
}

.qr-preview {
    margin-top: 24px;
    padding: 32px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    text-align: center;
    border: 2px dashed var(--border);
}

.qr-preview canvas {
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.loading {
    padding: 60px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
}

.photo-upload {
    margin: 20px 0;
}

.upload-btn {
    display: inline-block;
    padding: 12px 24px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.main h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.main h2 i {
    color: var(--primary);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-card:nth-child(1) { animation-delay: 0.05s; }
.tool-card:nth-child(2) { animation-delay: 0.1s; }
.tool-card:nth-child(3) { animation-delay: 0.15s; }
.tool-card:nth-child(4) { animation-delay: 0.2s; }
.tool-card:nth-child(5) { animation-delay: 0.25s; }
.tool-card:nth-child(6) { animation-delay: 0.3s; }
.tool-card:nth-child(7) { animation-delay: 0.35s; }
.tool-card:nth-child(8) { animation-delay: 0.4s; }
.tool-card:nth-child(9) { animation-delay: 0.45s; }
.tool-card:nth-child(10) { animation-delay: 0.5s; }
.tool-card:nth-child(11) { animation-delay: 0.55s; }
.tool-card:nth-child(12) { animation-delay: 0.6s; }

@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 14px;
        padding: 12px 16px;
    }
    
    .search-box {
        max-width: 100%;
    }
    
    .tool-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }
    
    .tool-card {
        padding: 20px 12px;
    }
    
    .tool-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }
    
    .tool-icon i {
        font-size: 20px;
    }
    
    .panels {
        grid-template-columns: 1fr;
    }
    
    .panels textarea {
        height: 280px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .panels textarea:last-child {
        border-left: none;
        border-bottom: none;
    }
    
    .toolbar {
        padding: 16px;
    }
    
    .tool-container .section {
        padding: 20px;
    }
    
    .result-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1200px) {
    .tool-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 992px) {
    .tool-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}