:root {
    --bg: #0b0b1a;
    --bg2: #0f0f23;
    --surface: rgba(255,255,255,0.04);
    --surface-hover: rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.07);
    --text: #f1f1f7;
    --text-muted: rgba(255,255,255,0.42);
    --primary: #6366f1;
    --accent: #a855f7;
    --secondary: #06b6d4;
    --gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --card-shadow: 0 2px 12px rgba(0,0,0,0.2);
    --icon-bg: rgba(99,102,241,0.12);
    --icon-bg-hover: rgba(99,102,241,0.2);
    --logo-filter: none;
}

body.light {
    --bg: #f0f2f5;
    --bg2: #e8ecf1;
    --surface: rgba(255,255,255,0.7);
    --surface-hover: rgba(255,255,255,0.95);
    --border: rgba(0,0,0,0.08);
    --text: #1d1d1f;
    --text-muted: rgba(0,0,0,0.42);
    --primary: #6366f1;
    --accent: #a855f7;
    --secondary: #0891b2;
    --gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --shadow: 0 8px 32px rgba(0,0,0,0.08);
    --card-shadow: 0 2px 12px rgba(0,0,0,0.06);
    --icon-bg: rgba(99,102,241,0.08);
    --icon-bg-hover: rgba(99,102,241,0.15);
    --logo-filter: brightness(0);
}

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

html { height: 100%; }

body {
    font-family: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    transition: background 0.5s ease, color 0.5s ease;
}

a { color: inherit; text-decoration: none; }

/* ─── Animated Background ─── */
.bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background: var(--bg2);
    transition: background 0.5s ease;
}

.bg::before, .bg::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.12;
    animation: float 25s ease-in-out infinite;
    transition: opacity 0.6s ease;
}

body.light .bg::before,
body.light .bg::after {
    opacity: 0.18;
}

.bg::before {
    width: 600px; height: 600px;
    background: var(--primary);
    top: -20%; left: -10%;
}

.bg::after {
    width: 500px; height: 500px;
    background: var(--accent);
    bottom: -20%; right: -10%;
    animation-delay: -12s;
}

@keyframes float {
    0%, 100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(80px,-60px) scale(1.1); }
    66% { transform: translate(-50px,40px) scale(0.95); }
}

.bg i {
    position: absolute;
    width: 3px; height: 3px;
    background: rgba(99,102,241,0.25);
    border-radius: 50%;
    animation: dotFloat linear infinite;
}

.bg i:nth-child(1) { top:20%; left:10%; animation-duration:14s; width:4px;height:4px; }
.bg i:nth-child(2) { top:70%; left:85%; animation-duration:18s; animation-delay:-3s; }
.bg i:nth-child(3) { top:40%; left:92%; animation-duration:12s; animation-delay:-6s; }
.bg i:nth-child(4) { top:85%; left:12%; animation-duration:16s; animation-delay:-8s; width:4px;height:4px; }
.bg i:nth-child(5) { top:15%; left:65%; animation-duration:13s; animation-delay:-4s; }
.bg i:nth-child(6) { top:55%; left:5%; animation-duration:15s; animation-delay:-10s; }
.bg i:nth-child(7) { top:25%; left:45%; animation-duration:19s; animation-delay:-5s; width:5px;height:5px; }
.bg i:nth-child(8) { top:75%; left:40%; animation-duration:11s; animation-delay:-7s; }

@keyframes dotFloat {
    0% { transform: translateY(0) scale(1); opacity:0; }
    10% { opacity:0.6; }
    90% { opacity:0.6; }
    100% { transform: translateY(-150px) scale(0); opacity:0; }
}

/* ─── Header ─── */
.header {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 32px;
    font-size: 13px;
    color: var(--text-muted);
}

.header-left { display: flex; gap: 14px; align-items: center; flex: 1; }
.header-center {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    flex: 1;
}
.header-greeting { color: var(--text); font-weight: 500; }
.header-right { display: flex; gap: 14px; align-items: center; flex: 1; justify-content: flex-end; }

.theme-btn {
    position: relative;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    overflow: hidden;
}

.theme-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0;
    transform: scale(0);
}

.theme-btn:active::after {
    animation: ripple 0.5s ease-out;
}

@keyframes ripple {
    from { transform: scale(0); opacity: 0.35; }
    to { transform: scale(2.5); opacity: 0; }
}

.theme-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.header-link {
    color: var(--text-muted);
    transition: color 0.2s;
    font-size: 13px;
}
.header-link:hover { color: var(--text); }
.header-link i { margin-right: 4px; }

/* ─── Main ─── */
.main {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 24px 40px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* ─── Hero ─── */
.hero {
    text-align: center;
    margin-bottom: 36px;
    width: 100%;
    max-width: 600px;
}

.hero-title {
    font-size: 2.4rem;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.hero-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.search-form { width: 100%; }

.search-box {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 4px 4px 4px 20px;
    transition: all 0.3s;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.search-icon { color: var(--text-muted); font-size: 15px; flex-shrink: 0; }

.search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 15px;
    padding: 12px 14px;
    font-family: inherit;
}

.search-input::placeholder { color: var(--text-muted); }

.search-btn {
    padding: 9px 24px;
    border: none;
    border-radius: 50px;
    background: var(--gradient);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    flex-shrink: 0;
}

.search-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
}

/* ─── Category Tabs ─── */
.categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 28px;
    width: 100%;
}

.cat-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.cat-tab:hover {
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--text);
}

.cat-tab.active {
    background: var(--gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.cat-tab i { font-size: 14px; }

.cat-tab .img-icon {
    width: 16px; height: 16px;
    border-radius: 4px;
    object-fit: cover;
}

/* ─── Links Grid ─── */
.links-container { width: 100%; }

.cat-section {
    animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius, 14px);
    transition: all 0.3s;
    min-width: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
}

.link-card:hover {
    background: var(--surface-hover);
    border-color: rgba(99, 102, 241, 0.25);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.link-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--icon-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--secondary);
    flex-shrink: 0;
    transition: background 0.3s;
    overflow: hidden;
}

.link-card:hover .link-icon {
    background: var(--icon-bg-hover);
}

.link-icon .img-icon {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.link-icon i { font-size: 18px; }

.link-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.link-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-desc {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.empty-msg {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* ─── Footer ─── */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 20px 24px;
    color: var(--text-muted);
    font-size: 13px;
}

.footer p {
    display: inline-block;
    padding: 8px 28px;
    border: 1px solid var(--border);
    border-radius: 50px;
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s;
}

.footer p:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.08);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .header { padding: 14px 18px; font-size: 12px; }
    .hero-title { font-size: 1.8rem; }
    .search-input { font-size: 14px; padding: 10px 12px; }
    .search-btn { padding: 8px 18px; font-size: 13px; }
    .cat-tab { padding: 8px 16px; font-size: 12px; }
    .links-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .link-card { padding: 12px 14px; }
    .link-icon { width: 34px; height: 34px; }
    .link-title { font-size: 13px; }
    .link-desc { display: none; }
}

@media (max-width: 480px) {
    .links-grid { grid-template-columns: repeat(2, 1fr); }
    .hero { margin-bottom: 24px; }
    .hero-title { font-size: 1.5rem; }
    .hero-sub { font-size: 13px; margin-bottom: 18px; }
    .categories { gap: 6px; }
    .cat-tab { padding: 6px 14px; font-size: 12px; }
    .cat-tab span { display: none; }
}
