:root {
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --bg: #f4f6f8;
    --bg-card: #ffffff;
    --bg-soft: #f0f2f5;
    --text: #1a1c20;
    --text-soft: #6c7280;
    --border: #e8eaf0;
    --shadow: 0 4px 20px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.03);
    --shadow-hover: 0 10px 28px rgba(0,0,0,.1), 0 2px 6px rgba(0,0,0,.04);
    --radius: 18px;
}

body[data-color="blue"]   { --accent:#3b82f6; --accent-hover:#2563eb; }
body[data-color="green"]  { --accent:#10b981; --accent-hover:#059669; }
body[data-color="purple"] { --accent:#8b5cf6; --accent-hover:#7c3aed; }
body[data-color="orange"] { --accent:#f59e0b; --accent-hover:#d97706; }
body[data-color="red"]    { --accent:#ef4444; --accent-hover:#dc2626; }

body[data-dark="1"] {
    --bg: #111216;
    --bg-card: #181a20;
    --bg-soft: #21232a;
    --text: #e8eaed;
    --text-soft: #9ca3af;
    --border: #282b33;
    --shadow: 0 4px 20px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.2);
    --shadow-hover: 0 10px 28px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    transition: background .3s, color .3s;
}

a { color: inherit; text-decoration: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* 顶部导航 */
.header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(255,255,255,.85);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}
body[data-dark="1"] .header { background: rgba(24,26,32,.85); }

.header-inner {
    display: flex; align-items: center; gap: 18px;
    height: 68px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; white-space: nowrap; letter-spacing: -0.5px; }
.logo .logo-mark {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,.1);
}

.search-box {
    flex: 1; position: relative; max-width: 520px;
}
.search-box input {
    width: 100%; height: 44px; padding: 0 16px 0 42px;
    border: 1px solid var(--border); border-radius: 24px;
    background: var(--bg-soft); color: var(--text);
    font-size: 15px; outline: none; transition: border .2s, box-shadow .2s;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
body[data-dark="1"] .search-box input:focus { box-shadow: 0 0 0 3px rgba(96,130,246,.12); }
.search-box .search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-soft); font-size: 14px; }

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--bg-soft); color: var(--text); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    transition: transform .15s, background .2s, color .2s, border-color .2s;
}
.icon-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); transform: translateY(-1px); }
.icon-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn {
    height: 40px; padding: 0 18px; border-radius: 12px; border: none;
    background: var(--accent); color: #fff; cursor: pointer; font-size: 14px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px; transition: background .2s, transform .15s;
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-ghost { background: var(--bg-soft); color: var(--text); }
.btn-ghost:hover { background: var(--accent); color: #fff; }

.theme-pop {
    position: absolute; top: 52px; right: 0; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 14px; padding: 14px;
    box-shadow: var(--shadow-hover); display: none; min-width: 180px; z-index: 120;
}
.theme-pop.show { display: block; }
.theme-pop .label { font-size: 12px; color: var(--text-soft); margin-bottom: 10px; }
.color-dots { display: flex; gap: 12px; }
.color-dot { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .15s; }
.color-dot:hover { transform: scale(1.1); }
.color-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--accent); }

/* 主体布局 */
.layout { display: flex; gap: 28px; margin-top: 28px; align-items: flex-start; }

.sidebar {
    width: 190px; flex-shrink: 0; position: sticky; top: 92px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.sidebar .side-title { font-size: 12px; color: var(--text-soft); padding: 8px 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.side-nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
    font-size: 14px; color: var(--text); transition: background .2s, color .2s;
}
.side-nav a:hover, .side-nav a.active { background: var(--bg-soft); color: var(--accent); font-weight: 600; }

.content { flex: 1; min-width: 0; }

.recommend { scroll-margin-top: 92px; }
/* 置顶推荐 */
.recommend { margin-bottom: 34px; }
.section-title {
    display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700;
    margin: 8px 0 18px; color: var(--text);
}
.section-title .bar { width: 4px; height: 18px; background: var(--accent); border-radius: 2px; }

.recommend-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px;
}
.rec-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s; position: relative; min-width: 0;
}
.rec-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.rec-card .rec-icon, .link-icon {
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 22px; overflow: hidden;
    background: var(--bg-soft);
    position: relative;
}
.rec-card .rec-icon img, .link-icon img { width: 100%; height: 100%; object-fit: cover; }
.rec-card .rec-info { min-width: 0; overflow: hidden; }
.rec-card .rec-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-card .rec-desc { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.fallback-initial {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 600; color: #fff;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--initial-bg) 0%, rgba(0,0,0,.12) 100%);
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
    text-shadow: 0 1px 2px rgba(0,0,0,.2);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 分类分组 */
.cat-group { margin-bottom: 36px; scroll-margin-top: 92px; }
.link-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px;
}
.link-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 15px; display: flex; align-items: center; gap: 13px; box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s, border-color .2s; position: relative; min-width: 0;
}
.link-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: rgba(59,130,246,.25); }
.link-card .link-info { min-width: 0; flex: 1; overflow: hidden; }
.link-card .link-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card .link-desc { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.link-card .fav-btn {
    position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%;
    border: none; background: transparent; cursor: pointer; font-size: 15px; color: var(--text-soft);
    display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .2s, color .2s, background .2s;
}
.link-card:hover .fav-btn { opacity: 1; }
.link-card .fav-btn.active { opacity: 1; color: #ef4444; }
.link-card .fav-btn:hover { background: rgba(239,68,68,.08); }
.badge-top {
    position: absolute; top: -7px; left: -7px; background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.12);
}

.empty { text-align: center; color: var(--text-soft); padding: 70px 0; font-size: 15px; }
.empty::before { content: '🔍'; display: block; font-size: 40px; margin-bottom: 12px; opacity: .5; }

/* 详情页 */
.detail-main { padding: 18px 0 50px; }
.detail-topbar {
    display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap;
}
.back-link {
    display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card);
    color: var(--text); font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
    transition: color .2s, border-color .2s, transform .2s, box-shadow .2s;
}
.back-link:hover {
    color: var(--accent); border-color: var(--accent);
    transform: translateX(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.14);
}
.detail-site-url {
    color: var(--text-soft); font-size: 13px; font-family: monospace;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 520px;
}

.detail-wrap { display: flex; gap: 22px; align-items: flex-start; justify-content: center; }
.detail-frame {
    width: 410px; flex: 0 0 auto; min-width: 0;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.detail-frame .frame-shot {
    display: block; background: #fff; line-height: 0;
}
.detail-frame .frame-shot-img {
    width: 100%; height: auto; display: block;
}
.detail-frame .frame-caption {
    display: flex; align-items: center; gap: 12px; padding: 13px 14px;
    background: var(--bg-soft); border-top: 1px solid var(--border);
}
.detail-frame .frame-domain {
    flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-soft);
    font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.detail-frame .frame-visit {
    flex-shrink: 0; font-size: 13px; font-weight: 600; color: var(--accent);
    text-decoration: none; transition: opacity .2s;
}
.detail-frame .frame-visit:hover { opacity: .7; }

.detail-side {
    width: 340px; flex-shrink: 0; position: sticky; top: 92px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.detail-side .side-header {
    padding: 26px; background: linear-gradient(135deg, var(--accent) 0%, rgba(0,0,0,.2) 100%);
    color: #fff; position: relative;
}
.detail-side .side-header::before {
    content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 20% 30%, rgba(255,255,255,.15) 0%, transparent 60%);
}
.detail-side .detail-head {
    position: relative; z-index: 1; align-items: flex-start; gap: 16px; margin: 0;
}
.detail-logo {
    width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 26px;
    background: var(--bg-soft);
}
.detail-side .detail-logo {
    width: 64px; height: 64px; border-radius: 18px; background: #fff; color: var(--accent);
    font-size: 28px; box-shadow: 0 8px 20px rgba(0,0,0,.12);
}
.detail-side .detail-logo.fallback-initial {
    background: linear-gradient(135deg, var(--initial-bg) 0%, rgba(0,0,0,.12) 100%); color: #fff;
}
.detail-logo img { width: 100%; height: 100%; object-fit: cover; }
.detail-title-box { min-width: 0; }
.detail-title { font-size: 20px; font-weight: 800; line-height: 1.3; word-break: break-word; }
.detail-side .detail-title { color: #fff; font-size: 22px; text-shadow: 0 1px 2px rgba(0,0,0,.15); }
.detail-desc { font-size: 13px; color: var(--text-soft); margin-top: 4px; line-height: 1.5; word-break: break-word; }
.detail-side .detail-desc { color: rgba(255,255,255,.85); margin-top: 6px; }

.detail-side .side-body { padding: 22px; }
.detail-visit { width: 100%; justify-content: center; margin-bottom: 16px; }
.detail-meta { list-style: none; }
.detail-meta li {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    margin-bottom: 10px; border-radius: 12px; background: var(--bg-soft);
    transition: background .2s, transform .1s;
}
.detail-meta li:hover { background: var(--bg); transform: translateX(2px); }
.detail-meta li:last-child { margin-bottom: 0; }
.m-label { display: flex; align-items: center; gap: 6px; width: 86px; font-size: 13px; color: var(--text-soft); flex-shrink: 0; }
.m-value { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; word-break: break-all; }
.m-value a { color: var(--accent); }
.m-value a:hover { text-decoration: underline; }
.hot-num { color: #f97316; font-weight: 800; }

/* 页脚 */
.footer { text-align: center; color: var(--text-soft); font-size: 13px; padding: 36px 0; }

/* 弹窗 */
.modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none;
    align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
    background: var(--bg-card); border-radius: 20px; width: 100%; max-width: 440px;
    padding: 26px; box-shadow: var(--shadow-hover); max-height: 90vh; overflow-y: auto;
    border: 1px solid var(--border);
}
.modal h3 { font-size: 18px; margin-bottom: 18px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 12px; color: var(--text-soft); margin-bottom: 6px; font-weight: 600; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-soft); color: var(--text); font-size: 14px; outline: none; font-family: inherit;
    transition: border .2s, box-shadow .2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.toast {
    position: fixed; top: 84px; left: 50%; transform: translateX(-50%);
    background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 12px;
    font-size: 14px; z-index: 300; opacity: 0; transition: opacity .3s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* 移动端 */
.mobile-cats {
    display: none; overflow-x: auto; gap: 10px; padding: 14px 0;
    position: sticky; top: 68px; z-index: 90; background: var(--bg);
}
.mobile-cats::-webkit-scrollbar { display: none; }
.mobile-cats a {
    flex-shrink: 0; padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 22px; font-size: 14px; white-space: nowrap; box-shadow: var(--shadow); font-weight: 500;
    transition: background .2s, color .2s, border-color .2s;
}
.mobile-cats a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

@media (max-width: 860px) {
    .sidebar { display: none; }
    .mobile-cats { display: flex; }
    .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 10px; }
    .logo { flex: 1; min-width: 0; font-size: 18px; }
    .logo .logo-mark { width: 34px; height: 34px; }
    .header-actions { margin-left: 0; }
    .btn span.txt { display: none; }
    .btn { padding: 0 12px; }
    .recommend-grid, .link-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .search-box { order: 3; flex-basis: 100%; max-width: none; }
    .detail-wrap { flex-direction: column; }
    .detail-topbar { margin-bottom: 14px; }
    .detail-site-url { max-width: none; width: 100%; }
    .detail-frame { width: 100%; }
    .detail-side { width: 100%; position: static; }
    .detail-side .side-header { padding: 20px; }
}
@media (max-width: 480px) {
    .recommend-grid, .link-grid { grid-template-columns: repeat(2, 1fr); }
    .rec-card, .link-card { padding: 12px; }
    .rec-card .rec-icon, .link-card .link-icon { width: 38px; height: 38px; border-radius: 10px; }
    .fallback-initial { font-size: 17px; }
    .section-title { font-size: 16px; }
}
