/* CSS变量 */
:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --error: #ef4444;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}
[data-theme="dark"] .header { background: rgba(15, 23, 42, 0.95); }

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: var(--radius);
    color: white; font-size: 1rem;
}
.logo-title {
    font-size: 1.1rem; font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.logo-subtitle { font-size: 0.7rem; color: var(--text-muted); }

.search-box { flex: 1; max-width: 400px; position: relative; }
.search-box input {
    width: 100%; height: 36px;
    padding: 0 1rem 0 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
}
.search-box input:focus { outline: none; border-color: var(--primary); }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.header-actions { display: flex; gap: 0.5rem; }
.theme-toggle {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
}

/* Main */
.main-content { flex: 1; max-width: 1400px; margin: 0 auto; padding: 1rem; width: 100%; }

/* Tabs */
.category-tabs {
    display: flex; gap: 0.5rem; padding: 0.75rem 0;
    overflow-x: auto; scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.8rem; font-weight: 500;
    cursor: pointer; white-space: nowrap;
}
.tab-btn:hover { background: var(--bg-tertiary); }
.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.tab-btn span { display: none; }
@media (min-width: 768px) { .tab-btn span { display: inline; } }

/* Count */
.api-count { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; font-size: 0.85rem; color: var(--text-secondary); }
.api-count i { color: var(--primary); }
.api-count strong { color: var(--text-primary); }

/* Grid */
.api-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
}
@media (min-width: 640px) { .api-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .api-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .api-grid { grid-template-columns: repeat(4, 1fr); } }

/* Card */
.api-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.api-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }

.card-header { padding: 0.75rem; display: flex; align-items: flex-start; gap: 0.6rem; position: relative; }
.card-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(139,92,246,0.1));
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: var(--radius);
    color: var(--primary); font-size: 1rem; flex-shrink: 0;
}
.card-info { flex: 1; min-width: 0; }
.card-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.card-desc { font-size: 0.75rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.card-number {
    position: absolute; top: 0.5rem; right: 0.5rem;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 50%;
    font-size: 0.7rem; font-weight: 600;
    color: var(--text-muted);
}

.favorite-btn {
    position: absolute; top: 0.5rem; right: 32px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.favorite-btn:hover { color: #ef4444; }
.favorite-btn.active { color: #ef4444; }

.card-body { padding: 0 0.75rem 0.75rem; }

/* Badges */
.card-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.badge { padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.65rem; font-weight: 500; }
.badge-source { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-image { background: rgba(34,197,94,0.1); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.badge-video { background: rgba(239,68,68,0.1); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.badge-upload { background: rgba(59,130,246,0.1); color: var(--primary); border: 1px solid rgba(59,130,246,0.3); }

/* Params */
.param-group { margin-bottom: 0.6rem; }
.param-label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.2rem; }
.param-label .required { color: var(--error); margin-left: 2px; }
.param-input, .param-select {
    width: 100%; height: 32px;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.8rem;
}
.param-input:focus, .param-select:focus { outline: none; border-color: var(--primary); }
.custom-input { margin-top: 0.4rem; }

/* File upload */
.file-upload { display: flex; align-items: center; gap: 0.5rem; }
.file-btn {
    padding: 0.4rem 0.8rem;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
}
.file-btn:hover { border-color: var(--primary); color: var(--primary); }
.file-name { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Button */
.call-btn {
    width: 100%; height: 34px;
    display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    border: none; border-radius: 6px;
    background: var(--primary);
    color: white;
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer;
}
.call-btn:hover { background: var(--primary-hover); }
.call-btn:disabled { opacity: 0.7; cursor: not-allowed; }

/* Result */
.result-container {
    margin-top: 0.6rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    overflow: hidden;
}
.result-content { padding: 0.6rem; font-size: 0.85rem; max-height: 500px; overflow-y: auto; }
.result-item { margin-bottom: 6px; line-height: 1.5; }

/* Result card with sections */
.result-card { font-size: 0.85rem; }
.result-section { padding: 0.4rem 0; }
.result-section.collapsed { display: none; }
.result-section.collapsible { border-bottom: 1px dashed var(--border); padding-bottom: 0.6rem; margin-bottom: 0.6rem; }

/* Item number */
.item-num {
    display: inline-block;
    width: 18px; height: 18px;
    line-height: 18px;
    text-align: center;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 600;
    margin-right: 6px;
    vertical-align: middle;
}

/* Expand button */
.expand-btn {
    display: block;
    width: 100%;
    padding: 0.4rem;
    border: none;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}
.expand-btn:hover { background: var(--primary); color: white; }

.error-box {
    padding: 0.6rem;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 6px;
    color: var(--error);
    font-size: 0.8rem;
    display: flex; align-items: center; gap: 0.4rem;
}

/* Reply section */
.reply-section {
    display: flex; gap: 0.4rem; padding: 0.6rem; border-top: 1px solid var(--border);
}
.reply-input {
    flex: 1; height: 32px;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8rem;
}
.reply-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 6px;
    background: var(--primary);
    color: white;
    cursor: pointer;
}

/* Hero info */
.hero-info { font-size: 0.85rem; }
.hero-header { margin-bottom: 0.6rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.hero-name { font-size: 1.1em; font-weight: 700; }
.hero-nick { color: var(--text-muted); font-size: 0.9em; }
.hero-type { display: inline-block; padding: 0.15rem 0.4rem; background: var(--primary); color: white; border-radius: 4px; font-size: 0.75rem; }
.hero-stats { margin: 0.6rem 0; }
.stat-item { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.4rem; font-size: 0.8rem; }
.stat-item > span:first-of-type { min-width: 50px; color: var(--text-muted); font-size: 0.75rem; }
.stat-bar { flex: 1; height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.stat-bar div { height: 100%; background: linear-gradient(90deg, var(--primary), #8b5cf6); border-radius: 4px; }
.hero-section { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px dashed var(--border); }
.section-title { font-weight: 600; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.skin-list { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.6; }
.skill-item { font-size: 0.8rem; margin-bottom: 0.5rem; padding: 0.4rem; background: var(--bg-tertiary); border-radius: 4px; line-height: 1.5; }

/* Upload result */
.upload-result { text-align: center; }
.upload-preview img { max-width: 100%; max-height: 150px; border-radius: 8px; cursor: pointer; margin-bottom: 0.4rem; }
.upload-link { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.upload-link input { flex: 1; padding: 0.4rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-tertiary); font-size: 0.75rem; }
.upload-link button { padding: 0.4rem 0.6rem; border: none; border-radius: 4px; background: var(--primary); color: white; cursor: pointer; }
.upload-info { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.4rem; }

/* News */
.news-title { font-weight: 600; margin-bottom: 0.4rem; }
.news-content { font-size: 0.85rem; line-height: 1.8; }

/* AI response */
.ai-response { line-height: 1.8; padding: 0.6rem; background: var(--bg-tertiary); border-radius: 8px; }

/* Random image/video wrapper */
.random-image-wrapper, .random-video-wrapper, .random-result { text-align: center; }
.refresh-btn {
    margin-top: 0.5rem; padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
}
.refresh-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Random result image animation */
.random-result img {
    transition: opacity 0.3s ease;
}

/* Loading */
.loading-inline { padding: 2rem; text-align: center; color: var(--text-muted); }
.loading-inline i { margin-right: 0.4rem; }

/* Game result */
.game-result { font-size: 0.85rem; }
.hint-text { font-style: italic; line-height: 1.7; white-space: pre-wrap; }
.hint-message { color: var(--text-muted); margin-top: 0.4rem; }
.hint-guide { margin-top: 0.4rem; }

/* Video */
video { max-width: 100%; }

/* Modal */
.media-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000; display: none; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); }
.modal-content { position: relative; z-index: 1; max-width: 90vw; max-height: 90vh; }
.modal-close {
    position: absolute; top: -36px; right: 0;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: white; font-size: 1rem;
    cursor: pointer;
}
.modal-close:hover { background: rgba(255,255,255,0.2); }
.media-container img, .media-container video { max-width: 90vw; max-height: 80vh; border-radius: 8px; }

/* Toast */
.toast-container { position: fixed; bottom: 1rem; right: 1rem; z-index: 1001; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    padding: 0.6rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    display: flex; align-items: center; gap: 0.4rem;
    animation: slideIn 0.3s ease;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--error); color: var(--error); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; }

/* Submit Modal */
.submit-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000; display: none; align-items: center; justify-content: center;
    padding: 20px;
}
.submit-modal .modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}
.submit-modal-content {
    position: relative; z-index: 1;
    width: 100%; max-width: 600px;
    max-height: 90vh;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.submit-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.submit-modal-header h3 {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 1rem; font-weight: 600;
    margin: 0;
}
.submit-modal-header h3 i { color: var(--primary); }
.submit-modal-header .modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.submit-modal-header .modal-close:hover { background: var(--bg-tertiary); color: var(--error); }

.submit-modal-body { padding: 1.25rem; max-height: calc(90vh - 60px); overflow-y: auto; }

.submit-tabs {
    display: flex; gap: 0.5rem; margin-bottom: 1rem;
}
.submit-tab {
    flex: 1; padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    text-align: center;
}
.submit-tab:hover { border-color: var(--primary); }
.submit-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.submit-form .form-row { display: flex; gap: 1rem; }
.submit-form .form-row .form-group { flex: 1; }

.submit-form .form-group { margin-bottom: 1rem; }
.submit-form label {
    display: block; font-size: 0.8rem; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 0.25rem;
}
.submit-form label .required { color: var(--error); }
.submit-form input,
.submit-form select,
.submit-form textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
}
.submit-form input:focus,
.submit-form select:focus,
.submit-form textarea:focus {
    outline: none; border-color: var(--primary);
}
.submit-form textarea {
    resize: vertical;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
}
.submit-form .form-hint {
    font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem;
}

.form-actions {
    display: flex; gap: 0.75rem; margin-top: 1.5rem;
    padding-top: 1rem; border-top: 1px solid var(--border);
}
.btn-cancel, .btn-submit {
    flex: 1; padding: 0.6rem 1rem;
    border: none; border-radius: 6px;
    font-size: 0.85rem; font-weight: 500;
    cursor: pointer;
}
.btn-cancel { background: var(--bg-tertiary); color: var(--text-secondary); }
.btn-cancel:hover { background: var(--border); }
.btn-submit { background: var(--primary); color: white; }
.btn-submit:hover { background: var(--primary-hover); }

@media (max-width: 640px) {
    .submit-form .form-row { flex-direction: column; gap: 0; }
}

/* Responsive */
@media (max-width: 768px) {
    .header-container { flex-wrap: wrap; height: auto; padding: 0.6rem; gap: 0.6rem; }
    .search-box { order: 3; max-width: 100%; width: 100%; }
    .logo-subtitle { display: none; }
    .media-modal { padding: 10px; }
    .modal-close { top: -32px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* 收藏计数 */
.fav-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--error);
    color: white;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

#favoritesBtn {
    position: relative;
}

/* 卡片动态高度 */
.api-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, height 0.3s ease;
}

.result-container {
    transition: max-height 0.3s ease;
    overflow: hidden;
}

/* 高亮动画 */
@keyframes highlight {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
    50% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* 收藏项悬停效果 */
.fav-item:hover {
    border-color: var(--primary) !important;
    transform: translateX(4px);
}
