/* ========== CSS Variables ========== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gradient-soft: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #fdf4ff 100%);
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.05);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --transition: .25s cubic-bezier(.4,0,.2,1);
    --max-width: 1200px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.4);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.5);
    --gradient-soft: linear-gradient(135deg, #1e293b 0%, #1e1b4b 50%, #312e81 100%);
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background var(--transition), color var(--transition);
}
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
ul { list-style: none; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* ========== Header ========== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: background var(--transition), border-color var(--transition);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 64px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}
.logo-icon { font-size: 28px; }
.logo-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.header-search {
    flex: 1;
    max-width: 400px;
    position: relative;
    margin-left: auto;
}
.header-search input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 44px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.header-search input::placeholder { color: var(--text-muted); }
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--primary); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ========== Ad Container ========== */
.ad-container {
    max-width: var(--max-width);
    margin: 16px auto;
    padding: 0 20px;
}
.ad-placeholder {
    background: var(--gradient-soft);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}
.ad-placeholder.small { height: 60px; border-radius: var(--radius-sm); }
.ad-mid { margin: 32px auto; }

/* ========== Hero ========== */
.hero {
    background: var(--gradient);
    padding: 48px 0;
    text-align: center;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,.1) 0%, transparent 60%);
    animation: float 8s ease-in-out infinite;
}
@keyframes float {
    0%,100% { transform: translate(0,0); }
    50% { transform: translate(30px,-30px); }
}
.hero-title {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 12px;
    position: relative;
}
.hero-subtitle {
    font-size: 16px;
    opacity: .9;
    margin-bottom: 28px;
    position: relative;
}
.hero-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    position: relative;
}
.stat { text-align: center; }
.stat-num { display: block; font-size: 28px; font-weight: 800; }
.stat-label { font-size: 13px; opacity: .8; }

/* ========== Categories ========== */
.categories {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 64px;
    z-index: 90;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.categories::-webkit-scrollbar { display: none; }
.categories .container {
    display: flex;
    gap: 8px;
    min-width: max-content;
}
.category-btn {
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    white-space: nowrap;
    transition: all var(--transition);
}
.category-btn:hover { border-color: var(--primary); color: var(--primary); }
.category-btn.active {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
}

/* ========== Tools Grid ========== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 24px 0;
}
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition);
}
.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}
.tool-card:hover::before { transform: scaleX(1); }
.tool-icon {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
}
.tool-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.tool-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.tool-tag {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--gradient-soft);
    color: var(--primary);
    margin-top: 8px;
    font-weight: 500;
}
.tool-tag.hot { background: #fef2f2; color: #ef4444; }
[data-theme="dark"] .tool-tag.hot { background: rgba(239,68,68,.15); }

/* ========== SEO Content ========== */
.seo-content {
    padding: 40px 0;
    border-top: 1px solid var(--border);
    margin-top: 20px;
}
.seo-content h2 {
    font-size: 22px;
    margin-bottom: 12px;
    color: var(--text);
}
.seo-content p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.8;
}
.seo-content ul { padding-left: 20px; }
.seo-content li {
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.8;
    list-style: disc;
}

/* ========== Footer ========== */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 40px 0 20px;
    margin-top: 40px;
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}
.footer-col h3 { font-size: 18px; margin-bottom: 12px; }
.footer-col h4 { font-size: 15px; margin-bottom: 12px; color: var(--text); }
.footer-col p { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.footer-col ul li { margin-bottom: 8px; }
.footer-col ul li a { font-size: 14px; color: var(--text-secondary); }
.footer-col ul li a:hover { color: var(--primary); }
.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}
.footer-bottom a { color: var(--text-muted); }
.footer-bottom a:hover { color: var(--primary); }

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    overflow-y: auto;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    box-shadow: var(--shadow-xl);
    transform: translateY(20px);
    transition: transform var(--transition);
    margin: auto;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 20px; font-weight: 700; }
.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: #ef4444; }
.modal-body { padding: 24px; max-height: 60vh; overflow-y: auto; }
.modal-ad { padding: 0 24px 20px; }

/* ========== Tool UI Components ========== */
.tool-section { margin-bottom: 20px; }
.tool-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}
.tool-input, .tool-textarea, .tool-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.tool-input:focus, .tool-textarea:focus, .tool-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.tool-textarea { min-height: 120px; resize: vertical; font-family: 'Courier New', monospace; }
.tool-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tool-row > * { flex: 1; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--gradient);
    color: #fff;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.tool-result {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    word-break: break-all;
    font-size: 14px;
}
.tool-result.empty { color: var(--text-muted); text-align: center; }
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--gradient-soft);
}
.drop-zone-icon { font-size: 40px; margin-bottom: 8px; }
.drop-zone-text { color: var(--text-secondary); font-size: 14px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.range-value {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
    color: var(--primary);
}
.checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; }
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}
.checkbox-item input { accent-color: var(--primary); width: 18px; height: 18px; }
.color-preview {
    width: 100%;
    height: 80px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 12px;
}
.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
}
.gradient-preview {
    width: 100%;
    height: 120px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}
.tab-group { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all var(--transition);
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.info-box {
    padding: 12px 16px;
    background: var(--gradient-soft);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 12px;
}
.result-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin: 4px 4px 4px 0;
}
.result-badge.green { background: #dcfce7; color: #16a34a; }
.result-badge.yellow { background: #fef9c3; color: #ca8a04; }
.result-badge.red { background: #fee2e2; color: #dc2626; }
.result-badge.blue { background: #dbeafe; color: #2563eb; }
[data-theme="dark"] .result-badge.green { background: rgba(22,163,74,.15); }
[data-theme="dark"] .result-badge.yellow { background: rgba(202,138,4,.15); }
[data-theme="dark"] .result-badge.red { background: rgba(220,38,38,.15); }
[data-theme="dark"] .result-badge.blue { background: rgba(37,99,235,.15); }
#qrcode { display: flex; justify-content: center; padding: 16px; }
#qrcode img, #qrcode canvas { border-radius: var(--radius-sm); }

/* ========== Back to Top ========== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    box-shadow: var(--shadow-md);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}
.back-to-top.show { opacity: 1; visibility: visible; }
.back-to-top:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .header-search { max-width: 200px; }
    .logo-text { display: none; }
    .hero-title { font-size: 26px; }
    .hero-subtitle { font-size: 14px; }
    .hero-stats { gap: 24px; }
    .stat-num { font-size: 22px; }
    .tools-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .tool-card { padding: 16px; }
    .tool-icon { font-size: 26px; }
    .tool-name { font-size: 14px; }
    .tool-desc { font-size: 12px; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 20px; }
    .modal { max-width: 100%; }
    .modal-body { padding: 16px; }
    .seo-content h2 { font-size: 18px; }
}
@media (max-width: 480px) {
    .header-search { display: none; }
    .tools-grid { grid-template-columns: 1fr 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .hero { padding: 32px 0; }
}
