:root {
    --bg: #f4f6fb;
    --bg-2: #eef1f8;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-solid: #ffffff;
    --text: #1b2030;
    --text-soft: #5a6275;
    --text-faint: #8b93a7;
    --border: rgba(20, 30, 60, 0.10);
    --shadow: 0 18px 50px -18px rgba(31, 45, 90, 0.35);
    --accent: #6d5efc;
    --accent-2: #ff5fa2;
    --accent-3: #21c7b6;
    --grad: linear-gradient(120deg, #6d5efc 0%, #9b5cfc 40%, #ff5fa2 100%);
    --radius: 22px;
    --radius-sm: 14px;
}

[data-theme="dark"] {
    --bg: #0c0f1a;
    --bg-2: #0a0d16;
    --surface: rgba(24, 29, 46, 0.66);
    --surface-solid: #161b2c;
    --text: #eef1fa;
    --text-soft: #aab2c8;
    --text-faint: #6f7891;
    --border: rgba(255, 255, 255, 0.09);
    --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
    --accent: #8b7bff;
    --accent-2: #ff74b3;
    --accent-3: #38e0cc;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(109, 94, 252, 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(255, 95, 162, 0.10), transparent 55%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    transition: background-color .4s ease, color .4s ease;
    overflow-x: hidden;
}

/* ---------- 背景光球 ---------- */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: float 18s ease-in-out infinite; }
.orb-1 { width: 380px; height: 380px; background: #6d5efc; top: -80px; left: -60px; }
.orb-2 { width: 320px; height: 320px; background: #ff5fa2; bottom: -90px; right: -40px; animation-delay: -6s; }
.orb-3 { width: 280px; height: 280px; background: #21c7b6; top: 40%; right: 12%; animation-delay: -11s; opacity: .4; }
[data-theme="dark"] .orb { opacity: .35; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -40px) scale(1.08); }
    66% { transform: translate(-25px, 25px) scale(.96); }
}

/* ---------- 顶栏 ---------- */
.topbar {
    margin: 0 auto;
    width: 100%;
    max-width: 960px;
    position: relative; z-index: 2;
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px clamp(18px, 5vw, 48px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-logo {
    display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
    background: var(--grad); color: #fff; box-shadow: 0 8px 20px -6px rgba(109, 94, 252, .6);
}
.brand-name {background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-size: 22px;
    letter-spacing: 2px;}

.theme-toggle {
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 100%;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    cursor: pointer; backdrop-filter: blur(10px); transition: transform .2s ease, background .3s ease;
}
.theme-toggle:hover { transform: translateY(-2px) rotate(12deg); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- 主舞台 ---------- */
.stage {
    position: relative; z-index: 1;
    flex: 1; width: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 26px; padding: 24px clamp(18px, 5vw, 48px) 40px;
    max-width: 760px; margin: 0 auto;
}

.hero { text-align: center; }

.title {
    margin: 0; font-size: clamp(30px, 7vw, 54px); line-height: 1.12; font-weight: 800;
    letter-spacing: -1px;
}
.title .grad {
    background: var(--grad); -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.subtitle {
    margin: 18px auto 0; max-width: 560px; color: var(--text-soft);
    font-size: clamp(14px, 2.4vw, 17px); line-height: 1.7;
}

/* ---------- 大按钮 ---------- */
.shuffle-btn {
    margin-top: 34px;
    display: inline-flex; align-items: center; gap: 14px;
    padding: 10px 34px; border: none; border-radius: 999px;
    background: var(--grad); color: #fff; cursor: pointer;
    font-size: clamp(16px, 2.6vw, 19px); font-weight: 700; letter-spacing: .5px;
    box-shadow: 0 18px 40px -12px rgba(109, 94, 252, .65);
    transition: transform .18s ease, box-shadow .25s ease, filter .2s ease;
}
.shuffle-btn:hover { transform: translateY(-3px); box-shadow: 0 26px 50px -14px rgba(109, 94, 252, .75); }
.shuffle-btn:active { transform: translateY(0) scale(.97); }
.shuffle-btn:disabled { filter: saturate(.6) opacity(.7); cursor: progress; }
.shuffle-btn .shuffle-icon { display: grid; place-items: center; transition: transform .5s ease; }
.shuffle-btn.is-spinning .shuffle-icon { animation: spin .6s cubic-bezier(.6,.2,.2,1); }
@keyframes spin { to { transform: rotate(360deg); } }

.meta-line {
    margin-top: 22px; color: var(--text-faint); font-size: 14px;
    display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.meta-line strong { color: var(--text); }
.meta-item { display: inline-flex; align-items: center; gap: 5px; }
.meta-item svg { width: 15px; height: 15px; color: var(--accent); flex: none; }
.meta-dot { opacity: .5; }

/* ---------- 分类筛选 ---------- */
.chips {
    display: flex; gap: 8px;justify-content: center; flex-wrap: wrap;
    margin-top: 22px;
}
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 10px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
    font-size: 13.5px; font-weight: 600; cursor: pointer;
    backdrop-filter: blur(8px); transition: transform .18s ease, color .2s ease, background .25s ease, border-color .2s ease;
}
.chip-ico { width: 16px; height: 16px; object-fit: contain; border-radius: 4px; flex: none; }
.chip:hover { color: var(--text); transform: translateY(-2px); }
.chip.active {
    border: none;
    background: var(--grad); color: #fff; border-color: transparent;
    box-shadow: 0 10px 22px -10px rgba(109, 94, 252, .6);
}

/* ---------- 博客卡片 ---------- */
.blog-card {
    position: relative;
    width: 100%;
    background: var(--surface); backdrop-filter: blur(18px) saturate(1.2);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(20px, 4vw, 30px);
    animation: rise .45s cubic-bezier(.2,.7,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* 顶部信息条：勋章（左）+ 分类（右）*/
.blog-top {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-bottom:28px;
}

/* 勋章：卡片左上（勋章等级图标 + 等级），颜色取自数据库 medal_levels.color */
.blog-medal {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 800; letter-spacing: .3px;
    color: var(--medal-color, var(--accent));
    background: color-mix(in srgb, var(--medal-color, #6d5efc) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--medal-color, #6d5efc) 34%, transparent);
    padding: 2px 11px; border-radius: 999px;
}
.blog-medal-icon { width: 20px; height: 20px; object-fit: contain; flex: none; }
.blog-medal-name { white-space: nowrap; }

/* 分类徽章：卡片右上（图标 + 名称）*/
.blog-category-badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 700; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    padding: 5px 12px; border-radius: 999px; max-width: 60%;
}
.blog-cat-icon { width: 16px; height: 16px; object-fit: contain; border-radius: 4px; flex: none; }
.blog-category-badge span {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.blog-head { display: flex; align-items: stretch; gap: 16px; }
/* 图标高度与「博客名称 + 博客网址」两行文字一致，并硬性限制最大尺寸，避免个别大图撑爆 */
.blog-icon {
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--border);
    flex: none;
    height: 46px;
    max-height: 46px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
.blog-meta { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.blog-name {
    margin: 0; font-size: clamp(18px, 3.6vw, 22px); font-weight: 800; line-height: 1.25;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.blog-host { margin: 0; color: var(--text-faint); font-size: 13px; line-height: 1.3; }
.blog-desc {
    margin: 16px 0 0; color: var(--text-soft); line-height: 1.65; font-size: 14.5px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.blog-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 20px; border-radius: 12px; font-size: 14.5px; font-weight: 700;
    text-decoration: none; cursor: pointer; border: 1px solid transparent;
    transition: transform .15s ease, background .25s ease, border-color .25s ease;
}
.btn-primary {border: none; background: var(--grad); color: #fff; box-shadow: 0 12px 26px -12px rgba(109,94,252,.7); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 历史记录 ---------- */
.history { width: 100%; }
.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.history-title { margin: 0; font-size: 16px; font-weight: 800; display: inline-flex; align-items: center; gap: 7px; }
.history-title svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 14px;
    background: var(--surface-solid); border: 1px solid var(--border);
    text-decoration: none; color: var(--text);
    transition: transform .15s ease, border-color .2s ease, box-shadow .2s ease;
}
.history-item:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.hi-icon { width: 42px; height: 42px; border-radius: 11px; object-fit: cover; flex: none; background: var(--surface); border: 1px solid var(--border); }
.hi-meta { min-width: 0; flex: 1; }
.hi-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-sub { color: var(--text-faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-time { color: var(--text-faint); font-size: 12px; white-space: nowrap; flex: none; }
.history-empty { color: var(--text-faint); font-size: 14px; text-align: center; padding: 18px 0; }

/* ---------- 页脚 ---------- */
.footer {
    position: relative; z-index: 1; text-align: center; padding: 22px;
    color: var(--text-faint); font-size: 13px;
}
.footer a { color: var(--text-soft); text-decoration: none; border-bottom: 1px dashed var(--border); }
.footer a:hover { color: var(--accent); }

/* ---------- 轻提示 ---------- */
.toast {
    position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
    background: var(--surface-solid); color: var(--text);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 20px; font-size: 14px; font-weight: 600;
    box-shadow: var(--shadow); opacity: 0; pointer-events: none;
    transition: opacity .25s ease, transform .25s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 520px) {
    .blog-actions { flex-direction: column; }
    .btn {}
    .blog-head { gap: 12px; }
    .blog-top { margin-bottom: 24px; }
}

@media (max-width: 46px) {
.chips {
    justify-content: space-between;
}
}

@media (prefers-reduced-motion: reduce) {
    .orb, .shuffle-btn.is-spinning .shuffle-icon { animation: none; }
}
